ui/hob: switch from buildFile to buildTargets for custom image builds

We need to use the buildTargets command to ensure dependencies, such as
native tools to build the rootfs, are correctly included. This patch
achieves this by modifying BBPATH and BBFILES to include matches for the
location of the generated recipe file and reparsing the metadata before
calling buildTargets.

Fixes [YOCTO #1228]

(Bitbake rev: 5840d59098141e773c12bea8ed8d9f4f1a706132)

Signed-off-by: Joshua Lock <josh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Lock
2011-07-15 10:30:48 -07:00
committed by Richard Purdie
parent 6d76379af8
commit 2d608f837d
3 changed files with 77 additions and 32 deletions

View File

@@ -244,6 +244,24 @@ class Configurator(gobject.GObject):
del self.orig_config del self.orig_config
self.orig_config = copy.deepcopy(self.config) self.orig_config = copy.deepcopy(self.config)
def insertTempBBPath(self, bbpath, bbfiles):
# Create a backup of the local.conf
bkup = "%s~" % self.local
os.rename(self.local, bkup)
# read the original conf into a list
with open(bkup, 'r') as config:
config_lines = config.readlines()
if bbpath:
config_lines.append("BBPATH := \"${BBPATH}:%s\"\n" % bbpath)
if bbfiles:
config_lines.append("BBFILES := \"${BBFILES} %s\"\n" % bbfiles)
# Write the updated lines list object to the local.conf
with open(self.local, "w") as n:
n.write("".join(config_lines))
def writeLayerConf(self): def writeLayerConf(self):
# If we've not added/removed new layers don't write # If we've not added/removed new layers don't write
if not self._isLayerConfDirty(): if not self._isLayerConfDirty():

View File

@@ -52,16 +52,13 @@ class HobHandler(gobject.GObject):
"error" : (gobject.SIGNAL_RUN_LAST, "error" : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)), (gobject.TYPE_STRING,)),
"build-complete" : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
()),
"reload-triggered" : (gobject.SIGNAL_RUN_LAST, "reload-triggered" : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, gobject.TYPE_NONE,
(gobject.TYPE_STRING, (gobject.TYPE_STRING,
gobject.TYPE_STRING)), gobject.TYPE_STRING)),
} }
(CFG_PATH_LOCAL, CFG_PATH_HOB, CFG_PATH_LAYERS, CFG_FILES_DISTRO, CFG_FILES_MACH, CFG_FILES_SDK, FILES_MATCH_CLASS, GENERATE_TGTS, REPARSE_FILES) = range(9) (CFG_PATH_LOCAL, CFG_PATH_HOB, CFG_PATH_LAYERS, CFG_FILES_DISTRO, CFG_FILES_MACH, CFG_FILES_SDK, FILES_MATCH_CLASS, GENERATE_TGTS, REPARSE_FILES, BUILD_IMAGE) = range(10)
def __init__(self, taskmodel, server): def __init__(self, taskmodel, server):
gobject.GObject.__init__(self) gobject.GObject.__init__(self)
@@ -111,8 +108,21 @@ class HobHandler(gobject.GObject):
self.generating = False self.generating = False
self.current_command = None self.current_command = None
elif self.current_command == self.REPARSE_FILES: elif self.current_command == self.REPARSE_FILES:
self.current_command = self.CFG_PATH_LAYERS if self.build_queue:
self.current_command = self.BUILD_IMAGE
else:
self.current_command = self.CFG_PATH_LAYERS
self.server.runCommand(["reparseFiles"]) self.server.runCommand(["reparseFiles"])
elif self.current_command == self.BUILD_IMAGE:
self.building = "image"
if self.generating:
self.emit("data-generated")
self.generating = False
bbpath = self.server.runCommand(["getVariable", "BBPATH"])
bbfiles = self.server.runCommand(["getVariable", "BBFILES"])
self.server.runCommand(["buildTargets", self.build_queue, "build"])
self.build_queue = []
self.current_command = None
def handle_event(self, event, running_build, pbar): def handle_event(self, event, running_build, pbar):
if not event: if not event:
@@ -208,27 +218,48 @@ class HobHandler(gobject.GObject):
pmake = "-j %s" % threads pmake = "-j %s" % threads
self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake]) self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake])
def run_build(self, tgts): def build_image(self, image, image_path, configurator):
self.building = "image"
targets = [] targets = []
targets.append(tgts) targets.append(image)
if self.build_toolchain and self.build_toolchain_headers: if self.build_toolchain and self.build_toolchain_headers:
targets = ["meta-toolchain-sdk"] + targets targets.append("meta-toolchain-sdk")
elif self.build_toolchain: elif self.build_toolchain:
targets = ["meta-toolchain"] + targets targets.append("meta-toolchain")
self.server.runCommand(["buildTargets", targets, "build"]) self.build_queue = targets
bbpath_ok = False
bbpath = self.server.runCommand(["getVariable", "BBPATH"])
if image_path in bbpath.split(":"):
bbpath_ok = True
bbfiles_ok = False
bbfiles = self.server.runCommand(["getVariable", "BBFILES"]).split(" ")
for files in bbfiles:
import re
pattern = "%s/\*.bb" % image_path
if re.match(pattern, files):
bbfiles_ok = True
if not bbpath_ok:
nbbp = image_path
else:
nbbp = None
if not bbfiles_ok:
nbbf = "%s/*.bb" % image_path
else:
nbbf = None
if not bbfiles_ok or not bbpath_ok:
configurator.insertTempBBPath(nbbp, nbbf)
self.current_command = self.REPARSE_FILES
self.run_next_command()
def build_packages(self, pkgs): def build_packages(self, pkgs):
self.building = "packages" self.building = "packages"
if 'meta-toolchain' in self.build_queue:
self.build_queue.remove('meta-toolchain')
pkgs.extend('meta-toolchain')
self.server.runCommand(["buildTargets", pkgs, "build"]) self.server.runCommand(["buildTargets", pkgs, "build"])
def build_file(self, image):
self.building = "image"
self.server.runCommand(["buildFile", image, "build"])
def cancel_build(self, force=False): def cancel_build(self, force=False):
if force: if force:
# Force the cooker to stop as quickly as possible # Force the cooker to stop as quickly as possible

View File

@@ -65,10 +65,8 @@ class MainWindow (gtk.Window):
self.build = RunningBuild() self.build = RunningBuild()
self.build.connect("build-failed", self.running_build_failed_cb) self.build.connect("build-failed", self.running_build_failed_cb)
self.build.connect("build-complete", self.handler.build_complete_cb)
self.build.connect("build-started", self.build_started_cb) self.build.connect("build-started", self.build_started_cb)
self.build.connect("build-complete", self.build_complete_cb)
self.handler.connect("build-complete", self.build_complete_cb)
vbox = gtk.VBox(False, 0) vbox = gtk.VBox(False, 0)
vbox.set_border_width(0) vbox.set_border_width(0)
@@ -373,16 +371,15 @@ class MainWindow (gtk.Window):
dialog.destroy() dialog.destroy()
if response == gtk.RESPONSE_CANCEL: if response == gtk.RESPONSE_CANCEL:
return return
else:
# TODO: show a confirmation dialog ?
if not self.save_path:
import tempfile, datetime
image_name = "hob-%s-variant-%s.bb" % (rep.base_image, datetime.date.today().isoformat())
image_dir = os.path.join(tempfile.gettempdir(), 'hob-images')
bb.utils.mkdirhier(image_dir)
recipepath = os.path.join(image_dir, image_name)
else: else:
recipepath = self.save_path self.handler.build_packages(rep.allpkgs.split(" "))
else:
import tempfile, datetime
image_name = "hob-%s-variant-%s" % (rep.base_image, datetime.date.today().isoformat())
image_file = "%s.bb" % (image_name)
image_dir = os.path.join(tempfile.gettempdir(), 'hob-images')
bb.utils.mkdirhier(image_dir)
recipepath = os.path.join(image_dir, image_file)
rep.writeRecipe(recipepath, self.model) rep.writeRecipe(recipepath, self.model)
# In the case where we saved the file for the purpose of building # In the case where we saved the file for the purpose of building
@@ -391,9 +388,8 @@ class MainWindow (gtk.Window):
if not self.save_path: if not self.save_path:
self.files_to_clean.append(recipepath) self.files_to_clean.append(recipepath)
self.handler.queue_image_recipe_path(recipepath) self.handler.build_image(image_name, image_dir, self.configurator)
self.handler.build_packages(rep.allpkgs.split(" "))
self.nb.set_current_page(1) self.nb.set_current_page(1)
def back_button_clicked_cb(self, button): def back_button_clicked_cb(self, button):