mirror of
https://git.yoctoproject.org/poky
synced 2026-09-16 09:49:35 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
f7233d7612
commit
5c3f42dbcf
@@ -61,8 +61,11 @@ class HobHandler(gobject.GObject):
|
|||||||
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) = range(8)
|
||||||
|
|
||||||
def __init__(self, taskmodel, server):
|
def __init__(self, taskmodel, server):
|
||||||
gobject.GObject.__init__(self)
|
gobject.GObject.__init__(self)
|
||||||
|
|
||||||
self.current_command = None
|
self.current_command = None
|
||||||
self.building = None
|
self.building = None
|
||||||
self.gplv3_excluded = False
|
self.gplv3_excluded = False
|
||||||
@@ -76,30 +79,37 @@ class HobHandler(gobject.GObject):
|
|||||||
|
|
||||||
self.image_output_types = self.server.runCommand(["getVariable", "IMAGE_FSTYPES"]).split(" ")
|
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):
|
def run_next_command(self):
|
||||||
# FIXME: this is ugly and I *will* replace it
|
if self.current_command and not self.generating:
|
||||||
if self.current_command:
|
self.emit("generating-data")
|
||||||
if not self.generating:
|
self.generating = True
|
||||||
self.emit("generating-data")
|
|
||||||
self.generating = True
|
if self.current_command == self.CFG_PATH_LOCAL:
|
||||||
next_cmd = self.command_map[self.current_command]
|
self.current_command = self.CFG_PATH_HOB
|
||||||
command = next_cmd[0]
|
self.server.runCommand(["findConfigFilePath", "hob.local.conf"])
|
||||||
argument = next_cmd[1]
|
elif self.current_command == self.CFG_PATH_HOB:
|
||||||
self.current_command = next_cmd[2]
|
self.current_command = self.CFG_PATH_LAYERS
|
||||||
args = [command]
|
self.server.runCommand(["findConfigFilePath", "bblayers.conf"])
|
||||||
args.extend(argument)
|
elif self.current_command == self.CFG_PATH_LAYERS:
|
||||||
self.server.runCommand(args)
|
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):
|
def handle_event(self, event, running_build, pbar):
|
||||||
if not event:
|
if not event:
|
||||||
@@ -109,8 +119,6 @@ class HobHandler(gobject.GObject):
|
|||||||
if self.building:
|
if self.building:
|
||||||
running_build.handle_event(event)
|
running_build.handle_event(event)
|
||||||
elif isinstance(event, bb.event.TargetsTreeGenerated):
|
elif isinstance(event, bb.event.TargetsTreeGenerated):
|
||||||
self.emit("data-generated")
|
|
||||||
self.generating = False
|
|
||||||
if event._model:
|
if event._model:
|
||||||
self.model.populate(event._model)
|
self.model.populate(event._model)
|
||||||
elif isinstance(event, bb.event.ConfigFilesFound):
|
elif isinstance(event, bb.event.ConfigFilesFound):
|
||||||
@@ -188,7 +196,7 @@ class HobHandler(gobject.GObject):
|
|||||||
selected_packages, _ = self.model.get_selected_packages()
|
selected_packages, _ = self.model.get_selected_packages()
|
||||||
self.emit("reload-triggered", img, " ".join(selected_packages))
|
self.emit("reload-triggered", img, " ".join(selected_packages))
|
||||||
self.server.runCommand(["reparseFiles"])
|
self.server.runCommand(["reparseFiles"])
|
||||||
self.current_command = "findConfigFilePathLayers"
|
self.current_command = self.CFG_PATH_LAYERS
|
||||||
self.run_next_command()
|
self.run_next_command()
|
||||||
|
|
||||||
def set_bbthreads(self, threads):
|
def set_bbthreads(self, threads):
|
||||||
|
|||||||
@@ -929,7 +929,7 @@ def main (server, eventHandler):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# kick the while thing off
|
# kick the while thing off
|
||||||
handler.current_command = "findConfigFilePathLocal"
|
handler.current_command = handler.CFG_PATH_LOCAL
|
||||||
server.runCommand(["findConfigFilePath", "local.conf"])
|
server.runCommand(["findConfigFilePath", "local.conf"])
|
||||||
except xmlrpclib.Fault:
|
except xmlrpclib.Fault:
|
||||||
print("XMLRPC Fault getting commandline:\n %s" % x)
|
print("XMLRPC Fault getting commandline:\n %s" % x)
|
||||||
|
|||||||
Reference in New Issue
Block a user