commit | 73b159426e7c8bea1051638c8def482865a66025 | [log] [tgz] |
---|---|---|
author | UebelAndre <github@uebelandre.com> | Tue Sep 03 03:36:40 2024 -0700 |
committer | GitHub <noreply@github.com> | Tue Sep 03 10:36:40 2024 +0000 |
tree | 51cda27db643ecf706842073bff43aa0ae451f12 | |
parent | ef8ac18bb44f8b480b7f50b6c031504a94785f2e [diff] |
Use `crate_name` to also match `crate_root`. (#2824) This allows targets to have special names that do not match their sources while still ensuring a root is found. I've encountered this when creating macros where I have a Rust target that is a side-effect and not the named target itself. E.g. ```starlark load("@rules_rust//rust:defs.bzl", "rust_binary") load("//control/private:control.bzl", _control_binary = "control_binary") def control_binary( name, # ... **kwargs): rust_binary( name = name + "_bin", # ... **kwargs ) _control_binary( name = name, bin = name + "_bin", # ... **kwargs ) ``` Being able to specify `crate_name` will both ensure the binary is compiled with a cleaner name for the runtime and be able to do the nominal `crate_root` matching. The diff after this PR achieves the desired behavior. ```diff --- before/defs.bzl 2024-08-31 12:41:24 +++ after/defs.bzl 2024-08-31 12:42:09 @@ -8,6 +8,7 @@ rust_binary( name = name + "_bin", + crate_name = name, # ... **kwargs ) ```
This repository provides rules for building Rust projects with Bazel.
General discussions and announcements take place in the GitHub Discussions, but there are additional places where community members gather to discuss rules_rust
.
Please refer to the full documentation.