summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake-dev/lib/bb/build.py9
-rw-r--r--bitbake/lib/bb/build.py14
2 files changed, 15 insertions, 8 deletions
diff --git a/bitbake-dev/lib/bb/build.py b/bitbake-dev/lib/bb/build.py
index 05b7d94d13..b37bcf63bc 100644
--- a/bitbake-dev/lib/bb/build.py
+++ b/bitbake-dev/lib/bb/build.py
@@ -28,6 +28,13 @@
28from bb import data, event, mkdirhier, utils 28from bb import data, event, mkdirhier, utils
29import bb, os, sys 29import bb, os, sys
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 """ 40 """
@@ -205,8 +212,6 @@ def exec_func_python(func, d, runfile, logfile):
205 f.write(tmp) 212 f.write(tmp)
206 comp = utils.better_compile(tmp, func, bbfile) 213 comp = utils.better_compile(tmp, func, bbfile)
207 g = {} # globals 214 g = {} # globals
208 g['bb'] = bb
209 g['os'] = os
210 g['d'] = d 215 g['d'] = d
211 try: 216 try:
212 utils.better_exec(comp, g, tmp, bbfile) 217 utils.better_exec(comp, g, tmp, bbfile)
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.