Creating symbolic links to toolchains
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to set up a rule that will create a symbolic link inside the buck-out folder to a toolchain that is stored elsewhere. I have a package management system that will ensure that the contents inside the symlinked folder won't change. The rule has an attribute which is the toolchain version, and when the rule/script is run with a different version, it will adjust the symlink to the right target path.
```
def _install_toolchain_impl(ctx = "context"):
base_folder = ctx.actions.declare_output("out", dir = True)
toolchain_folder = base_folder.project(ctx.attrs.toolchain_name)
command = cmd_args(["install_toolchain.py",
"--toolchain", ctx.attrs.toolchain_name,
"--version", ctx.attrs.version,
"--destination", toolchain_folder.as_output(),
]
)
sub_targets = {}
for sub_target in ctx.attrs.sub_targets:
output = package_folder.project(sub_target)
command.hidden(output.as_output())
sub_targets[sub_target] = [DefaultInfo(default_outputs = [output])]
```
The result of the script is to have `out/toolchain_name` be a symlink to the target directory.
However, buck is strict about what it considers to be a directory.
If I use declare_output with dir = True, I get something like `Required outputs are missing: Action didn’t produce output of the right type. Expected buck-out/v2/gen/root/folder/toolchain_name to be Directoryreal File.`
If I use base_folder.project() (like in the example above) then I get an error like `Find would traverse a leaf at path: buck-out/v2/gen/root/folder/out/include`.
It makes sense that buck is trying to stop me from declaring an artifact that's nested below a regular file. Is there any way to convince it to allow this? I'm suspecting that the best thing to do would be to find the place where the "Action didn't produce output of the right type" error is returned and change it to allow symlinks to folders. Any other thoughts?
Contributor guide
Research direction
Start with the install_toolchain.py entry point and reproduce the directory-versus-symlink errors described in the issue. Trace the action output validation and base_folder.project() path handling; done means a generated toolchain directory symlink is accepted without allowing invalid nested artifact paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100