summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/methodpool.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-23 10:47:10 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-05-24 10:34:52 +0100
commit8bef99d3c85f48ff409eaebb964b1c45b203bdcf (patch)
tree45663874832e85f9c80d6df9d521357a4e5dcb77 /bitbake/lib/bb/methodpool.py
parent3c5b9cf15f2034b704f571a75ad102cc57f9a3b6 (diff)
downloadpoky-8bef99d3c85f48ff409eaebb964b1c45b203bdcf.tar.gz
bitbake: methodpool: Retire it, remove global method scope
Having a global method scope confuses users and with the introduction of parallel parsing, its not even possible to correctly detect conflicting functions. Rather than try and fix that, its simpler to retire the global method scope and restrict functions to those locations they're defined within. This is more what users actually expect too. If we remove the global function scope, the need for methodpool is reduced to the point we may as well retire it. There is some small loss of caching of parsed functions but timing measurements so the impact to be neglibile in the overall parsing time. (Bitbake rev: 4d50690489ee8dc329a9b0c7bc4ceb29b71e95e9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/methodpool.py')
-rw-r--r--bitbake/lib/bb/methodpool.py42
1 files changed, 0 insertions, 42 deletions
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
33from bb.utils import better_compile, better_exec 20from bb.utils import better_compile, better_exec
34from bb import error
35
36# A dict of function names we have seen
37_parsed_fns = { }
38 21
39def insert_method(modulename, code, fn): 22def 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
60def parsed_module(modulename):
61 """
62 Has module been parsed?
63 """
64 return modulename in _parsed_methods
65
66def set_parsed_module(modulename):
67 """
68 Set module as parsed
69 """
70 _parsed_methods[modulename] = True
71