From 3bc7c61569f79c78616dfb9d39c95be4bb24b023 Mon Sep 17 00:00:00 2001 From: Brentley Jones Date: Mon, 19 Aug 2024 14:42:56 -0500 Subject: [PATCH] Filter environment variables when building with Bazel In order for Xcode builds to work with custom environment variables you need to use `xcodeproj.bazel_env`. This just takes the extra step of filtering out all other environment variables, ensuring more analysis cache hits. You can already do this in your own `tools/bazel`, but now people can get the benefit regardless. This change is needed for shared outputs bases to be performant. Signed-off-by: Brentley Jones --- xcodeproj/internal/templates/bazel_build.sh | 7 ++++++- xcodeproj/internal/templates/runner.sh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/xcodeproj/internal/templates/bazel_build.sh b/xcodeproj/internal/templates/bazel_build.sh index 6fc791abf0..3daf791792 100755 --- a/xcodeproj/internal/templates/bazel_build.sh +++ b/xcodeproj/internal/templates/bazel_build.sh @@ -69,7 +69,12 @@ fi readonly bazelrcs readonly bazel_cmd=( - env + env -i + "DEVELOPER_DIR=$DEVELOPER_DIR" + "HOME=$HOME" + "TERM=$TERM" + "TMPDIR=$TMPDIR" + "USER=$USER" %bazel_env% "%bazel_path%" diff --git a/xcodeproj/internal/templates/runner.sh b/xcodeproj/internal/templates/runner.sh index bee862b9d2..e2cd9234b9 100644 --- a/xcodeproj/internal/templates/runner.sh +++ b/xcodeproj/internal/templates/runner.sh @@ -179,7 +179,12 @@ common:rules_xcodeproj --repo_env=XCODE_VERSION=%xcode_version% EOF bazel_cmd=( - env + env -i + "DEVELOPER_DIR=$developer_dir" + "HOME=$HOME" + "TERM=$TERM" + "TMPDIR=$TMPDIR" + "USER=$USER" "${envs[@]}" "$bazel_path"