]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: Add bb and os to __builtins__, not the exec function global
authorRichard Purdie <rpurdie@linux.intel.com>
Tue, 13 Oct 2009 07:25:34 +0000 (08:25 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 13 Oct 2009 07:38:13 +0000 (08:38 +0100)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake-dev/lib/bb/build.py
bitbake/lib/bb/build.py

index 05b7d94d130d7d5e50c6731e899c47e6a14af8ac..b37bcf63bc42e13e82abfb81c709d0a58491873e 100644 (file)
 from bb import data, event, mkdirhier, utils
 import bb, os, sys
 
+# When we execute a python function we'd like certain things 
+# in all namespaces, hence we add them to __builtins__
+# If we do not do this and use the exec globals, they will
+# not be available to subfunctions.
+__builtins__['bb'] = bb
+__builtins__['os'] = os
+
 # events
 class FuncFailed(Exception):
     """
@@ -205,8 +212,6 @@ def exec_func_python(func, d, runfile, logfile):
     f.write(tmp)
     comp = utils.better_compile(tmp, func, bbfile)
     g = {} # globals
-    g['bb'] = bb
-    g['os'] = os
     g['d'] = d
     try:
         utils.better_exec(comp, g, tmp, bbfile)
index e56f4bcf167a1b0ef268d063d89dd1c10eb547e8..447aa4805847c4559117c07a8cd19b2e619bf4ec 100644 (file)
 from bb import data, fetch, event, mkdirhier, utils
 import bb, os
 
+# When we execute a python function we'd like certain things 
+# in all namespaces, hence we add them to __builtins__
+# If we do not do this and use the exec globals, they will
+# not be available to subfunctions.
+__builtins__['bb'] = bb
+__builtins__['os'] = os
+
 # events
 class FuncFailed(Exception):
     """Executed function failed"""
@@ -122,20 +129,15 @@ def exec_func(func, d, dirs = None):
 
 def exec_func_python(func, d):
     """Execute a python BB 'function'"""
-    import re, os
+    import re
 
     bbfile = bb.data.getVar('FILE', d, 1)
     tmp  = "def " + func + "():\n%s" % data.getVar(func, d)
     tmp += '\n' + func + '()'
     comp = utils.better_compile(tmp, func, bbfile)
-    prevdir = os.getcwd()
     g = {} # globals
-    g['bb'] = bb
-    g['os'] = os
     g['d'] = d
     utils.better_exec(comp, g, tmp, bbfile)
-    if os.path.exists(prevdir):
-        os.chdir(prevdir)
 
 def exec_func_shell(func, d, flags):
     """Execute a shell BB 'function' Returns true if execution was successful.