mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
bitbake: Add bb and os to __builtins__, not the exec function global
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
@@ -28,6 +28,13 @@
|
|||||||
from bb import data, event, mkdirhier, utils
|
from bb import data, event, mkdirhier, utils
|
||||||
import bb, os, sys
|
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
|
# events
|
||||||
class FuncFailed(Exception):
|
class FuncFailed(Exception):
|
||||||
"""
|
"""
|
||||||
@@ -205,8 +212,6 @@ def exec_func_python(func, d, runfile, logfile):
|
|||||||
f.write(tmp)
|
f.write(tmp)
|
||||||
comp = utils.better_compile(tmp, func, bbfile)
|
comp = utils.better_compile(tmp, func, bbfile)
|
||||||
g = {} # globals
|
g = {} # globals
|
||||||
g['bb'] = bb
|
|
||||||
g['os'] = os
|
|
||||||
g['d'] = d
|
g['d'] = d
|
||||||
try:
|
try:
|
||||||
utils.better_exec(comp, g, tmp, bbfile)
|
utils.better_exec(comp, g, tmp, bbfile)
|
||||||
|
|||||||
@@ -28,6 +28,13 @@
|
|||||||
from bb import data, fetch, event, mkdirhier, utils
|
from bb import data, fetch, event, mkdirhier, utils
|
||||||
import bb, os
|
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
|
# events
|
||||||
class FuncFailed(Exception):
|
class FuncFailed(Exception):
|
||||||
"""Executed function failed"""
|
"""Executed function failed"""
|
||||||
@@ -122,20 +129,15 @@ def exec_func(func, d, dirs = None):
|
|||||||
|
|
||||||
def exec_func_python(func, d):
|
def exec_func_python(func, d):
|
||||||
"""Execute a python BB 'function'"""
|
"""Execute a python BB 'function'"""
|
||||||
import re, os
|
import re
|
||||||
|
|
||||||
bbfile = bb.data.getVar('FILE', d, 1)
|
bbfile = bb.data.getVar('FILE', d, 1)
|
||||||
tmp = "def " + func + "():\n%s" % data.getVar(func, d)
|
tmp = "def " + func + "():\n%s" % data.getVar(func, d)
|
||||||
tmp += '\n' + func + '()'
|
tmp += '\n' + func + '()'
|
||||||
comp = utils.better_compile(tmp, func, bbfile)
|
comp = utils.better_compile(tmp, func, bbfile)
|
||||||
prevdir = os.getcwd()
|
|
||||||
g = {} # globals
|
g = {} # globals
|
||||||
g['bb'] = bb
|
|
||||||
g['os'] = os
|
|
||||||
g['d'] = d
|
g['d'] = d
|
||||||
utils.better_exec(comp, g, tmp, bbfile)
|
utils.better_exec(comp, g, tmp, bbfile)
|
||||||
if os.path.exists(prevdir):
|
|
||||||
os.chdir(prevdir)
|
|
||||||
|
|
||||||
def exec_func_shell(func, d, flags):
|
def exec_func_shell(func, d, flags):
|
||||||
"""Execute a shell BB 'function' Returns true if execution was successful.
|
"""Execute a shell BB 'function' Returns true if execution was successful.
|
||||||
|
|||||||
Reference in New Issue
Block a user