summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-02-24 20:16:43 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-08 19:38:26 (GMT)
commit9f33dde6e71b7b66db357b1bf289ae63e0db77d2 (patch)
treecd7c2725432bc7e331cd4bf153aed888d425944e /bitbake
parent88f4ba28bcc95b64940bd465793a3bb50abf0693 (diff)
downloadpoky-9f33dde6e71b7b66db357b1bf289ae63e0db77d2.tar.gz
cooker: use BBHandler.inherit for INHERIT
Ideally we'd avoid direct BBHandler usage, but honestly, to say the whole bb.parse abstraction is incredibly leaky is an understatement. If we try to make handle() not reparse classes, things get ugly fairly quickly, as inherit() calls handle() itself after adding the class to the inherit cache. This change fixes it so we no longer risk reparsing a class if: - it's listed in INHERIT multiple times - it's listed in INHERIT and is 'inherit'ed from a class in INHERIT (Bitbake rev: 057c3cddeb72584c6c3908bd702288cece9b66ea) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cooker.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index ad9af7b..b66d003 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -33,6 +33,7 @@ import sre_constants
33import threading 33import threading
34from cStringIO import StringIO 34from cStringIO import StringIO
35from contextlib import closing 35from contextlib import closing
36from functools import wraps
36import bb, bb.exceptions 37import bb, bb.exceptions
37from bb import utils, data, parse, event, cache, providers, taskdata, command, runqueue 38from bb import utils, data, parse, event, cache, providers, taskdata, command, runqueue
38 39
@@ -637,13 +638,6 @@ class BBCooker:
637 path, _ = os.path.split(path) 638 path, _ = os.path.split(path)
638 639
639 def parseConfigurationFiles(self, files): 640 def parseConfigurationFiles(self, files):
640 def _parse(f, data, include=False):
641 try:
642 return bb.parse.handle(f, data, include)
643 except (IOError, bb.parse.ParseError) as exc:
644 parselog.critical("Unable to parse %s: %s" % (f, exc))
645 sys.exit(1)
646
647 data = self.configuration.data 641 data = self.configuration.data
648 bb.parse.init_parser(data) 642 bb.parse.init_parser(data)
649 for f in files: 643 for f in files:
@@ -671,9 +665,9 @@ class BBCooker:
671 data = _parse(os.path.join("conf", "bitbake.conf"), data) 665 data = _parse(os.path.join("conf", "bitbake.conf"), data)
672 666
673 # Handle any INHERITs and inherit the base class 667 # Handle any INHERITs and inherit the base class
674 inherits = ["base"] + (data.getVar('INHERIT', True) or "").split() 668 bbclasses = ["base"] + (data.getVar('INHERIT', True) or "").split()
675 for inherit in inherits: 669 for bbclass in bbclasses:
676 data = _parse(os.path.join('classes', '%s.bbclass' % inherit), data, True) 670 data = _inherit(bbclass, data)
677 671
678 # Nomally we only register event handlers at the end of parsing .bb files 672 # Nomally we only register event handlers at the end of parsing .bb files
679 # We register any handlers we've found so far here... 673 # We register any handlers we've found so far here...
@@ -1123,6 +1117,26 @@ class CookerExit(bb.event.Event):
1123 def __init__(self): 1117 def __init__(self):
1124 bb.event.Event.__init__(self) 1118 bb.event.Event.__init__(self)
1125 1119
1120def catch_parse_error(func):
1121 """Exception handling bits for our parsing"""
1122 @wraps(func)
1123 def wrapped(fn, *args):
1124 try:
1125 return func(fn, *args)
1126 except (IOError, bb.parse.ParseError, bb.data_smart.ExpansionError) as exc:
1127 parselog.critical("Unable to parse %s: %s" % (fn, exc))
1128 sys.exit(1)
1129 return wrapped
1130
1131@catch_parse_error
1132def _parse(fn, data, include=False):
1133 return bb.parse.handle(fn, data, include)
1134
1135@catch_parse_error
1136def _inherit(bbclass, data):
1137 bb.parse.BBHandler.inherit([bbclass], data)
1138 return data
1139
1126class ParsingFailure(Exception): 1140class ParsingFailure(Exception):
1127 def __init__(self, realexception, recipe): 1141 def __init__(self, realexception, recipe):
1128 self.realexception = realexception 1142 self.realexception = realexception