Skip to content

Commit

Permalink
toaster: add get_or_create_targets API
Browse files Browse the repository at this point in the history
Target objects are created before the build if build is
started from UI in build mode. However, in analysis mode Target
objects don't exist and need to be created using information
from bitbake events.

Added new API call get_or_create_targets to retrive existing
target objects or create them if they don't exist yet.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Elliot Smith <elliot.smith@intel.com>
Signed-off-by: brian avery <avery.brian@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
  • Loading branch information
Ed Bartosh authored and rpurdie committed Oct 27, 2015
1 parent af88f53 commit ef69be3
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions lib/bb/ui/buildinfohelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ def create_build_object(self, build_info, brbe, project_id):
build.bitbake_version=build_info['bitbake_version']
build.save()

Target.objects.filter(build = build).delete()

else:
build = Build.objects.create(
project = prj,
Expand All @@ -184,18 +182,26 @@ def create_build_object(self, build_info, brbe, project_id):

return build

def create_target_objects(self, target_info):
assert 'build' in target_info
assert 'targets' in target_info

targets = []
for tgt_name in target_info['targets']:
tgt_object = Target.objects.create( build = target_info['build'],
target = tgt_name,
is_image = False,
)
targets.append(tgt_object)
return targets
@staticmethod
def get_or_create_targets(target_info):
result = []
for target in target_info['targets']:
task = ''
if ':' in target:
target, task = target.split(':', 1)
if task.startswith('do_'):
task = task[3:]
if task == 'build':
task = ''
obj, created = Target.objects.get_or_create(build=target_info['build'],
target=target)
if created:
obj.is_image = False
if task:
obj.task = task
obj.save()
result.append(obj)
return result

def update_build_object(self, build, errors, warnings, taskfailures):
assert isinstance(build,Build)
Expand Down Expand Up @@ -950,7 +956,7 @@ def store_started_build(self, event, consolelogfile):
target_information['targets'] = event._pkgs
target_information['build'] = build_obj

self.internal_state['targets'] = self.orm_wrapper.create_target_objects(target_information)
self.internal_state['targets'] = self.orm_wrapper.get_or_create_targets(target_information)

# Save build configuration
data = self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0]
Expand Down

0 comments on commit ef69be3

Please sign in to comment.