Skip to content

Commit

Permalink
Silence code signature warnings from vtool and strip when updatin…
Browse files Browse the repository at this point in the history
…g signed xcframeworks (#735)
  • Loading branch information
jszumski authored Jul 17, 2023
1 parent e8e6a0f commit fe9222d
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions tools/m1_utils/update_dynamic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,33 @@ set -e
# Note: this program is the simplest version of patching a dynamic library
# Other code should handle making frameworks, etc
patch() {
EXTDIR="$(mktemp -d "${TMPDIR:-/tmp}/bazel_m1_utils.XXXXXXXX")"
pushd $EXTDIR > /dev/null
trap "rm -rf $EXTDIR" EXIT
EXTDIR="$(mktemp -d "${TMPDIR:-/tmp}/bazel_m1_utils.XXXXXXXX")"
pushd $EXTDIR > /dev/null
trap "rm -rf $EXTDIR" EXIT

# Attempt lipo if it's a fat binary
ARCHS=()
while read ARCH; do
ARCHS+=($ARCH)
done < <(lipo -archs "$FWF")
if test "${#ARCHS[@]}" -gt 1; then
lipo "$FWF" -thin arm64 -output "OF.ar" || cp "$FWF" "OF.ar"
else
cp "$FWF" "OF.ar"
fi
# Attempt lipo if it's a fat binary
ARCHS=()
while read ARCH; do
ARCHS+=($ARCH)
done < <(lipo -archs "$FWF")
if test "${#ARCHS[@]}" -gt 1; then
lipo "$FWF" -thin arm64 -output "OF.ar" || cp "$FWF" "OF.ar"
else
cp "$FWF" "OF.ar"
fi

# FIXME: Versions should be input from the build system
xcrun vtool -arch arm64 -set-build-version 7 11.0 11.0 -replace -output "$OF" "OF.ar"
# FIXME: Versions should be input from the build system
# filter stderr to ignore code signature warnings
xcrun vtool -arch arm64 -set-build-version 7 11.0 11.0 -replace -output "$OF" "OF.ar" \
2> >(grep --invert 'warning: code signature will be invalid' >&2)

# Xcode 13.1-13.2.1 workaround - see update_static.sh
strip -S "$OF"
# Xcode 13.1-13.2.1 workaround - see update_static.sh
# filter stderr to ignore code signature warnings
strip -S "$OF" \
2> >(grep --invert 'warning: changes being made to the file will invalidate the code signature' >&2)
}

# Framework file
# Framework file
export FWF="$1"

# Output file
Expand Down

0 comments on commit fe9222d

Please sign in to comment.