On 22/01/2020 16.50, Richard Purdie wrote:
> 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).
Yeah, I just tried changing it to
v1 = "VAR"
v2 = "IABLE"
d.getVar(v1 + v2)
and bitbake no longer knew about the dependency on VARIABLE :(
I can't be the first one to want to substitute bitbake variables in
various source files, without necessarily knowing upfront which
variables might appear.
So thinking out loud (and apologies if this is very silly): Would it be
possible to implement some auto-deps class that a recipe playing the
above game could inherit. Something like
AUTO_DEPS_TASKS = "configure"
python() {
for t in AUTO_DEPS_TASKS:
f = (tmpdir/cachedir/somewhere)/autodeps/pn/t.inc
if f does not exist:
make sure the recipe gets rebuilt
return
include f
}
python write_autodeps(d, t):
logic to write a "do_t[vardeps] += ..." line to f, called at the end
of t (preferably automatically, but manually if need be)
python expand_autodeps(d, s):
helper to be used within an autodeps task, recording any variable used
in the expansion of s
Rasmus
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#48086): https://lists.yoctoproject.org/g/yocto/message/48086
Mute This Topic: https://lists.yoctoproject.org/mt/69979676/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-