You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build_windows.sh 1.9 KiB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Cross compile for Windows from Linux
  3. set -e
  4. TEMP_PATH="$(pwd)/winpath"
  5. BUILD_DIR="winbuild"
  6. # Build zlib from source
  7. if [ ! -d "zlib" ]; then
  8. git clone --depth 1 -b v1.2.13 https://github.com/madler/zlib && cd zlib
  9. cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH
  10. cmake --build build -j$(nproc)
  11. cmake --build build --target install
  12. cd ..
  13. fi
  14. # Build libpng from source
  15. if [ ! -d "libpng" ]; then
  16. git clone --depth 1 -b v1.6.39 https://github.com/glennrp/libpng && cd libpng
  17. cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH
  18. cmake --build build -j$(nproc)
  19. cmake --build build --target install
  20. cd ..
  21. fi
  22. # Download libsndfile
  23. if [ ! -d libsndfile-1.2.0-win64 ]; then
  24. wget https://github.com/libsndfile/libsndfile/releases/download/1.2.0/libsndfile-1.2.0-win64.zip
  25. unzip libsndfile-1.2.0-win64.zip
  26. cp "libsndfile-1.2.0-win64/bin/sndfile.dll" $TEMP_PATH/bin
  27. cp "libsndfile-1.2.0-win64/include/sndfile.h" $TEMP_PATH/include
  28. cp "libsndfile-1.2.0-win64/lib/sndfile.lib" $TEMP_PATH/lib
  29. fi
  30. find_dll() {
  31. filename=$(x86_64-w64-mingw32-gcc -print-file-name=$1)
  32. if [ -f $filename ]; then
  33. echo $filename
  34. else
  35. filename=$(x86_64-w64-mingw32-gcc -print-sysroot)/mingw/bin/$1
  36. if [ -f $filename ]; then
  37. echo $filename
  38. else
  39. echo "Could not find $1" >&2
  40. return 1
  41. fi
  42. fi
  43. }
  44. # Copy required GCC libs
  45. cp $(find_dll libgcc_s_seh-1.dll) $TEMP_PATH/bin
  46. cp $(find_dll libwinpthread-1.dll) $TEMP_PATH/bin
  47. # Build aptdec
  48. cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH
  49. cmake --build $BUILD_DIR -j$(nproc)
  50. cmake --build $BUILD_DIR --target package