| 1 |
#!/bin/bash |
| 2 |
# msys2-bundledlls - Copy DLLs linked against a Windows executable for bundling with a distribution |
| 3 |
|
| 4 |
if [ "$#" -ne 2 ]; |
| 5 |
then |
| 6 |
echo "Usage: ./bundledlls <executable> <directory>" |
| 7 |
exit |
| 8 |
fi |
| 9 |
|
| 10 |
DLL=$(cygpath -u "$1") |
| 11 |
DEST=$(cygpath -u "$2") |
| 12 |
PREFIX=$(cygpath -u "$MINGW_PREFIX") |
| 13 |
|
| 14 |
mkdir -p $DEST |
| 15 |
cd $DEST |
| 16 |
|
| 17 |
# Get list of dynamic libraries, filter by ones that are found in the current MSYS2 prefix |
| 18 |
# and strip off everything but the full path. E.g.: |
| 19 |
# `lua51.dll => /ucrt64/bin/lua51.dll (0xdeadbeef)` => `/ucrt64/bin/lua51.dll` |
| 20 |
list=$(ldd $DLL | grep $PREFIX | sed 's/.* => //' | sed 's/ \(.*\)//') |
| 21 |
|
| 22 |
for dll in $list; |
| 23 |
do |
| 24 |
echo $dll |
| 25 |
cp $dll $DEST/ |
| 26 |
done |
| 27 |
|