Skip to content

Commit a2e2695

Browse files
committed
[feat] Add a build setting to announce crate scope
This build setting is not used internally, but provides a way for dependencies to be aware that they are being compiled for a rust crate. Examples of complex scenarios allowed by this change: 1. Build with a mac-x86_64 toolchain on mac-aarch64 platforms (rosetta) - everything (including host tools) is compiled for aarch64 while proc_macros must be compiled for x86_64. 2. A `cc_library` linked to both a `cc_binary` and a `rust_binary`, but needs slightly different build flags when used for rust crates.
1 parent 3902162 commit a2e2695

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

rust/private/rust.bzl

+3-3
Original file line numberDiff line numberDiff line change
@@ -750,13 +750,13 @@ _common_attrs = {
750750
doc = "A version to inject in the cargo environment variable.",
751751
default = "0.0.0",
752752
),
753+
"_allowlist_function_transition": attr.label(
754+
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
755+
),
753756
"_stamp_flag": attr.label(
754757
doc = "A setting used to determine whether or not the `--stamp` flag is enabled",
755758
default = Label("//rust/private:stamp"),
756759
),
757-
"_allowlist_function_transition": attr.label(
758-
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
759-
),
760760
} | RUSTC_ATTRS
761761

762762
_coverage_attrs = {

test/crate_scope/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ rust_library(
4646
srcs = ["proc_macro_helper.rs"],
4747
data = select({
4848
"//rust/settings:proc_macro_scope": [":helper_data"],
49-
# Analysis fails if rust_library doesn't propagate the condition above.
49+
"//rust/settings:regular_crate_scope": [],
5050
}),
5151
edition = "2021",
5252
rustc_env = {"CARGO_MANIFEST_DIR": package_name()},

0 commit comments

Comments
 (0)