I am applying aspects but somehow seem to do something wrong. Imaging the famous reference picture.
In my case A is:
deps_aspect = aspect(
implementation = _deps_aspect_impl,
attr_aspects = ["resource_deps"],
attrs = {
},
)
For A(W), _deps_aspect_impl
returns:
return struct(
dep_files = set(),
)
Now, if I understood the documentation correctly, I should be able to access A(W) dep_files
via resource_deps
in A(Y).
If for A(Y), _deps_aspect_impl
I do:
print("DIR: %s" % dir(ctx.rule.attr))
There is no resource_deps
printed (and I cannot access it).
Am I understanding something wrong or how is this supposed to work?
So the problem was that I did not catch various nuances right.
attr_aspects
are recursive. Which means once you apply, they propagate downwards the graph. So the attributes are global for that one apply. Perhaps it would be better to be able to specify a dict with kind
-> attr
mapping.
Due to 1. you really need to have a look at kind
, so you have different code paths (the one thing I did right).
Data can NOT be propagated via the shadow graph. I imagined that before. You can only propagate on "solid" rule attrs
.