1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
#!/bin/bash
set -ex
# This script will cross compile Gargoyle for Windows using MinGW, and
# build an installer for it using NSIS. This script makes assumptions
# about the location of MinGW, so may need to be tweaked to get it to
# properly work.
#
# By default LLVM MinGW (assumed to be in /usr/llvm-mingw) is used. To
# use gcc MinGW (assumed to be in /usr), pass the -g flag.
#
# i686 is built by default. To select another architecture, use the -a
# option. Valid values:
#
# i686
# x86_64
# aarch64 (LLVM only)
# armv7 (LLVM only)
#
# An installer (if available) and standalone ZIP are created. To build
# without creating installers/ZIPs, pass the -b flag.
fatal() {
echo "${@}" >&2
exit 1
}
while getopts "a:bg" o
do
case "${o}" in
a)
GARGOYLE_ARCH="${OPTARG}"
;;
b)
GARGOYLE_BUILD_ONLY=1
;;
g)
GARGOYLE_MINGW_GCC=1
;;
*)
fatal "Usage: $0 [-a i686|x86_64|aarch64|armv7] [-b] [-g]"
;;
esac
done
GARGOYLE_ARCH=${GARGOYLE_ARCH:-"i686"}
case "${GARGOYLE_ARCH}" in
i686)
libgcc=dw2
;;
x86_64)
libgcc=seh
;;
aarch64|armv7)
GARGOYLE_NO_INSTALLER=1
[[ -n "${GARGOYLE_MINGW_GCC}" ]] && fatal "Unsupported arch on MinGW GCC: ${GARGOYLE_ARCH}"
;;
*)
fatal "Unsupported arch: ${GARGOYLE_ARCH}"
;;
esac
target="${GARGOYLE_ARCH}-w64-mingw32"
[[ -e build/dist ]] && exit 1
if [[ -n "${GARGOYLE_MINGW_GCC}" ]]
then
mingw_location=/usr
else
mingw_location=/usr/llvm-mingw
fi
export PATH="${mingw_location}/bin:${PATH}"
nproc=$(getconf _NPROCESSORS_ONLN)
ver=$(${target}-gcc --version | head -1 | awk '{print $3}')
mkdir build-mingw
(
cd build-mingw
env MINGW_TRIPLE=${target} MINGW_LOCATION=${mingw_location} cmake .. -DCMAKE_TOOLCHAIN_FILE=../Toolchain.cmake -DCMAKE_BUILD_TYPE=Release
make -j${nproc}
make install
)
if [[ -n "${GARGOYLE_MINGW_GCC}" ]]
then
cp "/usr/lib/gcc/${target}/${ver}/libstdc++-6.dll" "build/dist"
cp "${mingw_location}/${target}/lib/libwinpthread-1.dll" "build/dist"
libgccpath="/usr/lib/gcc/${target}/${ver}/libgcc_s_${libgcc}-1.dll"
[[ -e "${libgccpath}" ]] || libgccpath=/usr/lib/gcc/${target}/${ver}/libgcc_s_*-1.dll
cp ${libgccpath} "build/dist"
else
cp "${mingw_location}/${target}/bin/libc++.dll" "build/dist"
cp "${mingw_location}/${target}/bin/libunwind.dll" "build/dist"
fi
for dll in Qt5Core Qt5Gui Qt5Widgets SDL2 SDL2_mixer libfreetype-6 libjpeg-8 libmodplug-1 libmpg123-0 libogg-0 libopenmpt-0 libpng16-16 libvorbis-0 libvorbisfile-3 zlib1
do
cp "${mingw_location}/${target}/bin/${dll}.dll" "build/dist"
done
find build/dist -name '*.exe' -o -name '*.dll' -exec ${target}-strip --strip-unneeded {} \;
mkdir -p "build/dist/plugins/platforms"
cp "${mingw_location}/${target}/plugins/platforms/qwindows.dll" "build/dist/plugins/platforms"
[[ "${GARGOYLE_BUILD_ONLY}" ]] && exit
if [[ -z "${GARGOYLE_NO_INSTALLER}" ]]
then
export GARGOYLE_ARCH
makensis -V4 installer.nsi
fi
cp licenses/*.txt build/dist
cp fonts/*.ttf build/dist
unix2dos -n garglk/garglk.ini build/dist/garglk.ini
zip=gargoyle-$(<VERSION)-windows-${GARGOYLE_ARCH}.zip
rm -f ${zip}
(cd build/dist && zip -r ../../${zip} *)
|