summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/codeparser.py
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2011-10-28 21:32:26 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-10 11:44:29 +0000
commitae96ac11897c1017aea359a8e3325291bc198293 (patch)
tree60ea01a4a0b04ee64c5eda99f5f1759f115dd4a6 /bitbake/lib/bb/codeparser.py
parent48d7f5251bd5f3a44f713edfc297851258c57120 (diff)
downloadpoky-ae96ac11897c1017aea359a8e3325291bc198293.tar.gz
codeparser: accept a name for better messages
- If a name is passed to the parser, prepend the messages with "while parsing <name>:". This gives a bit more context. - Tweak the warning messages slightly (they had to be altered anyway to inject the variable being parsed). Before: DEBUG: Warning: in call to 'bb.data.getVar': argument ''%s' % var' is \ not a literal After: DEBUG: while parsing emit_pkgdata, in call of bb.data.getVar, argument \ ''%s' % var' is not a string literal (Bitbake rev: 1060193ae4d54e667735dbff5d1d2be49a3f95c9) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/codeparser.py')
-rw-r--r--bitbake/lib/bb/codeparser.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py
index 77156136f8..9a692a0c8e 100644
--- a/bitbake/lib/bb/codeparser.py
+++ b/bitbake/lib/bb/codeparser.py
@@ -155,8 +155,7 @@ class PythonParser():
155 expands = ("d.expand", "bb.data.expand", "data.expand") 155 expands = ("d.expand", "bb.data.expand", "data.expand")
156 execfuncs = ("bb.build.exec_func", "bb.build.exec_task") 156 execfuncs = ("bb.build.exec_func", "bb.build.exec_task")
157 157
158 @classmethod 158 def warn(self, func, arg):
159 def warn(cls, func, arg):
160 """Warn about calls of bitbake APIs which pass a non-literal 159 """Warn about calls of bitbake APIs which pass a non-literal
161 argument for the variable name, as we're not able to track such 160 argument for the variable name, as we're not able to track such
162 a reference. 161 a reference.
@@ -168,8 +167,7 @@ class PythonParser():
168 except TypeError: 167 except TypeError:
169 logger.debug(2, 'Failed to convert function and argument to source form') 168 logger.debug(2, 'Failed to convert function and argument to source form')
170 else: 169 else:
171 logger.debug(1, "Warning: in call to '%s', argument '%s' is " 170 logger.debug(1, self.unhandled_message % (funcstr, argstr))
172 "not a literal", funcstr, argstr)
173 171
174 def visit_Call(self, node): 172 def visit_Call(self, node):
175 name = self.called_node_name(node.func) 173 name = self.called_node_name(node.func)
@@ -208,13 +206,16 @@ class PythonParser():
208 else: 206 else:
209 break 207 break
210 208
211 def __init__(self): 209 def __init__(self, name):
212 self.var_references = set() 210 self.var_references = set()
213 self.var_execs = set() 211 self.var_execs = set()
214 self.execs = set() 212 self.execs = set()
215 self.var_expands = set() 213 self.var_expands = set()
216 self.references = set() 214 self.references = set()
217 215
216 self.unhandled_message = "in call of %s, argument '%s' is not a string literal"
217 self.unhandled_message = "while parsing %s, %s" % (name, self.unhandled_message)
218
218 def parse_python(self, node): 219 def parse_python(self, node):
219 h = hash(str(node)) 220 h = hash(str(node))
220 221
@@ -238,10 +239,12 @@ class PythonParser():
238 pythonparsecache[h]["execs"] = self.execs 239 pythonparsecache[h]["execs"] = self.execs
239 240
240class ShellParser(): 241class ShellParser():
241 def __init__(self): 242 def __init__(self, name):
242 self.funcdefs = set() 243 self.funcdefs = set()
243 self.allexecs = set() 244 self.allexecs = set()
244 self.execs = set() 245 self.execs = set()
246 self.unhandled_template = "unable to handle non-literal command '%s'"
247 self.unhandled_template = "while parsing %s, %s" % (name, self.unhandled_template)
245 248
246 def parse_shell(self, value): 249 def parse_shell(self, value):
247 """Parse the supplied shell code in a string, returning the external 250 """Parse the supplied shell code in a string, returning the external
@@ -356,8 +359,7 @@ class ShellParser():
356 359
357 cmd = word[1] 360 cmd = word[1]
358 if cmd.startswith("$"): 361 if cmd.startswith("$"):
359 logger.debug(1, "Warning: execution of non-literal " 362 logger.debug(1, self.unhandled_template % cmd)
360 "command '%s'", cmd)
361 elif cmd == "eval": 363 elif cmd == "eval":
362 command = " ".join(word for _, word in words[1:]) 364 command = " ".join(word for _, word in words[1:])
363 self.parse_shell(command) 365 self.parse_shell(command)