diff options
author | Christopher Larson <chris_larson@mentor.com> | 2011-11-04 14:59:46 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-11-10 11:44:29 +0000 |
commit | ab3488264b1323a29842d12b575fa7e117115ebc (patch) | |
tree | 29225ef240ee92e3170c883824c0327eb5cfaf0f /bitbake/lib | |
parent | 7e436a98454275bea71cb511d13ad3665a1caba9 (diff) | |
download | poky-ab3488264b1323a29842d12b575fa7e117115ebc.tar.gz |
codeparser: silence non-literal warnings for vardeps
If the vardeps flag is not None, we now silence the warnings about
non-literal usage for that variable.
(Bitbake rev: e724b9f417d1baf898f5afc6376c73c1a2ad8db9)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/codeparser.py | 28 | ||||
-rw-r--r-- | bitbake/lib/bb/data.py | 14 | ||||
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 8 |
3 files changed, 39 insertions, 11 deletions
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index 615fb7d610..d425514481 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py | |||
@@ -150,6 +150,22 @@ def parser_cache_savemerge(d): | |||
150 | bb.utils.unlockfile(glf) | 150 | bb.utils.unlockfile(glf) |
151 | 151 | ||
152 | 152 | ||
153 | Logger = logging.getLoggerClass() | ||
154 | class BufferedLogger(Logger): | ||
155 | def __init__(self, name, level=0, target=None): | ||
156 | Logger.__init__(self, name) | ||
157 | self.setLevel(level) | ||
158 | self.buffer = [] | ||
159 | self.target = target | ||
160 | |||
161 | def handle(self, record): | ||
162 | self.buffer.append(record) | ||
163 | |||
164 | def flush(self): | ||
165 | for record in self.buffer: | ||
166 | self.target.handle(record) | ||
167 | self.buffer = [] | ||
168 | |||
153 | class PythonParser(): | 169 | class PythonParser(): |
154 | getvars = ("d.getVar", "bb.data.getVar", "data.getVar") | 170 | getvars = ("d.getVar", "bb.data.getVar", "data.getVar") |
155 | execfuncs = ("bb.build.exec_func", "bb.build.exec_task") | 171 | execfuncs = ("bb.build.exec_func", "bb.build.exec_task") |
@@ -164,9 +180,9 @@ class PythonParser(): | |||
164 | funcstr = codegen.to_source(func) | 180 | funcstr = codegen.to_source(func) |
165 | argstr = codegen.to_source(arg) | 181 | argstr = codegen.to_source(arg) |
166 | except TypeError: | 182 | except TypeError: |
167 | logger.debug(2, 'Failed to convert function and argument to source form') | 183 | self.log.debug(2, 'Failed to convert function and argument to source form') |
168 | else: | 184 | else: |
169 | logger.debug(1, self.unhandled_message % (funcstr, argstr)) | 185 | self.log.debug(1, self.unhandled_message % (funcstr, argstr)) |
170 | 186 | ||
171 | def visit_Call(self, node): | 187 | def visit_Call(self, node): |
172 | name = self.called_node_name(node.func) | 188 | name = self.called_node_name(node.func) |
@@ -196,11 +212,12 @@ class PythonParser(): | |||
196 | else: | 212 | else: |
197 | break | 213 | break |
198 | 214 | ||
199 | def __init__(self, name): | 215 | def __init__(self, name, log): |
200 | self.var_references = set() | 216 | self.var_references = set() |
201 | self.var_execs = set() | 217 | self.var_execs = set() |
202 | self.execs = set() | 218 | self.execs = set() |
203 | self.references = set() | 219 | self.references = set() |
220 | self.log = BufferedLogger('BitBake.Data.%s' % name, logging.DEBUG, log) | ||
204 | 221 | ||
205 | self.unhandled_message = "in call of %s, argument '%s' is not a string literal" | 222 | self.unhandled_message = "in call of %s, argument '%s' is not a string literal" |
206 | self.unhandled_message = "while parsing %s, %s" % (name, self.unhandled_message) | 223 | self.unhandled_message = "while parsing %s, %s" % (name, self.unhandled_message) |
@@ -228,10 +245,11 @@ class PythonParser(): | |||
228 | pythonparsecache[h]["execs"] = self.execs | 245 | pythonparsecache[h]["execs"] = self.execs |
229 | 246 | ||
230 | class ShellParser(): | 247 | class ShellParser(): |
231 | def __init__(self, name): | 248 | def __init__(self, name, log): |
232 | self.funcdefs = set() | 249 | self.funcdefs = set() |
233 | self.allexecs = set() | 250 | self.allexecs = set() |
234 | self.execs = set() | 251 | self.execs = set() |
252 | self.log = BufferedLogger('BitBake.Data.%s' % name, logging.DEBUG, log) | ||
235 | self.unhandled_template = "unable to handle non-literal command '%s'" | 253 | self.unhandled_template = "unable to handle non-literal command '%s'" |
236 | self.unhandled_template = "while parsing %s, %s" % (name, self.unhandled_template) | 254 | self.unhandled_template = "while parsing %s, %s" % (name, self.unhandled_template) |
237 | 255 | ||
@@ -348,7 +366,7 @@ class ShellParser(): | |||
348 | 366 | ||
349 | cmd = word[1] | 367 | cmd = word[1] |
350 | if cmd.startswith("$"): | 368 | if cmd.startswith("$"): |
351 | logger.debug(1, self.unhandled_template % cmd) | 369 | self.log.debug(1, self.unhandled_template % cmd) |
352 | elif cmd == "eval": | 370 | elif cmd == "eval": |
353 | command = " ".join(word for _, word in words[1:]) | 371 | command = " ".join(word for _, word in words[1:]) |
354 | self.parse_shell(command) | 372 | self.parse_shell(command) |
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index bcb8b055b8..10188f3807 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py | |||
@@ -49,6 +49,7 @@ from bb import data_smart | |||
49 | from bb import codeparser | 49 | from bb import codeparser |
50 | import bb | 50 | import bb |
51 | 51 | ||
52 | logger = data_smart.logger | ||
52 | _dict_type = data_smart.DataSmart | 53 | _dict_type = data_smart.DataSmart |
53 | 54 | ||
54 | def init(): | 55 | def init(): |
@@ -258,7 +259,7 @@ def emit_func(func, o=sys.__stdout__, d = init()): | |||
258 | emit_var(key, o, d, False) and o.write('\n') | 259 | emit_var(key, o, d, False) and o.write('\n') |
259 | 260 | ||
260 | emit_var(func, o, d, False) and o.write('\n') | 261 | emit_var(func, o, d, False) and o.write('\n') |
261 | newdeps = bb.codeparser.ShellParser(func).parse_shell(d.getVar(func, True)) | 262 | newdeps = bb.codeparser.ShellParser(func, logger).parse_shell(d.getVar(func, True)) |
262 | seen = set() | 263 | seen = set() |
263 | while newdeps: | 264 | while newdeps: |
264 | deps = newdeps | 265 | deps = newdeps |
@@ -267,7 +268,7 @@ def emit_func(func, o=sys.__stdout__, d = init()): | |||
267 | for dep in deps: | 268 | for dep in deps: |
268 | if bb.data.getVarFlag(dep, "func", d): | 269 | if bb.data.getVarFlag(dep, "func", d): |
269 | emit_var(dep, o, d, False) and o.write('\n') | 270 | emit_var(dep, o, d, False) and o.write('\n') |
270 | newdeps |= bb.codeparser.ShellParser(dep).parse_shell(d.getVar(dep, True)) | 271 | newdeps |= bb.codeparser.ShellParser(dep, logger).parse_shell(d.getVar(dep, True)) |
271 | newdeps -= seen | 272 | newdeps -= seen |
272 | 273 | ||
273 | def update_data(d): | 274 | def update_data(d): |
@@ -276,25 +277,28 @@ def update_data(d): | |||
276 | 277 | ||
277 | def build_dependencies(key, keys, shelldeps, d): | 278 | def build_dependencies(key, keys, shelldeps, d): |
278 | deps = set() | 279 | deps = set() |
280 | vardeps = d.getVarFlag(key, "vardeps", True) | ||
279 | try: | 281 | try: |
280 | if d.getVarFlag(key, "func"): | 282 | if d.getVarFlag(key, "func"): |
281 | if d.getVarFlag(key, "python"): | 283 | if d.getVarFlag(key, "python"): |
282 | parsedvar = d.expandWithRefs(d.getVar(key, False), key) | 284 | parsedvar = d.expandWithRefs(d.getVar(key, False), key) |
283 | parser = bb.codeparser.PythonParser(key) | 285 | parser = bb.codeparser.PythonParser(key, logger) |
284 | parser.parse_python(parsedvar.value) | 286 | parser.parse_python(parsedvar.value) |
285 | deps = deps | parser.references | 287 | deps = deps | parser.references |
286 | else: | 288 | else: |
287 | parsedvar = d.expandWithRefs(d.getVar(key, False), key) | 289 | parsedvar = d.expandWithRefs(d.getVar(key, False), key) |
288 | parser = bb.codeparser.ShellParser(key) | 290 | parser = bb.codeparser.ShellParser(key, logger) |
289 | parser.parse_shell(parsedvar.value) | 291 | parser.parse_shell(parsedvar.value) |
290 | deps = deps | shelldeps | 292 | deps = deps | shelldeps |
293 | if vardeps is None: | ||
294 | parser.log.flush() | ||
291 | deps = deps | parsedvar.references | 295 | deps = deps | parsedvar.references |
292 | deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) | 296 | deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) |
293 | else: | 297 | else: |
294 | parser = d.expandWithRefs(d.getVar(key, False), key) | 298 | parser = d.expandWithRefs(d.getVar(key, False), key) |
295 | deps |= parser.references | 299 | deps |= parser.references |
296 | deps = deps | (keys & parser.execs) | 300 | deps = deps | (keys & parser.execs) |
297 | deps |= set((d.getVarFlag(key, "vardeps", True) or "").split()) | 301 | deps |= set((vardeps or "").split()) |
298 | deps -= set((d.getVarFlag(key, "vardepsexclude", True) or "").split()) | 302 | deps -= set((d.getVarFlag(key, "vardepsexclude", True) or "").split()) |
299 | except: | 303 | except: |
300 | bb.note("Error expanding variable %s" % key) | 304 | bb.note("Error expanding variable %s" % key) |
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 44369ed82d..072f4033a0 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -68,8 +68,14 @@ class VariableParse: | |||
68 | code = match.group()[3:-1] | 68 | code = match.group()[3:-1] |
69 | codeobj = compile(code.strip(), self.varname or "<expansion>", "eval") | 69 | codeobj = compile(code.strip(), self.varname or "<expansion>", "eval") |
70 | 70 | ||
71 | parser = bb.codeparser.PythonParser(self.varname) | 71 | parser = bb.codeparser.PythonParser(self.varname, logger) |
72 | parser.parse_python(code) | 72 | parser.parse_python(code) |
73 | if self.varname: | ||
74 | vardeps = self.d.getVarFlag(self.varname, "vardeps", True) | ||
75 | if vardeps is None: | ||
76 | parser.log.flush() | ||
77 | else: | ||
78 | parser.log.flush() | ||
73 | self.references |= parser.references | 79 | self.references |= parser.references |
74 | self.execs |= parser.execs | 80 | self.execs |= parser.execs |
75 | 81 | ||