]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
bundle: export lib bundling code to a standalone script
authorThomas Debesse <dev@illwieckz.net>
Mon, 17 Jun 2019 21:33:59 +0000 (23:33 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 18 Jun 2019 22:04:02 +0000 (00:04 +0200)
CMakeLists.txt
library-bundler [new file with mode: 0644]

index 4cbf3658077dcdd0dfe5b90ce91306cc31932470..dd247e084bd1fd446c77799b43db6c2c39421aeb 100644 (file)
@@ -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 '$<TARGET_FILE:${target}>' | 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" "$<TARGET_FILE:${target}>" "${PROJECT_BINARY_DIR}"
                 VERBATIM
-        )
+            )
         endif ()
     endmacro ()
 
diff --git a/library-bundler b/library-bundler
new file mode 100644 (file)
index 0000000..b776c53
--- /dev/null
@@ -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