From 8bef99d3c85f48ff409eaebb964b1c45b203bdcf Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 23 May 2013 10:47:10 +0100 Subject: 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 --- bitbake/lib/bb/methodpool.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'bitbake/lib/bb/methodpool.py') 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 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -""" - What is a method pool? - - BitBake has a global method scope where .bb, .inc and .bbclass - files can install methods. These methods are parsed from strings. - To avoid recompiling and executing these string we introduce - a method pool to do this task. - - This pool will be used to compile and execute the functions. It - will be smart enough to -""" - from bb.utils import better_compile, better_exec -from bb import error - -# A dict of function names we have seen -_parsed_fns = { } def insert_method(modulename, code, fn): """ @@ -44,28 +27,3 @@ def insert_method(modulename, code, fn): comp = better_compile(code, modulename, fn ) better_exec(comp, None, code, fn) - # now some instrumentation - code = comp.co_names - for name in code: - if name in ['None', 'False']: - continue - elif name in _parsed_fns and not _parsed_fns[name] == modulename: - 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])) - else: - _parsed_fns[name] = modulename - -# A dict of modules the parser has finished with -_parsed_methods = {} - -def parsed_module(modulename): - """ - Has module been parsed? - """ - return modulename in _parsed_methods - -def set_parsed_module(modulename): - """ - Set module as parsed - """ - _parsed_methods[modulename] = True - -- cgit v1.2.3-54-g00ecf