]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - library-bundler
gtkglext: build and bundle built-in gtkglext
[xonotic/netradiant.git] / library-bundler
index c1ba97d9b2ec421925ced97324bb4fb61ea0be99..1a3389c9dc0aab23f4f80b5bcc0b7d74f8ae735b 100755 (executable)
@@ -1,7 +1,12 @@
 #! /usr/bin/env bash
 
+set -e
+
+export LANG='C.UTF-8'
+export LANGUAGE="${LANG}"
+
 Common::noOp () {
-       printf ''
+       true
 }
 
 Common::getPath () {
@@ -39,6 +44,7 @@ Common::stripLdd () {
 Multi::excludeLdd () {
        case "${system_name}" in
                'linux')
+                       # - always bundle built-in libraries
                        # - always rely on up-to-date x11 and gl libraries, bundling them will break on future distros
                        # - gtk is not easily bundlable on linux because it looks for harcoded system path to optional
                        #   shared libraries like image codecs, theme engines, sound notification system, etc.
@@ -47,11 +53,27 @@ Multi::excludeLdd () {
                        #   which is likely to pull gtk itself, x11 and gl dependencies
                        # - old fontconfig does not work correctly if newer fontconfig configuration is installed
                        # - if gtk and fontconfig is installed, pango and freetype are
-                       egrep -v '/libc\.|/libstdc\+\+\.|/libdl\.|/libm\.|/libX|/libxcb|/libGL|/libICE\.|/libSM\.|/libpthread\.' \
-                       | egrep -v '/libatk|/libgdk|/libgtk|/libgio|/libglib|/libgmodule|/libgobject|/libcairo|/libpango|/libfontconfig|/libfreetype'
+                       local ldd_line
+                       while read ldd_line
+                       do
+                               if echo "${ldd_line}" | egrep '/builtins/'
+                               then
+                                       echo "${ldd_line}"
+                               elif echo "${ldd_line}" \
+                                       | egrep -q '/libc\.|/libstdc\+\+\.|/libdl\.|/libm\.|/libX|/libxcb|/libGL|/libICE\.|/libSM\.|/libpthread\.'
+                               then
+                                       Common::noOp
+                               elif echo "${ldd_line}" \
+                                       | egrep -q '/libatk|/libgdk|/libgtk|/libgio|/libglib|/libgmodule|/libgobject|/libcairo|/libpango|/libfontconfig|/libfreetype'
+                               then
+                                       Common::noOp
+                               else
+                                       echo "${ldd_line}"
+                               fi
+                       done
                        ;;
                'windows')
-                       egrep -i '\.dll => [A-Z]:\\msys64\\' \
+                       egrep -i '\.dll => [A-Z]:\\msys64\\'
                        ;;
        esac
 }
@@ -108,7 +130,7 @@ Multi::getRootPrefix () {
                        ;;
                'windows')
                        basename "${lib_file}" \
-                       | xargs -n1 -P 1 which \
+                       | xargs -n1 -P1 which \
                        | cut -f2 -d'/'
                        ;;
        esac
@@ -180,11 +202,18 @@ Multi::bundleGtkDepsFromFile () {
 
 Multi::bundleLibFromFile () {
        local exe_file="${1}"
+       local lib_file
 
        Multi::printLdd "${exe_file}" \
        | Multi::filterLib \
        | while read lib_file
        do
+               if [ "${lib_file}" = 'not found' ]
+               then
+                       printf 'ERROR: library not found while bundling %s (but link worked)\n' "${exe_file}" >&2
+                       Multi::printLdd "${exe_file}" | grep 'not found'
+                       exit 1
+               fi
                lib_basename="$(basename "${lib_file}")"
 
                if [ -f "${lib_dir}/${lib_basename}" ]
@@ -295,7 +324,11 @@ Windows::writeManifest () {
 
 system_name="${1}"; shift
 bundle_dir="${1}"; shift
-exe_file="${1}"; shift
+
+if ! [ -z "${1}" ]
+then
+       exe_file="${1}"; shift
+fi
 
 bundle_dir="$(Common::getPath "${bundle_dir}")"
 registry_dir="${bundle_dir}/registry"