diff options
Diffstat (limited to 'bitbake/lib/bb/codeparser.py')
-rw-r--r-- | bitbake/lib/bb/codeparser.py | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/bitbake/lib/bb/codeparser.py b/bitbake/lib/bb/codeparser.py index 691bdff75e..b25a2133d2 100644 --- a/bitbake/lib/bb/codeparser.py +++ b/bitbake/lib/bb/codeparser.py | |||
@@ -72,6 +72,11 @@ def add_module_functions(fn, functions, namespace): | |||
72 | parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f) | 72 | parser.parse_python(None, filename=fn, lineno=1, fixedhash=fixedhash+f) |
73 | #bb.warn("Cached %s" % f) | 73 | #bb.warn("Cached %s" % f) |
74 | except KeyError: | 74 | except KeyError: |
75 | targetfn = inspect.getsourcefile(functions[f]) | ||
76 | if fn != targetfn: | ||
77 | # Skip references to other modules outside this file | ||
78 | #bb.warn("Skipping %s" % name) | ||
79 | continue | ||
75 | lines, lineno = inspect.getsourcelines(functions[f]) | 80 | lines, lineno = inspect.getsourcelines(functions[f]) |
76 | src = "".join(lines) | 81 | src = "".join(lines) |
77 | parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f) | 82 | parser.parse_python(src, filename=fn, lineno=lineno, fixedhash=fixedhash+f) |
@@ -82,14 +87,14 @@ def add_module_functions(fn, functions, namespace): | |||
82 | if e in functions: | 87 | if e in functions: |
83 | execs.remove(e) | 88 | execs.remove(e) |
84 | execs.add(namespace + "." + e) | 89 | execs.add(namespace + "." + e) |
85 | modulecode_deps[name] = [parser.references.copy(), execs, parser.var_execs.copy(), parser.contains.copy()] | 90 | modulecode_deps[name] = [parser.references.copy(), execs, parser.var_execs.copy(), parser.contains.copy(), parser.extra] |
86 | #bb.warn("%s: %s\nRefs:%s Execs: %s %s %s" % (name, fn, parser.references, parser.execs, parser.var_execs, parser.contains)) | 91 | #bb.warn("%s: %s\nRefs:%s Execs: %s %s %s" % (name, fn, parser.references, parser.execs, parser.var_execs, parser.contains)) |
87 | 92 | ||
88 | def update_module_dependencies(d): | 93 | def update_module_dependencies(d): |
89 | for mod in modulecode_deps: | 94 | for mod in modulecode_deps: |
90 | excludes = set((d.getVarFlag(mod, "vardepsexclude") or "").split()) | 95 | excludes = set((d.getVarFlag(mod, "vardepsexclude") or "").split()) |
91 | if excludes: | 96 | if excludes: |
92 | modulecode_deps[mod] = [modulecode_deps[mod][0] - excludes, modulecode_deps[mod][1] - excludes, modulecode_deps[mod][2] - excludes, modulecode_deps[mod][3]] | 97 | modulecode_deps[mod] = [modulecode_deps[mod][0] - excludes, modulecode_deps[mod][1] - excludes, modulecode_deps[mod][2] - excludes, modulecode_deps[mod][3], modulecode_deps[mod][4]] |
93 | 98 | ||
94 | # A custom getstate/setstate using tuples is actually worth 15% cachesize by | 99 | # A custom getstate/setstate using tuples is actually worth 15% cachesize by |
95 | # avoiding duplication of the attribute names! | 100 | # avoiding duplication of the attribute names! |
@@ -112,21 +117,22 @@ class SetCache(object): | |||
112 | codecache = SetCache() | 117 | codecache = SetCache() |
113 | 118 | ||
114 | class pythonCacheLine(object): | 119 | class pythonCacheLine(object): |
115 | def __init__(self, refs, execs, contains): | 120 | def __init__(self, refs, execs, contains, extra): |
116 | self.refs = codecache.internSet(refs) | 121 | self.refs = codecache.internSet(refs) |
117 | self.execs = codecache.internSet(execs) | 122 | self.execs = codecache.internSet(execs) |
118 | self.contains = {} | 123 | self.contains = {} |
119 | for c in contains: | 124 | for c in contains: |
120 | self.contains[c] = codecache.internSet(contains[c]) | 125 | self.contains[c] = codecache.internSet(contains[c]) |
126 | self.extra = extra | ||
121 | 127 | ||
122 | def __getstate__(self): | 128 | def __getstate__(self): |
123 | return (self.refs, self.execs, self.contains) | 129 | return (self.refs, self.execs, self.contains, self.extra) |
124 | 130 | ||
125 | def __setstate__(self, state): | 131 | def __setstate__(self, state): |
126 | (refs, execs, contains) = state | 132 | (refs, execs, contains, extra) = state |
127 | self.__init__(refs, execs, contains) | 133 | self.__init__(refs, execs, contains, extra) |
128 | def __hash__(self): | 134 | def __hash__(self): |
129 | l = (hash(self.refs), hash(self.execs)) | 135 | l = (hash(self.refs), hash(self.execs), hash(self.extra)) |
130 | for c in sorted(self.contains.keys()): | 136 | for c in sorted(self.contains.keys()): |
131 | l = l + (c, hash(self.contains[c])) | 137 | l = l + (c, hash(self.contains[c])) |
132 | return hash(l) | 138 | return hash(l) |
@@ -155,7 +161,7 @@ class CodeParserCache(MultiProcessCache): | |||
155 | # so that an existing cache gets invalidated. Additionally you'll need | 161 | # so that an existing cache gets invalidated. Additionally you'll need |
156 | # to increment __cache_version__ in cache.py in order to ensure that old | 162 | # to increment __cache_version__ in cache.py in order to ensure that old |
157 | # recipe caches don't trigger "Taskhash mismatch" errors. | 163 | # recipe caches don't trigger "Taskhash mismatch" errors. |
158 | CACHE_VERSION = 11 | 164 | CACHE_VERSION = 12 |
159 | 165 | ||
160 | def __init__(self): | 166 | def __init__(self): |
161 | MultiProcessCache.__init__(self) | 167 | MultiProcessCache.__init__(self) |
@@ -169,8 +175,8 @@ class CodeParserCache(MultiProcessCache): | |||
169 | self.pythoncachelines = {} | 175 | self.pythoncachelines = {} |
170 | self.shellcachelines = {} | 176 | self.shellcachelines = {} |
171 | 177 | ||
172 | def newPythonCacheLine(self, refs, execs, contains): | 178 | def newPythonCacheLine(self, refs, execs, contains, extra): |
173 | cacheline = pythonCacheLine(refs, execs, contains) | 179 | cacheline = pythonCacheLine(refs, execs, contains, extra) |
174 | h = hash(cacheline) | 180 | h = hash(cacheline) |
175 | if h in self.pythoncachelines: | 181 | if h in self.pythoncachelines: |
176 | return self.pythoncachelines[h] | 182 | return self.pythoncachelines[h] |
@@ -338,6 +344,7 @@ class PythonParser(): | |||
338 | self.contains = {} | 344 | self.contains = {} |
339 | for i in codeparsercache.pythoncache[h].contains: | 345 | for i in codeparsercache.pythoncache[h].contains: |
340 | self.contains[i] = set(codeparsercache.pythoncache[h].contains[i]) | 346 | self.contains[i] = set(codeparsercache.pythoncache[h].contains[i]) |
347 | self.extra = codeparsercache.pythoncache[h].extra | ||
341 | return | 348 | return |
342 | 349 | ||
343 | if h in codeparsercache.pythoncacheextras: | 350 | if h in codeparsercache.pythoncacheextras: |
@@ -346,6 +353,7 @@ class PythonParser(): | |||
346 | self.contains = {} | 353 | self.contains = {} |
347 | for i in codeparsercache.pythoncacheextras[h].contains: | 354 | for i in codeparsercache.pythoncacheextras[h].contains: |
348 | self.contains[i] = set(codeparsercache.pythoncacheextras[h].contains[i]) | 355 | self.contains[i] = set(codeparsercache.pythoncacheextras[h].contains[i]) |
356 | self.extra = codeparsercache.pythoncacheextras[h].extra | ||
349 | return | 357 | return |
350 | 358 | ||
351 | if fixedhash and not node: | 359 | if fixedhash and not node: |
@@ -364,8 +372,11 @@ class PythonParser(): | |||
364 | self.visit_Call(n) | 372 | self.visit_Call(n) |
365 | 373 | ||
366 | self.execs.update(self.var_execs) | 374 | self.execs.update(self.var_execs) |
375 | self.extra = None | ||
376 | if fixedhash: | ||
377 | self.extra = bbhash(str(node)) | ||
367 | 378 | ||
368 | codeparsercache.pythoncacheextras[h] = codeparsercache.newPythonCacheLine(self.references, self.execs, self.contains) | 379 | codeparsercache.pythoncacheextras[h] = codeparsercache.newPythonCacheLine(self.references, self.execs, self.contains, self.extra) |
369 | 380 | ||
370 | class ShellParser(): | 381 | class ShellParser(): |
371 | def __init__(self, name, log): | 382 | def __init__(self, name, log): |