1 fixupOutputHooks
+=(_linkDLLs
)
3 addEnvHooks
"$targetOffset" linkDLLGetFolders
6 addToSearchPath
"LINK_DLL_FOLDERS" "$1/lib"
7 addToSearchPath
"LINK_DLL_FOLDERS" "$1/bin"
11 linkDLLsInfolder
"$prefix/bin"
14 # Try to links every known dependency of exe/dll in the folder of the 1str input
15 # into said folder, so they are found on invocation.
16 # (DLLs are first searched in the directory of the running exe file.)
17 # The links are relative, so relocating whole /nix/store won't break them.
22 if [ ! -d "$folder" ]; then
23 echo "Not linking DLLs in the non-existent folder $folder"
28 # Use associative arrays as set
31 declare -A filesToChecks
# files that still needs to have their dependancies checked
32 declare -A filesDone
# files that had their dependancies checked and who is copied to the bin folder if found
35 if [ ! "${filesDone[$1]+a}" ]; then filesDone
[$1]=a
; fi
36 if [ "${filesToChecks[$1]+a}" ]; then unset 'filesToChecks[$1]'; fi
40 if [ "${filesDone[$1]+a}" ]; then return; fi
41 if [ ! "${filesToChecks[$1]+a}" ]; then filesToChecks
[$1]=a
; fi
44 # Compose path list where DLLs should be located:
45 # prefix $PATH by currently-built outputs
48 for outName
in $
(getAllOutputNames
); do
49 addToSearchPath DLLPATH
"${!outName}/bin"
51 DLLPATH
="$DLLPATH:$LINK_DLL_FOLDERS"
53 echo DLLPATH
="'$DLLPATH'"
55 for peFile
in *.
{exe
,dll
}; do
56 if [ -e "./$peFile" ]; then
57 addFileToLink
"$peFile"
62 readarray
-td: searchPaths
< <(printf -- "%s" "$DLLPATH")
65 while [ ${#filesToChecks[*]} -gt 0 ]; do
66 local listOfDlls
=("${!filesToChecks[@]}")
67 local file=${listOfDlls[0]}
68 markFileAsDone
"$file"
69 if [ ! -e "./$file" ]; then
71 readarray
-d '' pathsFound
< <(find "${searchPaths[@]}" -name "$file" -type f
-print0)
72 if [ ${#pathsFound[@]} -eq 0 ]; then continue; fi
74 dllPath
="${pathsFound[0]}"
75 CYGWIN
+=" winsymlinks:nativestrict" ln -sr "$dllPath" .
76 echo "linking $dllPath"
78 linkCount
=$
((linkCount
+ 1))
81 # Look at the file’s dependancies
82 for dep_file
in $
($OBJDUMP -p "$file" |
sed -n 's/.*DLL Name: \(.*\)/\1/p' |
sort -u); do
83 addFileToLink
"$dep_file"
87 echo "Created $linkCount DLL link(s) in $folder"