I'm looking at run.
files for a recipe under Yocto 2.2. Some of the Python ones have the following structure:
def do_whatever(d):
# [...]
bb.build.exec_func("sub_function_foo", d)
bb.build.exec_func("sub_function_bar", d)
do_whatever(d)
def sub_function_foo(d):
[...]
def sub_function_bar(d):
[...]
The executed functions seem to be forward-referenced. If this is run like normal Python, then at the time do_whatever
is executed, the sub_function_foo
and sub_function_bar
are not yet defined.
How is this supposed to work?
Is the bitbake exec_func
mechanism just queuing jobs to be run later, which happens after this file is processed?
Or else, is this processed by a custom loader rather than Python, which puts definitions before top-level calls? (If so, why do that rather than simply generate the code in the proper order in the first place and hand it off to Python?)
The python run files themselves are debug output generated by bitbake with the function contents contained within them, they are not actually executed. So you can use them for debugging but they're not executable in their current form. This is something I've thought about fixing but its not been a priority right now. It would also mean dumping a static copy of the datastore into the file to construct objects like 'd'.
Just for reference, the shell script run files are actually executed.