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.py97
1 files changed, 63 insertions, 34 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 2c091b6522..38a8209760 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -97,14 +97,12 @@ class BBCooker:
97 bb.msg.note(2, bb.msg.domain.Build, "Renice to %s " % os.nice(nice)) 97 bb.msg.note(2, bb.msg.domain.Build, "Renice to %s " % os.nice(nice))
98 98
99 99
100 def tryBuildPackage(self, fn, item, task, the_data, build_depends): 100 def tryBuildPackage(self, fn, item, task, the_data):
101 """ 101 """
102 Build one task of a package, optionally build following task depends 102 Build one task of a package, optionally build following task depends
103 """ 103 """
104 bb.event.fire(bb.event.PkgStarted(item, the_data)) 104 bb.event.fire(bb.event.PkgStarted(item, the_data))
105 try: 105 try:
106 if not build_depends:
107 bb.data.setVarFlag('do_%s' % task, 'dontrundeps', 1, the_data)
108 if not self.configuration.dry_run: 106 if not self.configuration.dry_run:
109 bb.build.exec_task('do_%s' % task, the_data) 107 bb.build.exec_task('do_%s' % task, the_data)
110 bb.event.fire(bb.event.PkgSucceeded(item, the_data)) 108 bb.event.fire(bb.event.PkgSucceeded(item, the_data))
@@ -119,21 +117,20 @@ class BBCooker:
119 bb.event.fire(bb.event.PkgFailed(item, the_data)) 117 bb.event.fire(bb.event.PkgFailed(item, the_data))
120 raise 118 raise
121 119
122 def tryBuild( self, fn, build_depends): 120 def tryBuild(self, fn):
123 """ 121 """
124 Build a provider and its dependencies. 122 Build a provider and its dependencies.
125 build_depends is a list of previous build dependencies (not runtime) 123 build_depends is a list of previous build dependencies (not runtime)
126 If build_depends is empty, we're dealing with a runtime depends 124 If build_depends is empty, we're dealing with a runtime depends
127 """ 125 """
128
129 the_data = self.bb_cache.loadDataFull(fn, self.configuration.data) 126 the_data = self.bb_cache.loadDataFull(fn, self.configuration.data)
130 127
131 item = self.status.pkg_fn[fn] 128 item = self.status.pkg_fn[fn]
132 129
133 if bb.build.stamp_is_current('do_%s' % self.configuration.cmd, the_data): 130 #if bb.build.stamp_is_current('do_%s' % self.configuration.cmd, the_data):
134 return True 131 # return True
135 132
136 return self.tryBuildPackage(fn, item, self.configuration.cmd, the_data, build_depends) 133 return self.tryBuildPackage(fn, item, self.configuration.cmd, the_data)
137 134
138 def showVersions(self): 135 def showVersions(self):
139 pkg_pn = self.status.pkg_pn 136 pkg_pn = self.status.pkg_pn
@@ -184,6 +181,8 @@ class BBCooker:
184 self.cb = None 181 self.cb = None
185 self.bb_cache = bb.cache.init(self) 182 self.bb_cache = bb.cache.init(self)
186 fn = self.matchFile(buildfile) 183 fn = self.matchFile(buildfile)
184 if not fn:
185 sys.exit(1)
187 elif len(pkgs_to_build) == 1: 186 elif len(pkgs_to_build) == 1:
188 self.updateCache() 187 self.updateCache()
189 188
@@ -220,7 +219,7 @@ class BBCooker:
220 except Exception, e: 219 except Exception, e:
221 bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e) 220 bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
222 # emit the metadata which isnt valid shell 221 # emit the metadata which isnt valid shell
223 data.expandKeys( envdata ) 222 data.expandKeys( envdata )
224 for e in envdata.keys(): 223 for e in envdata.keys():
225 if data.getVarFlag( e, 'python', envdata ): 224 if data.getVarFlag( e, 'python', envdata ):
226 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, envdata, 1))) 225 sys.__stdout__.write("\npython %s () {\n%s}\n" % (e, data.getVar(e, envdata, 1)))
@@ -273,7 +272,7 @@ class BBCooker:
273 if fnid not in seen_fnids: 272 if fnid not in seen_fnids:
274 seen_fnids.append(fnid) 273 seen_fnids.append(fnid)
275 packages = [] 274 packages = []
276 print >> depends_file, '"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn) 275 print >> depends_file, '"%s" [label="%s %s\\n%s"]' % (pn, pn, version, fn)
277 for depend in self.status.deps[fn]: 276 for depend in self.status.deps[fn]:
278 print >> depends_file, '"%s" -> "%s"' % (pn, depend) 277 print >> depends_file, '"%s" -> "%s"' % (pn, depend)
279 rdepends = self.status.rundeps[fn] 278 rdepends = self.status.rundeps[fn]
@@ -387,19 +386,15 @@ class BBCooker:
387 try: 386 try:
388 self.configuration.data = bb.parse.handle( afile, self.configuration.data ) 387 self.configuration.data = bb.parse.handle( afile, self.configuration.data )
389 388
390 # Add the handlers we inherited by INHERIT 389 # Handle any INHERITs and inherit the base class
391 # we need to do this manually as it is not guranteed 390 inherits = ["base"] + (bb.data.getVar('INHERIT', self.configuration.data, True ) or "").split()
392 # we will pick up these classes... as we only INHERIT
393 # on .inc and .bb files but not on .conf
394 data = bb.data.createCopy( self.configuration.data )
395 inherits = ["base"] + (bb.data.getVar('INHERIT', data, True ) or "").split()
396 for inherit in inherits: 391 for inherit in inherits:
397 data = bb.parse.handle( os.path.join('classes', '%s.bbclass' % inherit ), data, True ) 392 self.configuration.data = bb.parse.handle(os.path.join('classes', '%s.bbclass' % inherit), self.configuration.data, True )
398 393
399 # FIXME: This assumes that we included at least one .inc file 394 # Nomally we only register event handlers at the end of parsing .bb files
400 for var in bb.data.keys(data): 395 # We register any handlers we've found so far here...
401 if bb.data.getVarFlag(var, 'handler', data): 396 for var in data.getVar('__BBHANDLERS', self.configuration.data) or []:
402 bb.event.register(var,bb.data.getVar(var, data)) 397 bb.event.register(var,bb.data.getVar(var, self.configuration.data))
403 398
404 bb.fetch.fetcher_init(self.configuration.data) 399 bb.fetch.fetcher_init(self.configuration.data)
405 400
@@ -463,30 +458,62 @@ class BBCooker:
463 bb.msg.error(bb.msg.domain.Parsing, "Unable to match %s (%s matches found):" % (buildfile, len(matches))) 458 bb.msg.error(bb.msg.domain.Parsing, "Unable to match %s (%s matches found):" % (buildfile, len(matches)))
464 for f in matches: 459 for f in matches:
465 bb.msg.error(bb.msg.domain.Parsing, " %s" % f) 460 bb.msg.error(bb.msg.domain.Parsing, " %s" % f)
466 sys.exit(1) 461 return False
467 return matches[0] 462 return matches[0]
468 463
469 def buildFile(self, buildfile): 464 def buildFile(self, buildfile):
470 """ 465 """
471 Build the file matching regexp buildfile 466 Build the file matching regexp buildfile
472 """ 467 """
473 468
474 bf = self.matchFile(buildfile) 469 # Make sure our target is a fully qualified filename
470 fn = self.matchFile(buildfile)
471 if not fn:
472 return False
475 473
476 bbfile_data = bb.parse.handle(bf, self.configuration.data) 474 # Load data into the cache for fn
475 self.bb_cache = bb.cache.init(self)
476 self.bb_cache.loadData(fn, self.configuration.data)
477
478 # Parse the loaded cache data
479 self.status = bb.cache.CacheData()
480 self.bb_cache.handle_data(fn, self.status)
481
482 # Tweak some variables
483 item = self.bb_cache.getVar('PN', fn, True)
484 self.status.ignored_dependencies = Set()
485 self.status.bbfile_priority[fn] = 1
486
487 # Remove external dependencies
488 self.status.task_deps[fn]['depends'] = {}
489 self.status.deps[fn] = []
490 self.status.rundeps[fn] = []
491 self.status.runrecs[fn] = []
477 492
478 # Remove stamp for target if force mode active 493 # Remove stamp for target if force mode active
479 if self.configuration.force: 494 if self.configuration.force:
480 bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (self.configuration.cmd, bf)) 495 bb.msg.note(2, bb.msg.domain.RunQueue, "Remove stamp %s, %s" % (self.configuration.cmd, fn))
481 bb.build.del_stamp('do_%s' % self.configuration.cmd, bbfile_data) 496 bb.build.del_stamp('do_%s' % self.configuration.cmd, bbfile_data)
482 497
483 item = bb.data.getVar('PN', bbfile_data, 1) 498 # Setup taskdata structure
484 try: 499 taskdata = bb.taskdata.TaskData(self.configuration.abort)
485 self.tryBuildPackage(bf, item, self.configuration.cmd, bbfile_data, True) 500 taskdata.add_provider(self.configuration.data, self.status, item)
486 except bb.build.EventException:
487 bb.msg.error(bb.msg.domain.Build, "Build of '%s' failed" % item )
488 501
489 sys.exit(0) 502 buildname = bb.data.getVar("BUILDNAME", self.configuration.data)
503 bb.event.fire(bb.event.BuildStarted(buildname, [item], self.configuration.event_data))
504
505 # Execute the runqueue
506 runlist = [[item, "do_%s" % self.configuration.cmd]]
507 rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
508 rq.prepare_runqueue()
509 try:
510 failures = rq.execute_runqueue()
511 except runqueue.TaskFailure, fnids:
512 for fnid in fnids:
513 bb.msg.error(bb.msg.domain.Build, "'%s' failed" % taskdata.fn_index[fnid])
514 return False
515 bb.event.fire(bb.event.BuildCompleted(buildname, [item], self.configuration.event_data, failures))
516 return True
490 517
491 def buildTargets(self, targets): 518 def buildTargets(self, targets):
492 """ 519 """
@@ -568,7 +595,9 @@ class BBCooker:
568 self.interactiveMode() 595 self.interactiveMode()
569 596
570 if self.configuration.buildfile is not None: 597 if self.configuration.buildfile is not None:
571 return self.buildFile(self.configuration.buildfile) 598 if not self.buildFile(self.configuration.buildfile):
599 sys.exit(1)
600 sys.exit(0)
572 601
573 # initialise the parsing status now we know we will need deps 602 # initialise the parsing status now we know we will need deps
574 self.updateCache() 603 self.updateCache()
@@ -676,7 +705,7 @@ class BBCooker:
676 for i in xrange( len( filelist ) ): 705 for i in xrange( len( filelist ) ):
677 f = filelist[i] 706 f = filelist[i]
678 707
679 bb.msg.debug(1, bb.msg.domain.Collection, "parsing %s" % f) 708 #bb.msg.debug(1, bb.msg.domain.Collection, "parsing %s" % f)
680 709
681 # read a file's metadata 710 # read a file's metadata
682 try: 711 try: