summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py77
1 files changed, 57 insertions, 20 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index c16709e552..c6597c52f9 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -67,6 +67,10 @@ class BBCooker:
67 if not self.configuration.cmd: 67 if not self.configuration.cmd:
68 self.configuration.cmd = bb.data.getVar("BB_DEFAULT_TASK", self.configuration.data) or "build" 68 self.configuration.cmd = bb.data.getVar("BB_DEFAULT_TASK", self.configuration.data) or "build"
69 69
70 bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, True)
71 if bbpkgs:
72 self.configuration.pkgs_to_build.extend(bbpkgs.split())
73
70 # 74 #
71 # Special updated configuration we use for firing events 75 # Special updated configuration we use for firing events
72 # 76 #
@@ -158,29 +162,68 @@ class BBCooker:
158 prefstr) 162 prefstr)
159 163
160 164
161 def showEnvironment( self ): 165 def showEnvironment(self , buildfile = None, pkgs_to_build = []):
162 """Show the outer or per-package environment""" 166 """
163 if self.configuration.buildfile: 167 Show the outer or per-package environment
168 """
169 fn = None
170 envdata = None
171
172 if 'world' in pkgs_to_build:
173 print "'world' is not a valid target for --environment."
174 sys.exit(1)
175
176 if len(pkgs_to_build) > 1:
177 print "Only one target can be used with the --environment option."
178 sys.exit(1)
179
180 if buildfile:
181 if len(pkgs_to_build) > 0:
182 print "No target should be used with the --environment and --buildfile options."
183 sys.exit(1)
164 self.cb = None 184 self.cb = None
165 self.bb_cache = bb.cache.init(self) 185 self.bb_cache = bb.cache.init(self)
166 bf = self.matchFile(self.configuration.buildfile) 186 fn = self.matchFile(buildfile)
187 elif len(pkgs_to_build) == 1:
188 self.updateCache()
189
190 localdata = data.createCopy(self.configuration.data)
191 bb.data.update_data(localdata)
192 bb.data.expandKeys(localdata)
193
194 taskdata = bb.taskdata.TaskData(self.configuration.abort)
195
196 try:
197 taskdata.add_provider(localdata, self.status, pkgs_to_build[0])
198 taskdata.add_unresolved(localdata, self.status)
199 except bb.providers.NoProvider:
200 sys.exit(1)
201
202 targetid = taskdata.getbuild_id(pkgs_to_build[0])
203 fnid = taskdata.build_targets[targetid][0]
204 fn = taskdata.fn_index[fnid]
205 else:
206 envdata = self.configuration.data
207
208 if fn:
167 try: 209 try:
168 self.configuration.data = self.bb_cache.loadDataFull(bf, self.configuration.data) 210 envdata = self.bb_cache.loadDataFull(fn, self.configuration.data)
169 except IOError, e: 211 except IOError, e:
170 bb.msg.fatal(bb.msg.domain.Parsing, "Unable to read %s: %s" % (bf, e)) 212 bb.msg.fatal(bb.msg.domain.Parsing, "Unable to read %s: %s" % (fn, e))
171 except Exception, e: 213 except Exception, e:
172 bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e) 214 bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
215
173 # emit variables and shell functions 216 # emit variables and shell functions
174 try: 217 try:
175 data.update_data( self.configuration.data ) 218 data.update_data( envdata )
176 data.emit_env(sys.__stdout__, self.configuration.data, True) 219 data.emit_env(sys.__stdout__, envdata, True)
177 except Exception, e: 220 except Exception, e:
178 bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e) 221 bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
179 # emit the metadata which isnt valid shell 222 # emit the metadata which isnt valid shell
180 data.expandKeys( self.configuration.data ) 223 data.expandKeys( envdata )
181 for e in self.configuration.data.keys(): 224 for e in envdata.keys():
182 if data.getVarFlag( e, 'python', self.configuration.data ): 225 if data.getVarFlag( e, 'python', envdata ):
183 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, self.configuration.data, 1))) 226 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, envdata, 1)))
184 227
185 def generateDotGraph( self, pkgs_to_build, ignore_deps ): 228 def generateDotGraph( self, pkgs_to_build, ignore_deps ):
186 """ 229 """
@@ -338,8 +381,6 @@ class BBCooker:
338 except ImportError, details: 381 except ImportError, details:
339 bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details ) 382 bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details )
340 else: 383 else:
341 bb.data.update_data( self.configuration.data )
342 bb.data.expandKeys( self.configuration.data )
343 shell.start( self ) 384 shell.start( self )
344 sys.exit( 0 ) 385 sys.exit( 0 )
345 386
@@ -519,7 +560,7 @@ class BBCooker:
519 """ 560 """
520 561
521 if self.configuration.show_environment: 562 if self.configuration.show_environment:
522 self.showEnvironment() 563 self.showEnvironment(self.configuration.buildfile, self.configuration.pkgs_to_build)
523 sys.exit( 0 ) 564 sys.exit( 0 )
524 565
525 self.buildSetVars() 566 self.buildSetVars()
@@ -539,11 +580,7 @@ class BBCooker:
539 580
540 pkgs_to_build = self.configuration.pkgs_to_build 581 pkgs_to_build = self.configuration.pkgs_to_build
541 582
542 bbpkgs = bb.data.getVar('BBPKGS', self.configuration.data, 1) 583 if len(pkgs_to_build) == 0 and not self.configuration.show_versions:
543 if bbpkgs:
544 pkgs_to_build.extend(bbpkgs.split())
545 if len(pkgs_to_build) == 0 and not self.configuration.show_versions \
546 and not self.configuration.show_environment:
547 print "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help'" 584 print "Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help'"
548 print "for usage information." 585 print "for usage information."
549 sys.exit(0) 586 sys.exit(0)