#! /usr/bin/env bash system_name="${1}" exe_file="${2}" bundle_dir="${3}" case "${system_name}" in 'windows') bundle_dir="$(cygpath --unix "${bundle_dir}")" exe_file="$(cygpath --unix "${exe_file}")" ntldd --recursive "${exe_file}" \ | egrep -i '\.dll => [A-Z]:\\msys64\\' \ | sed -e 's/ (0x[0-9a-f]*)$//;s/^.* => //' \ | cygpath --unix --file - \ | while read dll_file do dll_basename="$(basename "${dll_file}")" if [ -f "${bundle_dir}/${dll_basename}" ] then continue fi cp --preserve=timestamps "${dll_file}" "${bundle_dir}/${dll_basename}" if [ "${dll_basename}" = 'libgtk-win32-2.0-0.dll' ] then mingw="$(which 'libgtk-win32-2.0-0.dll' | cut -f2 -d'/')" for component_dir in \ 'share/themes/MS-Windows' \ 'share/icons/hicolor' \ 'lib/gdk-pixbuf-2.0' \ 'lib/gtk-2.0' do if ! [ -d "${bundle_dir}/${component_dir}" ] then mkdir --parents "${bundle_dir}/$(dirname "${component_dir}")" cp -r --preserve=timestamps "/${mingw}/${component_dir}" \ "${bundle_dir}/${component_dir}" fi done find "${bundle_dir}/lib" -type f -name '*.a' -exec rm {} \; find "${bundle_dir}/lib" -type f -name '*.h' -exec rm {} \; find "${bundle_dir}/lib" -type d -exec rmdir --ignore-fail-on-non-empty {} \; fi done ;; *) printf 'ERROR: unsupported system: %s\n' "${system_name}" >&2 exit 1 ;; esac