re: macros and targets
# development
w
re: macros and targets
twitter has approximately four or five target aliases/macros that used to be distinct target subclasses, but apparently have not been for a while
they all exist for two reasons, afaict: 1) to change the arguments or defaults for the target types 2) to store additional data in
tags
on the target
with regard to the v2 target API, i think that case (2) will be handled quite nicely by extensible fields
case (1) should continue to be macros, i think... basically just transforming args or defaults.
(...some cases of defaults could maybe be handled by extensible fields? but probably overkill)
cc @hundreds-father-404: ^
h
Ah, so
python3_library
is a macro that converts to
python_library
? Either way, we can very easily support it via extensible fields. It’s only a question of whether it’s less code for you to write a macro or to write a new target type :)
I guess what I’m more confused by is context_aware_factories and objects in BuildFileAlias? Are those within scope for the target API?
w
Ah, so
python3_library
is a macro that converts to
python_library
?
yes: just a macro that passes the
compatibility
argument.
👍 1
I guess what I’m more confused by is context_aware_factories and objects in BuildFileAlias? Are those within scope for the target API?
objects are literally just function or contructor calls... no need to change them (anytime) i don't think. context_aware_factories get a "parse_context" and can then create one or more objects using it. they do not need changes with regard to the Target API, but they will need changes when we change macros in https://github.com/pantsbuild/pants/issues/7022 (they are the canonical example of a macro).
👍 1
but #7022 is 100% independent from the target API, afaict. the target API should not allow for the kind of things that context_aware_object_factories need to.
💯 1
(multiple objects being created, in particular)
h
Cool, that makes me feel much better about the scope of the project. Thanks for clarifying that