]> git.lizzy.rs Git - dragonfireclient.git/blob - util/buildbot/buildwin64.sh
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / util / buildbot / buildwin64.sh
1 #!/bin/bash
2 set -e
3
4 GIT_ORG=https://github.com/dragonfireclient
5 CORE_GIT=$GIT_ORG/dragonfireclient
6 CORE_BRANCH=master
7 CORE_NAME=dragonfireclient
8 GAME_GIT=https://git.minetest.land/MineClone2/MineClone2
9 GAME_BRANCH=master
10 GAME_NAME=MineClone2
11 CLIENT_MODS="autotool diglib digcustom nametags autokey autoeat invutil killaura worldutil physics_override noweather chateffects simpletp"
12
13 dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14 if [ $# -ne 1 ]; then
15         echo "Usage: $0 <build directory>"
16         exit 1
17 fi
18 builddir=$1
19 mkdir -p $builddir
20 builddir="$( cd "$builddir" && pwd )"
21 libdir=$builddir/libs
22
23 # Test which win64 compiler is present
24 command -v x86_64-w64-mingw32-gcc >/dev/null &&
25         compiler=x86_64-w64-mingw32-gcc
26 command -v x86_64-w64-mingw32-gcc-posix >/dev/null &&
27         compiler=x86_64-w64-mingw32-gcc-posix
28
29 if [ -z "$compiler" ]; then
30         echo "Unable to determine which MinGW compiler to use"
31         exit 1
32 fi
33 toolchain_file=$dir/toolchain_${compiler/-gcc/}.cmake
34 echo "Using $toolchain_file"
35
36 # Try to find runtime DLLs in various paths (varies by distribution, sigh)
37 tmp=$(dirname "$(command -v $compiler)")/..
38 runtime_dlls=
39 for name in lib{gcc_,stdc++-,winpthread-}'*'.dll; do
40         for dir in $tmp/x86_64-w64-mingw32/{bin,lib} $tmp/lib/gcc/x86_64-w64-mingw32/*; do
41                 [ -d "$dir" ] || continue
42                 file=$(echo $dir/$name)
43                 [ -f "$file" ] && { runtime_dlls+="$file;"; break; }
44         done
45 done
46 [ -z "$runtime_dlls" ] &&
47         echo "The compiler runtime DLLs could not be found, they might be missing in the final package."
48
49 # Get stuff
50 irrlicht_version=1.9.0mt6
51 ogg_version=1.3.5
52 openal_version=1.21.1
53 vorbis_version=1.3.7
54 curl_version=7.81.0
55 gettext_version=0.20.1
56 freetype_version=2.11.1
57 sqlite3_version=3.37.2
58 luajit_version=2.1.0-beta3
59 leveldb_version=1.23
60 zlib_version=1.2.11
61 zstd_version=1.5.2
62
63 mkdir -p $libdir
64
65 download () {
66         local url=$1
67         local filename=$2
68         [ -z "$filename" ] && filename=${url##*/}
69         local foldername=${filename%%[.-]*}
70         local extract=$3
71         [ -z "$extract" ] && extract=unzip
72
73         [ -d "./$foldername" ] && return 0
74         wget "$url" -c -O "./$filename"
75         if [ "$extract" = "unzip" ]; then
76                 unzip -o "$filename" -d "$foldername"
77         elif [ "$extract" = "unzip_nofolder" ]; then
78                 unzip -o "$filename"
79         else
80                 return 1
81         fi
82 }
83
84 cd $libdir
85 download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win64.zip" irrlicht-$irrlicht_version.zip
86 download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-win64.zip"
87 download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win64.zip"
88 download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win64.zip"
89 download "http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win64.zip"
90 download "http://minetest.kitsunemimi.pw/curl-$curl_version-win64.zip"
91 download "http://minetest.kitsunemimi.pw/gettext-$gettext_version-win64.zip"
92 download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip" freetype-$freetype_version.zip
93 download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip"
94 download "http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip"
95 download "http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip" leveldb-$leveldb_version.zip
96 download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win64.zip"
97
98 # Set source dir, downloading Minetest as needed
99 if [ -n "$EXISTING_MINETEST_DIR" ]; then
100         sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
101 else
102         cd $builddir
103         sourcedir=$PWD/$CORE_NAME
104         [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
105                 git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
106         if [ -z "$NO_MINETEST_GAME" ]; then
107                 cd $sourcedir
108                 [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
109                         git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
110         fi
111         rm -f clientmods/mods.conf
112         for mod in $CLIENT_MODS; do
113                 cd $sourcedir
114                 [ -d clientmods/$mod ] && { pushd clientmods/$mod; git pull; popd; } || \
115                         git clone $GIT_ORG/$mod clientmods/$mod
116                 echo "load_mod_$mod = true" >> clientmods/mods.conf
117         done
118         cd $sourcedir
119         [ -d clientmods/lua_async ] && { pushd clientmods/lua_async; git pull; popd; } || \
120                 git clone --recursive https://github.com/EliasFleckenstein03/lua_async_mt clientmods/lua_async
121         echo "load_mod_lua_async = true" >> clientmods/mods.conf
122 fi
123
124 git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
125
126 # Build the thing
127 cd $builddir
128 [ -d build ] && rm -rf build
129
130 irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
131 vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
132 gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
133
134 cmake -S $sourcedir -B build \
135         -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
136         -DCMAKE_INSTALL_PREFIX=/tmp \
137         -DVERSION_EXTRA=$git_hash \
138         -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
139         -DEXTRA_DLL="$runtime_dlls" \
140         \
141         -DENABLE_SOUND=1 \
142         -DENABLE_CURL=1 \
143         -DENABLE_GETTEXT=1 \
144         -DENABLE_LEVELDB=1 \
145         \
146         -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
147         -DIRRLICHT_DLL="$irr_dlls" \
148         \
149         -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
150         -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
151         -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
152         \
153         -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
154         -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
155         -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
156         \
157         -DLUA_INCLUDE_DIR=$libdir/luajit/include \
158         -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
159         \
160         -DOGG_INCLUDE_DIR=$libdir/libogg/include \
161         -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
162         -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
163         \
164         -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
165         -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
166         -DVORBIS_DLL="$vorbis_dlls" \
167         -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
168         \
169         -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \
170         -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \
171         -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \
172         \
173         -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
174         -DCURL_INCLUDE_DIR=$libdir/curl/include \
175         -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
176         \
177         -DGETTEXT_MSGFMT=`command -v msgfmt` \
178         -DGETTEXT_DLL="$gettext_dlls" \
179         -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
180         -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
181         \
182         -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
183         -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
184         -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
185         -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
186         \
187         -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
188         -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
189         -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
190         \
191         -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
192         -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
193         -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
194
195 cmake --build build -j$(nproc)
196
197 [ -z "$NO_PACKAGE" ] && cmake --build build --target package
198
199 exit 0
200 # EOF