summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/codeparser.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/codeparser.py')
-rw-r--r--bitbake/lib/bb/codeparser.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py
index 116481559a..6e34eff999 100644
--- a/bitbake/lib/bb/codeparser.py
+++ b/bitbake/lib/bb/codeparser.py
@@ -1,6 +1,7 @@
1import ast 1import ast
2import codegen 2import codegen
3import logging 3import logging
4import collections
4import os.path 5import os.path
5import bb.utils, bb.data 6import bb.utils, bb.data
6from itertools import chain 7from itertools import chain
@@ -35,7 +36,7 @@ def check_indent(codestr):
35 36
36class CodeParserCache(MultiProcessCache): 37class CodeParserCache(MultiProcessCache):
37 cache_file_name = "bb_codeparser.dat" 38 cache_file_name = "bb_codeparser.dat"
38 CACHE_VERSION = 3 39 CACHE_VERSION = 4
39 40
40 def __init__(self): 41 def __init__(self):
41 MultiProcessCache.__init__(self) 42 MultiProcessCache.__init__(self)
@@ -122,7 +123,11 @@ class PythonParser():
122 name = self.called_node_name(node.func) 123 name = self.called_node_name(node.func)
123 if name in self.getvars or name in self.containsfuncs: 124 if name in self.getvars or name in self.containsfuncs:
124 if isinstance(node.args[0], ast.Str): 125 if isinstance(node.args[0], ast.Str):
125 self.references.add(node.args[0].s) 126 varname = node.args[0].s
127 if name in self.containsfuncs and isinstance(node.args[1], ast.Str):
128 self.contains[varname].add(node.args[1].s)
129 else:
130 self.references.add(node.args[0].s)
126 else: 131 else:
127 self.warn(node.func, node.args[0]) 132 self.warn(node.func, node.args[0])
128 elif name in self.execfuncs: 133 elif name in self.execfuncs:
@@ -148,6 +153,7 @@ class PythonParser():
148 153
149 def __init__(self, name, log): 154 def __init__(self, name, log):
150 self.var_execs = set() 155 self.var_execs = set()
156 self.contains = collections.defaultdict(set)
151 self.execs = set() 157 self.execs = set()
152 self.references = set() 158 self.references = set()
153 self.log = BufferedLogger('BitBake.Data.%s' % name, logging.DEBUG, log) 159 self.log = BufferedLogger('BitBake.Data.%s' % name, logging.DEBUG, log)
@@ -161,14 +167,15 @@ class PythonParser():
161 if h in codeparsercache.pythoncache: 167 if h in codeparsercache.pythoncache:
162 self.references = codeparsercache.pythoncache[h]["refs"] 168 self.references = codeparsercache.pythoncache[h]["refs"]
163 self.execs = codeparsercache.pythoncache[h]["execs"] 169 self.execs = codeparsercache.pythoncache[h]["execs"]
170 self.contains = codeparsercache.pythoncache[h]["contains"]
164 return 171 return
165 172
166 if h in codeparsercache.pythoncacheextras: 173 if h in codeparsercache.pythoncacheextras:
167 self.references = codeparsercache.pythoncacheextras[h]["refs"] 174 self.references = codeparsercache.pythoncacheextras[h]["refs"]
168 self.execs = codeparsercache.pythoncacheextras[h]["execs"] 175 self.execs = codeparsercache.pythoncacheextras[h]["execs"]
176 self.contains = codeparsercache.pythoncacheextras[h]["contains"]
169 return 177 return
170 178
171
172 code = compile(check_indent(str(node)), "<string>", "exec", 179 code = compile(check_indent(str(node)), "<string>", "exec",
173 ast.PyCF_ONLY_AST) 180 ast.PyCF_ONLY_AST)
174 181
@@ -181,6 +188,7 @@ class PythonParser():
181 codeparsercache.pythoncacheextras[h] = {} 188 codeparsercache.pythoncacheextras[h] = {}
182 codeparsercache.pythoncacheextras[h]["refs"] = self.references 189 codeparsercache.pythoncacheextras[h]["refs"] = self.references
183 codeparsercache.pythoncacheextras[h]["execs"] = self.execs 190 codeparsercache.pythoncacheextras[h]["execs"] = self.execs
191 codeparsercache.pythoncacheextras[h]["contains"] = self.contains
184 192
185class ShellParser(): 193class ShellParser():
186 def __init__(self, name, log): 194 def __init__(self, name, log):