Skip to content

Commit 47fca84

Browse files
committed
Added overrides
1 parent 9d3cd18 commit 47fca84

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

xcodeproj/internal/custom_toolchain.bzl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ def _custom_toolchain_impl(ctx):
44

55
default_toolchain_path = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain"
66
user_toolchain_path = "$(eval echo ~)/Library/Developer/Toolchains/{}.xctoolchain".format(ctx.attr.toolchain_name)
7+
built_toolchain_path = toolchain_dir.path
78

89
# Generate symlink creation commands dynamically, excluding plist files
910
symlink_script = """#!/bin/bash
@@ -12,26 +13,36 @@ set -e
1213
mkdir -p "{toolchain_dir}"
1314
1415
find "{default_toolchain}" -type f -o -type l | while read file; do
16+
base_name="$(basename "$file")"
1517
rel_path="${{file#"{default_toolchain}/"}}"
18+
19+
override_path="$(echo {overrides} | jq -r --arg key "$base_name" '.[$key] // empty')"
20+
if [[ -f "$override_path" ]]; then
21+
mkdir -p "{toolchain_dir}/$(dirname "$rel_path")"
22+
cp "$override_path" "{toolchain_dir}/$rel_path"
23+
continue
24+
fi
25+
1626
if [[ "$rel_path" != "ToolchainInfo.plist" ]]; then
1727
mkdir -p "{toolchain_dir}/$(dirname "$rel_path")"
1828
ln -s "$file" "{toolchain_dir}/$rel_path"
1929
fi
2030
done
2131
22-
mkdir -p "{toolchain_dir}"
2332
mv "{toolchain_plist}" "{toolchain_dir}/ToolchainInfo.plist"
2433
2534
# Remove existing symlink if present and create a new one in the user directory
2635
if [ -e "{user_toolchain_path}" ]; then
2736
rm -f "{user_toolchain_path}"
2837
fi
29-
ln -s "{toolchain_dir}" "{user_toolchain_path}"
38+
ln -s "{built_toolchain_path}" "{user_toolchain_path}"
3039
""".format(
3140
toolchain_dir=toolchain_dir.path,
3241
default_toolchain=default_toolchain_path,
42+
overrides=ctx.attr.overrides,
3343
toolchain_plist=toolchain_plist_file.path,
34-
user_toolchain_path=user_toolchain_path
44+
user_toolchain_path=user_toolchain_path,
45+
built_toolchain_path=built_toolchain_path
3546
)
3647

3748
script_file = ctx.actions.declare_file(ctx.attr.toolchain_name + "_setup.sh")
@@ -80,5 +91,7 @@ custom_toolchain = rule(
8091
implementation=_custom_toolchain_impl,
8192
attrs={
8293
"toolchain_name": attr.string(mandatory=True),
94+
"overrides": attr.string_dict(default={}),
8395
},
8496
)
97+

0 commit comments

Comments
 (0)