Repo-level aliasing
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the feature request:
I talked to @Wyverald and he said to file a bug here.
At the moment, in rust, it automatically defines the toolchain repos:
```
amd64_to_amd64
amd64_to_arm64
...
```
However, in order to build our host tools, we need to define `host_to_host`. At the moment, this is an exact copy of `amd64_to_amd64` on an amd64 machine, or `arm64_to_arm64` on an arm64 machine.
Because it changes, and because we still want to be able to access it via the original `amd64_to_amd64`, we cannot simply write:
```
use_repo(toolchains, host_to_host = "amd64_to_amd64")
```
In our module extension, I'd like to instead be able to write:
```
def module_extension(module_ctx):
for host in SUPPORTED_PLATFORMS:
for target in SUPPORTED_PLATFORMS:
define_toolchain_repo_rule(name = "{host}_to_{target}".format(host, target), host=host, target=target)
alias_repo(name = "host_to_host", actual = "{host}_to_{host}".format(get_host())
```
### Which category does this issue belong to?
External Dependency
### What underlying problem are you trying to solve with this feature?
Every rule inside the repo rule has to be executed twice, since it isn't a true alias of a repo.
### Which operating system are you running Bazel on?
Linux
### What is the output of `bazel info release`?
6.2.0
### 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 master; git rev-parse HEAD` ?
_No response_
### 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
Research direction
Start by reading the module extension example and the existing toolchain repository definitions described in the issue. Investigate how repository aliases are represented and used by use_repo; done means host_to_host can refer to the selected host-specific repository without executing the repository rule twice, while the original repository names remain available.
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