build: update macOS linker tool to 1.5
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
0c39a5ba7a
commit
41952d0625
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
version=1.4
|
version=1.5
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# parse options
|
# parse options
|
||||||
|
@ -35,7 +35,7 @@ main() {
|
||||||
app_bundle=$(echo "$1" | fully_resolve_links)
|
app_bundle=$(echo "$1" | fully_resolve_links)
|
||||||
|
|
||||||
case "$app_bundle" in
|
case "$app_bundle" in
|
||||||
*.app|*.APP)
|
*.[aA][pP][pP])
|
||||||
if [ ! -d "$app_bundle" ]; then
|
if [ ! -d "$app_bundle" ]; then
|
||||||
usage
|
usage
|
||||||
quit 1
|
quit 1
|
||||||
|
@ -196,21 +196,45 @@ fully_resolve_links() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock() {
|
||||||
|
mkdir -p "$lock_dir/$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock() {
|
||||||
|
rm -rf "$lock_dir/$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_lock() {
|
||||||
|
while [ -d "$lock_dir/$1" ]; do
|
||||||
|
/bin/bash -c 'sleep 0.1'
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
relink_all() {
|
relink_all() {
|
||||||
for exe in "$@"; do
|
lock_dir="$tmp/locks"
|
||||||
|
|
||||||
|
find "$app_bundle/Contents/Frameworks" -name '*.dylib' > "$tmp/libs"
|
||||||
|
|
||||||
|
for exe in "$@"; do (
|
||||||
# dylib search path for executable
|
# dylib search path for executable
|
||||||
|
wait_lock "$exe"
|
||||||
|
lock "$exe"
|
||||||
install_name_tool -add_rpath '@loader_path/../Frameworks' "$exe"
|
install_name_tool -add_rpath '@loader_path/../Frameworks' "$exe"
|
||||||
|
unlock "$exe"
|
||||||
|
|
||||||
OLDIFS=$IFS
|
OLDIFS=$IFS
|
||||||
IFS='
|
IFS='
|
||||||
'
|
'
|
||||||
set --
|
set --
|
||||||
for lib in $(find "$app_bundle/Contents/Frameworks" -name '*.dylib'); do
|
for lib in $(cat "$tmp/libs"); do
|
||||||
set -- "$@" "$lib"
|
set -- "$@" "$lib"
|
||||||
done
|
done
|
||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
|
|
||||||
for lib in "$@"; do
|
for lib in "$@"; do
|
||||||
|
wait_lock "$lib"
|
||||||
|
lock "$lib"
|
||||||
|
|
||||||
# make lib writable
|
# make lib writable
|
||||||
chmod u+w "$lib"
|
chmod u+w "$lib"
|
||||||
|
|
||||||
|
@ -220,12 +244,18 @@ relink_all() {
|
||||||
# set search path of lib
|
# set search path of lib
|
||||||
install_name_tool -add_rpath '@loader_path/../Frameworks' "$lib"
|
install_name_tool -add_rpath '@loader_path/../Frameworks' "$lib"
|
||||||
|
|
||||||
|
unlock "$lib"
|
||||||
|
|
||||||
# relink executable and all other libs to this lib
|
# relink executable and all other libs to this lib
|
||||||
for target in "$exe" "$@"; do
|
for target in "$exe" "$@"; do (
|
||||||
relink "$lib" "$target"
|
relink "$lib" "$target"
|
||||||
done
|
) & done
|
||||||
|
wait
|
||||||
done
|
done
|
||||||
done
|
) & done
|
||||||
|
wait
|
||||||
|
|
||||||
|
rm -rf "$tmp/libs" "$lock_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
relink() {
|
relink() {
|
||||||
|
@ -261,7 +291,12 @@ relink() {
|
||||||
case "$longer" in
|
case "$longer" in
|
||||||
"$shorter"*)
|
"$shorter"*)
|
||||||
# and if so, relink target to the lib
|
# and if so, relink target to the lib
|
||||||
|
wait_lock "$lib"
|
||||||
|
lock "$lib"
|
||||||
|
|
||||||
install_name_tool -change "$lib_link_path" "@rpath/$lib_basename" "$target"
|
install_name_tool -change "$lib_link_path" "@rpath/$lib_basename" "$target"
|
||||||
|
|
||||||
|
unlock "$lib"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue