]> git.lizzy.rs Git - dragonfireclient.git/blob - util/buildbot/buildwin64.sh
c1e446d3917c79761fab90102b35f9f736dc677e
[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.0mt5
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 fi
119
120 git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
121
122 # Build the thing
123 cd $builddir
124 [ -d build ] && rm -rf build
125
126 irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
127 vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
128 gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
129
130 cmake -S $sourcedir -B build \
131         -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
132         -DCMAKE_INSTALL_PREFIX=/tmp \
133         -DVERSION_EXTRA=$git_hash \
134         -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
135         -DEXTRA_DLL="$runtime_dlls" \
136         \
137         -DENABLE_SOUND=1 \
138         -DENABLE_CURL=1 \
139         -DENABLE_GETTEXT=1 \
140         -DENABLE_LEVELDB=1 \
141         \
142         -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
143         -DIRRLICHT_DLL="$irr_dlls" \
144         \
145         -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
146         -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
147         -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
148         \
149         -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
150         -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
151         -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
152         \
153         -DLUA_INCLUDE_DIR=$libdir/luajit/include \
154         -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
155         \
156         -DOGG_INCLUDE_DIR=$libdir/libogg/include \
157         -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
158         -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
159         \
160         -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
161         -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
162         -DVORBIS_DLL="$vorbis_dlls" \
163         -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
164         \
165         -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \
166         -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \
167         -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \
168         \
169         -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
170         -DCURL_INCLUDE_DIR=$libdir/curl/include \
171         -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
172         \
173         -DGETTEXT_MSGFMT=`command -v msgfmt` \
174         -DGETTEXT_DLL="$gettext_dlls" \
175         -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
176         -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
177         \
178         -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
179         -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
180         -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
181         -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
182         \
183         -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
184         -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
185         -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
186         \
187         -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
188         -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
189         -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
190
191 cmake --build build -j$(nproc)
192
193 [ -z "$NO_PACKAGE" ] && cmake --build build --target package
194
195 exit 0
196 # EOF