diff options
author | Chris Larson <clarson@kergoth.com> | 2004-03-15 20:16:57 +0000 |
---|---|---|
committer | Chris Larson <clarson@kergoth.com> | 2004-03-15 20:16:57 +0000 |
commit | 9d51add583a39dd3ae60adef0ae6f43dab3d29fa (patch) | |
tree | 036b9fa5e2a8ebbce54074c033a7b3e69b525e79 /bin/oe/build.py | |
parent | fb1288ba5727674c74597514b8e4906fe1117cf5 (diff) | |
download | bitbake-contrib-9d51add583a39dd3ae60adef0ae6f43dab3d29fa.tar.gz |
Update the way we execute python functions, so on failure we actually see what function and line number the failure occurred at. Also put said execution into its own scope to prevent namespace pollution.
Diffstat (limited to 'bin/oe/build.py')
-rw-r--r-- | bin/oe/build.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bin/oe/build.py b/bin/oe/build.py index 53073afee..fa4370c02 100644 --- a/bin/oe/build.py +++ b/bin/oe/build.py @@ -119,15 +119,20 @@ def tmpFunction(d): def exec_func_python(func, d): """Execute a python OE 'function'""" + import re, os + body = data.getVar(func, d) if not body: return - tmp = "def tmpFunction(d):\n%s" % body - comp = compile(tmp, "tmpFunction(d)", "exec") + tmp = "def " + func + "():\n%s" % body + comp = compile(tmp + '\n' + func + '()', oe.data.getVar('FILE', d, 1) + ':' + func, "exec") prevdir = os.getcwd() - exec(comp) + g = {} # globals + g['oe'] = oe + g['os'] = os + g['d'] = d + exec comp in g os.chdir(prevdir) - tmpFunction(d) def exec_func_shell(func, d): """Execute a shell OE 'function' Returns true if execution was successful. |