How do target configuration constraints work?
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
I found this code from grepping the repository:
```
kwargs["link_style"] = select({
"DEFAULT": link_style,
"ovr_config//os:macos": "static",
})
```
How does parsing of this `"ovr_config//os:macos"` string work? That also looks a lot like one of those target patterns, but that clearly is not a target. And it's not the same thing as `@prelude//toolchains:cxx.bzl` either, because it doesn't have an `@` at the beginning, and doesn't refer to a file.
I grepped for `ovr_config` and found this:
```
[repository_aliases]
ovr_config = prelude
```
I guess it's coming from here. But the exact syntax isn't documented. And what is `os`? What other selectors are there that I could use besides `os`? It looks like this pattern might be a "target configuration constraint", which I figured out by looking at this piece of code from somewhere else:
```
def _tp2_constraint(project, version):
"""
Return the target configuration constraint to use for the given project
version
"""
return "ovr_config//third-party/{}/constraints:{}".format(project, version)
```
but if you type "constraint" into the search box of the documentation page you get nothing.
And how do these map to values from `.buckconfig`? Concrete example: Let's say I have this in my `.buckconfig`:
```
[foo]
bar = baz
```
How can I do the following two things:
1. Write a `select()` statement that passes `--compiler-flag-1` if `foo.bar == baz`, pass `--compiler-flag-2` if `foo.bar == buzz`, and generate a build failure if `foo.bar` is anything else?
2. Ignore `.buckconfig` for the purposes of obtaining a value of `foo.bar`, and have the user write `buck2 build `?
Contributor guide
Assessment
This issue has not been assessed yet.