diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2008-12-06 12:57:17 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2008-12-06 12:57:17 +0000 |
commit | f7d2413939ba15b024a853c960c27d22a4a3ac4e (patch) | |
tree | 8a4e489ea2b2329c3208e04e0bdeccb0d47a4e4e | |
parent | a59037d9b5baecfdf389a6d57712ea709d0b1ff6 (diff) | |
download | bitbake-f7d2413939ba15b024a853c960c27d22a4a3ac4e.tar.gz |
Pass around the tasks to execute rather than using magic variables. Also use the empty_environment() function to clear the environment
-rw-r--r-- | lib/bb/command.py | 9 | ||||
-rw-r--r-- | lib/bb/cooker.py | 38 | ||||
-rw-r--r-- | lib/bb/data.py | 2 | ||||
-rw-r--r-- | lib/bb/shell.py | 6 | ||||
-rw-r--r-- | lib/bb/utils.py | 7 |
5 files changed, 41 insertions, 21 deletions
diff --git a/lib/bb/command.py b/lib/bb/command.py index 7cee1d5d3..f86e0f191 100644 --- a/lib/bb/command.py +++ b/lib/bb/command.py @@ -146,16 +146,18 @@ class CommandsAsync: Build a set of targets """ pkgs_to_build = params[0] + task = params[1] - command.cooker.buildTargets(pkgs_to_build) + command.cooker.buildTargets(pkgs_to_build, task) def generateDepTreeEvent(self, command, params): """ Generate an event containing the dependency information """ pkgs_to_build = params[0] + task = params[1] - command.cooker.generateDepTreeEvent(pkgs_to_build) + command.cooker.generateDepTreeEvent(pkgs_to_build, task) command.finishAsyncCommand() def generateDotGraph(self, command, params): @@ -163,8 +165,9 @@ class CommandsAsync: Dump dependency information to disk as .dot files """ pkgs_to_build = params[0] + task = params[1] - command.cooker.generateDotGraphFiles(pkgs_to_build) + command.cooker.generateDotGraphFiles(pkgs_to_build, task) command.finishAsyncCommand() def showVersions(self, command, params): diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index 551b14077..2197a0e41 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -145,13 +145,13 @@ class BBCooker: self.commandlineAction = ["parseFiles"] elif self.configuration.dot_graph: if self.configuration.pkgs_to_build: - self.commandlineAction = ["generateDotGraph", self.configuration.pkgs_to_build] + self.commandlineAction = ["generateDotGraph", self.configuration.pkgs_to_build, self.configuration.cmd] else: self.commandlineAction = None bb.error("Please specify a package name for dependency graph generation.") else: if self.configuration.pkgs_to_build: - self.commandlineAction = ["buildTargets", self.configuration.pkgs_to_build] + self.commandlineAction = ["buildTargets", self.configuration.pkgs_to_build, self.configuration.cmd] else: self.commandlineAction = None bb.error("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") @@ -302,7 +302,7 @@ class BBCooker: if data.getVarFlag( e, 'python', envdata ): bb.msg.plain("\npython %s () {\n%s}\n" % (e, data.getVar(e, envdata, 1))) - def generateDepTreeData(self, pkgs_to_build): + def generateDepTreeData(self, pkgs_to_build, task): """ Create a dependency tree of pkgs_to_build, returning the data. """ @@ -310,6 +310,10 @@ class BBCooker: # Need files parsed self.updateCache() + # If we are told to do the None task then query the default task + if (task == None): + task = self.configuration.cmd + pkgs_to_build = self.checkPackages(pkgs_to_build) localdata = data.createCopy(self.configuration.data) @@ -320,7 +324,7 @@ class BBCooker: runlist = [] for k in pkgs_to_build: taskdata.add_provider(localdata, self.status, k) - runlist.append([k, "do_%s" % self.configuration.cmd]) + runlist.append([k, "do_%s" % task]) taskdata.add_unresolved(localdata, self.status) rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) @@ -390,21 +394,21 @@ class BBCooker: return depend_tree - def generateDepTreeEvent(self, pkgs_to_build): + def generateDepTreeEvent(self, pkgs_to_build, task): """ Create a task dependency graph of pkgs_to_build. Generate an event with the result """ - depgraph = self.generateDepTreeData(pkgs_to_build) + depgraph = self.generateDepTreeData(pkgs_to_build, task) bb.event.fire(bb.event.DepTreeGenerated(self.configuration.data, depgraph)) - def generateDotGraphFiles(self, pkgs_to_build): + def generateDotGraphFiles(self, pkgs_to_build, task): """ Create a task dependency graph of pkgs_to_build. Save the result to a set of .dot files. """ - depgraph = self.generateDepTreeData(pkgs_to_build) + depgraph = self.generateDepTreeData(pkgs_to_build, task) # Prints a flattened form of package-depends below where subpackages of a package are merged into the main pn depends_file = file('pn-depends.dot', 'w' ) @@ -615,6 +619,10 @@ class BBCooker: Build the file matching regexp buildfile """ + # If we are told to do the None task then query the default task + if (task == None): + task = self.configuration.cmd + fn = self.matchFile(buildfile) self.buildSetVars() @@ -650,7 +658,7 @@ class BBCooker: bb.event.fire(bb.event.BuildStarted(buildname, [item], self.configuration.event_data)) # Execute the runqueue - runlist = [[item, "do_%s" % self.configuration.cmd]] + runlist = [[item, "do_%s" % task]] rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) @@ -677,7 +685,7 @@ class BBCooker: self.cookerIdle = False self.server.register_idle_function(buildFileIdle, rq) - def buildTargets(self, targets): + def buildTargets(self, targets, task): """ Attempt to build the targets specified """ @@ -685,6 +693,10 @@ class BBCooker: # Need files parsed self.updateCache() + # If we are told to do the NULL task then query the default task + if (task == None): + task = self.configuration.cmd + targets = self.checkPackages(targets) def buildTargetsIdle(server, rq, abort): @@ -721,7 +733,7 @@ class BBCooker: runlist = [] for k in targets: taskdata.add_provider(localdata, self.status, k) - runlist.append([k, "do_%s" % self.configuration.cmd]) + runlist.append([k, "do_%s" % task]) taskdata.add_unresolved(localdata, self.status) rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) @@ -903,6 +915,10 @@ class BBCooker: def serve(self): + # Empty the environment. The environment will be populated as + # necessary from the data store. + bb.utils.empty_environment() + if self.configuration.profile: try: import cProfile as profile diff --git a/lib/bb/data.py b/lib/bb/data.py index 82eef4498..19e67dbc3 100644 --- a/lib/bb/data.py +++ b/lib/bb/data.py @@ -331,8 +331,6 @@ def inheritFromOS(d): setVar(s, os.environ[s], d) except TypeError: pass - os.unsetenv(s) - del os.environ[s] def emit_var(var, o=sys.__stdout__, d = init(), all=False): """Emit a variable to be sourced by a shell.""" diff --git a/lib/bb/shell.py b/lib/bb/shell.py index 34828fe42..b825d9fde 100644 --- a/lib/bb/shell.py +++ b/lib/bb/shell.py @@ -240,18 +240,14 @@ class BitBakeShellCommands: bf = completeFilePath( name ) print "SHELL: Calling '%s' on '%s'" % ( cmd, bf ) - oldcmd = cooker.configuration.cmd - cooker.configuration.cmd = cmd - try: - cooker.buildFile(bf) + cooker.buildFile(bf, cmd) except parse.ParseError: print "ERROR: Unable to open or parse '%s'" % bf except build.EventException, e: print "ERROR: Couldn't build '%s'" % name last_exception = e - cooker.configuration.cmd = oldcmd fileBuild.usage = "<bbfile>" def fileClean( self, params ): diff --git a/lib/bb/utils.py b/lib/bb/utils.py index 4284d8381..90ba9ac2e 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -373,6 +373,13 @@ def clean_environment(): good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split()) filter_environment(good_vars) +def empty_environment(): + """ + Remove all variable from the environment. + """ + for s in os.environ.keys(): + os.unsetenv(s) + del os.environ[s] def prunedir(topdir): # Delete everything reachable from the directory named in 'topdir'. |