diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/methodpool.py | 42 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 8 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 4 |
4 files changed, 5 insertions, 51 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index daf37ebd45..eed489f5d4 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -1454,6 +1454,7 @@ class Parser(multiprocessing.Process): | |||
1454 | self.quit = quit | 1454 | self.quit = quit |
1455 | self.init = init | 1455 | self.init = init |
1456 | multiprocessing.Process.__init__(self) | 1456 | multiprocessing.Process.__init__(self) |
1457 | self.context = bb.utils._context.copy() | ||
1457 | 1458 | ||
1458 | def run(self): | 1459 | def run(self): |
1459 | if self.init: | 1460 | if self.init: |
@@ -1488,6 +1489,7 @@ class Parser(multiprocessing.Process): | |||
1488 | 1489 | ||
1489 | def parse(self, filename, appends, caches_array): | 1490 | def parse(self, filename, appends, caches_array): |
1490 | try: | 1491 | try: |
1492 | bb.utils._context = self.context.copy() | ||
1491 | return True, bb.cache.Cache.parse(filename, appends, self.cfg, caches_array) | 1493 | return True, bb.cache.Cache.parse(filename, appends, self.cfg, caches_array) |
1492 | except Exception as exc: | 1494 | except Exception as exc: |
1493 | tb = sys.exc_info()[2] | 1495 | tb = sys.exc_info()[2] |
diff --git a/bitbake/lib/bb/methodpool.py b/bitbake/lib/bb/methodpool.py index 8ad23c650b..bf2e9f5542 100644 --- a/bitbake/lib/bb/methodpool.py +++ b/bitbake/lib/bb/methodpool.py | |||
@@ -17,24 +17,7 @@ | |||
17 | # with this program; if not, write to the Free Software Foundation, Inc., | 17 | # with this program; if not, write to the Free Software Foundation, Inc., |
18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | 19 | ||
20 | |||
21 | """ | ||
22 | What is a method pool? | ||
23 | |||
24 | BitBake has a global method scope where .bb, .inc and .bbclass | ||
25 | files can install methods. These methods are parsed from strings. | ||
26 | To avoid recompiling and executing these string we introduce | ||
27 | a method pool to do this task. | ||
28 | |||
29 | This pool will be used to compile and execute the functions. It | ||
30 | will be smart enough to | ||
31 | """ | ||
32 | |||
33 | from bb.utils import better_compile, better_exec | 20 | from bb.utils import better_compile, better_exec |
34 | from bb import error | ||
35 | |||
36 | # A dict of function names we have seen | ||
37 | _parsed_fns = { } | ||
38 | 21 | ||
39 | def insert_method(modulename, code, fn): | 22 | def insert_method(modulename, code, fn): |
40 | """ | 23 | """ |
@@ -44,28 +27,3 @@ def insert_method(modulename, code, fn): | |||
44 | comp = better_compile(code, modulename, fn ) | 27 | comp = better_compile(code, modulename, fn ) |
45 | better_exec(comp, None, code, fn) | 28 | better_exec(comp, None, code, fn) |
46 | 29 | ||
47 | # now some instrumentation | ||
48 | code = comp.co_names | ||
49 | for name in code: | ||
50 | if name in ['None', 'False']: | ||
51 | continue | ||
52 | elif name in _parsed_fns and not _parsed_fns[name] == modulename: | ||
53 | bb.fatal("The function %s defined in %s was already declared in %s. BitBake has a global python function namespace so shared functions should be declared in a common include file rather than being duplicated, or if the functions are different, please use different function names." % (name, modulename, _parsed_fns[name])) | ||
54 | else: | ||
55 | _parsed_fns[name] = modulename | ||
56 | |||
57 | # A dict of modules the parser has finished with | ||
58 | _parsed_methods = {} | ||
59 | |||
60 | def parsed_module(modulename): | ||
61 | """ | ||
62 | Has module been parsed? | ||
63 | """ | ||
64 | return modulename in _parsed_methods | ||
65 | |||
66 | def set_parsed_module(modulename): | ||
67 | """ | ||
68 | Set module as parsed | ||
69 | """ | ||
70 | _parsed_methods[modulename] = True | ||
71 | |||
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index b2657f8044..713bef1cc2 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -148,9 +148,8 @@ class MethodNode(AstNode): | |||
148 | text = '\n'.join(self.body) | 148 | text = '\n'.join(self.body) |
149 | if self.func_name == "__anonymous": | 149 | if self.func_name == "__anonymous": |
150 | funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-', '____')))) | 150 | funcname = ("__anon_%s_%s" % (self.lineno, self.filename.translate(string.maketrans('/.+-', '____')))) |
151 | if not funcname in bb.methodpool._parsed_fns: | 151 | text = "def %s(d):\n" % (funcname) + text |
152 | text = "def %s(d):\n" % (funcname) + text | 152 | bb.methodpool.insert_method(funcname, text, self.filename) |
153 | bb.methodpool.insert_method(funcname, text, self.filename) | ||
154 | anonfuncs = data.getVar('__BBANONFUNCS') or [] | 153 | anonfuncs = data.getVar('__BBANONFUNCS') or [] |
155 | anonfuncs.append(funcname) | 154 | anonfuncs.append(funcname) |
156 | data.setVar('__BBANONFUNCS', anonfuncs) | 155 | data.setVar('__BBANONFUNCS', anonfuncs) |
@@ -171,8 +170,7 @@ class PythonMethodNode(AstNode): | |||
171 | # 'this' file. This means we will not parse methods from | 170 | # 'this' file. This means we will not parse methods from |
172 | # bb classes twice | 171 | # bb classes twice |
173 | text = '\n'.join(self.body) | 172 | text = '\n'.join(self.body) |
174 | if not bb.methodpool.parsed_module(self.modulename): | 173 | bb.methodpool.insert_method(self.modulename, text, self.filename) |
175 | bb.methodpool.insert_method(self.modulename, text, self.filename) | ||
176 | data.setVarFlag(self.function, "func", 1) | 174 | data.setVarFlag(self.function, "func", 1) |
177 | data.setVarFlag(self.function, "python", 1) | 175 | data.setVarFlag(self.function, "python", 1) |
178 | data.setVar(self.function, text) | 176 | data.setVar(self.function, text) |
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 87a1530cb5..01f22d3b24 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -167,10 +167,6 @@ def handle(fn, d, include): | |||
167 | if oldfile: | 167 | if oldfile: |
168 | d.setVar("FILE", oldfile) | 168 | d.setVar("FILE", oldfile) |
169 | 169 | ||
170 | # we have parsed the bb class now | ||
171 | if ext == ".bbclass" or ext == ".inc": | ||
172 | bb.methodpool.set_parsed_module(base_name) | ||
173 | |||
174 | return d | 170 | return d |
175 | 171 | ||
176 | def feeder(lineno, s, fn, root, statements): | 172 | def feeder(lineno, s, fn, root, statements): |