Skip to content

Commit 90a19fa

Browse files
authored
Support exec_compatible_with for Cargo build scripts (#3951)
Fixes: #3854
1 parent 8c66239 commit 90a19fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cargo/private/cargo_build_script_wrapper.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ def cargo_build_script(
150150
if "CARGO_CRATE_NAME" not in rustc_env:
151151
rustc_env["CARGO_CRATE_NAME"] = name_to_crate_name(name_to_pkg_name(name))
152152

153+
exec_compatible_with = kwargs.pop("exec_compatible_with", None)
154+
153155
script_kwargs = {}
154-
for arg in ("exec_compatible_with", "testonly"):
156+
for arg in ("testonly",):
155157
if arg in kwargs:
156158
script_kwargs[arg] = kwargs[arg]
157159

@@ -160,6 +162,12 @@ def cargo_build_script(
160162
if arg in kwargs:
161163
wrapper_kwargs[arg] = kwargs[arg]
162164

165+
# The script is always run in an `exec` configuration so whenever the
166+
# `cargo_build_script` is given an `exec_compatible_with`, for this target
167+
# it is translated to `target_compatible_with` to match the `cfg = "exec"`
168+
# consumption of the target.
169+
script_kwargs["target_compatible_with"] = exec_compatible_with
170+
163171
binary_tags = depset(
164172
(tags if tags else []) + ["manual"],
165173
).to_list()

0 commit comments

Comments
 (0)