diff options
author | Vladimír Čunát <vcunat@gmail.com> | 2016-05-05 08:30:19 +0200 |
---|---|---|
committer | Vladimír Čunát <vcunat@gmail.com> | 2016-05-05 08:30:19 +0200 |
commit | 1dc36904d8cefa8188c785efd03274637c838e31 (patch) | |
tree | 0cf37f0803f1e9c6985d09f2870e5ec61229d2ca /pkgs/build-support/setup-hooks/win-dll-link.sh | |
parent | 75f1cc61b86b002f551529f1cafa30b4f4010bd9 (diff) | |
parent | 7a005601d48f760864258e369364b3b847d4e9fd (diff) | |
download | nixlib-1dc36904d8cefa8188c785efd03274637c838e31.tar nixlib-1dc36904d8cefa8188c785efd03274637c838e31.tar.gz nixlib-1dc36904d8cefa8188c785efd03274637c838e31.tar.bz2 nixlib-1dc36904d8cefa8188c785efd03274637c838e31.tar.lz nixlib-1dc36904d8cefa8188c785efd03274637c838e31.tar.xz nixlib-1dc36904d8cefa8188c785efd03274637c838e31.tar.zst nixlib-1dc36904d8cefa8188c785efd03274637c838e31.zip |
Merge #14920: windows improvements, mainly mingw
Diffstat (limited to 'pkgs/build-support/setup-hooks/win-dll-link.sh')
-rw-r--r-- | pkgs/build-support/setup-hooks/win-dll-link.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/win-dll-link.sh b/pkgs/build-support/setup-hooks/win-dll-link.sh new file mode 100644 index 000000000000..be63f69ca10b --- /dev/null +++ b/pkgs/build-support/setup-hooks/win-dll-link.sh @@ -0,0 +1,45 @@ + +fixupOutputHooks+=(_linkDLLs) + +# For every *.{exe,dll} in $output/bin/ we try to find all (potential) +# transitive dependencies and symlink those DLLs into $output/bin +# so they are found on invocation. +# (DLLs are first searched in the directory of the running exe file.) +# The links are relative, so relocating whole /nix/store won't break them. +_linkDLLs() { +( + if [ ! -d "$prefix/bin" ]; then exit; fi + cd "$prefix/bin" + + # Compose path list where DLLs should be located: + # prefix $PATH by currently-built outputs + local DLLPATH="" + local outName + for outName in $outputs; do + addToSearchPath DLLPATH "${!outName}/bin" + done + DLLPATH="$DLLPATH:$PATH" + + echo DLLPATH="'$DLLPATH'" + + linkCount=0 + # Iterate over any DLL that we depend on. + local dll + for dll in $(objdump -p *.{exe,dll} | sed -n 's/.*DLL Name: \(.*\)/\1/p' | sort -u); do + if [ -e "./$dll" ]; then continue; fi + # Locate the DLL - it should be an *executable* file on $DLLPATH. + local dllPath="$(PATH="$DLLPATH" type -P "$dll")" + if [ -z "$dllPath" ]; then continue; fi + # That DLL might have its own (transitive) dependencies, + # so add also all DLLs from its directory to be sure. + local dllPath2 + for dllPath2 in "$dllPath" "$(dirname "$dllPath")"/*.dll; do + if [ -e ./"$(basename "$dllPath2")" ]; then continue; fi + ln -sr "$dllPath2" . + linkCount=$(($linkCount+1)) + done + done + echo "Created $linkCount DLL link(s) in $prefix/bin" +) +} + |