Skip to content

Commit 69a75c9

Browse files
committed
Integrate Samba rsync
Signed-off-by: Adin Cebic <cebic.ad@gmail.com>
1 parent 79f26ec commit 69a75c9

File tree

6 files changed

+46
-21
lines changed

6 files changed

+46
-21
lines changed

MODULE.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ bazel_dep(
4343
version = "6.3.3",
4444
dev_dependency = True,
4545
)
46+
bazel_dep(
47+
name = "rsync",
48+
version = "3.4.1",
49+
dev_dependency = True,
50+
)
4651
bazel_dep(
4752
name = "rules_pkg",
4853
version = "1.0.1",

xcodeproj/internal/bazel_integration_files/BUILD

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _BASE_FILES = [
99
filegroup(
1010
name = "bazel_integration_files",
1111
srcs = _BASE_FILES + [
12+
":renamed_rsync",
1213
":renamed_swiftc_stub",
1314
":rsync_excludes",
1415
] + glob(
@@ -125,6 +126,27 @@ fi
125126
],
126127
)
127128

129+
genrule(
130+
name = "renamed_rsync",
131+
srcs = ["@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+
visibility = ["//visibility:public"],
148+
)
149+
128150
# Release
129151

130152
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
@@ -63,6 +63,7 @@ fi
6363
readonly src_generated_xcfilelist="$PWD/%generated_xcfilelist%"
6464
readonly src_generated_directories_filelist="$PWD/%generated_directories_filelist%"
6565
readonly src_project_pbxproj="$PWD/%project_pbxproj%"
66+
readonly src_rsync="$PWD/%rsync%"
6667
readonly src_xcschememanagement="$PWD/%xcschememanagement%"
6768
readonly src_xcschemes="$PWD/%xcschemes%/"
6869
readonly src_xcworkspacedata="$PWD/%contents_xcworkspacedata%"
@@ -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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ def _write_installer(
280280
install_path,
281281
name,
282282
project_pbxproj,
283+
rsync,
283284
template,
284285
xcschememanagement,
285286
xcschemes):
@@ -303,6 +304,7 @@ def _write_installer(
303304
"%generated_xcfilelist%": generated_xcfilelist.short_path,
304305
"%output_path%": install_path,
305306
"%project_pbxproj%": project_pbxproj.short_path,
307+
"%rsync%": rsync.short_path,
306308
"%xcschememanagement%": xcschememanagement.short_path,
307309
"%xcschemes%": xcschemes.short_path,
308310
},
@@ -772,6 +774,7 @@ Are you using an `alias`? `xcodeproj.focused_targets` and \
772774
install_path = install_path,
773775
name = name,
774776
project_pbxproj = project_pbxproj,
777+
rsync = ctx.file._rsync,
775778
template = ctx.file._installer_template,
776779
xcschememanagement = xcschememanagement,
777780
xcschemes = xcschemes,
@@ -903,6 +906,11 @@ A dict mapping of Labels for StoreKit Testing configuration files to their File
903906
"//xcodeproj/internal/templates:installer.sh",
904907
),
905908
),
909+
"_rsync": attr.label(
910+
allow_single_file = True,
911+
cfg = "exec",
912+
default = Label("//xcodeproj/internal/bazel_integration_files:renamed_rsync"),
913+
),
906914
# TODO: Remove 5.8 when support for Xcode 16.x is dropped.
907915
"_legacy_index_import": attr.label(
908916
cfg = "exec",

0 commit comments

Comments
 (0)