ci-build-mingw.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/bash -e
  2. topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. [[ -z "$CC" || -z "$CXX" ]] && exit 255
  4. variant=win32
  5. [[ "$(basename "$CXX")" == "x86_64-"* ]] && variant=win64
  6. with_sdl=0
  7. [[ "$extras" == *"-sdl"* ]] && with_sdl=1
  8. #with_gl3=0
  9. #[[ "$extras" == *"-gl3"* ]] && with_gl3=1
  10. libjpeg_version=3.0.1
  11. libpng_version=1.6.40
  12. sdl2_version=2.28.5
  13. zlib_version=1.3.1
  14. download () {
  15. local url=$1
  16. local filename=${url##*/}
  17. local foldername=${filename%%[.-]*}
  18. [ -d "./$foldername" ] && return 0
  19. [ -e "$filename" ] || wget "$url" -O "$filename"
  20. sha256sum -w -c <(grep -F "$filename" "$topdir/sha256sums.txt")
  21. unzip -o "$filename" -d "$foldername"
  22. }
  23. libs=$PWD/libs
  24. mkdir -p libs
  25. pushd libs
  26. libhost="http://minetest.kitsunemimi.pw"
  27. download "$libhost/llvm/libjpeg-$libjpeg_version-$variant.zip"
  28. download "$libhost/llvm/libpng-$libpng_version-$variant.zip"
  29. [ $with_sdl -eq 1 ] && download "$libhost/llvm/sdl2-$sdl2_version-$variant.zip"
  30. download "$libhost/llvm/zlib-$zlib_version-$variant.zip"
  31. popd
  32. tmp=(
  33. -DCMAKE_SYSTEM_NAME=Windows \
  34. -DPNG_LIBRARY=$libs/libpng/lib/libpng.dll.a \
  35. -DPNG_PNG_INCLUDE_DIR=$libs/libpng/include \
  36. -DJPEG_LIBRARY=$libs/libjpeg/lib/libjpeg.dll.a \
  37. -DJPEG_INCLUDE_DIR=$libs/libjpeg/include \
  38. -DZLIB_LIBRARY=$libs/zlib/lib/libz.dll.a \
  39. -DZLIB_INCLUDE_DIR=$libs/zlib/include
  40. )
  41. if [ $with_sdl -eq 1 ]; then
  42. tmp+=(
  43. -DUSE_SDL2=ON
  44. -DCMAKE_PREFIX_PATH=$libs/sdl2/lib/cmake
  45. )
  46. else
  47. tmp+=(-DUSE_SDL2=OFF)
  48. fi
  49. #[ $with_gl3 -eq 1 ] && tmp+=(-DENABLE_OPENGL=OFF -DENABLE_OPENGL3=ON)
  50. cmake . "${tmp[@]}"
  51. make -j$(nproc)
  52. if [ "$1" = "package" ]; then
  53. make DESTDIR=$PWD/_install install
  54. # strip library
  55. "${CXX%-*}-strip" --strip-unneeded _install/usr/local/lib/*.dll
  56. # bundle the DLLs that are specific to Irrlicht (kind of a hack)
  57. shopt -s nullglob
  58. cp -p $libs/*/bin/{libjpeg,libpng,SDL}*.dll _install/usr/local/lib/
  59. # create a ZIP
  60. (cd _install/usr/local; zip -9r "$OLDPWD/irrlicht-$variant$extras.zip" -- *)
  61. fi
  62. exit 0