summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-07-13 16:01:43 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-26 20:15:47 +0100
commit5c3f42dbcf4d1b6ed21f50be95b4fb39eb7ae3c0 (patch)
tree15c71859b23567f06a8ff5462ea373a0c88867b6 /bitbake/lib/bb/ui
parentf7233d7612c01886233c4627547aec6eecd28256 (diff)
downloadast2050-yocto-poky-5c3f42dbcf4d1b6ed21f50be95b4fb39eb7ae3c0.zip
ast2050-yocto-poky-5c3f42dbcf4d1b6ed21f50be95b4fb39eb7ae3c0.tar.gz
ui/hob: replace the ugly static command map
The command_map was never a good idea, what's implemented here is a fraction less ugly but a significant factor more readable and therefore easy to maintain. The method implemented in this patch also has the advantage of not being static meaning we can determine the desired runCommand arguments dynamically at call time. (Bitbake rev: 8b11c68ffcda355d0ba49cfc27790d245192ae24) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r--bitbake/lib/bb/ui/crumbs/hobeventhandler.py60
-rw-r--r--bitbake/lib/bb/ui/hob.py2
2 files changed, 35 insertions, 27 deletions
diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
index 2f45350..78a5090 100644
--- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
+++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py
@@ -61,8 +61,11 @@ class HobHandler(gobject.GObject):
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) = range(8)
+
def __init__(self, taskmodel, server):
gobject.GObject.__init__(self)
+
self.current_command = None
self.building = None
self.gplv3_excluded = False
@@ -76,30 +79,37 @@ class HobHandler(gobject.GObject):
self.image_output_types = self.server.runCommand(["getVariable", "IMAGE_FSTYPES"]).split(" ")
- self.command_map = {
- "findConfigFilePathLocal" : ("findConfigFilePath", ["hob.local.conf"], "findConfigFilePathHobLocal"),
- "findConfigFilePathHobLocal" : ("findConfigFilePath", ["bblayers.conf"], "findConfigFilePathLayers"),
- "findConfigFilePathLayers" : ("findConfigFiles", ["DISTRO"], "findConfigFilesDistro"),
- "findConfigFilesDistro" : ("findConfigFiles", ["MACHINE"], "findConfigFilesMachine"),
- "findConfigFilesMachine" : ("findConfigFiles", ["MACHINE-SDK"], "findConfigFilesSdkMachine"),
- "findConfigFilesSdkMachine" : ("findFilesMatchingInDir", ["rootfs_", "classes"], "findFilesMatchingPackage"),
- "findFilesMatchingPackage" : ("generateTargetsTree", ["classes/image.bbclass"], None),
- "generateTargetsTree" : (None, [], None),
- }
-
def run_next_command(self):
- # FIXME: this is ugly and I *will* replace it
- if self.current_command:
- if not self.generating:
- self.emit("generating-data")
- self.generating = True
- next_cmd = self.command_map[self.current_command]
- command = next_cmd[0]
- argument = next_cmd[1]
- self.current_command = next_cmd[2]
- args = [command]
- args.extend(argument)
- self.server.runCommand(args)
+ if self.current_command and not self.generating:
+ self.emit("generating-data")
+ self.generating = True
+
+ if self.current_command == self.CFG_PATH_LOCAL:
+ self.current_command = self.CFG_PATH_HOB
+ self.server.runCommand(["findConfigFilePath", "hob.local.conf"])
+ elif self.current_command == self.CFG_PATH_HOB:
+ self.current_command = self.CFG_PATH_LAYERS
+ self.server.runCommand(["findConfigFilePath", "bblayers.conf"])
+ elif self.current_command == self.CFG_PATH_LAYERS:
+ self.current_command = self.CFG_FILES_DISTRO
+ self.server.runCommand(["findConfigFiles", "DISTRO"])
+ elif self.current_command == self.CFG_FILES_DISTRO:
+ self.current_command = self.CFG_FILES_MACH
+ self.server.runCommand(["findConfigFiles", "MACHINE"])
+ elif self.current_command == self.CFG_FILES_MACH:
+ self.current_command = self.CFG_FILES_SDK
+ self.server.runCommand(["findConfigFiles", "MACHINE-SDK"])
+ elif self.current_command == self.CFG_FILES_SDK:
+ self.current_command = self.FILES_MATCH_CLASS
+ self.server.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"])
+ elif self.current_command == self.FILES_MATCH_CLASS:
+ self.current_command = self.GENERATE_TGTS
+ self.server.runCommand(["generateTargetsTree", "classes/image.bbclass"])
+ elif self.current_command == self.GENERATE_TGTS:
+ if self.generating:
+ self.emit("data-generated")
+ self.generating = False
+ self.current_command = None
def handle_event(self, event, running_build, pbar):
if not event:
@@ -109,8 +119,6 @@ class HobHandler(gobject.GObject):
if self.building:
running_build.handle_event(event)
elif isinstance(event, bb.event.TargetsTreeGenerated):
- self.emit("data-generated")
- self.generating = False
if event._model:
self.model.populate(event._model)
elif isinstance(event, bb.event.ConfigFilesFound):
@@ -188,7 +196,7 @@ class HobHandler(gobject.GObject):
selected_packages, _ = self.model.get_selected_packages()
self.emit("reload-triggered", img, " ".join(selected_packages))
self.server.runCommand(["reparseFiles"])
- self.current_command = "findConfigFilePathLayers"
+ self.current_command = self.CFG_PATH_LAYERS
self.run_next_command()
def set_bbthreads(self, threads):
diff --git a/bitbake/lib/bb/ui/hob.py b/bitbake/lib/bb/ui/hob.py
index 09a63c6..448d590 100644
--- a/bitbake/lib/bb/ui/hob.py
+++ b/bitbake/lib/bb/ui/hob.py
@@ -929,7 +929,7 @@ def main (server, eventHandler):
try:
# kick the while thing off
- handler.current_command = "findConfigFilePathLocal"
+ handler.current_command = handler.CFG_PATH_LOCAL
server.runCommand(["findConfigFilePath", "local.conf"])
except xmlrpclib.Fault:
print("XMLRPC Fault getting commandline:\n %s" % x)
OpenPOWER on IntegriCloud