|
|
|
ComponentInfo = provider(fields = dict(foo = "", bar = "", baz = "")) |
|
|
|
foo = rule(implementation = lambda _: []) |
|
bar = rule(implementation = lambda _: []) |
|
baz = rule(implementation = lambda _: []) |
|
component = rule( |
|
implementation = lambda c: ComponentInfo( |
|
foo = c.attr.foo, bar = c.attr.bar, baz = c.attr.baz, |
|
), |
|
provides = [ComponentInfo], |
|
attrs = dict(foo = attr.label(), bar = attr.label(), baz = attr.label()), |
|
) |
|
|
|
project_component = macro( |
|
implementation = lambda name, visibility, **kw: [ |
|
foo(name = name + ".foo", visibility = visibility, **kw), |
|
bar(name = name + ".bar", visibility = visibility, **kw), |
|
baz(name = name + ".baz", visibility = visibility, **kw), |
|
component( |
|
name = name, visibility = visibility, |
|
foo = name + ".foo", |
|
bar = name + ".bar", |
|
baz = name + ".baz", |
|
), |
|
None |
|
][-1], |
|
) |
|
|
|
consumer1 = rule( |
|
implementation = lambda _: [], |
|
attrs = dict( |
|
component = attr.label(providers = [ComponentInfo]), |
|
_foo = attr.label(default = lambda component: Label(str(component) + [print(component, type(component)), ".foo"][1])), |
|
_bar = attr.label(default = lambda component: Label(str(component) + ".bar")), |
|
_baz = attr.label(default = lambda component: Label(str(component) + ".baz")), |
|
) |
|
) |
|
|
|
consumer2 = rule( |
|
implementation = lambda _: [], |
|
attrs = dict( |
|
component = attr.label(providers = [ComponentInfo]), |
|
_foo = attr.label(), |
|
_bar = attr.label(), |
|
_baz = attr.label(), |
|
), |
|
initializer = lambda component, **kw: dict( |
|
_foo = str(component) + [".foo", print(component, type(component))][0], |
|
_bar = str(component) + ".bar", |
|
_baz = str(component) + ".baz", |
|
) |
|
) |