diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 61 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 24 |
2 files changed, 63 insertions, 22 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index cd1c998f8f..008fec2308 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -23,8 +23,8 @@ __func_start_regexp__ = re.compile(r"(((?P<py>python(?=(\s|\()))|(?P<fr>faker | |||
23 | __inherit_regexp__ = re.compile(r"inherit\s+(.+)" ) | 23 | __inherit_regexp__ = re.compile(r"inherit\s+(.+)" ) |
24 | __inherit_def_regexp__ = re.compile(r"inherit_defer\s+(.+)" ) | 24 | __inherit_def_regexp__ = re.compile(r"inherit_defer\s+(.+)" ) |
25 | __export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) | 25 | __export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) |
26 | __addtask_regexp__ = re.compile(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") | 26 | __addtask_regexp__ = re.compile(r"addtask\s+([^#\n]+)(?P<comment>#.*|.*?)") |
27 | __deltask_regexp__ = re.compile(r"deltask\s+(.+)") | 27 | __deltask_regexp__ = re.compile(r"deltask\s+([^#\n]+)(?P<comment>#.*|.*?)") |
28 | __addhandler_regexp__ = re.compile(r"addhandler\s+(.+)" ) | 28 | __addhandler_regexp__ = re.compile(r"addhandler\s+(.+)" ) |
29 | __def_regexp__ = re.compile(r"def\s+(\w+).*:" ) | 29 | __def_regexp__ = re.compile(r"def\s+(\w+).*:" ) |
30 | __python_func_regexp__ = re.compile(r"(\s+.*)|(^$)|(^#)" ) | 30 | __python_func_regexp__ = re.compile(r"(\s+.*)|(^$)|(^#)" ) |
@@ -34,6 +34,7 @@ __infunc__ = [] | |||
34 | __inpython__ = False | 34 | __inpython__ = False |
35 | __body__ = [] | 35 | __body__ = [] |
36 | __classname__ = "" | 36 | __classname__ = "" |
37 | __residue__ = [] | ||
37 | 38 | ||
38 | cached_statements = {} | 39 | cached_statements = {} |
39 | 40 | ||
@@ -41,12 +42,22 @@ def supports(fn, d): | |||
41 | """Return True if fn has a supported extension""" | 42 | """Return True if fn has a supported extension""" |
42 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] | 43 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] |
43 | 44 | ||
45 | def inherit_defer(expression, fn, lineno, d): | ||
46 | inherit = (expression, fn, lineno) | ||
47 | inherits = d.getVar('__BBDEFINHERITS', False) or [] | ||
48 | inherits.append(inherit) | ||
49 | d.setVar('__BBDEFINHERITS', inherits) | ||
50 | |||
44 | def inherit(files, fn, lineno, d, deferred=False): | 51 | def inherit(files, fn, lineno, d, deferred=False): |
45 | __inherit_cache = d.getVar('__inherit_cache', False) or [] | 52 | __inherit_cache = d.getVar('__inherit_cache', False) or [] |
46 | #if "${" in files and not deferred: | 53 | #if "${" in files and not deferred: |
47 | # bb.warn("%s:%s has non deferred conditional inherit" % (fn, lineno)) | 54 | # bb.warn("%s:%s has non deferred conditional inherit" % (fn, lineno)) |
48 | files = d.expand(files).split() | 55 | files = d.expand(files).split() |
49 | for file in files: | 56 | for file in files: |
57 | defer = (d.getVar("BB_DEFER_BBCLASSES") or "").split() | ||
58 | if not deferred and file in defer: | ||
59 | inherit_defer(file, fn, lineno, d) | ||
60 | continue | ||
50 | classtype = d.getVar("__bbclasstype", False) | 61 | classtype = d.getVar("__bbclasstype", False) |
51 | origfile = file | 62 | origfile = file |
52 | for t in ["classes-" + classtype, "classes"]: | 63 | for t in ["classes-" + classtype, "classes"]: |
@@ -80,7 +91,7 @@ def inherit(files, fn, lineno, d, deferred=False): | |||
80 | __inherit_cache = d.getVar('__inherit_cache', False) or [] | 91 | __inherit_cache = d.getVar('__inherit_cache', False) or [] |
81 | 92 | ||
82 | def get_statements(filename, absolute_filename, base_name): | 93 | def get_statements(filename, absolute_filename, base_name): |
83 | global cached_statements | 94 | global cached_statements, __residue__, __body__ |
84 | 95 | ||
85 | try: | 96 | try: |
86 | return cached_statements[absolute_filename] | 97 | return cached_statements[absolute_filename] |
@@ -100,6 +111,11 @@ def get_statements(filename, absolute_filename, base_name): | |||
100 | # add a blank line to close out any python definition | 111 | # add a blank line to close out any python definition |
101 | feeder(lineno, "", filename, base_name, statements, eof=True) | 112 | feeder(lineno, "", filename, base_name, statements, eof=True) |
102 | 113 | ||
114 | if __residue__: | ||
115 | raise ParseError("Unparsed lines %s: %s" % (filename, str(__residue__)), filename, lineno) | ||
116 | if __body__: | ||
117 | raise ParseError("Unparsed lines from unclosed function %s: %s" % (filename, str(__body__)), filename, lineno) | ||
118 | |||
103 | if filename.endswith(".bbclass") or filename.endswith(".inc"): | 119 | if filename.endswith(".bbclass") or filename.endswith(".inc"): |
104 | cached_statements[absolute_filename] = statements | 120 | cached_statements[absolute_filename] = statements |
105 | return statements | 121 | return statements |
@@ -233,29 +249,38 @@ def feeder(lineno, s, fn, root, statements, eof=False): | |||
233 | 249 | ||
234 | m = __addtask_regexp__.match(s) | 250 | m = __addtask_regexp__.match(s) |
235 | if m: | 251 | if m: |
236 | if len(m.group().split()) == 2: | 252 | after = "" |
237 | # Check and warn for "addtask task1 task2" | 253 | before = "" |
238 | m2 = re.match(r"addtask\s+(?P<func>\w+)(?P<ignores>.*)", s) | 254 | |
239 | if m2 and m2.group('ignores'): | 255 | # This code splits on 'before' and 'after' instead of on whitespace so we can defer |
240 | logger.warning('addtask ignored: "%s"' % m2.group('ignores')) | 256 | # evaluation to as late as possible. |
241 | 257 | tasks = m.group(1).split(" before ")[0].split(" after ")[0] | |
242 | # Check and warn for "addtask task1 before task2 before task3", the | ||
243 | # similar to "after" | ||
244 | taskexpression = s.split() | ||
245 | for word in ('before', 'after'): | ||
246 | if taskexpression.count(word) > 1: | ||
247 | logger.warning("addtask contained multiple '%s' keywords, only one is supported" % word) | ||
248 | 258 | ||
249 | # Check and warn for having task with exprssion as part of task name | 259 | for exp in m.group(1).split(" before "): |
260 | exp2 = exp.split(" after ") | ||
261 | if len(exp2) > 1: | ||
262 | after = after + " ".join(exp2[1:]) | ||
263 | |||
264 | for exp in m.group(1).split(" after "): | ||
265 | exp2 = exp.split(" before ") | ||
266 | if len(exp2) > 1: | ||
267 | before = before + " ".join(exp2[1:]) | ||
268 | |||
269 | # Check and warn for having task with a keyword as part of task name | ||
270 | taskexpression = s.split() | ||
250 | for te in taskexpression: | 271 | for te in taskexpression: |
251 | if any( ( "%s_" % keyword ) in te for keyword in bb.data_smart.__setvar_keyword__ ): | 272 | if any( ( "%s_" % keyword ) in te for keyword in bb.data_smart.__setvar_keyword__ ): |
252 | raise ParseError("Task name '%s' contains a keyword which is not recommended/supported.\nPlease rename the task not to include the keyword.\n%s" % (te, ("\n".join(map(str, bb.data_smart.__setvar_keyword__)))), fn) | 273 | raise ParseError("Task name '%s' contains a keyword which is not recommended/supported.\nPlease rename the task not to include the keyword.\n%s" % (te, ("\n".join(map(str, bb.data_smart.__setvar_keyword__)))), fn) |
253 | ast.handleAddTask(statements, fn, lineno, m) | 274 | |
275 | if tasks is not None: | ||
276 | ast.handleAddTask(statements, fn, lineno, tasks, before, after) | ||
254 | return | 277 | return |
255 | 278 | ||
256 | m = __deltask_regexp__.match(s) | 279 | m = __deltask_regexp__.match(s) |
257 | if m: | 280 | if m: |
258 | ast.handleDelTask(statements, fn, lineno, m) | 281 | task = m.group(1) |
282 | if task is not None: | ||
283 | ast.handleDelTask(statements, fn, lineno, task) | ||
259 | return | 284 | return |
260 | 285 | ||
261 | m = __addhandler_regexp__.match(s) | 286 | m = __addhandler_regexp__.match(s) |
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 7826dee7d3..9ddbae123d 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -20,10 +20,10 @@ from bb.parse import ParseError, resolve_file, ast, logger, handle | |||
20 | __config_regexp__ = re.compile( r""" | 20 | __config_regexp__ = re.compile( r""" |
21 | ^ | 21 | ^ |
22 | (?P<exp>export\s+)? | 22 | (?P<exp>export\s+)? |
23 | (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?) | 23 | (?P<var>[a-zA-Z0-9\-_+.${}/~:]*?) |
24 | (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]*)\])? | 24 | (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@/]*)\])? |
25 | 25 | ||
26 | \s* ( | 26 | (?P<whitespace>\s*) ( |
27 | (?P<colon>:=) | | 27 | (?P<colon>:=) | |
28 | (?P<lazyques>\?\?=) | | 28 | (?P<lazyques>\?\?=) | |
29 | (?P<ques>\?=) | | 29 | (?P<ques>\?=) | |
@@ -32,7 +32,7 @@ __config_regexp__ = re.compile( r""" | |||
32 | (?P<predot>=\.) | | 32 | (?P<predot>=\.) | |
33 | (?P<postdot>\.=) | | 33 | (?P<postdot>\.=) | |
34 | = | 34 | = |
35 | ) \s* | 35 | ) (?P<whitespace2>\s*) |
36 | 36 | ||
37 | (?!'[^']*'[^']*'$) | 37 | (?!'[^']*'[^']*'$) |
38 | (?!\"[^\"]*\"[^\"]*\"$) | 38 | (?!\"[^\"]*\"[^\"]*\"$) |
@@ -43,10 +43,12 @@ __config_regexp__ = re.compile( r""" | |||
43 | """, re.X) | 43 | """, re.X) |
44 | __include_regexp__ = re.compile( r"include\s+(.+)" ) | 44 | __include_regexp__ = re.compile( r"include\s+(.+)" ) |
45 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 45 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
46 | __includeall_regexp__ = re.compile( r"include_all\s+(.+)" ) | ||
46 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) | 47 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) |
47 | __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) | 48 | __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) |
48 | __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" ) | 49 | __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" ) |
49 | __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) | 50 | __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) |
51 | __addfragments_regexp__ = re.compile(r"addfragments\s+(.+)\s+(.+)\s+(.+)\s+(.+)" ) | ||
50 | 52 | ||
51 | def init(data): | 53 | def init(data): |
52 | return | 54 | return |
@@ -164,6 +166,10 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): | |||
164 | m = __config_regexp__.match(s) | 166 | m = __config_regexp__.match(s) |
165 | if m: | 167 | if m: |
166 | groupd = m.groupdict() | 168 | groupd = m.groupdict() |
169 | if groupd['var'] == "": | ||
170 | raise ParseError("Empty variable name in assignment: '%s'" % s, fn, lineno); | ||
171 | if not groupd['whitespace'] or not groupd['whitespace2']: | ||
172 | logger.warning("%s:%s has a lack of whitespace around the assignment: '%s'" % (fn, lineno, s)) | ||
167 | ast.handleData(statements, fn, lineno, groupd) | 173 | ast.handleData(statements, fn, lineno, groupd) |
168 | return | 174 | return |
169 | 175 | ||
@@ -177,6 +183,11 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): | |||
177 | ast.handleInclude(statements, fn, lineno, m, True) | 183 | ast.handleInclude(statements, fn, lineno, m, True) |
178 | return | 184 | return |
179 | 185 | ||
186 | m = __includeall_regexp__.match(s) | ||
187 | if m: | ||
188 | ast.handleIncludeAll(statements, fn, lineno, m) | ||
189 | return | ||
190 | |||
180 | m = __export_regexp__.match(s) | 191 | m = __export_regexp__.match(s) |
181 | if m: | 192 | if m: |
182 | ast.handleExport(statements, fn, lineno, m) | 193 | ast.handleExport(statements, fn, lineno, m) |
@@ -197,6 +208,11 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): | |||
197 | ast.handlePyLib(statements, fn, lineno, m) | 208 | ast.handlePyLib(statements, fn, lineno, m) |
198 | return | 209 | return |
199 | 210 | ||
211 | m = __addfragments_regexp__.match(s) | ||
212 | if m: | ||
213 | ast.handleAddFragments(statements, fn, lineno, m) | ||
214 | return | ||
215 | |||
200 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); | 216 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); |
201 | 217 | ||
202 | # Add us to the handlers list | 218 | # Add us to the handlers list |