buildwin64.sh 6.0 KB

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