quaint-telephone-89068
01/23/2023, 8:08 PM# some/BUILD
@python_sources
def some_name():
# Function calls in the target body provides field values.
# Set description and tags
description("foo bar")
tags("this", "and", "that")
# Optional dependencies based on if `src/foo:bar` is tagged with `foo`
# The `target[ADDR]` syntax requests a single target with ADDR
if "foo" in target["src/foo:bar"].tags:
dependencies("quux", "qorgi")
# Append additional tags from all targets in `src/proj/lib::`
# The `targets[SPEC]` syntax requests all targets for the `SPEC`.
for t in targets["src/proj/lib::"]:
# `self` allows access to the field values currently being defined in this target body.
tags(*self.tags, *t.tags)
The idea being that this syntax would be fully compatible with the regular syntax, and only used for cases where the extra flexibility is needed.
Also, this is just sci-fi day-dreaming on my part--not something that I'm actually in need of today.
Declaring the field values as function calls, allows attaching additional information to the field values in a natural way. Also the arguments to the method itself may be used for oob pragma style information/control what-not.
@target
def example(pragma="declaration"):
field(value, meta=data, additional=info)
pantsbuild/pants