Add support for config selectors in dep addresses.
Review Request #3025 - Created Oct. 23, 2015 and submitted
|ity, patricklaw, stuhood|
This allows for modelling many variants of a target through a single target with many configurations. When the set of applicable configuratons for a dependee has more than one element, the required configuration can be specified by "sub-addressing" into a target's (named) configurations. This change adds an example of this: ``` ./pants run src/python/pants/engine/exp/examples:viz -- \ tests/python/pants_test/engine/exp/examples/scheduler_inputs \ compile \ src/java/codegen/selector:selected ``` As well as an example of what happens when more than one configuration applies (a failing example): ``` ./pants run src/python/pants/engine/exp/examples:viz -- \ tests/python/pants_test/engine/exp/examples/scheduler_inputs \ compile \ src/java/codegen/selector:conflict ... pants.engine.exp.scheduler.ConflictingProducersError: Collected the following plans for generating "Sources(u'.java')" from Target(address=src/thrift/codegen/selector) ApacheThriftPlanner ScroogePlanner FAILURE: /home/jsirois/dev/3rdparty/jsirois-pants3/build-support/pants_dev_deps.venv/bin/python2.7 pants.engine.exp.examples.visualizer:main tests/python/pants_test/engine/exp/examples/scheduler_inputs compile src/java/codegen/selector:conflict ... exited non-zero (1) ``` src/python/pants/engine/exp/BUILD | 1 + src/python/pants/engine/exp/addressable.py | 29 ++++++ src/python/pants/engine/exp/examples/planners.py | 246 +++++++++++++++++++++++++++++++++++++++----------- src/python/pants/engine/exp/examples/visualizer.py | 2 +- src/python/pants/engine/exp/graph.py | 5 +- src/python/pants/engine/exp/scheduler.py | 67 +++++++++++--- tests/python/pants_test/engine/exp/examples/scheduler_inputs/src/java/codegen/selector/BLD.json | 25 +++++ tests/python/pants_test/engine/exp/examples/scheduler_inputs/src/java/codegen/selector/Selector.java | 1 + tests/python/pants_test/engine/exp/examples/scheduler_inputs/src/thrift/BLD.json | 80 ++++++++++++++-- tests/python/pants_test/engine/exp/examples/scheduler_inputs/src/thrift/codegen/selector/BLD.json | 8 ++ tests/python/pants_test/engine/exp/examples/scheduler_inputs/src/thrift/codegen/selector/selector.thrift | 1 + tests/python/pants_test/engine/exp/test_engine.py | 4 +- tests/python/pants_test/engine/exp/test_scheduler.py | 8 +- 13 files changed, 396 insertions(+), 81 deletions(-)
Locally, ran the
yielded the attached plan graph.
CI went green here:
Review request changed
Oops, adding reviewers just before TBR'ing. Ity and Patrick - we whiteboarded this 2x IIRC, once in NY, once in SF. Stu - the idea is instead of a macro to expand 1 target to N, you have 1 target with N configs. If the configs are all unique for some definition of unique - no worries, a dependee will find the right one (IFF a planner is coded that way like the current thrift apache and scrooge planners are). If not, things blow up unless a configuratin is selected by a dependee via the @config-selector address suffix.