build: update mac link tool to 1.4

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2024-04-16 02:13:37 +00:00
parent b52edf52ff
commit ff3b5ee042
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
version=1.3
version=1.4
main() {
# parse options
@ -68,12 +68,22 @@ main() {
mkdir -p "$frameworks"
scan_libs "$@" | fully_resolve_links | sort -u | \
scan_libs "$@" | sort -u | \
while read lib; do
if [ -n "$list" ]; then
echo "$lib"
else
cp -f "$lib" "$frameworks" 2>/dev/null
resolved=$(echo "$lib" | fully_resolve_links)
resolved_basename=${resolved##*/}
if [ ! -f "$frameworks/$resolved_basename" ]; then
cp -f "$resolved" "$frameworks" 2>/dev/null
fi
if [ "$resolved" != "$lib" ]; then
lib_basename=${lib##*/}
if [ ! -f "$frameworks/$lib_basename" ]; then
ln -s "$resolved_basename" "$frameworks/$lib_basename"
fi
fi
fi
done
@ -223,13 +233,13 @@ relink() {
target=$2
lib_basename=${lib##*/}
lib_basename_unversioned_re=$(echo "$lib_basename" | sed 's/[0-9.-]*\.dylib$//; s/\./\\./g')
lib_basename_unversioned_re=$(echo "$lib_basename" | sed 's/\.[0-9.-]*\.dylib$//; s/\./\\./g')
# remove full path and version of lib in executable
lib_link_path=$(
otool -l "$target" 2>/dev/null | \
sed -n 's,^ *name \(.*/*'"$lib_basename_unversioned_re"'[0-9.-]*\.dylib\) (offset .*,\1,p' | \
head -1
sed -n 's,^ *name \(.*/*'"$lib_basename_unversioned_re"'\.[0-9.-]*\.dylib\) (offset .*,\1,p' | \
head -1
)
[ -z "$lib_link_path" ] && return 0