summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-10-13 08:25:34 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2009-10-13 08:38:13 +0100
commit44549775ebc01edbca7d934875a43a2d315bdd9b (patch)
treeb7ff54eed32b10f6b5caea78bd5952605a762e03 /bitbake/lib/bb/build.py
parent74016daa3a9131129974463452221e4a740bb860 (diff)
downloadpoky-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.py14
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 @@
28from bb import data, fetch, event, mkdirhier, utils 28from bb import data, fetch, event, mkdirhier, utils
29import bb, os 29import 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
32class FuncFailed(Exception): 39class FuncFailed(Exception):
33 """Executed function failed""" 40 """Executed function failed"""
@@ -122,20 +129,15 @@ def exec_func(func, d, dirs = None):
122 129
123def exec_func_python(func, d): 130def 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
140def exec_func_shell(func, d, flags): 142def 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.