diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/__init__.py | 15 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 8 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 11 |
5 files changed, 26 insertions, 16 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 308805a712..bf25a8320e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -1398,7 +1398,7 @@ def _parse(fn, data, include=True): | |||
1398 | 1398 | ||
1399 | @catch_parse_error | 1399 | @catch_parse_error |
1400 | def _inherit(bbclass, data): | 1400 | def _inherit(bbclass, data): |
1401 | bb.parse.BBHandler.inherit([bbclass], data) | 1401 | bb.parse.BBHandler.inherit([bbclass], "configuration INHERITs", 0, data) |
1402 | return data | 1402 | return data |
1403 | 1403 | ||
1404 | class ParsingFailure(Exception): | 1404 | class ParsingFailure(Exception): |
diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py index c5005aec9a..8b7ec73c57 100644 --- a/bitbake/lib/bb/parse/__init__.py +++ b/bitbake/lib/bb/parse/__init__.py | |||
@@ -37,6 +37,17 @@ logger = logging.getLogger("BitBake.Parsing") | |||
37 | 37 | ||
38 | class ParseError(Exception): | 38 | class ParseError(Exception): |
39 | """Exception raised when parsing fails""" | 39 | """Exception raised when parsing fails""" |
40 | def __init__(self, msg, filename, lineno=0): | ||
41 | self.msg = msg | ||
42 | self.filename = filename | ||
43 | self.lineno = lineno | ||
44 | Exception.__init__(self, msg, filename, lineno) | ||
45 | |||
46 | def __str__(self): | ||
47 | if self.lineno: | ||
48 | return "ParseError at %s:%d: %s" % (self.filename, self.lineno, self.msg) | ||
49 | else: | ||
50 | return "ParseError in %s: %s" % (self.filename, self.msg) | ||
40 | 51 | ||
41 | class SkipPackage(Exception): | 52 | class SkipPackage(Exception): |
42 | """Exception raised to skip this package""" | 53 | """Exception raised to skip this package""" |
@@ -78,7 +89,7 @@ def handle(fn, data, include = 0): | |||
78 | for h in handlers: | 89 | for h in handlers: |
79 | if h['supports'](fn, data): | 90 | if h['supports'](fn, data): |
80 | return h['handle'](fn, data, include) | 91 | return h['handle'](fn, data, include) |
81 | raise ParseError("%s is not a BitBake file" % fn) | 92 | raise ParseError("not a BitBake file", fn) |
82 | 93 | ||
83 | def init(fn, data): | 94 | def init(fn, data): |
84 | for h in handlers: | 95 | for h in handlers: |
@@ -111,7 +122,7 @@ def vars_from_file(mypkg, d): | |||
111 | parts = myfile[0].split('_') | 122 | parts = myfile[0].split('_') |
112 | __pkgsplit_cache__[mypkg] = parts | 123 | __pkgsplit_cache__[mypkg] = parts |
113 | if len(parts) > 3: | 124 | if len(parts) > 3: |
114 | raise ParseError("Unable to generate default variables from the filename: %s (too many underscores)" % mypkg) | 125 | raise ParseError("Unable to generate default variables from filename (too many underscores)", mypkg) |
115 | exp = 3 - len(parts) | 126 | exp = 3 - len(parts) |
116 | tmplist = [] | 127 | tmplist = [] |
117 | while exp != 0: | 128 | while exp != 0: |
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 31c930d9cf..94fa175bba 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -59,9 +59,9 @@ class IncludeNode(AstNode): | |||
59 | 59 | ||
60 | # TODO: Cache those includes... maybe not here though | 60 | # TODO: Cache those includes... maybe not here though |
61 | if self.force: | 61 | if self.force: |
62 | bb.parse.ConfHandler.include(self.filename, s, data, "include required") | 62 | bb.parse.ConfHandler.include(self.filename, s, self.lineno, data, "include required") |
63 | else: | 63 | else: |
64 | bb.parse.ConfHandler.include(self.filename, s, data, False) | 64 | bb.parse.ConfHandler.include(self.filename, s, self.lineno, data, False) |
65 | 65 | ||
66 | class ExportNode(AstNode): | 66 | class ExportNode(AstNode): |
67 | def __init__(self, filename, lineno, var): | 67 | def __init__(self, filename, lineno, var): |
@@ -267,7 +267,7 @@ class InheritNode(AstNode): | |||
267 | self.classes = classes | 267 | self.classes = classes |
268 | 268 | ||
269 | def eval(self, data): | 269 | def eval(self, data): |
270 | bb.parse.BBHandler.inherit(self.classes, data) | 270 | bb.parse.BBHandler.inherit(self.classes, self.filename, self.lineno, data) |
271 | 271 | ||
272 | def handleInclude(statements, filename, lineno, m, force): | 272 | def handleInclude(statements, filename, lineno, m, force): |
273 | statements.append(IncludeNode(filename, lineno, m.group(1), force)) | 273 | statements.append(IncludeNode(filename, lineno, m.group(1), force)) |
@@ -450,7 +450,7 @@ def multi_finalize(fn, d): | |||
450 | d.setVar("BBEXTENDVARIANT", variantmap[name]) | 450 | d.setVar("BBEXTENDVARIANT", variantmap[name]) |
451 | else: | 451 | else: |
452 | d.setVar("PN", "%s-%s" % (pn, name)) | 452 | d.setVar("PN", "%s-%s" % (pn, name)) |
453 | bb.parse.BBHandler.inherit([extendedmap[name]], d) | 453 | bb.parse.BBHandler.inherit([extendedmap[name]], fn, 0, d) |
454 | 454 | ||
455 | safe_d.setVar("BBCLASSEXTEND", extended) | 455 | safe_d.setVar("BBCLASSEXTEND", extended) |
456 | _create_variants(datastores, extendedmap.keys(), extendfunc) | 456 | _create_variants(datastores, extendedmap.keys(), extendfunc) |
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 |