1 # ex:ts=4:sw=4:sts=4:et
2 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
5 # Copyright (C) 2006 Holger Hans Peter Freyther
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
11 # Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
14 # Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # Neither the name Holger Hans Peter Freyther nor the names of its
19 # contributors may be used to endorse or promote products derived
20 # from this software without specific prior written permission.
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 # POSSIBILITY OF SUCH DAMAGE.
37 What is a method pool?
39 BitBake has a global method scope where .bb, .inc and .bbclass
40 files can install methods. These methods are parsed from strings.
41 To avoid recompiling and executing these string we introduce
42 a method pool to do this task.
44 This pool will be used to compile and execute the functions. It
45 will be smart enough to
48 from bb.utils import better_compile, better_exec
50 # A dict of modules we have handled
51 # it is the number of .bbclasses + x in size
54 def insert_method(modulename, code, fn):
56 Add code of a module should be added. The methods
57 will be simply added, no checking will be done
59 comp = better_compile(code, "<bb>", fn )
60 better_exec(comp, __builtins__, code, fn)
62 def check_insert_method(modulename, code, fn):
64 Add the code if it wasnt added before. The module
65 name will be used for that
67 if not modulename in _parsed_methods:
68 return insert_method(modulename, code)
70 def parsed_module(modulename):
72 Inform me file xyz was parsed
74 return modulename in _parsed_methods
77 def get_parsed_dict():
81 return _parsed_methods