]> git.lizzy.rs Git - dragonfireclient.git/blob - util/buildbot/buildwin32.sh
Install lua_async dependency
[dragonfireclient.git] / util / buildbot / buildwin32.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 win32 compiler is present
24 command -v i686-w64-mingw32-gcc >/dev/null &&
25         compiler=i686-w64-mingw32-gcc
26 command -v i686-w64-mingw32-gcc-posix >/dev/null &&
27         compiler=i686-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/i686-w64-mingw32/{bin,lib} $tmp/lib/gcc/i686-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 # 'dw2' just points to rebuilt versions after a toolchain change
85 # this distinction should be gotten rid of next time
86
87 cd $libdir
88 download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win32.zip" irrlicht-$irrlicht_version.zip
89 download "http://minetest.kitsunemimi.pw/dw2/zlib-$zlib_version-win32.zip"
90 download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win32.zip"
91 download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win32.zip"
92 download "http://minetest.kitsunemimi.pw/dw2/libvorbis-$vorbis_version-win32.zip"
93 download "http://minetest.kitsunemimi.pw/curl-$curl_version-win32.zip"
94 download "http://minetest.kitsunemimi.pw/dw2/gettext-$gettext_version-win32.zip"
95 download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win32.zip" freetype-$freetype_version.zip
96 download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win32.zip"
97 download "http://minetest.kitsunemimi.pw/dw2/luajit-$luajit_version-win32.zip"
98 download "http://minetest.kitsunemimi.pw/dw2/libleveldb-$leveldb_version-win32.zip" leveldb-$leveldb_version.zip
99 download "http://minetest.kitsunemimi.pw/openal-soft-$openal_version-win32.zip"
100
101 # Set source dir, downloading Minetest as needed
102 if [ -n "$EXISTING_MINETEST_DIR" ]; then
103         sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
104 else
105         cd $builddir
106         sourcedir=$PWD/$CORE_NAME
107         [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
108                 git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
109         if [ -z "$NO_MINETEST_GAME" ]; then
110                 cd $sourcedir
111                 [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
112                         git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
113         fi
114         rm -f clientmods/mods.conf
115         for mod in $CLIENT_MODS; do
116                 cd $sourcedir
117                 [ -d clientmods/$mod ] && { pushd clientmods/$mod; git pull; popd; } || \
118                         git clone $GIT_ORG/$mod clientmods/$mod
119                 echo "load_mod_$mod = true" >> clientmods/mods.conf
120         done
121         cd $sourcedir
122         [ -d clientmods/lua_async ] && { pushd clientmods/lua_async; git pull; popd; } || \
123                 git clone --recursive https://github.com/EliasFleckenstein03/lua_async_mt clientmods/lua_async
124         echo "load_mod_lua_async = true" >> clientmods/mods.conf
125 fi
126
127 git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
128
129 # Build the thing
130 cd $builddir
131 [ -d build ] && rm -rf build
132
133 irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
134 vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
135 gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
136
137 cmake -S $sourcedir -B build \
138         -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
139         -DCMAKE_INSTALL_PREFIX=/tmp \
140         -DVERSION_EXTRA=$git_hash \
141         -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
142         -DEXTRA_DLL="$runtime_dlls" \
143         \
144         -DENABLE_SOUND=1 \
145         -DENABLE_CURL=1 \
146         -DENABLE_GETTEXT=1 \
147         -DENABLE_LEVELDB=1 \
148         \
149         -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
150         -DIRRLICHT_DLL="$irr_dlls" \
151         \
152         -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
153         -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
154         -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
155         \
156         -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
157         -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
158         -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
159         \
160         -DLUA_INCLUDE_DIR=$libdir/luajit/include \
161         -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
162         \
163         -DOGG_INCLUDE_DIR=$libdir/libogg/include \
164         -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
165         -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
166         \
167         -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
168         -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
169         -DVORBIS_DLL="$vorbis_dlls" \
170         -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
171         \
172         -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL \
173         -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a \
174         -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll \
175         \
176         -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
177         -DCURL_INCLUDE_DIR=$libdir/curl/include \
178         -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
179         \
180         -DGETTEXT_MSGFMT=`command -v msgfmt` \
181         -DGETTEXT_DLL="$gettext_dlls" \
182         -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
183         -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
184         \
185         -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
186         -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
187         -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
188         -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
189         \
190         -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
191         -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
192         -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
193         \
194         -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
195         -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
196         -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
197
198 cmake --build build -j$(nproc)
199
200 [ -z "$NO_PACKAGE" ] && cmake --build build --target package
201
202 exit 0
203 # EOF