Skip to content

Instantly share code, notes, and snippets.

@cwchentw

cwchentw/deploy2win

Last active Sep 29, 2020
Embed
What would you like to do?
Depoly a MSYS2 Executable to Native Windows Environment
#!/bin/sh
# deploy2win - Deploy a MSYS2 executable to native Windows environment
#
# Copyright (c) 2020, Michael Chen. Licensed under MIT.
target="$1"
# Check whether `$target` is an executable.
if ! [ -x "$target" ];
then
echo "Not a valid executable: ${target}" >&2
exit 1
fi
# Get the destination directory.
dest="$(dirname $(realpath $target))"
# Iterate over the required DLLs, excluding those in system directories.
for dll in `ldd $target | grep -i -v WINDOWS | cut -d ' ' -f 3`;
do
src="$(dirname $(realpath $dll))"
# If the `$src` of the `$dll` is not the same as `$dest`,
# copy the `$dll` to `$dest`.
if [ "$src" != "$dest" ];
then
cp "$dll" "$dest" || (
echo "Fail to copy $dll to $dest" >&2
)
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.