'How does Yocto decide whether a specific task needs to be re-run
I got a bb file whose do_install() task calls external source code generator to generate C++ sources from XML files, the generated C++ files would be needed by other bb modules.
It would be necessary to automatically redo the generation task if any of the xml files get changed, but I don't know how to do it.
I know it could be done by put it to cmake by add_customer_command/target() which automatically do the regeneration if the depended source file get changed. But How it could be done in bb file directly?
Thanks~
Solution 1:[1]
You may use something like the following, like I did on the python3 recipe (modified for simplicity):
python(){
filename = os.path.join(d.getVar('THISDIR'), 'files', 'your-file.xml')
# This python() changes the datastore based on the contents of a file, so mark
# that dependency.
bb.parse.mark_dependency(d, filename)
}
https://git.yoctoproject.org/poky/tree/meta/recipes-devtools/python/python3_3.10.1.bb#n249
That would force bitbake to reparse is the file changed.
I'm sure you could also play around with the 'vardeps' varflag to the task although that works only to set a task dependency to variables, if those variables change then it needs to be re-run. https://docs.yoctoproject.org/bitbake/bitbake-user-manual/bitbake-user-manual-metadata.html#variable-flags
The simplest way however would likely be to add your xml files to the SRC_URI variable, the do_fetch task has an internal mechanism somewhat like whats explained above, calculating the checksum of all files within the SRC_URI variable and if those change the task is re-run.
So simply adding them to SRC_URI would cause do_fetch to be re-run, and since do_install depends on do_fetch, it would be re-run too, the pros of this is you dont have to come up with your custom solution, the downside is that do_unpack, do_configure and do_compile would be re-run too, not just do_install.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
