]> git.lizzy.rs Git - dragonfireclient.git/blob - util/buildbot/buildwin64.sh
Fix some issues with buildbot scripts (#11860)
[dragonfireclient.git] / util / buildbot / buildwin64.sh
1 #!/bin/bash
2 set -e
3
4 CORE_GIT=https://github.com/minetest/minetest
5 CORE_BRANCH=master
6 CORE_NAME=minetest
7 GAME_GIT=https://github.com/minetest/minetest_game
8 GAME_BRANCH=master
9 GAME_NAME=minetest_game
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 win64 compiler is present
22 command -v x86_64-w64-mingw32-gcc >/dev/null &&
23         compiler=x86_64-w64-mingw32-gcc
24 command -v x86_64-w64-mingw32-gcc-posix >/dev/null &&
25         compiler=x86_64-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/x86_64-w64-mingw32/{bin,lib} $tmp/lib/gcc/x86_64-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.0mt3
49 ogg_version=1.3.4
50 vorbis_version=1.3.7
51 curl_version=7.76.1
52 gettext_version=0.20.1
53 freetype_version=2.10.4
54 sqlite3_version=3.35.5
55 luajit_version=2.1.0-beta3
56 leveldb_version=1.23
57 zlib_version=1.2.11
58 zstd_version=1.4.9
59
60 mkdir -p $libdir
61
62 download () {
63         local url=$1
64         local filename=$2
65         [ -z "$filename" ] && filename=${url##*/}
66         local foldername=${filename%%[.-]*}
67         local extract=$3
68         [ -z "$extract" ] && extract=unzip
69
70         [ -d "./$foldername" ] && return 0
71         wget "$url" -c -O "./$filename"
72         if [ "$extract" = "unzip" ]; then
73                 unzip -o "$filename" -d "$foldername"
74         elif [ "$extract" = "unzip_nofolder" ]; then
75                 unzip -o "$filename"
76         else
77                 return 1
78         fi
79 }
80
81 cd $libdir
82 download "https://github.com/minetest/irrlicht/releases/download/$irrlicht_version/win64.zip" irrlicht-$irrlicht_version.zip
83 download "http://minetest.kitsunemimi.pw/zlib-$zlib_version-win64.zip"
84 download "http://minetest.kitsunemimi.pw/zstd-$zstd_version-win64.zip"
85 download "http://minetest.kitsunemimi.pw/libogg-$ogg_version-win64.zip"
86 download "http://minetest.kitsunemimi.pw/libvorbis-$vorbis_version-win64.zip"
87 download "http://minetest.kitsunemimi.pw/curl-$curl_version-win64.zip"
88 download "http://minetest.kitsunemimi.pw/gettext-$gettext_version-win64.zip"
89 download "http://minetest.kitsunemimi.pw/freetype2-$freetype_version-win64.zip" freetype-$freetype_version.zip
90 download "http://minetest.kitsunemimi.pw/sqlite3-$sqlite3_version-win64.zip"
91 download "http://minetest.kitsunemimi.pw/luajit-$luajit_version-win64.zip"
92 download "http://minetest.kitsunemimi.pw/libleveldb-$leveldb_version-win64.zip" leveldb-$leveldb_version.zip
93 download "http://minetest.kitsunemimi.pw/openal_stripped64.zip" 'openal_stripped.zip' unzip_nofolder
94
95 # Set source dir, downloading Minetest as needed
96 if [ -n "$EXISTING_MINETEST_DIR" ]; then
97         sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
98 else
99         cd $builddir
100         sourcedir=$PWD/$CORE_NAME
101         [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull; popd; } || \
102                 git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
103         if [ -z "$NO_MINETEST_GAME" ]; then
104                 cd $sourcedir
105                 [ -d games/$GAME_NAME ] && { pushd games/$GAME_NAME; git pull; popd; } || \
106                         git clone -b $GAME_BRANCH $GAME_GIT games/$GAME_NAME
107         fi
108 fi
109
110 git_hash=$(cd $sourcedir && git rev-parse --short HEAD)
111
112 # Build the thing
113 cd $builddir
114 [ -d build ] && rm -rf build
115 mkdir build
116 cd build
117
118 irr_dlls=$(echo $libdir/irrlicht/lib/*.dll | tr ' ' ';')
119 vorbis_dlls=$(echo $libdir/libvorbis/bin/libvorbis{,file}-*.dll | tr ' ' ';')
120 gettext_dlls=$(echo $libdir/gettext/bin/lib{intl,iconv}-*.dll | tr ' ' ';')
121
122 cmake -S $sourcedir -B . \
123         -DCMAKE_TOOLCHAIN_FILE=$toolchain_file \
124         -DCMAKE_INSTALL_PREFIX=/tmp \
125         -DVERSION_EXTRA=$git_hash \
126         -DBUILD_CLIENT=1 -DBUILD_SERVER=0 \
127         -DEXTRA_DLL="$runtime_dlls" \
128         \
129         -DENABLE_SOUND=1 \
130         -DENABLE_CURL=1 \
131         -DENABLE_GETTEXT=1 \
132         -DENABLE_FREETYPE=1 \
133         -DENABLE_LEVELDB=1 \
134         \
135         -DCMAKE_PREFIX_PATH=$libdir/irrlicht \
136         -DIRRLICHT_DLL="$irr_dlls" \
137         \
138         -DZLIB_INCLUDE_DIR=$libdir/zlib/include \
139         -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a \
140         -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll \
141         \
142         -DZSTD_INCLUDE_DIR=$libdir/zstd/include \
143         -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a \
144         -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll \
145         \
146         -DLUA_INCLUDE_DIR=$libdir/luajit/include \
147         -DLUA_LIBRARY=$libdir/luajit/libluajit.a \
148         \
149         -DOGG_INCLUDE_DIR=$libdir/libogg/include \
150         -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a \
151         -DOGG_DLL=$libdir/libogg/bin/libogg-0.dll \
152         \
153         -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include \
154         -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a \
155         -DVORBIS_DLL="$vorbis_dlls" \
156         -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a \
157         \
158         -DOPENAL_INCLUDE_DIR=$libdir/openal_stripped/include/AL \
159         -DOPENAL_LIBRARY=$libdir/openal_stripped/lib/libOpenAL32.dll.a \
160         -DOPENAL_DLL=$libdir/openal_stripped/bin/OpenAL32.dll \
161         \
162         -DCURL_DLL=$libdir/curl/bin/libcurl-4.dll \
163         -DCURL_INCLUDE_DIR=$libdir/curl/include \
164         -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a \
165         \
166         -DGETTEXT_MSGFMT=`command -v msgfmt` \
167         -DGETTEXT_DLL="$gettext_dlls" \
168         -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include \
169         -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a \
170         \
171         -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2 \
172         -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2 \
173         -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a \
174         -DFREETYPE_DLL=$libdir/freetype/bin/libfreetype-6.dll \
175         \
176         -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include \
177         -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a \
178         -DSQLITE3_DLL=$libdir/sqlite3/bin/libsqlite3-0.dll \
179         \
180         -DLEVELDB_INCLUDE_DIR=$libdir/leveldb/include \
181         -DLEVELDB_LIBRARY=$libdir/leveldb/lib/libleveldb.dll.a \
182         -DLEVELDB_DLL=$libdir/leveldb/bin/libleveldb.dll
183
184 make -j$(nproc)
185
186 [ -z "$NO_PACKAGE" ] && make package
187
188 exit 0
189 # EOF