diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dfdffe91..021874b98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/xcodeproj/repositories.bzl b/xcodeproj/repositories.bzl index 202536194..eb524c9af 100644 --- a/xcodeproj/repositories.bzl +++ b/xcodeproj/repositories.bzl @@ -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(