summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-02 17:48:40 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-03 17:45:54 +0000
commitd1e66643ae2e379f5e51ab9370ef8cb7e66dcb35 (patch)
tree2e129b3f58109ba30d1b8ce757f6adbe979e2601 /bitbake/lib/bb
parentb8f0963592aa6a9ebd679fa363ca6f894b132d75 (diff)
downloadpoky-d1e66643ae2e379f5e51ab9370ef8cb7e66dcb35.tar.gz
bitbake: cooker/command/hob: Cleanup configuration init/reset functions and commands
initConfigurationData and loadConfigurationData are similar functions, the only reason for them appears to be to be able to reset the pre/post configuration files. The current code is confusing and unmaintainable. Instead this patch creates a new Sync command which allows these to be explicitly set. The init and load functions can then be merged into one. There is then no need for a parseConfiguration command, we can simply reset the server to have the settings take effect. The reset fuction is not an instant value return and triggers an event so it should be an Async command, not a sync one. The number of calls for the set pre/post command is probably higher than it need be but someone with more familiarity with the hob code base can probably figure out the right places its needed (maybe just init_cooker?). (Bitbake rev: bae5210d7e048022f083361964ebec7daf1608f7) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/command.py38
-rw-r--r--bitbake/lib/bb/cooker.py31
-rwxr-xr-xbitbake/lib/bb/ui/crumbs/builder.py1
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobeventhandler.py17
4 files changed, 34 insertions, 53 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index a2795ce0b7..e30d21d379 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -196,18 +196,11 @@ class CommandsSync:
196 """ 196 """
197 command.cooker.disableDataTracking() 197 command.cooker.disableDataTracking()
198 198
199 def initCooker(self, command, params): 199 def setPrePostConfFiles(self, command, params):
200 """ 200 prefiles = params[0].split()
201 Init the cooker to initial state with nothing parsed 201 postfiles = params[1].split()
202 """ 202 command.cooker.configuration.prefile = prefiles
203 command.cooker.initialize() 203 command.cooker.configuration.postfile = postfiles
204
205 def resetCooker(self, command, params):
206 """
207 Reset the cooker to its initial state, thus forcing a reparse for
208 any async command that has the needcache property set to True
209 """
210 command.cooker.reset()
211 204
212 def getCpuCount(self, command, params): 205 def getCpuCount(self, command, params):
213 """ 206 """
@@ -420,18 +413,6 @@ class CommandsAsync:
420 command.finishAsyncCommand() 413 command.finishAsyncCommand()
421 compareRevisions.needcache = True 414 compareRevisions.needcache = True
422 415
423 def parseConfigurationFiles(self, command, params):
424 """
425 Parse the configuration files
426 """
427 prefiles = params[0].split()
428 postfiles = params[1].split()
429 command.cooker.configuration.prefile = prefiles
430 command.cooker.configuration.postfile = postfiles
431 command.cooker.loadConfigurationData()
432 command.finishAsyncCommand()
433 parseConfigurationFiles.needcache = False
434
435 def triggerEvent(self, command, params): 416 def triggerEvent(self, command, params):
436 """ 417 """
437 Trigger a certain event 418 Trigger a certain event
@@ -441,3 +422,12 @@ class CommandsAsync:
441 command.currentAsyncCommand = None 422 command.currentAsyncCommand = None
442 triggerEvent.needcache = False 423 triggerEvent.needcache = False
443 424
425 def resetCooker(self, command, params):
426 """
427 Reset the cooker to its initial state, thus forcing a reparse for
428 any async command that has the needcache property set to True
429 """
430 command.cooker.reset()
431 command.finishAsyncCommand()
432 resetCooker.needcache = False
433
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 7b10f80680..fcf8db5c11 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -117,7 +117,7 @@ class BBCooker:
117 117
118 self.configuration = configuration 118 self.configuration = configuration
119 119
120 self.loadConfigurationData() 120 self.initConfigurationData()
121 121
122 # Take a lock so only one copy of bitbake can run against a given build 122 # Take a lock so only one copy of bitbake can run against a given build
123 # directory at a time 123 # directory at a time
@@ -152,9 +152,11 @@ class BBCooker:
152 def initConfigurationData(self): 152 def initConfigurationData(self):
153 153
154 self.state = state.initial 154 self.state = state.initial
155
156 self.caches_array = [] 155 self.caches_array = []
157 156
157 if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
158 self.enableDataTracking()
159
158 all_extra_cache_names = [] 160 all_extra_cache_names = []
159 # We hardcode all known cache types in a single place, here. 161 # We hardcode all known cache types in a single place, here.
160 if CookerFeatures.HOB_EXTRA_CACHES in self.featureset: 162 if CookerFeatures.HOB_EXTRA_CACHES in self.featureset:
@@ -176,19 +178,6 @@ class BBCooker:
176 self.databuilder = bb.cookerdata.CookerDataBuilder(self.configuration, False) 178 self.databuilder = bb.cookerdata.CookerDataBuilder(self.configuration, False)
177 self.data = self.databuilder.data 179 self.data = self.databuilder.data
178 180
179 def enableDataTracking(self):
180 self.configuration.tracking = True
181 self.data.enableTracking()
182
183 def disableDataTracking(self):
184 self.configuration.tracking = False
185 self.data.disableTracking()
186
187 def loadConfigurationData(self):
188 if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
189 self.enableDataTracking()
190
191 self.initConfigurationData()
192 self.databuilder.parseBaseConfiguration() 181 self.databuilder.parseBaseConfiguration()
193 self.data = self.databuilder.data 182 self.data = self.databuilder.data
194 self.data_hash = self.databuilder.data_hash 183 self.data_hash = self.databuilder.data_hash
@@ -203,6 +192,13 @@ class BBCooker:
203 if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset: 192 if CookerFeatures.BASEDATASTORE_TRACKING in self.featureset:
204 self.disableDataTracking() 193 self.disableDataTracking()
205 194
195 def enableDataTracking(self):
196 self.configuration.tracking = True
197 self.data.enableTracking()
198
199 def disableDataTracking(self):
200 self.configuration.tracking = False
201 self.data.disableTracking()
206 202
207 def modifyConfigurationVar(self, var, val, default_file, op): 203 def modifyConfigurationVar(self, var, val, default_file, op):
208 if op == "append": 204 if op == "append":
@@ -1333,11 +1329,8 @@ class BBCooker:
1333 def finishcommand(self): 1329 def finishcommand(self):
1334 self.state = state.initial 1330 self.state = state.initial
1335 1331
1336 def initialize(self):
1337 self.initConfigurationData()
1338
1339 def reset(self): 1332 def reset(self):
1340 self.loadConfigurationData() 1333 self.initConfigurationData()
1341 1334
1342def server_main(cooker, func, *args): 1335def server_main(cooker, func, *args):
1343 cooker.pre_serve() 1336 cooker.pre_serve()
diff --git a/bitbake/lib/bb/ui/crumbs/builder.py b/bitbake/lib/bb/ui/crumbs/builder.py
index 1ace5cf714..e0fc0d1114 100755
--- a/bitbake/lib/bb/ui/crumbs/builder.py
+++ b/bitbake/lib/bb/ui/crumbs/builder.py
@@ -704,7 +704,6 @@ class Builder(gtk.Window):
704 self.set_user_config_proxies() 704 self.set_user_config_proxies()
705 705
706 def set_user_config(self): 706 def set_user_config(self):
707 self.handler.reset_cooker()
708 # set bb layers 707 # set bb layers
709 self.handler.set_bblayers(self.configuration.layers) 708 self.handler.set_bblayers(self.configuration.layers)
710 # set local configuration 709 # set local configuration
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 06a05b67f4..ce8584df4c 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -149,9 +149,7 @@ class HobHandler(gobject.GObject):
149 elif next_command == self.SUB_MATCH_CLASS: 149 elif next_command == self.SUB_MATCH_CLASS:
150 self.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"]) 150 self.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"])
151 elif next_command == self.SUB_PARSE_CONFIG: 151 elif next_command == self.SUB_PARSE_CONFIG:
152 self.runCommand(["enableDataTracking"]) 152 self.runCommand(["resetCooker"])
153 self.runCommand(["parseConfigurationFiles", "conf/.hob.conf", ""])
154 self.runCommand(["disableDataTracking"])
155 elif next_command == self.SUB_GNERATE_TGTS: 153 elif next_command == self.SUB_GNERATE_TGTS:
156 self.runCommand(["generateTargetsTree", "classes/image.bbclass", []]) 154 self.runCommand(["generateTargetsTree", "classes/image.bbclass", []])
157 elif next_command == self.SUB_GENERATE_PKGINFO: 155 elif next_command == self.SUB_GENERATE_PKGINFO:
@@ -206,7 +204,8 @@ class HobHandler(gobject.GObject):
206 reparse = self.runCommand(["getVariable", "BB_INVALIDCONF"]) or None 204 reparse = self.runCommand(["getVariable", "BB_INVALIDCONF"]) or None
207 if reparse is True: 205 if reparse is True:
208 self.set_var_in_file("BB_INVALIDCONF", False, "local.conf") 206 self.set_var_in_file("BB_INVALIDCONF", False, "local.conf")
209 self.runCommand(["parseConfigurationFiles", "conf/.hob.conf", ""]) 207 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
208 self.commands_async.prepend(self.SUB_PARSE_CONFIG)
210 self.run_next_command() 209 self.run_next_command()
211 210
212 elif isinstance(event, bb.event.SanityCheckFailed): 211 elif isinstance(event, bb.event.SanityCheckFailed):
@@ -304,12 +303,8 @@ class HobHandler(gobject.GObject):
304 return 303 return
305 304
306 def init_cooker(self): 305 def init_cooker(self):
307 self.runCommand(["initCooker"])
308 self.runCommand(["createConfigFile", ".hob.conf"]) 306 self.runCommand(["createConfigFile", ".hob.conf"])
309 307
310 def reset_cooker(self):
311 self.runCommand(["resetCooker"])
312
313 def set_extra_inherit(self, bbclass): 308 def set_extra_inherit(self, bbclass):
314 inherits = self.runCommand(["getVariable", "INHERIT"]) or "" 309 inherits = self.runCommand(["getVariable", "INHERIT"]) or ""
315 inherits = inherits + " " + bbclass 310 inherits = inherits + " " + bbclass
@@ -409,15 +404,17 @@ class HobHandler(gobject.GObject):
409 self.run_next_command(self.NETWORK_TEST) 404 self.run_next_command(self.NETWORK_TEST)
410 405
411 def generate_configuration(self): 406 def generate_configuration(self):
412 self.commands_async.append(self.SUB_PARSE_CONFIG) 407 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
413 self.commands_async.append(self.SUB_PATH_LAYERS) 408 self.commands_async.append(self.SUB_PATH_LAYERS)
414 self.commands_async.append(self.SUB_FILES_DISTRO) 409 self.commands_async.append(self.SUB_FILES_DISTRO)
415 self.commands_async.append(self.SUB_FILES_MACH) 410 self.commands_async.append(self.SUB_FILES_MACH)
416 self.commands_async.append(self.SUB_FILES_SDKMACH) 411 self.commands_async.append(self.SUB_FILES_SDKMACH)
417 self.commands_async.append(self.SUB_MATCH_CLASS) 412 self.commands_async.append(self.SUB_MATCH_CLASS)
413 self.commands_async.append(self.SUB_PARSE_CONFIG)
418 self.run_next_command(self.GENERATE_CONFIGURATION) 414 self.run_next_command(self.GENERATE_CONFIGURATION)
419 415
420 def generate_recipes(self): 416 def generate_recipes(self):
417 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
421 self.commands_async.append(self.SUB_PARSE_CONFIG) 418 self.commands_async.append(self.SUB_PARSE_CONFIG)
422 self.commands_async.append(self.SUB_GNERATE_TGTS) 419 self.commands_async.append(self.SUB_GNERATE_TGTS)
423 self.run_next_command(self.GENERATE_RECIPES) 420 self.run_next_command(self.GENERATE_RECIPES)
@@ -427,6 +424,7 @@ class HobHandler(gobject.GObject):
427 targets.extend(tgts) 424 targets.extend(tgts)
428 self.recipe_queue = targets 425 self.recipe_queue = targets
429 self.default_task = default_task 426 self.default_task = default_task
427 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
430 self.commands_async.append(self.SUB_PARSE_CONFIG) 428 self.commands_async.append(self.SUB_PARSE_CONFIG)
431 self.commands_async.append(self.SUB_BUILD_RECIPES) 429 self.commands_async.append(self.SUB_BUILD_RECIPES)
432 self.run_next_command(self.GENERATE_PACKAGES) 430 self.run_next_command(self.GENERATE_PACKAGES)
@@ -438,6 +436,7 @@ class HobHandler(gobject.GObject):
438 self.package_queue = image_packages 436 self.package_queue = image_packages
439 self.toolchain_packages = toolchain_packages 437 self.toolchain_packages = toolchain_packages
440 self.default_task = default_task 438 self.default_task = default_task
439 self.runCommand(["setPrePostConfFiles", "conf/.hob.conf", ""])
441 self.commands_async.append(self.SUB_PARSE_CONFIG) 440 self.commands_async.append(self.SUB_PARSE_CONFIG)
442 self.commands_async.append(self.SUB_BUILD_IMAGE) 441 self.commands_async.append(self.SUB_BUILD_IMAGE)
443 self.run_next_command(self.GENERATE_IMAGE) 442 self.run_next_command(self.GENERATE_IMAGE)