summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
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
parentf7233d7612c01886233c4627547aec6eecd28256 (diff)
downloadpoky-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')
-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 2f45350c32..78a50901d5 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):
61 gobject.TYPE_STRING)), 61 gobject.TYPE_STRING)),
62 } 62 }
63 63
64 (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)
65
64 def __init__(self, taskmodel, server): 66 def __init__(self, taskmodel, server):
65 gobject.GObject.__init__(self) 67 gobject.GObject.__init__(self)
68
66 self.current_command = None 69 self.current_command = None
67 self.building = None 70 self.building = None
68 self.gplv3_excluded = False 71 self.gplv3_excluded = False
@@ -76,30 +79,37 @@ class HobHandler(gobject.GObject):
76 79
77 self.image_output_types = self.server.runCommand(["getVariable", "IMAGE_FSTYPES"]).split(" ") 80 self.image_output_types = self.server.runCommand(["getVariable", "IMAGE_FSTYPES"]).split(" ")
78 81
79 self.command_map = {
80 "findConfigFilePathLocal" : ("findConfigFilePath", ["hob.local.conf"], "findConfigFilePathHobLocal"),
81 "findConfigFilePathHobLocal" : ("findConfigFilePath", ["bblayers.conf"], "findConfigFilePathLayers"),
82 "findConfigFilePathLayers" : ("findConfigFiles", ["DISTRO"], "findConfigFilesDistro"),
83 "findConfigFilesDistro" : ("findConfigFiles", ["MACHINE"], "findConfigFilesMachine"),
84 "findConfigFilesMachine" : ("findConfigFiles", ["MACHINE-SDK"], "findConfigFilesSdkMachine"),
85 "findConfigFilesSdkMachine" : ("findFilesMatchingInDir", ["rootfs_", "classes"], "findFilesMatchingPackage"),
86 "findFilesMatchingPackage" : ("generateTargetsTree", ["classes/image.bbclass"], None),
87 "generateTargetsTree" : (None, [], None),
88 }
89
90 def run_next_command(self): 82 def run_next_command(self):
91 # FIXME: this is ugly and I *will* replace it 83 if self.current_command and not self.generating:
92 if self.current_command: 84 self.emit("generating-data")
93 if not self.generating: 85 self.generating = True
94 self.emit("generating-data") 86
95 self.generating = True 87 if self.current_command == self.CFG_PATH_LOCAL:
96 next_cmd = self.command_map[self.current_command] 88 self.current_command = self.CFG_PATH_HOB
97 command = next_cmd[0] 89 self.server.runCommand(["findConfigFilePath", "hob.local.conf"])
98 argument = next_cmd[1] 90 elif self.current_command == self.CFG_PATH_HOB:
99 self.current_command = next_cmd[2] 91 self.current_command = self.CFG_PATH_LAYERS
100 args = [command] 92 self.server.runCommand(["findConfigFilePath", "bblayers.conf"])
101 args.extend(argument) 93 elif self.current_command == self.CFG_PATH_LAYERS:
102 self.server.runCommand(args) 94 self.current_command = self.CFG_FILES_DISTRO
95 self.server.runCommand(["findConfigFiles", "DISTRO"])
96 elif self.current_command == self.CFG_FILES_DISTRO:
97 self.current_command = self.CFG_FILES_MACH
98 self.server.runCommand(["findConfigFiles", "MACHINE"])
99 elif self.current_command == self.CFG_FILES_MACH:
100 self.current_command = self.CFG_FILES_SDK
101 self.server.runCommand(["findConfigFiles", "MACHINE-SDK"])
102 elif self.current_command == self.CFG_FILES_SDK:
103 self.current_command = self.FILES_MATCH_CLASS
104 self.server.runCommand(["findFilesMatchingInDir", "rootfs_", "classes"])
105 elif self.current_command == self.FILES_MATCH_CLASS:
106 self.current_command = self.GENERATE_TGTS
107 self.server.runCommand(["generateTargetsTree", "classes/image.bbclass"])
108 elif self.current_command == self.GENERATE_TGTS:
109 if self.generating:
110 self.emit("data-generated")
111 self.generating = False
112 self.current_command = None
103 113
104 def handle_event(self, event, running_build, pbar): 114 def handle_event(self, event, running_build, pbar):
105 if not event: 115 if not event:
@@ -109,8 +119,6 @@ class HobHandler(gobject.GObject):
109 if self.building: 119 if self.building:
110 running_build.handle_event(event) 120 running_build.handle_event(event)
111 elif isinstance(event, bb.event.TargetsTreeGenerated): 121 elif isinstance(event, bb.event.TargetsTreeGenerated):
112 self.emit("data-generated")
113 self.generating = False
114 if event._model: 122 if event._model:
115 self.model.populate(event._model) 123 self.model.populate(event._model)
116 elif isinstance(event, bb.event.ConfigFilesFound): 124 elif isinstance(event, bb.event.ConfigFilesFound):
@@ -188,7 +196,7 @@ class HobHandler(gobject.GObject):
188 selected_packages, _ = self.model.get_selected_packages() 196 selected_packages, _ = self.model.get_selected_packages()
189 self.emit("reload-triggered", img, " ".join(selected_packages)) 197 self.emit("reload-triggered", img, " ".join(selected_packages))
190 self.server.runCommand(["reparseFiles"]) 198 self.server.runCommand(["reparseFiles"])
191 self.current_command = "findConfigFilePathLayers" 199 self.current_command = self.CFG_PATH_LAYERS
192 self.run_next_command() 200 self.run_next_command()
193 201
194 def set_bbthreads(self, threads): 202 def set_bbthreads(self, threads):
diff --git a/bitbake/lib/bb/ui/hob.py b/bitbake/lib/bb/ui/hob.py
index 09a63c6717..448d590e49 100644
--- a/bitbake/lib/bb/ui/hob.py
+++ b/bitbake/lib/bb/ui/hob.py
@@ -929,7 +929,7 @@ def main (server, eventHandler):
929 929
930 try: 930 try:
931 # kick the while thing off 931 # kick the while thing off
932 handler.current_command = "findConfigFilePathLocal" 932 handler.current_command = handler.CFG_PATH_LOCAL
933 server.runCommand(["findConfigFilePath", "local.conf"]) 933 server.runCommand(["findConfigFilePath", "local.conf"])
934 except xmlrpclib.Fault: 934 except xmlrpclib.Fault:
935 print("XMLRPC Fault getting commandline:\n %s" % x) 935 print("XMLRPC Fault getting commandline:\n %s" % x)