common.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. CORE_GIT=https://github.com/minetest/minetest
  2. CORE_BRANCH=master
  3. CORE_NAME=minetest
  4. ogg_version=1.3.5
  5. openal_version=1.23.1
  6. vorbis_version=1.3.7
  7. curl_version=8.5.0
  8. gettext_version=0.20.2
  9. freetype_version=2.13.2
  10. sqlite3_version=3.44.2
  11. luajit_version=20240125
  12. leveldb_version=1.23
  13. zlib_version=1.3.1
  14. zstd_version=1.5.5
  15. libjpeg_version=3.0.1
  16. libpng_version=1.6.40
  17. download () {
  18. local url=$1
  19. local filename=$2
  20. [ -z "$filename" ] && filename=${url##*/}
  21. local foldername=${filename%%[.-]*}
  22. local extract=${3:-unzip}
  23. [ -d "./$foldername" ] && return 0
  24. wget "$url" -c -O "./$filename"
  25. sha256sum -w -c <(grep -F "$filename" "$topdir/sha256sums.txt")
  26. if [ "$extract" = "unzip" ]; then
  27. unzip -o "$filename" -d "$foldername"
  28. elif [ "$extract" = "unzip_nofolder" ]; then
  29. unzip -o "$filename"
  30. else
  31. return 1
  32. fi
  33. }
  34. # sets $sourcedir
  35. get_sources () {
  36. if [ -n "$EXISTING_MINETEST_DIR" ]; then
  37. sourcedir="$( cd "$EXISTING_MINETEST_DIR" && pwd )"
  38. return
  39. fi
  40. cd $builddir
  41. sourcedir=$PWD/$CORE_NAME
  42. [ -d $CORE_NAME ] && { pushd $CORE_NAME; git pull --ff-only; popd; } || \
  43. git clone -b $CORE_BRANCH $CORE_GIT $CORE_NAME
  44. }
  45. # sets $runtime_dlls
  46. find_runtime_dlls () {
  47. local triple=$1
  48. # Try to find runtime DLLs in various paths
  49. local tmp=$(dirname "$(command -v $compiler)")/..
  50. runtime_dlls=
  51. for name in lib{clang_rt,c++,unwind,winpthread-}'*'.dll; do
  52. for dir in $tmp/$triple/{bin,lib}; do
  53. [ -d "$dir" ] || continue
  54. local file=$(echo $dir/$name)
  55. [ -f "$file" ] && { runtime_dlls+="$file;"; break; }
  56. done
  57. done
  58. if [ -z "$runtime_dlls" ]; then
  59. echo "The compiler runtime DLLs could not be found, they might be missing in the final package."
  60. else
  61. echo "Found DLLs: $runtime_dlls"
  62. fi
  63. }
  64. _dlls () {
  65. for f in "$@"; do
  66. if [ ! -e "$f" ]; then
  67. echo "Could not find $f" >&2
  68. elif [[ -f "$f" && "$f" == *.dll ]]; then
  69. printf '%s;' "$f"
  70. fi
  71. done
  72. }
  73. add_cmake_libs () {
  74. cmake_args+=(
  75. -DPNG_LIBRARY=$libdir/libpng/lib/libpng.dll.a
  76. -DPNG_PNG_INCLUDE_DIR=$libdir/libpng/include
  77. -DPNG_DLL="$(_dlls $libdir/libpng/bin/*)"
  78. -DJPEG_LIBRARY=$libdir/libjpeg/lib/libjpeg.dll.a
  79. -DJPEG_INCLUDE_DIR=$libdir/libjpeg/include
  80. -DJPEG_DLL="$(_dlls $libdir/libjpeg/bin/libjpeg*)"
  81. -DZLIB_INCLUDE_DIR=$libdir/zlib/include
  82. -DZLIB_LIBRARY=$libdir/zlib/lib/libz.dll.a
  83. -DZLIB_DLL=$libdir/zlib/bin/zlib1.dll
  84. -DZSTD_INCLUDE_DIR=$libdir/zstd/include
  85. -DZSTD_LIBRARY=$libdir/zstd/lib/libzstd.dll.a
  86. -DZSTD_DLL=$libdir/zstd/bin/libzstd.dll
  87. -DLUA_INCLUDE_DIR=$libdir/luajit/include
  88. -DLUA_LIBRARY=$libdir/luajit/libluajit.a
  89. -DOGG_INCLUDE_DIR=$libdir/libogg/include
  90. -DOGG_LIBRARY=$libdir/libogg/lib/libogg.dll.a
  91. -DOGG_DLL="$(_dlls $libdir/libogg/bin/*)"
  92. -DVORBIS_INCLUDE_DIR=$libdir/libvorbis/include
  93. -DVORBIS_LIBRARY=$libdir/libvorbis/lib/libvorbis.dll.a
  94. -DVORBIS_DLL="$(_dlls $libdir/libvorbis/bin/libvorbis{,file}[-.]*)"
  95. -DVORBISFILE_LIBRARY=$libdir/libvorbis/lib/libvorbisfile.dll.a
  96. -DOPENAL_INCLUDE_DIR=$libdir/openal/include/AL
  97. -DOPENAL_LIBRARY=$libdir/openal/lib/libOpenAL32.dll.a
  98. -DOPENAL_DLL=$libdir/openal/bin/OpenAL32.dll
  99. -DCURL_DLL="$(_dlls $libdir/curl/bin/libcurl*)"
  100. -DCURL_INCLUDE_DIR=$libdir/curl/include
  101. -DCURL_LIBRARY=$libdir/curl/lib/libcurl.dll.a
  102. -DGETTEXT_MSGFMT=`command -v msgfmt`
  103. -DGETTEXT_DLL="$(_dlls $libdir/gettext/bin/lib{intl,iconv}*)"
  104. -DGETTEXT_INCLUDE_DIR=$libdir/gettext/include
  105. -DGETTEXT_LIBRARY=$libdir/gettext/lib/libintl.dll.a
  106. -DFREETYPE_INCLUDE_DIR_freetype2=$libdir/freetype/include/freetype2
  107. -DFREETYPE_INCLUDE_DIR_ft2build=$libdir/freetype/include/freetype2
  108. -DFREETYPE_LIBRARY=$libdir/freetype/lib/libfreetype.dll.a
  109. -DFREETYPE_DLL="$(_dlls $libdir/freetype/bin/libfreetype*)"
  110. -DSQLITE3_INCLUDE_DIR=$libdir/sqlite3/include
  111. -DSQLITE3_LIBRARY=$libdir/sqlite3/lib/libsqlite3.dll.a
  112. -DSQLITE3_DLL="$(_dlls $libdir/sqlite3/bin/libsqlite*)"
  113. -DLEVELDB_INCLUDE_DIR=$libdir/libleveldb/include
  114. -DLEVELDB_LIBRARY=$libdir/libleveldb/lib/libleveldb.dll.a
  115. -DLEVELDB_DLL=$libdir/libleveldb/bin/libleveldb.dll
  116. )
  117. }