Skip to content

Commit

Permalink
Filter environment variables when building with Bazel
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
brentleyjones committed Aug 19, 2024
1 parent d2d9bd3 commit 3bc7c61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion xcodeproj/internal/templates/bazel_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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%"

Expand Down
7 changes: 6 additions & 1 deletion xcodeproj/internal/templates/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 3bc7c61

Please sign in to comment.