Skip to content

Commit 93e2f56

Browse files
author
Karim Alweheshy
committed
fix copying the overrides correctly
1 parent 854e37e commit 93e2f56

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

xcodeproj/internal/templates/custom_toolchain_override.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ for tool_name in $(cat "$TOOL_NAMES_FILE"); do
3030
continue
3131
fi
3232

33-
find "$DEFAULT_TOOLCHAIN" -name "$tool_name" | while read -r default_tool_path; do
33+
find "$DEFAULT_TOOLCHAIN/usr/bin" -name "$tool_name" | while read -r default_tool_path; do
3434
rel_path="${default_tool_path#"$DEFAULT_TOOLCHAIN/"}"
3535
target_file="$FINAL_TOOLCHAIN_DIR/$rel_path"
3636

xcodeproj/internal/templates/custom_toolchain_symlink.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ TOOLCHAIN_NAME_BASE="%toolchain_name_base%"
66
TOOLCHAIN_DIR="%toolchain_dir%"
77
XCODE_VERSION="%xcode_version%"
88

9-
# Store the list of tools that will be overridden
10-
TOOL_NAMES_FILE=$(mktemp)
11-
echo "%tool_names_list%" > "$TOOL_NAMES_FILE"
12-
139
# Get Xcode version and default toolchain path
1410
DEFAULT_TOOLCHAIN=$(xcrun --find clang | sed 's|/usr/bin/clang$||')
1511
XCODE_RAW_VERSION=$(xcodebuild -version | head -n 1)
1612

17-
# Define toolchain names for reference only
13+
TOOL_NAMES_FILE=$(mktemp)
14+
echo "%tool_names_list%" > "$TOOL_NAMES_FILE"
15+
1816
HOME_TOOLCHAIN_NAME="BazelRulesXcodeProj${XCODE_VERSION}"
17+
USER_TOOLCHAIN_PATH="/Users/$(id -un)/Library/Developer/Toolchains/${HOME_TOOLCHAIN_NAME}.xctoolchain"
18+
BUILT_TOOLCHAIN_PATH="$PWD/$TOOLCHAIN_DIR"
1919

2020
mkdir -p "$TOOLCHAIN_DIR"
2121

@@ -34,7 +34,6 @@ find "$DEFAULT_TOOLCHAIN" -type f -o -type l | while read -r file; do
3434
for tool_name in $(cat "$TOOL_NAMES_FILE"); do
3535
if [[ "$base_name" == "$tool_name" ]]; then
3636
# Skip creating a symlink for overridden tools
37-
echo "Skipping symlink for tool to be overridden: $base_name"
3837
should_skip=1
3938
break
4039
fi
@@ -79,5 +78,8 @@ cat > "$TOOLCHAIN_DIR/ToolchainInfo.plist" << EOF
7978
</plist>
8079
EOF
8180

82-
# Clean up
83-
rm -f "$TOOL_NAMES_FILE"
81+
mkdir -p "$(dirname "$USER_TOOLCHAIN_PATH")"
82+
if [[ -e "$USER_TOOLCHAIN_PATH" || -L "$USER_TOOLCHAIN_PATH" ]]; then
83+
rm -rf "$USER_TOOLCHAIN_PATH"
84+
fi
85+
ln -sf "$BUILT_TOOLCHAIN_PATH" "$USER_TOOLCHAIN_PATH"

0 commit comments

Comments
 (0)