diff --git a/xcodeproj/internal/templates/bazel_build.sh b/xcodeproj/internal/templates/bazel_build.sh index 6fc791abf0..3b1d062b5e 100755 --- a/xcodeproj/internal/templates/bazel_build.sh +++ b/xcodeproj/internal/templates/bazel_build.sh @@ -68,8 +68,23 @@ if [[ -s "$BAZEL_INTEGRATION_DIR/xcodeproj_extra_flags.bazelrc" ]]; then fi readonly bazelrcs +readonly allowed_vars=( + "BUILD_WORKSPACE_DIRECTORY" + "DEVELOPER_DIR" + "HOME" + "TERM" + "USER" +) +passthrough_env=() +for var in "${allowed_vars[@]}"; do + if [[ -n "${!var:-}" ]]; then + passthrough_env+=("$var=${!var}") + fi +done + readonly bazel_cmd=( - env + env -i + "${passthrough_env[@]}" %bazel_env% "%bazel_path%" diff --git a/xcodeproj/internal/templates/runner.sh b/xcodeproj/internal/templates/runner.sh index d5227aa19d..8f79e0d3ef 100644 --- a/xcodeproj/internal/templates/runner.sh +++ b/xcodeproj/internal/templates/runner.sh @@ -178,8 +178,23 @@ common:rules_xcodeproj --repo_env=USE_CLANG_CL=%xcode_version% common:rules_xcodeproj --repo_env=XCODE_VERSION=%xcode_version% EOF +readonly allowed_vars=( + "BUILD_WORKSPACE_DIRECTORY" + "HOME" + "TERM" + "USER" +) +passthrough_env=() +for var in "${allowed_vars[@]}"; do + if [[ -n "${!var:-}" ]]; then + passthrough_env+=("$var=${!var}") + fi +done + bazel_cmd=( - env + env -i + "DEVELOPER_DIR=$developer_dir" + "${passthrough_env[@]}" "${envs[@]}" "$bazel_path"