OS X: Make bundling of libraries recursion-safe (#1818)

Bash variables are global by default. Therefore, recursing into sub-
dependencies was breaking ID updates in the dependency parent.

Mark variables that are local to each recursion step as local so that
their original value gets restored when the recursion returns.
console-destruction
Nicolas Hake 2016-09-04 14:11:51 +02:00
parent 6a78a9facb
commit 2e4afb70a9
1 changed files with 8 additions and 6 deletions

View File

@ -52,12 +52,14 @@ fi
echo "Bundling libraries..."
bundle_dependencies() {
_object_path="$1"
local _object_path="$1"
local _library_name
"${_otool}" -L "${_object_path}" | \
awk '/^\t+\// { print $1 }' | \
grep -v '@executable_path.*' | \
while read _library_name; do
_library_path="${_library_name}"
local _library_path="${_library_name}"
# If the library isn't available at the stored path, it may be
# stored inside the sysroot (when cross-compiling for example)
@ -67,7 +69,7 @@ bundle_dependencies() {
# If the library still isn't available there, there might be a YAML
# stub instead in more recent SDKs; if we find one of those, the
# library is part of the base install and doesn't need to be bundled
_stub_path="${_library_path%.dylib}.tbd"
local _stub_path="${_library_path%.dylib}.tbd"
if [ ! -e "${_library_path}" -a -e "${_stub_path}" ]; then
continue
fi
@ -78,10 +80,10 @@ bundle_dependencies() {
exit 1
fi
_base="$(basename "${_library_name}")"
_bundle_path="${_frameworks_folder_path}/${_base}"
local _base="$(basename "${_library_name}")"
local _bundle_path="${_frameworks_folder_path}/${_base}"
_id="@executable_path/../Frameworks/${_base}"
local _id="@executable_path/../Frameworks/${_base}"
# Skip if it's a library stub (because we can't change the install name
# of those anyway)