From 44549775ebc01edbca7d934875a43a2d315bdd9b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Tue, 13 Oct 2009 08:25:34 +0100 Subject: bitbake: Add bb and os to __builtins__, not the exec function global Signed-off-by: Richard Purdie --- bitbake/lib/bb/build.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'bitbake/lib/bb') diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index e56f4bcf1..447aa4805 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -28,6 +28,13 @@ 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. -- cgit v1.2.3