]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - util/buildbot/buildwin32.sh
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / util / buildbot / buildwin32.sh
index fc42db8a79c9e78b0abdb382d23d32a6193031d1..4484b24a79de820b1d7d478e3ba79a002a374452 100755 (executable)
@@ -1,4 +1,13 @@
 #!/bin/bash
+set -e
+
+CORE_GIT=https://github.com/EliasFleckenstein03/dragonfireclient
+CORE_BRANCH=master
+CORE_NAME=dragonfireclient
+GAME_GIT=https://git.minetest.land/MineClone2/MineClone2
+GAME_BRANCH=master
+GAME_NAME=MineClone2
+
 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 if [ $# -ne 1 ]; then
        echo "Usage: $0 <build directory>"
@@ -7,126 +16,175 @@ fi
 builddir=$1
 mkdir -p $builddir
 builddir="$( cd "$builddir" && pwd )"
-packagedir=$builddir/packages
 libdir=$builddir/libs
 
-toolchain_file=$dir/toolchain_mingw.cmake
-openal_stripped_file=$dir/openal_stripped.zip
-mingwm10_dll_file=$dir/mingwm10.dll
-irrlicht_version=1.7.2
-ogg_version=1.2.1
-vorbis_version=1.3.3
-curl_version=7.18.0
-
-# unzip -l $openal_stripped_file:
-#        0  2012-04-03 00:25   openal_stripped/
-#        0  2012-04-03 00:25   openal_stripped/bin/
-#   109080  2012-04-03 00:03   openal_stripped/bin/OpenAL32.dll
-#        0  2012-04-03 00:29   openal_stripped/include/
-#    26443  2006-12-08 17:30   openal_stripped/include/al.h
-#     8282  2007-04-13 17:02   openal_stripped/include/alc.h
-#        0  2012-04-03 00:07   openal_stripped/lib/
-#    20552  2005-08-02 08:53   openal_stripped/lib/OpenAL32.lib
-
-mkdir -p $packagedir
-mkdir -p $libdir
+# Test which win32 compiler is present
+command -v i686-w64-mingw32-gcc >/dev/null &&
+       compiler=i686-w64-mingw32-gcc
+command -v i686-w64-mingw32-gcc-posix >/dev/null &&
+       compiler=i686-w64-mingw32-gcc-posix
 
-cd $builddir
+if [ -z "$compiler" ]; then
+       echo "Unable to determine which MinGW compiler to use"
+       exit 1
+fi
+toolchain_file=$dir/toolchain_${compiler/-gcc/}.cmake
+echo "Using $toolchain_file"
+
+# Try to find runtime DLLs in various paths (varies by distribution, sigh)
+tmp=$(dirname "$(command -v $compiler)")/..
+runtime_dlls=
+for name in lib{gcc_,stdc++-,winpthread-}'*'.dll; do
+       for dir in $tmp/i686-w64-mingw32/{bin,lib} $tmp/lib/gcc/i686-w64-mingw32/*; do
+               [ -d "$dir" ] || continue
+               file=$(echo $dir/$name)
+               [ -f "$file" ] && { runtime_dlls+="$file;"; break; }
+       done
+done
+[ -z "$runtime_dlls" ] &&
+       echo "The compiler runtime DLLs could not be found, they might be missing in the final package."
 
 # Get stuff
-[ -e $packagedir/irrlicht-$irrlicht_version.zip ] || wget http://downloads.sourceforge.net/irrlicht/irrlicht-$irrlicht_version.zip \
-       -c -O $packagedir/irrlicht-$irrlicht_version.zip || exit 1
-[ -e $packagedir/zlib125.zip ] || wget http://www.winimage.com/zLibDll/zlib125.zip \
-       -c -O $packagedir/zlib125.zip || exit 1
-[ -e $packagedir/zlib125dll.zip ] || wget http://www.winimage.com/zLibDll/zlib125dll.zip \
-       -c -O $packagedir/zlib125dll.zip || exit 1
-[ -e $packagedir/libogg-$ogg_version-dev.7z ] || wget http://mirror.transact.net.au/sourceforge/w/project/wi/winlibs/libogg/libogg-$ogg_version-dev.7z \
-       -c -O $packagedir/libogg-$ogg_version-dev.7z || exit 1
-[ -e $packagedir/libogg-$ogg_version-dll.7z ] || wget http://mirror.transact.net.au/sourceforge/w/project/wi/winlibs/libogg/libogg-$ogg_version-dll.7z \
-       -c -O $packagedir/libogg-$ogg_version-dll.7z || exit 1
-[ -e $packagedir/libvorbis-$vorbis_version-dev.7z ] || wget http://minetest.ru/bin/libvorbis-$vorbis_version-dev.7z \
-       -c -O $packagedir/libvorbis-$vorbis_version-dev.7z || exit 1
-[ -e $packagedir/libvorbis-$vorbis_version-dll.7z ] || wget http://minetest.ru/bin/libvorbis-$vorbis_version-dll.7z \
-       -c -O $packagedir/libvorbis-$vorbis_version-dll.7z || exit 1
-[ -e $packagedir/libcurl-$curl_version-win32-msvc.zip ] || wget http://curl.haxx.se/download/libcurl-$curl_version-win32-msvc.zip \
-       -c -O $packagedir/libcurl-$curl_version-win32-msvc.zip || exit 1
-wget http://github.com/minetest/minetest/zipball/master \
-       -c -O $packagedir/minetest.zip --tries=3 || (echo "Please download http://github.com/minetest/minetest/zipball/master manually and save it as $packagedir/minetest.zip"; read -s)
-[ -e $packagedir/minetest.zip ] || (echo "minetest.zip not found"; exit 1)
-wget http://github.com/minetest/minetest_game/zipball/master \
-       -c -O $packagedir/minetest_game.zip --tries=3 || (echo "Please download http://github.com/minetest/minetest_game/zipball/master manually and save it as $packagedir/minetest_game.zip"; read -s)
-[ -e $packagedir/minetest_game.zip ] || (echo "minetest_game.zip not found"; exit 1)
-[ -e $packagedir/openal_stripped.zip ] || wget http://minetest.ru/bin/openal_stripped.zip \
-       -c -O $packagedir/openal_stripped.zip || exit 1
-[ -e $packagedir/mingwm10.dll ] || wget http://minetest.ru/bin/mingwm10.dll \
-       -c -O $packagedir/mingwm10.dll || exit 1
-
-
-# Figure out some path names from the packages
-minetestdirname=`unzip -l $packagedir/minetest.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'`
-minetestdir=$builddir/$minetestdirname || exit 1
-git_hash=`echo $minetestdirname | sed -e 's/minetest-minetest-//'`
-minetest_gamedirname=`unzip -l $packagedir/minetest_game.zip | head -n 7 | tail -n 1 | sed -e 's/^[^m]*//' -e 's/\/.*$//'`
-
-# Extract stuff
-cd $libdir || exit 1
-unzip -o $packagedir/irrlicht-$irrlicht_version.zip || exit 1
-unzip -o $packagedir/zlib125.zip || exit 1
-unzip -o $packagedir/zlib125dll.zip -d zlib125dll || exit 1
-7z x -y -olibogg $packagedir/libogg-$ogg_version-dev.7z || exit 1
-7z x -y -olibogg $packagedir/libogg-$ogg_version-dll.7z || exit 1
-7z x -y -olibvorbis $packagedir/libvorbis-$vorbis_version-dev.7z || exit 1
-7z x -y -olibvorbis $packagedir/libvorbis-$vorbis_version-dll.7z || exit 1
-unzip -o $packagedir/libcurl-$curl_version-win32-msvc.zip -d libcurl || exit 1
-unzip -o $packagedir/openal_stripped.zip || exit 1
-cd $builddir || exit 1
-unzip -o $packagedir/minetest.zip || exit 1
-
-# Symlink minetestdir
-rm -rf $builddir/minetest
-ln -s $minetestdir $builddir/minetest
-
-# Extract minetest_game
-cd $minetestdir/games || exit 1
-rm -rf minetest_game || exit 1
-unzip -o $packagedir/minetest_game.zip || exit 1
-minetest_gamedir=$minetestdir/games/$minetest_gamedirname || exit 1
-mv $minetest_gamedir $minetestdir/games/minetest_game || exit 1
+irrlicht_version=1.9.0mt5
+ogg_version=1.3.5
+openal_version=1.21.1
+vorbis_version=1.3.7
+curl_version=7.81.0
+gettext_version=0.20.1
+freetype_version=2.11.1
+sqlite3_version=3.37.2
+luajit_version=2.1.0-beta3
+leveldb_version=1.23
+zlib_version=1.2.11
+zstd_version=1.5.2
+
+mkdir -p $libdir
+
+download () {
+       local url=$1
+       local filename=$2
+       [ -z "$filename" ] && filename=${url##*/}
+       local foldername=${filename%%[.-]*}
+       local extract=$3
+       [ -z "$extract" ] && extract=unzip
+
+       [ -d "./$foldername" ] && return 0
+       wget "$url" -c -O "./$filename"
+       if [ "$extract" = "unzip" ]; then
+               unzip -o "$filename" -d "$foldername"
+       elif [ "$extract" = "unzip_nofolder" ]; then
+               unzip -o "$filename"
+       else
+               return 1
+       fi
+}
+
+# 'dw2' just points to rebuilt versions after a toolchain change
+# this distinction should be gotten rid of next time
+
+cd $libdir
+download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win32.zip" irrlicht-$irrlicht_version.zip
+download "http://minetest.kitsunemimi.pw/dw2/zlib-$zlib_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/dw2/libvorbis-$vorbis_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/curl-$curl_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/dw2/gettext-$gettext_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win32.zip" freetype-$freetype_version.zip
+download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/dw2/luajit-$luajit_version-win32.zip"
+download "http://minetest.kitsunemimi.pw/dw2/libleveldb-$leveldb_version-win32.zip" leveldb-$leveldb_version.zip
+download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win32.zip"
+
+# Set source dir, downloading Minetest as needed
+if [ -n "$EXISTING_MINETEST_DIR" ]; then
+       sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
+else
+       cd $builddir
+       sourcedir=$PWD/$CORE_NAME
+       [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
+               git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
+       if [ -z "$NO_MINETEST_GAME" ]; then
+               cd $sourcedir
+               [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
+                       git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
+       fi
+fi
+
+git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
 
 # Build the thing
-cd $minetestdir || exit 1
-mkdir -p build || exit 1
-cd build || exit 1
-cmake $minetestdir -DCMAKE_TOOLCHAIN_FILE=$toolchain_file -DENABLE_SOUND=1 \
-       -DIRRLICHT_INCLUDE_DIR=$libdir/irrlicht-$irrlicht_version/include \
-       -DIRRLICHT_LIBRARY=$libdir/irrlicht-$irrlicht_version/lib/Win32-gcc/libIrrlicht.dll.a \
-       -DIRRLICHT_DLL=$libdir/irrlicht-$irrlicht_version/bin/Win32-gcc/Irrlicht.dll \
-       -DZLIB_INCLUDE_DIR=$libdir/zlib-1.2.5 \
-       -DZLIB_LIBRARIES=$libdir/zlib125dll/dll32/zlibwapi.lib \
-       -DZLIB_DLL=$libdir/zlib125dll/dll32/zlibwapi.dll \
+cd $builddir
+[ -d build ] && rm -rf build
+
+irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
+vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
+gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
+
+cmake -S $sourcedir -B build \
+       -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
+       -DCMAKE_INSTALL_PREFIX=/tmp \
+       -DVERSION_EXTRA=$git_hash \
+       -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
+       -DEXTRA_DLL="$runtime_dlls" \
+       \
+       -DENABLE_SOUND=1 \
+       -DENABLE_CURL=1 \
+       -DENABLE_GETTEXT=1 \
+       -DENABLE_LEVELDB=1 \
+       \
+       -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
+       -DIRRLICHT_DLL="$irr_dlls" \
+       \
+       -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
+       -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
+       -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
+       \
+       -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
+       -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
+       -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
+       \
+       -DLUA_INCLUDE_DIR=$libdir/luajit/include \
+       -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
+       \
        -DOGG_INCLUDE_DIR=$libdir/libogg/include \
        -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
        -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
+       \
        -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
        -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
-       -DVORBIS_DLL=$libdir/libvorbis/bin/libvorbis-0.dll \
+       -DVORBIS_DLL="$vorbis_dlls" \
        -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
-       -DVORBISFILE_DLL=$libdir/libvorbis/bin/libvorbisfile-3.dll \
-       -DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include \
-       -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/OpenAL32.lib \
-       -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
-       -DENABLE_CURL=1 \
-       -DCURL_DLL=$libdir/libcurl/libcurl.dll \
-       -DCURL_INCLUDE_DIR=$libdir/libcurl/include \
-       -DCURL_LIBRARY=$libdir/libcurl/libcurl.lib \
-       -DMINGWM10_DLL=$packagedir/mingwm10.dll \
-       -DCMAKE_INSTALL_PREFIX=/tmp \
-       -DVERSION_EXTRA=$git_hash \
-       || exit 1
-make -j2 package || exit 1
+       \
+       -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \
+       -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \
+       -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \
+       \
+       -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
+       -DCURL_INCLUDE_DIR=$libdir/curl/include \
+       -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
+       \
+       -DGETTEXT_MSGFMT=`command -v msgfmt` \
+       -DGETTEXT_DLL="$gettext_dlls" \
+       -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
+       -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
+       \
+       -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
+       -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
+       -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
+       -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
+       \
+       -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
+       -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
+       -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
+       \
+       -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
+       -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
+       -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
+
+cmake --build build -j$(nproc)
 
-#pubdir=/home/celeron55/public_html/random/`date +%Y-%m` || exit 1
-#mkdir -p $pubdir || exit 1
-#cp *autobuild*.zip $pubdir/ || exit 1
+[ -z "$NO_PACKAGE" ] && cmake --build build --target package
 
+exit 0
 # EOF