bazelbuild / bazelbuild/bazel

Allow alias to apply transitions

Open
#27,123 3 comments 1 reaction 0 assignees View on GitHub
P3 team-Configurability type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

Allow alias to apply config settings and/or transitions. e.g.
```
alias(
name = "foo",
config_settings = {
"//some:flag": "bla"
}
actual = ":actual"
)

# and/or
alias_transition = transition(...) # sets //some:flag=bla
my_alias = alias.custom(transition=alias_transition)

my_alias(
name = "foo",
actual = ":actual"
)
```

cc @fmeum

### Which category does this issue belong to?

_No response_

### What underlying problem are you trying to solve with this feature?

The underlying goal is to make it possible to transparently apply transitions to an arbitrary target. Aliases make replacing one target with another transparent (e.g. all providers are forwarded). A custom rule can apply transitions, but it can't forward all providers -- only ones it has been hard coded to forward.

The particular case I have in mind is: a language A target depends on a language B target. Language B doesn't care about the flags of language A, so it makes sense to reset language A flags to a fixed state to reduce the config variation. A custom rule can apply transitions, but this doesn't scale well -- language A has to have a different custom rule for each language it might depend on.

To date, I'm aware of the following prior art:
* rules_go has wrapper rules to reset go flags
* Within Google, there's a special rule to do similar. This case also comes up
* The cpu=any value in `@platforms` was motivated by similar (dependencies being agnostic as to CPU).
* In rules_python, I'm thinking to create something like what rules_go has

So it definitely feels like there's a common pattern here.

### Which operating system are you running Bazel on?

_No response_

### What is the output of `bazel info release`?

_No response_

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse HEAD` ?

```text

```

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

The issue names no files or tests; start by locating Bazel's existing alias and transition entry points and comparing them with the custom-rule behavior described. Review the cited rules_go and rules_python wrapper approaches. Done means defining and implementing a way for aliases to apply config settings or transitions while preserving transparent provider forwarding.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.