diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2012-02-23 17:38:08 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-02-23 22:52:15 +0000 |
commit | 99d326a818a49faf457c707ceeec6163bf8c8e16 (patch) | |
tree | 6e03dca72ed109a691356bd2d9feb172423da6ab /bitbake/lib/bb/parse/parse_py | |
parent | ebc0d4252a19e6ab38052473e54138d29b172dfc (diff) | |
download | poky-99d326a818a49faf457c707ceeec6163bf8c8e16.tar.gz |
bitbake: add file and line number to ParseError
Ensure that a file and line number are reported for ParseError where
possible. This helps particularly in the case of inherit and require
which previously did not report either of these upon failure.
(Bitbake rev: f588ba69622a2df35417ced184e56c79ac1b40d5)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 2d6e331a1d..125f458de7 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -68,10 +68,8 @@ def supports(fn, d): | |||
68 | """Return True if fn has a supported extension""" | 68 | """Return True if fn has a supported extension""" |
69 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] | 69 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] |
70 | 70 | ||
71 | def inherit(files, d): | 71 | def inherit(files, fn, lineno, d): |
72 | __inherit_cache = data.getVar('__inherit_cache', d) or [] | 72 | __inherit_cache = data.getVar('__inherit_cache', d) or [] |
73 | fn = "" | ||
74 | lineno = 0 | ||
75 | for file in files: | 73 | for file in files: |
76 | file = data.expand(file, d) | 74 | file = data.expand(file, d) |
77 | if not os.path.isabs(file) and not file.endswith(".bbclass"): | 75 | if not os.path.isabs(file) and not file.endswith(".bbclass"): |
@@ -81,7 +79,7 @@ def inherit(files, d): | |||
81 | logger.log(logging.DEBUG -1, "BB %s:%d: inheriting %s", fn, lineno, file) | 79 | logger.log(logging.DEBUG -1, "BB %s:%d: inheriting %s", fn, lineno, file) |
82 | __inherit_cache.append( file ) | 80 | __inherit_cache.append( file ) |
83 | data.setVar('__inherit_cache', __inherit_cache, d) | 81 | data.setVar('__inherit_cache', __inherit_cache, d) |
84 | include(fn, file, d, "inherit") | 82 | include(fn, file, lineno, d, "inherit") |
85 | __inherit_cache = data.getVar('__inherit_cache', d) or [] | 83 | __inherit_cache = data.getVar('__inherit_cache', d) or [] |
86 | 84 | ||
87 | def get_statements(filename, absolute_filename, base_name): | 85 | def get_statements(filename, absolute_filename, base_name): |
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 6ae9d973e7..9242632c50 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -44,10 +44,11 @@ def init(data): | |||
44 | def supports(fn, d): | 44 | def supports(fn, d): |
45 | return fn[-5:] == ".conf" | 45 | return fn[-5:] == ".conf" |
46 | 46 | ||
47 | def include(oldfn, fn, data, error_out): | 47 | def include(oldfn, fn, lineno, data, error_out): |
48 | """ | 48 | """ |
49 | error_out If True a ParseError will be raised if the to be included | 49 | error_out: A string indicating the verb (e.g. "include", "inherit") to be |
50 | config-files could not be included. | 50 | used in a ParseError that will be raised if the file to be included could |
51 | not be included. Specify False to avoid raising an error in this case. | ||
51 | """ | 52 | """ |
52 | if oldfn == fn: # prevent infinite recursion | 53 | if oldfn == fn: # prevent infinite recursion |
53 | return None | 54 | return None |
@@ -68,7 +69,7 @@ def include(oldfn, fn, data, error_out): | |||
68 | ret = handle(fn, data, True) | 69 | ret = handle(fn, data, True) |
69 | except IOError: | 70 | except IOError: |
70 | if error_out: | 71 | if error_out: |
71 | raise ParseError("Could not %(error_out)s file %(fn)s" % vars() ) | 72 | raise ParseError("Could not %(error_out)s file %(fn)s" % vars(), oldfn, lineno) |
72 | logger.debug(2, "CONF file '%s' not found", fn) | 73 | logger.debug(2, "CONF file '%s' not found", fn) |
73 | 74 | ||
74 | def handle(fn, data, include): | 75 | def handle(fn, data, include): |
@@ -131,7 +132,7 @@ def feeder(lineno, s, fn, statements): | |||
131 | ast.handleExport(statements, fn, lineno, m) | 132 | ast.handleExport(statements, fn, lineno, m) |
132 | return | 133 | return |
133 | 134 | ||
134 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); | 135 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); |
135 | 136 | ||
136 | # Add us to the handlers list | 137 | # Add us to the handlers list |
137 | from bb.parse import handlers | 138 | from bb.parse import handlers |