Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ END_UNRELEASED_TEMPLATE

### Fixed

* Fixed incompatible output base causing startup options change: [#3229](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3229)
* Fixed incompatible output base causing startup options change: [#3229](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3229), [#3233](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3233)

### Ruleset Development Changes

Expand Down
24 changes: 18 additions & 6 deletions xcodeproj/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,25 @@ package_group(
""",
)

if repository_ctx.execute(["command", "-v", "/sbin/md5"]).return_code == 0:
md5_command = "/sbin/md5"
else:
md5_command = "md5sum"

# Calculate the hash of the output base path, stripping /private if needed.
output_base_script = """
set -euo pipefail

if command -v /sbin/md5 >/dev/null 2>&1; then
md5_command=/sbin/md5
else
md5_command=md5sum
fi

output_base="${PWD%/*/*/*/*}"
if [[ $output_base == /private/* ]]; then
output_base="${output_base#/private}"
fi

echo "$output_base" | $md5_command | awk '{print $1}'
"""
output_base_hash_result = repository_ctx.execute(
["bash", "-c", "set -euo pipefail; echo \"${PWD%/*/*/*/*}\" | " + md5_command + " | awk '{print $1}'"],
["bash", "-c", output_base_script],
)
if output_base_hash_result.return_code != 0:
fail("Failed to calculate output base hash: {}".format(
Expand Down