From: Thomas Debesse Date: Mon, 17 Jun 2019 21:33:59 +0000 (+0200) Subject: bundle: export lib bundling code to a standalone script X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=de06ea449dfca5a3f0a5ad1f5bd91be0225d9d3e;p=xonotic%2Fnetradiant.git bundle: export lib bundling code to a standalone script --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cbf3658..dd247e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,10 +216,10 @@ if (BUILD_BINARIES) macro (copy_dlls target) if (BUNDLE_LIBRARIES AND WIN32) add_custom_command(TARGET ${target} POST_BUILD - COMMAND bash - ARGS -c "ldd '$' | egrep -i '\\.dll ' | grep -iv '/c/Windows' | awk '{ print $1 }' | while read dll; do dllbasename=\"$(which \"$dll\")\"; [ -f \"${PROJECT_BINARY_DIR}/$dllbasename\" ] || cp --preserve=timestamps \"$dllbasename\" '${PROJECT_BINARY_DIR}'; done" + COMMAND "${PROJECT_SOURCE_DIR}/library-bundler" + ARGS "windows" "$" "${PROJECT_BINARY_DIR}" VERBATIM - ) + ) endif () endmacro () diff --git a/library-bundler b/library-bundler new file mode 100644 index 00000000..b776c532 --- /dev/null +++ b/library-bundler @@ -0,0 +1,24 @@ +#! /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}")" + ldd "${exe_file}" \ + | egrep -i '\.dll => /mingw64/' \ + | sed -e 's/ (0x[0-9a-f]*)$//;s/^.* => //' \ + | while read dll_file + do + dll_basename="$(basename "${dll_file}")" + cp -n --preserve=timestamps "${dll_file}" "${bundle_dir}/${dll_basename}" + done + ;; + *) + printf 'ERROR: unsupported system: %s\n' "${system_name}" >&2 + exit 1 + ;; +esac