summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/cooker.py104
-rw-r--r--bitbake/lib/bb/event.py21
-rw-r--r--bitbake/lib/bb/server/none.py2
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py2
4 files changed, 78 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):
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index f3efae9bdf..fb355089a3 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -26,6 +26,7 @@ import os, sys
26import warnings 26import warnings
27import pickle 27import pickle
28import logging 28import logging
29import atexit
29import bb.utils 30import bb.utils
30 31
31# This is the pid for which we should generate the event. This is set when 32# This is the pid for which we should generate the event. This is set when
@@ -74,7 +75,27 @@ def fire_class_handlers(event, d):
74 h(event) 75 h(event)
75 del event.data 76 del event.data
76 77
78ui_queue = []
79@atexit.register
80def print_ui_queue():
81 """If we're exiting before a UI has been spawned, display any queued
82 LogRecords to the console."""
83 logger = logging.getLogger("BitBake")
84 if not _ui_handlers:
85 console = logging.StreamHandler(sys.stdout)
86 console.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
87 logger.handlers = [console]
88 while ui_queue:
89 event, d = ui_queue.pop()
90 if isinstance(event, logging.LogRecord):
91 logger.handle(event)
92
77def fire_ui_handlers(event, d): 93def fire_ui_handlers(event, d):
94 if not _ui_handlers:
95 # No UI handlers registered yet, queue up the messages
96 ui_queue.append((event, d))
97 return
98
78 errors = [] 99 errors = []
79 for h in _ui_handlers: 100 for h in _ui_handlers:
80 #print "Sending event %s" % event 101 #print "Sending event %s" % event
diff --git a/bitbake/lib/bb/server/none.py b/bitbake/lib/bb/server/none.py
index dafb2feba9..2708807dfc 100644
--- a/bitbake/lib/bb/server/none.py
+++ b/bitbake/lib/bb/server/none.py
@@ -174,6 +174,8 @@ class BitBakeServerConnection():
174 self.server = serverinfo.server 174 self.server = serverinfo.server
175 self.connection = serverinfo.commands 175 self.connection = serverinfo.commands
176 self.events = bb.server.none.BBUIEventQueue(self.server) 176 self.events = bb.server.none.BBUIEventQueue(self.server)
177 for event in bb.event.ui_queue:
178 self.events.queue_event(event)
177 179
178 def terminate(self): 180 def terminate(self):
179 try: 181 try:
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index c2bfe12176..0d03e308d0 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -243,6 +243,8 @@ class BitBakeServerConnection():
243 t = BBTransport() 243 t = BBTransport()
244 self.connection = xmlrpclib.Server("http://%s:%s" % (serverinfo.host, serverinfo.port), transport=t, allow_none=True) 244 self.connection = xmlrpclib.Server("http://%s:%s" % (serverinfo.host, serverinfo.port), transport=t, allow_none=True)
245 self.events = uievent.BBUIEventQueue(self.connection) 245 self.events = uievent.BBUIEventQueue(self.connection)
246 for event in bb.event.ui_queue:
247 self.events.queue_event(event)
246 248
247 def terminate(self): 249 def terminate(self):
248 # Don't wait for server indefinitely 250 # Don't wait for server indefinitely