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