https://pantsbuild.org/ logo
#development
Title
# development
w

witty-crayon-22786

04/21/2022, 4:05 AM
this is probably bonkers, but: what if we supported a
TargetOption
option type which took either a target address string, or … literal BUILD file content which defined a target to use.
it would make it trivial to add “toolchain” target types which needed a built in default
because you could do something like:
Copy code
default = 'python_requirement(requirements=["mypy==0.782"])'
or
Copy code
default = 'jdk(id="adoptjdk:1.11", max_memory="12G")'
etc
cc @fast-nail-55400
from an implementation perspective, it should be fairly straightforward… the big thing to figure out would just be which address to use for the targets. maybe
//#something
(thinking about this because https://github.com/pantsbuild/pants/issues/13067 would suggest that default global memory settings and args should really be per-JDK, and using lots of maps for things isn’t scalable)
h

happy-kitchen-89482

04/21/2022, 5:34 AM
Not that bonkers!
There are a lot of uses for this. For one thing, it could be used in the places we currently ask for requirement strings (Python tools mostly), so you could have tools be built out of in-repo code.
h

hundreds-father-404

04/21/2022, 12:19 PM
What's the benefit of inlining? You could define it externally and reference it, right?
b

bitter-ability-32190

04/21/2022, 12:22 PM
@hundreds-father-404 I'm guessing from the python example this could benefit plugin authors. You can't really reference a target in the plugins repo but you can inline a synth target
1
w

witty-crayon-22786

04/21/2022, 4:34 PM
What’s the benefit of inlining? You could define it externally and reference it, right?
the primary benefit is the default values of “toolchain like” settings like the JDK, the resolve, etc… complex objects. you want a default to reduce the boilerplate involved in setting up a brand new repository
1
currently we define 3 or 4 options next to one another when a default is complex
or have maps in the case of multiple resolves
… in the light of day, it’s possible that what this should be instead is builtin hidden BUILD files of some sort (maybe as resources?) and TargetOption would just always reference an address. that might be more magical though, because options help would have to understand the address
h

hundreds-father-404

04/21/2022, 4:47 PM
I wonder if we could have a unique name space for target options?
w

witty-crayon-22786

04/21/2022, 4:48 PM
yea, we’d probably want to. because i can imagine one option wanting to refer to a default created by another option.
f

fast-nail-55400

04/21/2022, 5:39 PM
What is the benefit of this approach versus other approaches such as engine-provided targets (with engine-scoped addresses for them)?
Or proper toolchain selection support.
w

witty-crayon-22786

04/21/2022, 5:44 PM
What is the benefit of this approach versus other approaches such as engine-provided targets (with engine-scoped addresses for them)?
it is just a concrete design for that feature, basically. a benefit to this design is that it has useful help right out of the box.
Or proper toolchain selection support.
i’m not sure what that means: afaict, a toolchain is a collection of settings, the same as a target. and having it be configured as a target option allows for toggling it based on context.