Expressive target declarations in BUILD files #18067
kaos
started this conversation in
Development
Replies: 1 comment 1 reply
-
That seems very scary and a bit too magical for me. I could, however, see turning targets into a context manager: with python_sources(name="some_name") as some_name:
# Function calls in the target body provides field values.
# Set description and tags
some_name.description("foo bar")
some_name.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:
some_name.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.
some_name.tags(*self.tags, *t.tags) That would mean that object construction would be complete when |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This idea is a bit on the wild side, but I think it may have potential..
It serves two main purposes:
a) Flexibility in field values and meta field values
b) Target-lookups from within BUILD files.
So, here's a rough straw-man sketch of this idea:
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.
Beta Was this translation helpful? Give feedback.
All reactions