On Wed, 2020-01-22 at 15:46 +0000, Rasmus Villemoes wrote:
> On 22/01/2020 15.35, Richard Purdie wrote:
> > Bitbake can only detect direct references to variables. The code
> > above only runs at configure time, not at parse time so its not
> > really surprising that bitbake can't know what its doing.
>
> Well, I thought that as well at first. But there must be something
> done at run-time to feed back the variable dependencies, because if I
> add a completely dumb
>
> python do_configure() {
> import fileinput
> + d.getVar("VARIABLE") # silly
> with open("foo.txt", "w") as out:
> for line in
> fileinput.input(files=d.getVar("FOO_INPUT").split()):
> line = d.expand(line)
> out.write(line)
> }
>
> build the recipe (because now it has of course changed), and then
> change VARIABLE, the recipe does get re-built. Or does bitbake
> specifically look for d.getVar(<literal>) when it parses a python
> function?
Bitbake has ASTs for all its python fragments and can search those for
getVar() calls. It will spot getVar("X") but can't know what is in
d.expand(line).
> > You'd need to read the data from this file at parse time for
> > bitbake to
> > stand some chance of seeing it, or manually set the variables it
> > depends upon using the vardeps flag.
> >
> > Something like:
> >
> > do_configure[vardeps] = "${@my_depends_function(d)}"
> >
> > where my_depends_function would return a list of variables it
> > references.
> >
> > Reading files like that at parse time doesn't work out well for
> > performance.
>
> Yeah, so I'd very much like to avoid that, and the above observation
> suggests that I might be able to do the expansion manually, just
> looking for the \$\{...\} regexp and calling getVar to find the
> replacement. But that seems like something that should be solved
> already.
Well, if you have the expansion, just put it in a variable the function
references...
Cheers,
Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#48085): https://lists.yoctoproject.org/g/yocto/message/48085
Mute This Topic: https://lists.yoctoproject.org/mt/69979676/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-