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.py104
1 files changed, 53 insertions, 51 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index c1e2105c5e..7adda09fde 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -494,69 +494,71 @@ class BBCooker:
494 path, _ = os.path.split(path) 494 path, _ = os.path.split(path)
495 495
496 def parseConfigurationFiles(self, files): 496 def parseConfigurationFiles(self, files):
497 try: 497 def _parse(f, data):
498 data = self.configuration.data 498 try:
499 499 return bb.parse.handle(f, data)
500 bb.parse.init_parser(data, self.configuration.dump_signatures) 500 except (IOError, bb.parse.ParseError) as exc:
501 for f in files: 501 parselog.critical("Unable to parse %s: %s" % (f, exc))
502 data = bb.parse.handle(f, data) 502 sys.exit(1)
503
504 data = self.configuration.data
503 505
504 layerconf = self._findLayerConf() 506 bb.parse.init_parser(data, self.configuration.dump_signatures)
505 if layerconf: 507 for f in files:
506 parselog.debug(2, "Found bblayers.conf (%s)", layerconf) 508 data = _parse(f, data)
507 data = bb.parse.handle(layerconf, data)
508 509
509 layers = (bb.data.getVar('BBLAYERS', data, True) or "").split() 510 layerconf = self._findLayerConf()
511 if layerconf:
512 parselog.debug(2, "Found bblayers.conf (%s)", layerconf)
513 data = _parse(layerconf, data)
510 514
511 data = bb.data.createCopy(data) 515 layers = (bb.data.getVar('BBLAYERS', data, True) or "").split()
512 for layer in layers:
513 parselog.debug(2, "Adding layer %s", layer)
514 bb.data.setVar('LAYERDIR', layer, data)
515 data = bb.parse.handle(os.path.join(layer, "conf", "layer.conf"), data)
516 516
517 # XXX: Hack, relies on the local keys of the datasmart 517 data = bb.data.createCopy(data)
518 # instance being stored in the 'dict' attribute and makes 518 for layer in layers:
519 # assumptions about how variable expansion works, but 519 parselog.debug(2, "Adding layer %s", layer)
520 # there's no better way to force an expansion of a single 520 bb.data.setVar('LAYERDIR', layer, data)
521 # variable across the datastore today, and this at least 521 data = _parse(os.path.join(layer, "conf", "layer.conf"), data)
522 # lets us reference LAYERDIR without having to immediately
523 # eval all our variables that use it.
524 for key in data.dict:
525 if key != "_data":
526 value = data.getVar(key, False)
527 if value and "${LAYERDIR}" in value:
528 data.setVar(key, value.replace("${LAYERDIR}", layer))
529 522
530 bb.data.delVar('LAYERDIR', data) 523 # XXX: Hack, relies on the local keys of the datasmart
524 # instance being stored in the 'dict' attribute and makes
525 # assumptions about how variable expansion works, but
526 # there's no better way to force an expansion of a single
527 # variable across the datastore today, and this at least
528 # lets us reference LAYERDIR without having to immediately
529 # eval all our variables that use it.
530 for key in data.dict:
531 if key != "_data":
532 value = data.getVar(key, False)
533 if value and "${LAYERDIR}" in value:
534 data.setVar(key, value.replace("${LAYERDIR}", layer))
531 535
532 if not data.getVar("BBPATH", True): 536 bb.data.delVar('LAYERDIR', data)
533 raise SystemExit("The BBPATH variable is not set")
534 537
535 data = bb.parse.handle(os.path.join("conf", "bitbake.conf"), data) 538 if not data.getVar("BBPATH", True):
539 raise SystemExit("The BBPATH variable is not set")
536 540
537 self.configuration.data = data 541 data = _parse(os.path.join("conf", "bitbake.conf"), data)
538 542
539 # Handle any INHERITs and inherit the base class 543 self.configuration.data = data
540 inherits = ["base"] + (bb.data.getVar('INHERIT', self.configuration.data, True ) or "").split()
541 for inherit in inherits:
542 self.configuration.data = bb.parse.handle(os.path.join('classes', '%s.bbclass' % inherit), self.configuration.data, True )
543 544
544 # Nomally we only register event handlers at the end of parsing .bb files 545 # Handle any INHERITs and inherit the base class
545 # We register any handlers we've found so far here... 546 inherits = ["base"] + (bb.data.getVar('INHERIT', self.configuration.data, True ) or "").split()
546 for var in bb.data.getVar('__BBHANDLERS', self.configuration.data) or []: 547 for inherit in inherits:
547 bb.event.register(var, bb.data.getVar(var, self.configuration.data)) 548 self.configuration.data = _parse(os.path.join('classes', '%s.bbclass' % inherit), self.configuration.data, True )
548 549
549 if bb.data.getVar("BB_WORKERCONTEXT", self.configuration.data) is None: 550 # Nomally we only register event handlers at the end of parsing .bb files
550 bb.fetch.fetcher_init(self.configuration.data) 551 # We register any handlers we've found so far here...
551 bb.codeparser.parser_cache_init(self.configuration.data) 552 for var in bb.data.getVar('__BBHANDLERS', self.configuration.data) or []:
553 bb.event.register(var, bb.data.getVar(var, self.configuration.data))
552 554
553 bb.parse.init_parser(data, self.configuration.dump_signatures) 555 if bb.data.getVar("BB_WORKERCONTEXT", self.configuration.data) is None:
556 bb.fetch.fetcher_init(self.configuration.data)
557 bb.codeparser.parser_cache_init(self.configuration.data)
554 558
555 bb.event.fire(bb.event.ConfigParsed(), self.configuration.data) 559 bb.parse.init_parser(data, self.configuration.dump_signatures)
556 560
557 except (IOError, bb.parse.ParseError): 561 bb.event.fire(bb.event.ConfigParsed(), self.configuration.data)
558 parselog.exception("Error when parsing %s", files)
559 sys.exit(1)
560 562
561 def handleCollections( self, collections ): 563 def handleCollections( self, collections ):
562 """Handle collections""" 564 """Handle collections"""
@@ -899,7 +901,7 @@ class BBCooker:
899 if not base in self.appendlist: 901 if not base in self.appendlist:
900 self.appendlist[base] = [] 902 self.appendlist[base] = []
901 self.appendlist[base].append(f) 903 self.appendlist[base].append(f)
902 904
903 return (bbfiles, masked) 905 return (bbfiles, masked)
904 906
905 def get_file_appends(self, fn): 907 def get_file_appends(self, fn):
@@ -909,7 +911,7 @@ class BBCooker:
909 """ 911 """
910 f = os.path.basename(fn) 912 f = os.path.basename(fn)
911 if f in self.appendlist: 913 if f in self.appendlist:
912 return self.appendlist[f] 914 return self.appendlist[f]
913 return [] 915 return []
914 916
915 def pre_serve(self): 917 def pre_serve(self):