summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/ui/crumbs/configurator.py18
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobeventhandler.py67
-rw-r--r--bitbake/lib/bb/ui/hob.py24
3 files changed, 77 insertions, 32 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/configurator.py b/bitbake/lib/bb/ui/crumbs/configurator.py
index 6481608483..ec48a4f3f0 100644
--- a/bitbake/lib/bb/ui/crumbs/configurator.py
+++ b/bitbake/lib/bb/ui/crumbs/configurator.py
@@ -244,6 +244,24 @@ class Configurator(gobject.GObject):
244 del self.orig_config 244 del self.orig_config
245 self.orig_config = copy.deepcopy(self.config) 245 self.orig_config = copy.deepcopy(self.config)
246 246
247 def insertTempBBPath(self, bbpath, bbfiles):
248 # Create a backup of the local.conf
249 bkup = "%s~" % self.local
250 os.rename(self.local, bkup)
251
252 # read the original conf into a list
253 with open(bkup, 'r') as config:
254 config_lines = config.readlines()
255
256 if bbpath:
257 config_lines.append("BBPATH := \"${BBPATH}:%s\"\n" % bbpath)
258 if bbfiles:
259 config_lines.append("BBFILES := \"${BBFILES} %s\"\n" % bbfiles)
260
261 # Write the updated lines list object to the local.conf
262 with open(self.local, "w") as n:
263 n.write("".join(config_lines))
264
247 def writeLayerConf(self): 265 def writeLayerConf(self):
248 # If we've not added/removed new layers don't write 266 # If we've not added/removed new layers don't write
249 if not self._isLayerConfDirty(): 267 if not self._isLayerConfDirty():
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index d10c8588dc..4897bccd26 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -52,16 +52,13 @@ class HobHandler(gobject.GObject):
52 "error" : (gobject.SIGNAL_RUN_LAST, 52 "error" : (gobject.SIGNAL_RUN_LAST,
53 gobject.TYPE_NONE, 53 gobject.TYPE_NONE,
54 (gobject.TYPE_STRING,)), 54 (gobject.TYPE_STRING,)),
55 "build-complete" : (gobject.SIGNAL_RUN_LAST,
56 gobject.TYPE_NONE,
57 ()),
58 "reload-triggered" : (gobject.SIGNAL_RUN_LAST, 55 "reload-triggered" : (gobject.SIGNAL_RUN_LAST,
59 gobject.TYPE_NONE, 56 gobject.TYPE_NONE,
60 (gobject.TYPE_STRING, 57 (gobject.TYPE_STRING,
61 gobject.TYPE_STRING)), 58 gobject.TYPE_STRING)),
62 } 59 }
63 60
64 (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) 61 (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)
65 62
66 def __init__(self, taskmodel, server): 63 def __init__(self, taskmodel, server):
67 gobject.GObject.__init__(self) 64 gobject.GObject.__init__(self)
@@ -111,8 +108,21 @@ class HobHandler(gobject.GObject):
111 self.generating = False 108 self.generating = False
112 self.current_command = None 109 self.current_command = None
113 elif self.current_command == self.REPARSE_FILES: 110 elif self.current_command == self.REPARSE_FILES:
114 self.current_command = self.CFG_PATH_LAYERS 111 if self.build_queue:
112 self.current_command = self.BUILD_IMAGE
113 else:
114 self.current_command = self.CFG_PATH_LAYERS
115 self.server.runCommand(["reparseFiles"]) 115 self.server.runCommand(["reparseFiles"])
116 elif self.current_command == self.BUILD_IMAGE:
117 self.building = "image"
118 if self.generating:
119 self.emit("data-generated")
120 self.generating = False
121 bbpath = self.server.runCommand(["getVariable", "BBPATH"])
122 bbfiles = self.server.runCommand(["getVariable", "BBFILES"])
123 self.server.runCommand(["buildTargets", self.build_queue, "build"])
124 self.build_queue = []
125 self.current_command = None
116 126
117 def handle_event(self, event, running_build, pbar): 127 def handle_event(self, event, running_build, pbar):
118 if not event: 128 if not event:
@@ -208,27 +218,48 @@ class HobHandler(gobject.GObject):
208 pmake = "-j %s" % threads 218 pmake = "-j %s" % threads
209 self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake]) 219 self.server.runCommand(["setVariable", "BB_NUMBER_THREADS", pmake])
210 220
211 def run_build(self, tgts): 221 def build_image(self, image, image_path, configurator):
212 self.building = "image"
213 targets = [] 222 targets = []
214 targets.append(tgts) 223 targets.append(image)
215 if self.build_toolchain and self.build_toolchain_headers: 224 if self.build_toolchain and self.build_toolchain_headers:
216 targets = ["meta-toolchain-sdk"] + targets 225 targets.append("meta-toolchain-sdk")
217 elif self.build_toolchain: 226 elif self.build_toolchain:
218 targets = ["meta-toolchain"] + targets 227 targets.append("meta-toolchain")
219 self.server.runCommand(["buildTargets", targets, "build"]) 228 self.build_queue = targets
229
230 bbpath_ok = False
231 bbpath = self.server.runCommand(["getVariable", "BBPATH"])
232 if image_path in bbpath.split(":"):
233 bbpath_ok = True
234
235 bbfiles_ok = False
236 bbfiles = self.server.runCommand(["getVariable", "BBFILES"]).split(" ")
237 for files in bbfiles:
238 import re
239 pattern = "%s/\*.bb" % image_path
240 if re.match(pattern, files):
241 bbfiles_ok = True
242
243 if not bbpath_ok:
244 nbbp = image_path
245 else:
246 nbbp = None
247
248 if not bbfiles_ok:
249 nbbf = "%s/*.bb" % image_path
250 else:
251 nbbf = None
252
253 if not bbfiles_ok or not bbpath_ok:
254 configurator.insertTempBBPath(nbbp, nbbf)
255
256 self.current_command = self.REPARSE_FILES
257 self.run_next_command()
220 258
221 def build_packages(self, pkgs): 259 def build_packages(self, pkgs):
222 self.building = "packages" 260 self.building = "packages"
223 if 'meta-toolchain' in self.build_queue:
224 self.build_queue.remove('meta-toolchain')
225 pkgs.extend('meta-toolchain')
226 self.server.runCommand(["buildTargets", pkgs, "build"]) 261 self.server.runCommand(["buildTargets", pkgs, "build"])
227 262
228 def build_file(self, image):
229 self.building = "image"
230 self.server.runCommand(["buildFile", image, "build"])
231
232 def cancel_build(self, force=False): 263 def cancel_build(self, force=False):
233 if force: 264 if force:
234 # Force the cooker to stop as quickly as possible 265 # Force the cooker to stop as quickly as possible
diff --git a/bitbake/lib/bb/ui/hob.py b/bitbake/lib/bb/ui/hob.py
index 448d590e49..654d2dfc71 100644
--- a/bitbake/lib/bb/ui/hob.py
+++ b/bitbake/lib/bb/ui/hob.py
@@ -65,10 +65,8 @@ class MainWindow (gtk.Window):
65 65
66 self.build = RunningBuild() 66 self.build = RunningBuild()
67 self.build.connect("build-failed", self.running_build_failed_cb) 67 self.build.connect("build-failed", self.running_build_failed_cb)
68 self.build.connect("build-complete", self.handler.build_complete_cb)
69 self.build.connect("build-started", self.build_started_cb) 68 self.build.connect("build-started", self.build_started_cb)
70 69 self.build.connect("build-complete", self.build_complete_cb)
71 self.handler.connect("build-complete", self.build_complete_cb)
72 70
73 vbox = gtk.VBox(False, 0) 71 vbox = gtk.VBox(False, 0)
74 vbox.set_border_width(0) 72 vbox.set_border_width(0)
@@ -373,16 +371,15 @@ class MainWindow (gtk.Window):
373 dialog.destroy() 371 dialog.destroy()
374 if response == gtk.RESPONSE_CANCEL: 372 if response == gtk.RESPONSE_CANCEL:
375 return 373 return
376 else:
377 # TODO: show a confirmation dialog ?
378 if not self.save_path:
379 import tempfile, datetime
380 image_name = "hob-%s-variant-%s.bb" % (rep.base_image, datetime.date.today().isoformat())
381 image_dir = os.path.join(tempfile.gettempdir(), 'hob-images')
382 bb.utils.mkdirhier(image_dir)
383 recipepath = os.path.join(image_dir, image_name)
384 else: 374 else:
385 recipepath = self.save_path 375 self.handler.build_packages(rep.allpkgs.split(" "))
376 else:
377 import tempfile, datetime
378 image_name = "hob-%s-variant-%s" % (rep.base_image, datetime.date.today().isoformat())
379 image_file = "%s.bb" % (image_name)
380 image_dir = os.path.join(tempfile.gettempdir(), 'hob-images')
381 bb.utils.mkdirhier(image_dir)
382 recipepath = os.path.join(image_dir, image_file)
386 383
387 rep.writeRecipe(recipepath, self.model) 384 rep.writeRecipe(recipepath, self.model)
388 # In the case where we saved the file for the purpose of building 385 # In the case where we saved the file for the purpose of building
@@ -391,9 +388,8 @@ class MainWindow (gtk.Window):
391 if not self.save_path: 388 if not self.save_path:
392 self.files_to_clean.append(recipepath) 389 self.files_to_clean.append(recipepath)
393 390
394 self.handler.queue_image_recipe_path(recipepath) 391 self.handler.build_image(image_name, image_dir, self.configurator)
395 392
396 self.handler.build_packages(rep.allpkgs.split(" "))
397 self.nb.set_current_page(1) 393 self.nb.set_current_page(1)
398 394
399 def back_button_clicked_cb(self, button): 395 def back_button_clicked_cb(self, button):