cygwin-dll-link: cleanup (#488398)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
addLinkDLLPaths() {
|
||||
addToSearchPath "LINK_DLL_FOLDERS" "$1/lib"
|
||||
addToSearchPath "LINK_DLL_FOLDERS" "$1/bin"
|
||||
addToSearchPath "LINK_DLL_FOLDERS" "$1/lib"
|
||||
addToSearchPath "LINK_DLL_FOLDERS" "$1/bin"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
addEnvHooks "$targetOffset" addLinkDLLPaths
|
||||
|
||||
addOutputDLLPaths() {
|
||||
@@ -15,36 +18,37 @@ addOutputDLLPaths() {
|
||||
postInstallHooks+=(addOutputDLLPaths)
|
||||
|
||||
_dllDeps() {
|
||||
"$OBJDUMP" -p "$1" \
|
||||
| sed -n 's/.*DLL Name: \(.*\)/\1/p' \
|
||||
| sort -u
|
||||
"$OBJDUMP" -p "$1" \
|
||||
| sed -n 's/.*DLL Name: \(.*\)/\1/p' \
|
||||
| sort -u
|
||||
}
|
||||
|
||||
_linkDeps() {
|
||||
local target="$1" dir="$2" check="$3"
|
||||
echo 'target:' "$target"
|
||||
local dll
|
||||
_dllDeps "$target" | while read dll; do
|
||||
echo ' dll:' "$dll"
|
||||
if [[ -e "$dir/$dll" ]]; then continue; fi
|
||||
# Locate the DLL - it should be an *executable* file on $LINK_DLL_FOLDERS.
|
||||
local dllPath="$(PATH="$(dirname "$target"):$LINK_DLL_FOLDERS" type -P "$dll")"
|
||||
if [[ -z "$dllPath" ]]; then
|
||||
if [[ -z "$check" || -n "${allowedImpureDLLsMap[$dll]}" ]]; then
|
||||
continue
|
||||
fi
|
||||
echo unable to find $dll in $LINK_DLL_FOLDERS >&2
|
||||
exit 1
|
||||
fi
|
||||
echo ' linking to:' "$dllPath"
|
||||
CYGWIN+=\ winsymlinks:nativestrict ln -sr "$dllPath" "$dir"
|
||||
# That DLL might have its own (transitive) dependencies,
|
||||
# so add also all DLLs from its directory to be sure.
|
||||
_linkDeps "$dllPath" "$dir" ""
|
||||
done
|
||||
local target="$1" dir="$2" check="$3"
|
||||
echo 'target:' "$target"
|
||||
local dll
|
||||
_dllDeps "$target" | while read -r dll; do
|
||||
echo ' dll:' "$dll"
|
||||
if [[ -e "$dir/$dll" ]]; then continue; fi
|
||||
# Locate the DLL - it should be an *executable* file on $LINK_DLL_FOLDERS.
|
||||
local dllPath
|
||||
if ! dllPath="$(PATH="$(dirname "$target"):$LINK_DLL_FOLDERS" type -P "$dll")"; then
|
||||
if [[ -z "$check" || -n "${allowedImpureDLLsMap[$dll]}" ]]; then
|
||||
continue
|
||||
fi
|
||||
echo unable to find "$dll" in "$LINK_DLL_FOLDERS" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo ' linking to:' "$dllPath"
|
||||
CYGWIN+=\ winsymlinks:nativestrict ln -sr "$dllPath" "$dir"
|
||||
# That DLL might have its own (transitive) dependencies,
|
||||
# so add also all DLLs from its directory to be sure.
|
||||
_linkDeps "$dllPath" "$dir" ""
|
||||
done
|
||||
}
|
||||
|
||||
linkDLLs() {
|
||||
# shellcheck disable=SC2154
|
||||
if [ ! -d "$prefix" ]; then return; fi
|
||||
(
|
||||
set -e
|
||||
|
||||
Reference in New Issue
Block a user