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.
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.
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.
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 nominalcrate_root
matching. The diff after this PR achieves the desired behavior.