Skip to content

Commit ec3303c

Browse files
committed
Only remove Metal toolchains from the list but keep the rest
1 parent 03ba4c1 commit ec3303c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

xcodeproj/internal/templates/bazel_build.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,23 @@ readonly base_pre_config_flags=(
9797
# Custom Swift toolchains
9898

9999
if [[ -n "${TOOLCHAINS-}" ]]; then
100-
toolchain="${TOOLCHAINS%% *}"
101-
if [[ "$toolchain" == "com.apple.dt.toolchain.XcodeDefault" ]]; then
102-
unset toolchain
100+
# We remove all Metal toolchains from the list first
101+
toolchains_array=($TOOLCHAINS)
102+
filtered_toolchains=()
103+
for tc in "${toolchains_array[@]}"; do
104+
if [[ "$tc" != *"com.apple.dt.toolchain.Metal"* ]]; then
105+
filtered_toolchains+=("$tc")
106+
fi
107+
done
108+
109+
if [[ ${#filtered_toolchains[@]} -gt 0 ]]; then
110+
toolchain="${filtered_toolchains[0]}"
111+
if [[ "$toolchain" == "com.apple.dt.toolchain.XcodeDefault" ]]; then
112+
unset toolchain
113+
fi
103114
fi
104115
fi
105116

106-
# We unset Metal toolchains since Xcode 26+ complains when that's passed as action_env
107-
# Older Xcode versions don't seem to populate this variable with Metal toolchain
108-
# This is why there is no version check
109-
if [[ "${toolchain:-}" == *"com.apple.dt.toolchain.Metal"* ]]; then
110-
unset toolchain
111-
fi
112-
113117
# Build
114118

115119
echo "Starting Bazel build"

0 commit comments

Comments
 (0)