summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbitbake/bin/bitbake3
-rw-r--r--bitbake/lib/bb/command.py20
-rw-r--r--bitbake/lib/bb/cooker.py47
-rw-r--r--bitbake/lib/bb/cookerdata.py57
-rw-r--r--bitbake/lib/bb/ui/depexp.py16
-rw-r--r--bitbake/lib/bb/ui/goggle.py14
-rwxr-xr-xbitbake/lib/bb/ui/hob.py3
-rw-r--r--bitbake/lib/bb/ui/knotty.py19
-rw-r--r--bitbake/lib/bb/ui/ncurses.py14
9 files changed, 104 insertions, 89 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index 7087d2d94b..c87e5b3984 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -238,7 +238,6 @@ def main():
238 try: 238 try:
239 configuration.setServerRegIdleCallback(server.getServerIdleCB()) 239 configuration.setServerRegIdleCallback(server.getServerIdleCB())
240 cooker = bb.cooker.BBCooker(configuration) 240 cooker = bb.cooker.BBCooker(configuration)
241 cooker.parseCommandLine()
242 241
243 server.addcooker(cooker) 242 server.addcooker(cooker)
244 server.saveConnectionDetails() 243 server.saveConnectionDetails()
@@ -272,7 +271,7 @@ def main():
272 os.environ[k] = cleanedvars[k] 271 os.environ[k] = cleanedvars[k]
273 272
274 try: 273 try:
275 return server.launchUI(ui_main, server_connection.connection, server_connection.events) 274 return server.launchUI(ui_main, server_connection.connection, server_connection.events, configParams)
276 finally: 275 finally:
277 bb.event.ui_queue = [] 276 bb.event.ui_queue = []
278 server_connection.terminate() 277 server_connection.terminate()
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 8577df6e0c..29d31d5985 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -143,18 +143,6 @@ class CommandsSync:
143 """ 143 """
144 command.cooker.stop() 144 command.cooker.stop()
145 145
146 def getCmdLineAction(self, command, params):
147 """
148 Get any command parsed from the commandline
149 """
150 cmd_action = command.cooker.commandlineAction
151 if cmd_action is None:
152 return None
153 elif 'msg' in cmd_action and cmd_action['msg']:
154 raise CommandError(cmd_action['msg'])
155 else:
156 return cmd_action['action']
157
158 def getVariable(self, command, params): 146 def getVariable(self, command, params):
159 """ 147 """
160 Read the value of a variable from configuration.data 148 Read the value of a variable from configuration.data
@@ -174,6 +162,14 @@ class CommandsSync:
174 value = str(params[1]) 162 value = str(params[1])
175 command.cooker.configuration.data.setVar(varname, value) 163 command.cooker.configuration.data.setVar(varname, value)
176 164
165 def setConfig(self, command, params):
166 """
167 Set the value of variable in configuration
168 """
169 varname = params[0]
170 value = str(params[1])
171 setattr(command.cooker.configuration, varname, value)
172
177 def enableDataTracking(self, command, params): 173 def enableDataTracking(self, command, params):
178 """ 174 """
179 Enable history tracking for variables 175 Enable history tracking for variables
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 1a2c01639e..ca544558f0 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -147,10 +147,6 @@ class BBCooker:
147 if not self.lock: 147 if not self.lock:
148 bb.fatal("Only one copy of bitbake should be run against a build directory") 148 bb.fatal("Only one copy of bitbake should be run against a build directory")
149 149
150 bbpkgs = self.configuration.data.getVar('BBPKGS', True)
151 if bbpkgs and len(self.configuration.pkgs_to_build) == 0:
152 self.configuration.pkgs_to_build.extend(bbpkgs.split())
153
154 # 150 #
155 # Special updated configuration we use for firing events 151 # Special updated configuration we use for firing events
156 # 152 #
@@ -175,7 +171,7 @@ class BBCooker:
175 171
176 def initConfigurationData(self): 172 def initConfigurationData(self):
177 self.configuration.data = bb.data.init() 173 self.configuration.data = bb.data.init()
178 if self.configuration.show_environment: 174 if self.configuration.tracking:
179 self.configuration.data.enableTracking() 175 self.configuration.data.enableTracking()
180 176
181 if not self.configuration.server_register_idlecallback: 177 if not self.configuration.server_register_idlecallback:
@@ -203,9 +199,6 @@ class BBCooker:
203 logger.exception("Error parsing configuration files") 199 logger.exception("Error parsing configuration files")
204 sys.exit(1) 200 sys.exit(1)
205 201
206 if not self.configuration.cmd:
207 self.configuration.cmd = self.configuration.data.getVar("BB_DEFAULT_TASK", True) or "build"
208
209 def saveConfigurationVar(self, var, val, default_file): 202 def saveConfigurationVar(self, var, val, default_file):
210 203
211 replaced = False 204 replaced = False
@@ -309,44 +302,6 @@ class BBCooker:
309 302
310 self.handleCollections( self.configuration.data.getVar("BBFILE_COLLECTIONS", True) ) 303 self.handleCollections( self.configuration.data.getVar("BBFILE_COLLECTIONS", True) )
311 304
312 def parseCommandLine(self):
313 # Parse any commandline into actions
314 self.commandlineAction = {'action':None, 'msg':None}
315 if self.configuration.show_environment:
316 if 'world' in self.configuration.pkgs_to_build:
317 self.commandlineAction['msg'] = "'world' is not a valid target for --environment."
318 elif 'universe' in self.configuration.pkgs_to_build:
319 self.commandlineAction['msg'] = "'universe' is not a valid target for --environment."
320 elif len(self.configuration.pkgs_to_build) > 1:
321 self.commandlineAction['msg'] = "Only one target can be used with the --environment option."
322 elif self.configuration.buildfile and len(self.configuration.pkgs_to_build) > 0:
323 self.commandlineAction['msg'] = "No target should be used with the --environment and --buildfile options."
324 elif len(self.configuration.pkgs_to_build) > 0:
325 self.commandlineAction['action'] = ["showEnvironmentTarget", self.configuration.pkgs_to_build]
326 self.configuration.data.setVar("BB_CONSOLELOG", None)
327 else:
328 self.commandlineAction['action'] = ["showEnvironment", self.configuration.buildfile]
329 self.configuration.data.setVar("BB_CONSOLELOG", None)
330 elif self.configuration.buildfile is not None:
331 self.commandlineAction['action'] = ["buildFile", self.configuration.buildfile, self.configuration.cmd]
332 elif self.configuration.revisions_changed:
333 self.commandlineAction['action'] = ["compareRevisions"]
334 elif self.configuration.show_versions:
335 self.commandlineAction['action'] = ["showVersions"]
336 elif self.configuration.parse_only:
337 self.commandlineAction['action'] = ["parseFiles"]
338 elif self.configuration.dot_graph:
339 if self.configuration.pkgs_to_build:
340 self.commandlineAction['action'] = ["generateDotGraph", self.configuration.pkgs_to_build, self.configuration.cmd]
341 else:
342 self.commandlineAction['msg'] = "Please specify a package name for dependency graph generation."
343 else:
344 if self.configuration.pkgs_to_build:
345 self.commandlineAction['action'] = ["buildTargets", self.configuration.pkgs_to_build, self.configuration.cmd]
346 else:
347 #self.commandlineAction['msg'] = "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."
348 self.commandlineAction = None
349
350 def runCommands(self, server, data, abort): 305 def runCommands(self, server, data, abort):
351 """ 306 """
352 Run any queued asynchronous command 307 Run any queued asynchronous command
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 2c3275ac65..3c2469ef87 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -50,6 +50,61 @@ class ConfigParameters(object):
50 def parseEnvironment(self): 50 def parseEnvironment(self):
51 return os.environ.copy() 51 return os.environ.copy()
52 52
53 def updateFromServer(self, server):
54 if not self.options.cmd:
55 defaulttask, error = server.runCommand(["getVariable", "BB_DEFAULT_TASK"])
56 if error:
57 raise Exception("Unable to get the value of BB_DEFAULT_TASK from the server: %s" % error)
58 self.options.cmd = defaulttask or "build"
59 _, error = server.runCommand(["setConfig", "cmd", self.options.cmd])
60 if error:
61 raise Exception("Unable to set configuration option 'cmd' on the server: %s" % error)
62
63 if not self.options.pkgs_to_build:
64 bbpkgs, error = server.runCommand(["getVariable", "BBPKGS"])
65 if error:
66 raise Exception("Unable to get the value of BBPKGS from the server: %s" % error)
67 if bbpkgs:
68 self.options.pkgs_to_build.extend(bbpkgs.split())
69
70 def parseActions(self):
71 # Parse any commandline into actions
72 action = {'action':None, 'msg':None}
73 if self.options.show_environment:
74 if 'world' in self.options.pkgs_to_build:
75 action['msg'] = "'world' is not a valid target for --environment."
76 elif 'universe' in self.options.pkgs_to_build:
77 action['msg'] = "'universe' is not a valid target for --environment."
78 elif len(self.options.pkgs_to_build) > 1:
79 action['msg'] = "Only one target can be used with the --environment option."
80 elif self.options.buildfile and len(self.options.pkgs_to_build) > 0:
81 action['msg'] = "No target should be used with the --environment and --buildfile options."
82 elif len(self.options.pkgs_to_build) > 0:
83 action['action'] = ["showEnvironmentTarget", self.options.pkgs_to_build]
84 else:
85 action['action'] = ["showEnvironment", self.options.buildfile]
86 elif self.options.buildfile is not None:
87 action['action'] = ["buildFile", self.options.buildfile, self.options.cmd]
88 elif self.options.revisions_changed:
89 action['action'] = ["compareRevisions"]
90 elif self.options.show_versions:
91 action['action'] = ["showVersions"]
92 elif self.options.parse_only:
93 action['action'] = ["parseFiles"]
94 elif self.options.dot_graph:
95 if self.options.pkgs_to_build:
96 action['action'] = ["generateDotGraph", self.options.pkgs_to_build, self.options.cmd]
97 else:
98 action['msg'] = "Please specify a package name for dependency graph generation."
99 else:
100 if self.options.pkgs_to_build:
101 action['action'] = ["buildTargets", self.options.pkgs_to_build, self.options.cmd]
102 else:
103 #action['msg'] = "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information."
104 action = None
105 self.options.initialaction = action
106 return action
107
53class CookerConfiguration(object): 108class CookerConfiguration(object):
54 """ 109 """
55 Manages build options and configurations for one run 110 Manages build options and configurations for one run
@@ -61,7 +116,7 @@ class CookerConfiguration(object):
61 self.prefile = [] 116 self.prefile = []
62 self.postfile = [] 117 self.postfile = []
63 self.debug = 0 118 self.debug = 0
64 self.pkgs_to_build = [] 119 self.cmd = None
65 120
66 def setConfigParameters(self, parameters): 121 def setConfigParameters(self, parameters):
67 self.params = parameters 122 self.params = parameters
diff --git a/bitbake/lib/bb/ui/depexp.py b/bitbake/lib/bb/ui/depexp.py
index 85910f6925..885c31aeac 100644
--- a/bitbake/lib/bb/ui/depexp.py
+++ b/bitbake/lib/bb/ui/depexp.py
@@ -196,16 +196,18 @@ class gtkthread(threading.Thread):
196 gtkthread.quit.set() 196 gtkthread.quit.set()
197 197
198 198
199def main(server, eventHandler): 199def main(server, eventHandler, params):
200 try: 200 try:
201 cmdline, error = server.runCommand(["getCmdLineAction"]) 201 params.updateFromServer(server)
202 if error: 202 cmdline = params.parseActions()
203 print("Error getting bitbake commandline: %s" % error) 203 if not cmdline:
204 return 1
205 elif not cmdline:
206 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 204 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
207 return 1 205 return 1
208 elif not cmdline or cmdline[0] != "generateDotGraph": 206 if 'msg' in cmdline and cmdline['msg']:
207 logger.error(cmdline['msg'])
208 return 1
209 cmdline = cmdline['action']
210 if not cmdline or cmdline[0] != "generateDotGraph":
209 print("This UI is only compatible with the -g option") 211 print("This UI is only compatible with the -g option")
210 return 1 212 return 1
211 ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]]) 213 ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]])
diff --git a/bitbake/lib/bb/ui/goggle.py b/bitbake/lib/bb/ui/goggle.py
index e8a54ab295..16faba4c21 100644
--- a/bitbake/lib/bb/ui/goggle.py
+++ b/bitbake/lib/bb/ui/goggle.py
@@ -63,7 +63,7 @@ class MainWindow (gtk.Window):
63 scrolled_window.add (self.cur_build_tv) 63 scrolled_window.add (self.cur_build_tv)
64 64
65 65
66def main (server, eventHandler): 66def main (server, eventHandler, params):
67 gobject.threads_init() 67 gobject.threads_init()
68 gtk.gdk.threads_init() 68 gtk.gdk.threads_init()
69 69
@@ -80,13 +80,15 @@ def main (server, eventHandler):
80 running_build.connect ("build-failed", running_build_failed_cb) 80 running_build.connect ("build-failed", running_build_failed_cb)
81 81
82 try: 82 try:
83 cmdline, error = server.runCommand(["getCmdLineAction"]) 83 params.updateFromServer(server)
84 if error: 84 cmdline = params.parseActions()
85 print("Error getting bitbake commandline: %s" % error) 85 if not cmdline:
86 return 1
87 elif not cmdline:
88 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 86 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
89 return 1 87 return 1
88 if 'msg' in cmdline and cmdline['msg']:
89 logger.error(cmdline['msg'])
90 return 1
91 cmdline = cmdline['action']
90 ret, error = server.runCommand(cmdline) 92 ret, error = server.runCommand(cmdline)
91 if error: 93 if error:
92 print("Error running command '%s': %s" % (cmdline, error)) 94 print("Error running command '%s': %s" % (cmdline, error))
diff --git a/bitbake/lib/bb/ui/hob.py b/bitbake/lib/bb/ui/hob.py
index 55bd84cca8..2c75cb8fd1 100755
--- a/bitbake/lib/bb/ui/hob.py
+++ b/bitbake/lib/bb/ui/hob.py
@@ -58,7 +58,8 @@ def event_handle_idle_func(eventHandler, hobHandler):
58 event = eventHandler.getEvent() 58 event = eventHandler.getEvent()
59 return True 59 return True
60 60
61def main (server = None, eventHandler = None): 61def main (server, eventHandler, params):
62 params.updateFromServer(server)
62 gobject.threads_init() 63 gobject.threads_init()
63 64
64 # That indicates whether the Hob and the bitbake server are 65 # That indicates whether the Hob and the bitbake server are
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 6ea7d8694c..389c3cc64d 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -216,7 +216,7 @@ class TerminalFilter(object):
216 fd = sys.stdin.fileno() 216 fd = sys.stdin.fileno()
217 self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup) 217 self.termios.tcsetattr(fd, self.termios.TCSADRAIN, self.stdinbackup)
218 218
219def main(server, eventHandler, tf = TerminalFilter): 219def main(server, eventHandler, params, tf = TerminalFilter):
220 220
221 # Get values of variables which control our output 221 # Get values of variables which control our output
222 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"]) 222 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
@@ -245,7 +245,8 @@ def main(server, eventHandler, tf = TerminalFilter):
245 bb.msg.addDefaultlogFilter(console) 245 bb.msg.addDefaultlogFilter(console)
246 console.setFormatter(format) 246 console.setFormatter(format)
247 logger.addHandler(console) 247 logger.addHandler(console)
248 if consolelogfile: 248
249 if consolelogfile and not params.options.show_environment:
249 bb.utils.mkdirhier(os.path.dirname(consolelogfile)) 250 bb.utils.mkdirhier(os.path.dirname(consolelogfile))
250 conlogformat = bb.msg.BBLogFormatter(format_str) 251 conlogformat = bb.msg.BBLogFormatter(format_str)
251 consolelog = logging.FileHandler(consolelogfile) 252 consolelog = logging.FileHandler(consolelogfile)
@@ -254,14 +255,16 @@ def main(server, eventHandler, tf = TerminalFilter):
254 logger.addHandler(consolelog) 255 logger.addHandler(consolelog)
255 256
256 try: 257 try:
257 cmdline, error = server.runCommand(["getCmdLineAction"]) 258 params.updateFromServer(server)
258 if error: 259 cmdline = params.parseActions()
259 logger.error("Unable to get bitbake commandline arguments: %s" % error) 260 if not cmdline:
260 return 1
261 elif not cmdline:
262 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 261 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
263 return 1 262 return 1
264 ret, error = server.runCommand(cmdline) 263 if 'msg' in cmdline and cmdline['msg']:
264 logger.error(cmdline['msg'])
265 return 1
266
267 ret, error = server.runCommand(cmdline['action'])
265 if error: 268 if error:
266 logger.error("Command '%s' failed: %s" % (cmdline, error)) 269 logger.error("Command '%s' failed: %s" % (cmdline, error))
267 return 1 270 return 1
diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py
index 98647fc3e0..c45ffd63ac 100644
--- a/bitbake/lib/bb/ui/ncurses.py
+++ b/bitbake/lib/bb/ui/ncurses.py
@@ -196,7 +196,7 @@ class NCursesUI:
196# t.start() 196# t.start()
197 197
198 #-------------------------------------------------------------------------# 198 #-------------------------------------------------------------------------#
199 def main(self, stdscr, server, eventHandler): 199 def main(self, stdscr, server, eventHandler, params):
200 #-------------------------------------------------------------------------# 200 #-------------------------------------------------------------------------#
201 height, width = stdscr.getmaxyx() 201 height, width = stdscr.getmaxyx()
202 202
@@ -236,13 +236,15 @@ class NCursesUI:
236 shutdown = 0 236 shutdown = 0
237 237
238 try: 238 try:
239 cmdline, error = server.runCommand(["getCmdLineAction"]) 239 params.updateFromServer(server)
240 cmdline = params.parseActions()
240 if not cmdline: 241 if not cmdline:
241 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 242 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
242 return 243 return 1
243 elif error: 244 if 'msg' in cmdline and cmdline['msg']:
244 print("Error getting bitbake commandline: %s" % error) 245 logger.error(cmdline['msg'])
245 return 246 return 1
247 cmdline = cmdline['action']
246 ret, error = server.runCommand(cmdline) 248 ret, error = server.runCommand(cmdline)
247 if error: 249 if error:
248 print("Error running command '%s': %s" % (cmdline, error)) 250 print("Error running command '%s': %s" % (cmdline, error))