From 2f3a548881373fc6706b2cf28b0a875d1e6b7560 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 3 Sep 2021 21:14:35 +0200 Subject: [PATCH] Make MinGW build script work again --- util/build-mingw.sh | 56 ++++++++++++++++++++++++++++++++++ util/build_win.sh | 73 --------------------------------------------- 2 files changed, 56 insertions(+), 73 deletions(-) create mode 100755 util/build-mingw.sh delete mode 100755 util/build_win.sh diff --git a/util/build-mingw.sh b/util/build-mingw.sh new file mode 100755 index 0000000..0e1df54 --- /dev/null +++ b/util/build-mingw.sh @@ -0,0 +1,56 @@ +#!/bin/bash -e + +[ -z "$CXX" ] && exit 255 +export CC=false # don't need it actually + +variant=win32 +[[ "$(basename "$CXX")" == "x86_64-"* ]] && variant=win64 + +####### +# this expects unpacked libraries similar to what Minetest's buildbot uses +# $extradlls will typically point to the DLLs for libgcc, libstdc++ and libpng +libgd_dir= +zlib_dir= +zstd_dir= +sqlite_dir= +leveldb_dir= +extradlls=() +####### + +[ -f ./CMakeLists.txt ] || exit 1 + +cmake -S . -B build \ + -DCMAKE_SYSTEM_NAME=Windows \ + -DCMAKE_EXE_LINKER_FLAGS="-s" \ + \ + -DENABLE_LEVELDB=1 \ + \ + -DLEVELDB_INCLUDE_DIR=$leveldb_dir/include \ + -DLEVELDB_LIBRARY=$leveldb_dir/lib/libleveldb.dll.a \ + -DLIBGD_INCLUDE_DIR=$libgd_dir/include \ + -DLIBGD_LIBRARY=$libgd_dir/lib/libgd.dll.a \ + -DSQLITE3_INCLUDE_DIR=$sqlite_dir/include \ + -DSQLITE3_LIBRARY=$sqlite_dir/lib/libsqlite3.dll.a \ + -DZLIB_INCLUDE_DIR=$zlib_dir/include \ + -DZLIB_LIBRARY=$zlib_dir/lib/libz.dll.a \ + -DZSTD_INCLUDE_DIR=$zstd_dir/include \ + -DZSTD_LIBRARY=$zstd_dir/lib/libzstd.dll.a \ + +make -C build -j4 + +mkdir pack +cp -p \ + AUTHORS colors.txt COPYING README.rst \ + build/minetestmapper.exe \ + $leveldb_dir/bin/libleveldb.dll \ + $libgd_dir/bin/libgd*.dll \ + $sqlite_dir/bin/libsqlite*.dll \ + $zlib_dir/bin/zlib1.dll \ + $zstd_dir/bin/libzstd.dll \ + "${extradlls[@]}" \ + pack/ +zipfile=$PWD/minetestmapper-$variant.zip +(cd pack; zip -9r "$zipfile" *) + +rm -rf build pack +echo "Done." diff --git a/util/build_win.sh b/util/build_win.sh deleted file mode 100755 index 79847d1..0000000 --- a/util/build_win.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -e - -####### -# this expects an env similar to what minetest's buildbot uses -# extradll_path will typically contain libgcc, libstdc++ and libpng -toolchain_file= -toolchain_file64= -libgd_dir= -libgd_dir64= -zlib_dir= -zlib_dir64= -sqlite_dir= -sqlite_dir64= -leveldb_dir= -leveldb_dir64= -extradll_path= -extradll_path64= -####### - -[ -f ./CMakeLists.txt ] || exit 1 - -if [ "$1" == "32" ]; then - : -elif [ "$1" == "64" ]; then - toolchain_file=$toolchain_file64 - libgd_dir=$libgd_dir64 - zlib_dir=$zlib_dir64 - sqlite_dir=$sqlite_dir64 - leveldb_dir=$leveldb_dir64 - extradll_path=$extradll_path64 -else - echo "Usage: $0 <32 / 64>" - exit 1 -fi - -cmake . \ - -DCMAKE_INSTALL_PREFIX=/tmp \ - -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \ - -DCMAKE_EXE_LINKER_FLAGS="-s" \ - \ - -DENABLE_LEVELDB=1 \ - \ - -DLIBGD_INCLUDE_DIR=$libgd_dir/include \ - -DLIBGD_LIBRARY=$libgd_dir/lib/libgd.dll.a \ - \ - -DZLIB_INCLUDE_DIR=$zlib_dir/include \ - -DZLIB_LIBRARY=$zlib_dir/lib/libz.dll.a \ - \ - -DSQLITE3_INCLUDE_DIR=$sqlite_dir/include \ - -DSQLITE3_LIBRARY=$sqlite_dir/lib/libsqlite3.dll.a \ - \ - -DLEVELDB_INCLUDE_DIR=$leveldb_dir/include \ - -DLEVELDB_LIBRARY=$leveldb_dir/lib/libleveldb.dll.a - -make -j4 - -mkdir pack -cp -p \ - AUTHORS colors.txt COPYING README.rst \ - minetestmapper.exe \ - $libgd_dir/bin/libgd-3.dll \ - $zlib_dir/bin/zlib1.dll \ - $sqlite_dir/bin/libsqlite3-0.dll \ - $leveldb_dir/bin/libleveldb.dll \ - $extradll_path/*.dll \ - pack/ -zipfile=minetestmapper-win$1.zip -(cd pack; zip -9r ../$zipfile *) - -make clean -rm -r pack CMakeCache.txt - -echo "Done."