Files
qt5/coin/provisioning/common/macos/fix_relative_dependencies.sh
Artem Dyomin 26a71457ae Implement dynamical ffmpeg linking on macOS
* fix dependencies and install names (absolute => relative)
* fix compilation build of dylib on xcode 15.
* add matching build instructions to yaml.
* old macos versions don't have 'realpath', workaround is used.

Task-number: QTBUG-120989
Pick-to: 6.6 6.5
Change-Id: I22e413d8f6d05c8c7d6d09a5926691216e781fd3
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
(cherry picked from commit a53b63019f)
2024-04-20 08:39:40 +02:00

26 lines
931 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright (C) 2024 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
set -e
# realpath is not included to macOS <= 12.
# dir=$(realpath "$1")
dir=$(cd "$1" && pwd)
dir_length=${#dir}
dylib_regex="^$dir/.*\.dylib$"
find "$dir" -type f -name '*.dylib' | while read -r library_path; do
install_name=$(otool -D "$library_path" | sed -n '2p' | egrep "$dylib_regex" )
if [ -n "$install_name" ]; then
fixed_install_name="@rpath${install_name:dir_length}"
install_name_tool -id "$fixed_install_name" "$library_path"
fi
otool -L "$library_path" | awk '/\t/ {print $1}' | egrep "$dylib_regex" | while read -r dependency_path; do
fixed_dependency_path="@loader_path${dependency_path:dir_length}"
install_name_tool -change "$dependency_path" "$fixed_dependency_path" "$library_path"
done
done