From 53b1de6dd912efe681a8686cc969d9cfbb3fc0d0 Mon Sep 17 00:00:00 2001 From: David Marcin Date: Fri, 19 Nov 2021 03:11:41 -0800 Subject: [PATCH] Make action_env work for rustc actions (#1022) Currently, action_env is not passed through to rustc actions, which means that variables like `DEVELOPER_DIR` needed in some cases on macOS cannot be passed through. This PR passes action_env through to rustc actions. Similar to existing code at https://github.com/bazelbuild/rules_rust/blob/e2f0fccda912daac686b533ad77c5bc5d2f2ddb7/cargo/cargo_build_script.bzl#L68 --- rust/private/rustc.bzl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index a53a089e3e..3a306b77ad 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -729,7 +729,7 @@ def rustc_compile_action( stamp = stamp, ) - args, env = construct_arguments( + args, env_from_args = construct_arguments( ctx = ctx, attr = attr, file = ctx.file, @@ -749,6 +749,9 @@ def rustc_compile_action( stamp = stamp, ) + env = dict(ctx.configuration.default_shell_env) + env.update(env_from_args) + if hasattr(attr, "version") and attr.version != "0.0.0": formatted_version = " v{}".format(attr.version) else: