Skip to content

Commit 905287e

Browse files
committed
Inegrate rsync from BCR
1 parent 79f26ec commit 905287e

File tree

6 files changed

+42
-21
lines changed

6 files changed

+42
-21
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ bazel_dep(
1919
repo_name = "build_bazel_rules_apple",
2020
)
2121
bazel_dep(name = "rules_python", version = "0.27.1")
22+
bazel_dep(name = "rsync", version = "3.4.1")
2223

2324
internal = use_extension("//xcodeproj:extensions.bzl", "internal")
2425
use_repo(internal, "rules_xcodeproj_generated")

xcodeproj/internal/bazel_integration_files/BUILD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ filegroup(
1010
name = "bazel_integration_files",
1111
srcs = _BASE_FILES + [
1212
":renamed_swiftc_stub",
13+
":renamed_rsync",
1314
":rsync_excludes",
1415
] + glob(
1516
["**/*"],
@@ -125,6 +126,26 @@ fi
125126
],
126127
)
127128

129+
genrule(
130+
name = "renamed_rsync",
131+
srcs = ["@rsync//:rsync"],
132+
outs = ["rsync"],
133+
# Make `rsync` have the right name
134+
cmd = """\
135+
readonly output="$@"
136+
if [[ $$(stat -f '%d' "$<") == $$(stat -f '%d' "$${output%/*}") ]]; then
137+
cp -c "$<" "$@"
138+
else
139+
cp "$<" "$@"
140+
fi
141+
""",
142+
message = "Renaming rsync",
143+
tags = [
144+
"manual",
145+
"no-sandbox",
146+
],
147+
)
148+
128149
# Release
129150

130151
filegroup(

xcodeproj/internal/bazel_integration_files/copy_dsyms.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@ function patch_dsym() {
4646
EOF
4747
}
4848

49+
readonly rsync="$BAZEL_INTEGRATION_DIR/rsync"
50+
4951
if [[ -n "${BAZEL_OUTPUTS_DSYM:-}" ]]; then
5052
cd "${BAZEL_OUT%/*}"
5153

52-
# NOTE: use `which` to find the path to `rsync`.
53-
# In macOS 15.4, the system `rsync` is using `openrsync` which contains some permission issues.
54-
# This allows users to workaround the issue by overriding the system `rsync` with a working version.
55-
# Remove this once we no longer support macOS versions with broken `rsync`.
5654
# shellcheck disable=SC2046
57-
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" \
58-
rsync \
55+
"$rsync" \
5956
--copy-links \
6057
--recursive \
6158
--times \

xcodeproj/internal/bazel_integration_files/copy_outputs.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ readonly test_frameworks=(
2121
"XCUnit.framework"
2222
)
2323

24+
readonly rsync="$BAZEL_INTEGRATION_DIR/rsync"
25+
2426
if [[ "$ACTION" != indexbuild ]]; then
2527
# Copy product
2628
if [[ -n ${BAZEL_OUTPUTS_PRODUCT:-} ]]; then
@@ -32,12 +34,7 @@ if [[ "$ACTION" != indexbuild ]]; then
3234
ln -sfh "$PWD/$BAZEL_OUTPUTS_PRODUCT_BASENAME" "$TARGET_BUILD_DIR/$PRODUCT_NAME"
3335
else
3436
# Product is a bundle
35-
# NOTE: use `which` to find the path to `rsync`.
36-
# In macOS 15.4, the system `rsync` is using `openrsync` which contains some permission issues.
37-
# This allows users to workaround the issue by overriding the system `rsync` with a working version.
38-
# Remove this once we no longer support macOS versions with broken `rsync`.
39-
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" \
40-
rsync \
37+
"$rsync" \
4138
--copy-links \
4239
--recursive \
4340
--times \

xcodeproj/internal/templates/installer.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ readonly src_project_pbxproj="$PWD/%project_pbxproj%"
6666
readonly src_xcschememanagement="$PWD/%xcschememanagement%"
6767
readonly src_xcschemes="$PWD/%xcschemes%/"
6868
readonly src_xcworkspacedata="$PWD/%contents_xcworkspacedata%"
69+
readonly src_rsync="$PWD/%rsync%"
6970

7071
# Resolve the destination
7172
[[ -z "${dest:-}" ]] \
@@ -82,13 +83,7 @@ readonly dest_xcschemes="$dest/xcshareddata/xcschemes"
8283

8384
mkdir -p "$dest_xcschemes"
8485

85-
# NOTE: use `which` to find the path to `rsync`.
86-
# In macOS 15.4, the system `rsync` is using `openrsync` which contains some permission issues.
87-
# This allows users to workaround the issue by overriding the system `rsync` with a working version.
88-
# Remove this once we no longer support macOS versions with broken `rsync`.
89-
# shellcheck disable=SC2046
90-
PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" \
91-
rsync \
86+
"$src_rsync" \
9287
--archive \
9388
--perms \
9489
--chmod=u+w,F-x \
@@ -124,6 +119,7 @@ mkdir -p "$dest/rules_xcodeproj/bazel"
124119
rm -rf "$dest/rules_xcodeproj/bazel"/*
125120
$cp_cmd "${bazel_integration_files[@]}" "$dest/rules_xcodeproj/bazel"
126121
$cp_cmd "$xcodeproj_bazelrc" "$dest/rules_xcodeproj/bazel/xcodeproj.bazelrc"
122+
chmod u+rx "$dest/rules_xcodeproj/bazel/rsync"
127123

128124
if [[ -s "${extra_flags_bazelrc:-}" ]]; then
129125
$cp_cmd "$extra_flags_bazelrc" "$dest/rules_xcodeproj/bazel/xcodeproj_extra_flags.bazelrc"
@@ -141,10 +137,10 @@ chmod u+w "$dest_generated_xcfilelist"
141137

142138
# - Keep only scripts as runnable
143139
find "$dest/rules_xcodeproj/bazel" \
144-
-type f \( -name "*.sh" -o -name "*.py" -o -name "ld" -o -name "libtool" \) \
140+
-type f \( -name "*.sh" -o -name "*.py" -o -name "ld" -o -name "libtool" -o -name "rsync" \) \
145141
-print0 | xargs -0 chmod u+x
146142
find "$dest/rules_xcodeproj/bazel" \
147-
-type f ! \( -name "swiftc" -o -name "ld" -o -name "libtool" -o -name "import_indexstores" -o -name "*.sh" -o -name "*.py" \) \
143+
-type f ! \( -name "swiftc" -o -name "ld" -o -name "libtool" -o -name "import_indexstores" -o -name "rsync" -o -name "*.sh" -o -name "*.py" \) \
148144
-print0 | xargs -0 chmod -x
149145

150146
# Copy over `project.xcworkspace/contents.xcworkspacedata` if needed

xcodeproj/internal/xcodeproj_rule.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ def _write_installer(
283283
template,
284284
xcschememanagement,
285285
xcschemes):
286+
rsync_file = None
287+
for f in bazel_integration_files:
288+
if f.basename == "rsync":
289+
rsync_file = f
290+
break
291+
if rsync_file == None:
292+
fail("Failed to find rsync in bazel integration files")
293+
286294
installer = actions.declare_file(
287295
"{}-installer.sh".format(name),
288296
)
@@ -303,6 +311,7 @@ def _write_installer(
303311
"%generated_xcfilelist%": generated_xcfilelist.short_path,
304312
"%output_path%": install_path,
305313
"%project_pbxproj%": project_pbxproj.short_path,
314+
"%rsync%": rsync_file.short_path,
306315
"%xcschememanagement%": xcschememanagement.short_path,
307316
"%xcschemes%": xcschemes.short_path,
308317
},

0 commit comments

Comments
 (0)