diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2006-01-05 19:54:04 +0000 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2006-01-05 19:54:04 +0000 |
commit | dcf8e5e245911ea22931904ebc76379cd0fa9d5f (patch) | |
tree | 20ada08bc546dfbe3aeba3f939d8e34187bf194f /lib/bb/parse/parse_py | |
parent | a89d98cb9eae153302e820c7025d2d986998d32d (diff) | |
download | bitbake-dcf8e5e245911ea22931904ebc76379cd0fa9d5f.tar.gz |
bitbake/lib/bb/parse:
-Implement the 'require' keyword in bitbake. The semantic
inherits the semantic of include.
It only differs in the way missing files are handled.
Require will raise a ParseError when a 'required' file
could not be found.
-We add a new keyword and scan for it
-We change the include method to carry an additional parameter
Diffstat (limited to 'lib/bb/parse/parse_py')
-rw-r--r-- | lib/bb/parse/parse_py/ConfHandler.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/bb/parse/parse_py/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py index ecae5d1d9..f2eb53881 100644 --- a/lib/bb/parse/parse_py/ConfHandler.py +++ b/lib/bb/parse/parse_py/ConfHandler.py @@ -28,6 +28,7 @@ from bb.parse import ParseError #__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") __config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$") __include_regexp__ = re.compile( r"include\s+(.+)" ) +__require_regexp__ = re.compile( r"require\s+(.+)" ) def init(data): if not bb.data.getVar('TOPDIR', data): @@ -83,7 +84,11 @@ def obtain(fn, data = bb.data.init()): return localfn -def include(oldfn, fn, data = bb.data.init()): +def include(oldfn, fn, data = bb.data.init(), error_out = False): + """ + + error_out If True a ParseError will be reaised if the to be included + """ if oldfn == fn: # prevent infinate recursion return None @@ -93,8 +98,10 @@ def include(oldfn, fn, data = bb.data.init()): from bb.parse import handle try: - ret = handle(fn, data, 1) + ret = handle(fn, data, True) except IOError: + if error_out: + raise ParseError("Could not include required file %(fn)s" % vars() ) debug(2, "CONF file '%s' not found" % fn) def handle(fn, data = bb.data.init(), include = 0): @@ -191,6 +198,11 @@ def feeder(lineno, s, fn, data = bb.data.init()): include(fn, s, data) return + m = __require_regexp__.match(s) + if m: + s = bb.data.expand(m.group(1), data) + include(fn, s, data, True) + raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); # Add us to the handlers list |