summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/codeparser.py28
-rw-r--r--bitbake/lib/bb/data.py10
-rw-r--r--bitbake/lib/bb/data_smart.py8
3 files changed, 37 insertions, 9 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
153Logger = logging.getLoggerClass()
154class 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
153class PythonParser(): 169class 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
230class ShellParser(): 247class 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 5bb2595893..7c1533cfa9 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -49,6 +49,7 @@ from bb import data_smart
49from bb import codeparser 49from bb import codeparser
50import bb 50import bb
51 51
52logger = data_smart.logger
52_dict_type = data_smart.DataSmart 53_dict_type = data_smart.DataSmart
53 54
54def init(): 55def 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
273def update_data(d): 274def update_data(d):
@@ -276,6 +277,7 @@ def update_data(d):
276 277
277def build_dependencies(key, keys, shelldeps, vardepvals, d): 278def build_dependencies(key, keys, shelldeps, vardepvals, d):
278 deps = set() 279 deps = set()
280 vardeps = d.getVarFlag(key, "vardeps", True)
279 try: 281 try:
280 value = d.getVar(key, False) 282 value = d.getVar(key, False)
281 if key in vardepvals: 283 if key in vardepvals:
@@ -291,13 +293,15 @@ def build_dependencies(key, keys, shelldeps, vardepvals, d):
291 parser = bb.codeparser.ShellParser(key, logger) 293 parser = bb.codeparser.ShellParser(key, logger)
292 parser.parse_shell(parsedvar.value) 294 parser.parse_shell(parsedvar.value)
293 deps = deps | shelldeps 295 deps = deps | shelldeps
296 if vardeps is None:
297 parser.log.flush()
294 deps = deps | parsedvar.references 298 deps = deps | parsedvar.references
295 deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) 299 deps = deps | (keys & parser.execs) | (keys & parsedvar.execs)
296 else: 300 else:
297 parser = d.expandWithRefs(value, key) 301 parser = d.expandWithRefs(value, key)
298 deps |= parser.references 302 deps |= parser.references
299 deps = deps | (keys & parser.execs) 303 deps = deps | (keys & parser.execs)
300 deps |= set((d.getVarFlag(key, "vardeps", True) or "").split()) 304 deps |= set((vardeps or "").split())
301 deps -= set((d.getVarFlag(key, "vardepsexclude", True) or "").split()) 305 deps -= set((d.getVarFlag(key, "vardepsexclude", True) or "").split())
302 except: 306 except:
303 bb.note("Error expanding variable %s" % key) 307 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