diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-10-13 08:25:34 +0100 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-10-13 08:38:13 +0100 |
commit | 44549775ebc01edbca7d934875a43a2d315bdd9b (patch) | |
tree | b7ff54eed32b10f6b5caea78bd5952605a762e03 /bitbake/lib/bb/build.py | |
parent | 74016daa3a9131129974463452221e4a740bb860 (diff) | |
download | poky-44549775ebc01edbca7d934875a43a2d315bdd9b.tar.gz |
bitbake: Add bb and os to __builtins__, not the exec function global
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r-- | bitbake/lib/bb/build.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index e56f4bcf16..447aa48058 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -28,6 +28,13 @@ | |||
28 | from bb import data, fetch, event, mkdirhier, utils | 28 | from bb import data, fetch, event, mkdirhier, utils |
29 | import bb, os | 29 | import bb, os |
30 | 30 | ||
31 | # When we execute a python function we'd like certain things | ||
32 | # in all namespaces, hence we add them to __builtins__ | ||
33 | # If we do not do this and use the exec globals, they will | ||
34 | # not be available to subfunctions. | ||
35 | __builtins__['bb'] = bb | ||
36 | __builtins__['os'] = os | ||
37 | |||
31 | # events | 38 | # events |
32 | class FuncFailed(Exception): | 39 | class FuncFailed(Exception): |
33 | """Executed function failed""" | 40 | """Executed function failed""" |
@@ -122,20 +129,15 @@ def exec_func(func, d, dirs = None): | |||
122 | 129 | ||
123 | def exec_func_python(func, d): | 130 | def exec_func_python(func, d): |
124 | """Execute a python BB 'function'""" | 131 | """Execute a python BB 'function'""" |
125 | import re, os | 132 | import re |
126 | 133 | ||
127 | bbfile = bb.data.getVar('FILE', d, 1) | 134 | bbfile = bb.data.getVar('FILE', d, 1) |
128 | tmp = "def " + func + "():\n%s" % data.getVar(func, d) | 135 | tmp = "def " + func + "():\n%s" % data.getVar(func, d) |
129 | tmp += '\n' + func + '()' | 136 | tmp += '\n' + func + '()' |
130 | comp = utils.better_compile(tmp, func, bbfile) | 137 | comp = utils.better_compile(tmp, func, bbfile) |
131 | prevdir = os.getcwd() | ||
132 | g = {} # globals | 138 | g = {} # globals |
133 | g['bb'] = bb | ||
134 | g['os'] = os | ||
135 | g['d'] = d | 139 | g['d'] = d |
136 | utils.better_exec(comp, g, tmp, bbfile) | 140 | utils.better_exec(comp, g, tmp, bbfile) |
137 | if os.path.exists(prevdir): | ||
138 | os.chdir(prevdir) | ||
139 | 141 | ||
140 | def exec_func_shell(func, d, flags): | 142 | def exec_func_shell(func, d, flags): |
141 | """Execute a shell BB 'function' Returns true if execution was successful. | 143 | """Execute a shell BB 'function' Returns true if execution was successful. |