cooker: Move commandline parsing back into the UI/cookerdata
PATCH 1/1 cooker: Move commandline parsing back into the UI/cookerdata
Building up a set of actions for the server is tricky since we depend upon the commandline but fall back to values from the datastore. We should be able to build a datastore without a commandline and vice versa. Ultimately the UI should send the commands to the server.
This patch amounts to code rearranging, moving the heavy lifting to the UI, though a helper in the configuration option. This will need further cleanup/tweaking but this should be the only update needed to the UIs. The code now queries the server for any missing data should it need to.
This code allows various knowledge of configuration variables to move to the UI side only, partcularly pkgs_to_build but also all the command specifiers. It should also be possible to move cmd eventually, I'm just unsure if any callers call the commands expecting this to default to something sane right now.
---
bitbake/bin/bitbake +1 -2
@@ -238,7 +238,6 @@ def main(): try: configuration.setServerRegIdleCallback(server.getServerIdleCB()) cooker = bb.cooker.BBCooker(configuration) - cooker.parseCommandLine() server.addcooker(cooker) server.saveConnectionDetails()
@@ -272,7 +271,7 @@ def main(): os.environ[k] = cleanedvars[k] try: - return server.launchUI(ui_main, server_connection.connection, server_connection.events) + return server.launchUI(ui_main, server_connection.connection, server_connection.events, configParams) finally: bb.event.ui_queue = [] server_connection.terminate()
bitbake/lib/bb/command.py +8 -12
@@ -143,18 +143,6 @@ class CommandsSync: """ command.cooker.stop() - def getCmdLineAction(self, command, params): - """ - Get any command parsed from the commandline - """ - cmd_action = command.cooker.commandlineAction - if cmd_action is None: - return None - elif 'msg' in cmd_action and cmd_action['msg']: - raise CommandError(cmd_action['msg']) - else: - return cmd_action['action'] - def getVariable(self, command, params): """ Read the value of a variable from configuration.data
@@ -174,6 +162,14 @@ class CommandsSync: value = str(params[1]) command.cooker.configuration.data.setVar(varname, value) + def setConfig(self, command, params): + """ + Set the value of variable in configuration + """ + varname = params[0] + value = str(params[1]) + setattr(command.cooker.configuration, varname, value) + def enableDataTracking(self, command, params): """ Enable history tracking for variables
bitbake/lib/bb/cooker.py +1 -46
71 lines not on this page · raw message
bitbake/lib/bb/cookerdata.py +56 -1
69 lines not on this page · raw message
bitbake/lib/bb/ui/depexp.py +9 -7
@@ -196,16 +196,18 @@ class gtkthread(threading.Thread): gtkthread.quit.set() -def main(server, eventHandler): +def main(server, eventHandler, params): try: - cmdline, error = server.runCommand(["getCmdLineAction"]) - if error: - print("Error getting bitbake commandline: %s" % error) - return 1 - elif not cmdline: + params.updateFromServer(server) + cmdline = params.parseActions() + if not cmdline: print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") return 1 - elif not cmdline or cmdline[0] != "generateDotGraph": + if 'msg' in cmdline and cmdline['msg']: + logger.error(cmdline['msg']) + return 1 + cmdline = cmdline['action'] + if not cmdline or cmdline[0] != "generateDotGraph": print("This UI is only compatible with the -g option") return 1 ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]])
bitbake/lib/bb/ui/goggle.py +8 -6
@@ -63,7 +63,7 @@ class MainWindow (gtk.Window): scrolled_window.add (self.cur_build_tv) -def main (server, eventHandler): +def main (server, eventHandler, params): gobject.threads_init() gtk.gdk.threads_init()
@@ -80,13 +80,15 @@ def main (server, eventHandler): running_build.connect ("build-failed", running_build_failed_cb) try: - cmdline, error = server.runCommand(["getCmdLineAction"]) - if error: - print("Error getting bitbake commandline: %s" % error) - return 1 - elif not cmdline: + params.updateFromServer(server) + cmdline = params.parseActions() + if not cmdline: print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") return 1 + if 'msg' in cmdline and cmdline['msg']: + logger.error(cmdline['msg']) + return 1 + cmdline = cmdline['action'] ret, error = server.runCommand(cmdline) if error: print("Error running command '%s': %s" % (cmdline, error))
bitbake/lib/bb/ui/hob.py +2 -1
@@ -58,7 +58,8 @@ def event_handle_idle_func(eventHandler, hobHandler): event = eventHandler.getEvent() return True -def main (server = None, eventHandler = None): +def main (server, eventHandler, params): + params.updateFromServer(server) gobject.threads_init() # That indicates whether the Hob and the bitbake server are
bitbake/lib/bb/ui/knotty.py +11 -8
@@ -216,7 +216,7 @@ class TerminalFilter(object): fd = sys.stdin.fileno() self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) -def main(server, eventHandler, tf = TerminalFilter): +def main(server, eventHandler, params, tf = TerminalFilter): # Get values of variables which control our output includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
@@ -245,7 +245,8 @@ def main(server, eventHandler, tf = TerminalFilter): bb.msg.addDefaultlogFilter(console) console.setFormatter(format) logger.addHandler(console) - if consolelogfile: + + if consolelogfile and not params.options.show_environment: bb.utils.mkdirhier(os.path.dirname(consolelogfile)) conlogformat = bb.msg.BBLogFormatter(format_str) consolelog = logging.FileHandler(consolelogfile)
@@ -254,14 +255,16 @@ def main(server, eventHandler, tf = TerminalFilter): logger.addHandler(consolelog) try: - cmdline, error = server.runCommand(["getCmdLineAction"]) - if error: - logger.error("Unable to get bitbake commandline arguments: %s" % error) - return 1 - elif not cmdline: + params.updateFromServer(server) + cmdline = params.parseActions() + if not cmdline: print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") return 1 - ret, error = server.runCommand(cmdline) + if 'msg' in cmdline and cmdline['msg']: + logger.error(cmdline['msg']) + return 1 + + ret, error = server.runCommand(cmdline['action']) if error: logger.error("Command '%s' failed: %s" % (cmdline, error)) return 1
bitbake/lib/bb/ui/ncurses.py +8 -6
@@ -196,7 +196,7 @@ class NCursesUI: # t.start() #-------------------------------------------------------------------------# - def main(self, stdscr, server, eventHandler): + def main(self, stdscr, server, eventHandler, params): #-------------------------------------------------------------------------# height, width = stdscr.getmaxyx()
@@ -236,13 +236,15 @@ class NCursesUI: shutdown = 0 try: - cmdline, error = server.runCommand(["getCmdLineAction"]) + params.updateFromServer(server) + cmdline = params.parseActions() if not cmdline: print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") - return - elif error: - print("Error getting bitbake commandline: %s" % error) - return + return 1 + if 'msg' in cmdline and cmdline['msg']: + logger.error(cmdline['msg']) + return 1 + cmdline = cmdline['action'] ret, error = server.runCommand(cmdline) if error: print("Error running command '%s': %s" % (cmdline, error))