diff --git a/buildscripts/build_ffmpeg.sh b/buildscripts/build_ffmpeg.sh index 92a922e71..b0de9e552 100755 --- a/buildscripts/build_ffmpeg.sh +++ b/buildscripts/build_ffmpeg.sh @@ -6,45 +6,27 @@ set -euo pipefail -usage() -{ - echo "Download and build ffmpeg for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done - -if [ "$ARCH" != "win32" ] && [ "$ARCH" != "win64" ]; then - echo "Unexpected arch $ARCH" - usage - exit 1 -fi - -"$(dirname "$(realpath "$0")")/download/download_ffmpeg.sh" +parse_arch --dep "ffmpeg" --supported "win32 win64" "$@" if [ "${ARCH}" == "win64" ]; then FFMPEG_ARCH="x86_64" - CROSS_PREFIX="x86_64-w64-mingw32-" else FFMPEG_ARCH="x86" - CROSS_PREFIX="i686-w64-mingw32-" fi +"${SCRIPT_DIR}/download/download_ffmpeg.sh" + ./configure --arch=${FFMPEG_ARCH} \ --enable-gpl \ --enable-shared \ --disable-static \ - --prefix=/windows/ \ + "--prefix=${DEP_PREFIX}" \ --target-os="mingw32" \ - --cross-prefix="${CROSS_PREFIX}" \ + "--cross-prefix=${MINGW_ARCH}-w64-mingw32-" \ --pkg-config="pkg-config" \ --extra-cflags="-O2 -g0" \ --disable-debug \ @@ -88,5 +70,5 @@ fi --enable-decoder=mjpeg \ --enable-decoder=rawvideo -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_gdb_windows.sh b/buildscripts/build_gdb_windows.sh index af5e100e3..ddf384875 100755 --- a/buildscripts/build_gdb_windows.sh +++ b/buildscripts/build_gdb_windows.sh @@ -6,38 +6,18 @@ set -euo pipefail -usage() -{ - echo "Download and build gmp for windows" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +source "${SCRIPT_DIR}/build_utils.sh" -if [ "$ARCH" != "win32" ] && [ "$ARCH" != "win64" ]; then - echo "Unexpected arch $ARCH" - usage - exit 1 -fi +parse_arch --dep "gdb" --supported "win32 win64" "$@" -if [ "${ARCH}" == "win64" ]; then - HOST="x86_64-w64-mingw32" -else - HOST="i686-w64-mingw32" -fi +"${SCRIPT_DIR}/download/download_gdb.sh" -"$(dirname "$(realpath "$0")")/download/download_gdb.sh" - -CFLAGS="-O2 -g0" ./configure --host="${HOST}" \ - --prefix="/windows" \ +CFLAGS="-O2 -g0" ./configure "${HOST_OPTION}" \ + --prefix="${DEP_PREFIX}" \ --enable-static \ --disable-shared -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_gmp_windows.sh b/buildscripts/build_gmp_windows.sh index 1f9d100ab..d472e6910 100755 --- a/buildscripts/build_gmp_windows.sh +++ b/buildscripts/build_gmp_windows.sh @@ -6,38 +6,18 @@ set -euo pipefail -usage() -{ - echo "Download and build gmp for windows" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +source "${SCRIPT_DIR}/build_utils.sh" -if [ "$ARCH" != "win32" ] && [ "$ARCH" != "win64" ]; then - echo "Unexpected arch $ARCH" - usage - exit 1 -fi +parse_arch --dep "gmp" --supported "win32 win64" "$@" -if [ "${ARCH}" == "win64" ]; then - HOST="x86_64-w64-mingw32" -else - HOST="i686-w64-mingw32" -fi - -"$(dirname "$(realpath "$0")")/download/download_gmp.sh" +"${SCRIPT_DIR}/download/download_gmp.sh" # https://gmplib.org/list-archives/gmp-discuss/2020-July/006519.html -CC_FOR_BUILD=gcc CFLAGS="-O2 -g0" ./configure --host="${HOST}" \ - --prefix="/windows" \ +CC_FOR_BUILD=gcc CFLAGS="-O2 -g0" ./configure "${HOST_OPTION}" \ + --prefix="${DEP_PREFIX}" \ --enable-static \ --disable-shared -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_libexif.sh b/buildscripts/build_libexif.sh index 894a57c73..3f7fa24fe 100755 --- a/buildscripts/build_libexif.sh +++ b/buildscripts/build_libexif.sh @@ -6,42 +6,20 @@ set -euo pipefail -usage() -{ - echo "Download and build libexif for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "libexif" --supported "win32 win64" "$@" -if [ "$ARCH" != "win32" ] && [ "$ARCH" != "win64" ]; then - echo "Unexpected arch $ARCH" - usage - exit 1 -fi +"${SCRIPT_DIR}/download/download_libexif.sh" -"$(dirname "$(realpath "$0")")/download/download_libexif.sh" - -if [ "${ARCH}" == "win64" ]; then - HOST="x86_64-w64-mingw32" -else - HOST="i686-w64-mingw32" -fi - -CFLAGS="-O2 -g0" ./configure --host="${HOST}" \ - --prefix=/windows/ \ +CFLAGS="-O2 -g0" ./configure "${HOST_OPTION}" \ + "--prefix=${DEP_PREFIX}" \ --enable-shared \ --disable-static \ --disable-docs \ --disable-nls -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_libexpat_windows.sh b/buildscripts/build_libexpat_windows.sh index bbd3181e6..7f5bb17d5 100755 --- a/buildscripts/build_libexpat_windows.sh +++ b/buildscripts/build_libexpat_windows.sh @@ -6,38 +6,18 @@ set -euo pipefail -usage() -{ - echo "Download and build libexpat for windows" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +source "${SCRIPT_DIR}/build_utils.sh" -if [ "$ARCH" != "win32" ] && [ "$ARCH" != "win64" ]; then - echo "Unexpected arch $ARCH" - usage - exit 1 -fi +parse_arch --dep "libexpat" --supported "win32 win64" "$@" -"$(dirname "$(realpath "$0")")/download/download_libexpat.sh" +"${SCRIPT_DIR}/download/download_libexpat.sh" -if [ "${ARCH}" == "win64" ]; then - HOST="x86_64-w64-mingw32" -else - HOST="i686-w64-mingw32" -fi - -CFLAGS="-O2 -g0" ./configure --host="${HOST}" \ - --prefix="/windows" \ +CFLAGS="-O2 -g0" ./configure "${HOST_OPTION}" \ + --prefix="${DEP_PREFIX}" \ --enable-static \ --disable-shared -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_msgpack_c.sh b/buildscripts/build_msgpack_c.sh index fa891af02..5442cce79 100755 --- a/buildscripts/build_msgpack_c.sh +++ b/buildscripts/build_msgpack_c.sh @@ -5,14 +5,21 @@ set -euo pipefail -"$(dirname "$(realpath "$0")")/download/download_msgpack_c.sh" +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -cmake -DCMAKE_INSTALL_PREFIX=/windows/ \ +source "${SCRIPT_DIR}/build_utils.sh" + +parse_arch --dep "msgpack-c" --supported "win32 win64" "$@" + +"${SCRIPT_DIR}/download/download_msgpack_c.sh" + +cmake .\ + "-DCMAKE_INSTALL_PREFIX=${DEP_PREFIX}" \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake \ + "${CMAKE_TOOLCHAIN_FILE}" \ -DMSGPACK_BUILD_EXAMPLES=OFF \ -DMSGPACK_BUILD_TESTS=OFF \ . -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_openal.sh b/buildscripts/build_openal.sh index dbfccf314..2203b3c20 100755 --- a/buildscripts/build_openal.sh +++ b/buildscripts/build_openal.sh @@ -8,48 +8,23 @@ set -euo pipefail readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -usage() -{ - echo "Download and build openal for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +source "${SCRIPT_DIR}/build_utils.sh" -ARCH="" - -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done - -if [ "$ARCH" != "win32" ] && [ "$ARCH" != "win64" ]; then - echo "Unexpected arch $ARCH" - usage - exit 1 -fi +parse_arch --dep "openal" --supported "win32 win64" "$@" "${SCRIPT_DIR}/download/download_openal.sh" patch -p1 < "${SCRIPT_DIR}/patches/openal-cmake-3-11.patch" - -if [ "${ARCH}" == "win64" ]; then - MINGW_DIR="x86_64-w64-mingw32" -else - MINGW_DIR="x86-w64-mingw32" -fi - export CFLAGS="-fPIC" -cmake -DCMAKE_INSTALL_PREFIX=/windows/ \ +cmake "-DCMAKE_INSTALL_PREFIX=${DEP_PREFIX}" \ -DCMAKE_BUILD_TYPE=Release \ -DALSOFT_UTILS=OFF \ -DALSOFT_EXAMPLES=OFF \ - -DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake \ - -DDSOUND_INCLUDE_DIR="/usr/${MINGW_DIR}/include" \ - -DDSOUND_LIBRARY="/usr/${MINGW_DIR}/lib/libdsound.a" \ + "${CMAKE_TOOLCHAIN_FILE}" \ + -DDSOUND_INCLUDE_DIR="/usr/${MINGW_ARCH}-w64-mingw32/include" \ + -DDSOUND_LIBRARY="/usr/${MINGW_ARCH}-w64-mingw32/lib/libdsound.a" \ . -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_openssl.sh b/buildscripts/build_openssl.sh index dbc441f22..27f25be63 100755 --- a/buildscripts/build_openssl.sh +++ b/buildscripts/build_openssl.sh @@ -6,41 +6,25 @@ set -euo pipefail -usage() -{ - echo "Download and build openssl for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "openssl" --supported "win32 win64" "$@" -if [[ "$ARCH" == "win64" ]]; then +if [[ "$SCRIPT_ARCH" == "win64" ]]; then OPENSSL_ARCH="mingw64" - PREFIX="x86_64-w64-mingw32-" -elif [[ "$ARCH" == "win32" ]]; then - OPENSSL_ARCH="mingw" - PREFIX="i686-w64-mingw32-" else - echo "Invalid architecture" - usage - exit 1 + OPENSSL_ARCH="mingw" fi -"$(dirname "$(realpath "$0")")/download/download_openssl.sh" +"${SCRIPT_DIR}/download/download_openssl.sh" -./Configure --prefix=/windows/ \ - --openssldir=/windows/ssl \ +./Configure "--prefix=${DEP_PREFIX}" \ + "--openssldir=${DEP_PREFIX}/ssl" \ shared \ $OPENSSL_ARCH \ - --cross-compile-prefix=${PREFIX} + "--cross-compile-prefix=${MINGW_ARCH}-w64-mingw32-" -make -j $(nproc) +make -j "${MAKE_JOBS}" make install_sw diff --git a/buildscripts/build_opus.sh b/buildscripts/build_opus.sh index dae2aa952..8cd16cc00 100755 --- a/buildscripts/build_opus.sh +++ b/buildscripts/build_opus.sh @@ -6,41 +6,21 @@ set -euo pipefail -usage() -{ - echo "Download and build opus for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "opus" --supported "win32 win64" "$@" -if [[ "$ARCH" == "win64" ]]; then - HOST="x86_64-w64-mingw32" -elif [[ "$ARCH" == "win32" ]]; then - HOST="i686-w64-mingw32" -else - echo "Unexpected arch $ARCH" - usage - exit 1 -fi - -"$(dirname "$(realpath "$0")")/download/download_opus.sh" +"${SCRIPT_DIR}/download/download_opus.sh" LDFLAGS="-fstack-protector" CFLAGS="-O2 -g0" \ - ./configure --host="${HOST}" \ - --prefix=/windows/ \ + ./configure "${HOST_OPTION}" \ + "--prefix=${DEP_PREFIX}" \ --enable-shared \ --disable-static \ --disable-extra-programs \ --disable-doc -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_qrencode.sh b/buildscripts/build_qrencode.sh index 2f53aa361..9edb8c90c 100755 --- a/buildscripts/build_qrencode.sh +++ b/buildscripts/build_qrencode.sh @@ -6,41 +6,21 @@ set -euo pipefail -usage() -{ - echo "Download and build qrencode for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "qrencode" --supported "win32 win64" "$@" -if [[ "$ARCH" == "win64" ]]; then - HOST="x86_64-w64-mingw32" -elif [[ "$ARCH" == "win32" ]]; then - HOST="i686-w64-mingw32" -else - echo "Unexpected arch $ARCH" - usage - exit 1 -fi +"${SCRIPT_DIR}/download/download_qrencode.sh" -"$(dirname "$(realpath "$0")")/download/download_qrencode.sh" - -CFLAGS="-O2 -g0" ./configure --host="${HOST}" \ - --prefix=/windows \ +CFLAGS="-O2 -g0" ./configure "${HOST_OPTION}" \ + --prefix="${DEP_PREFIX}" \ --enable-shared \ --disable-static \ --disable-sdltest \ --without-tools \ --without-debug -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_qt_windows.sh b/buildscripts/build_qt_windows.sh index e0a6a47f5..c3264a9a7 100755 --- a/buildscripts/build_qt_windows.sh +++ b/buildscripts/build_qt_windows.sh @@ -6,41 +6,21 @@ set -euo pipefail -usage() -{ - echo "Download and build qt for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "qt" --supported "win32 win64" "$@" -if [[ "$ARCH" == "win64" ]]; then - CROSS="x86_64-w64-mingw32-" -elif [[ "$ARCH" == "win32" ]]; then - CROSS="i686-w64-mingw32-" -else - echo "Unexpected arch $ARCH" - usage - exit 1 -fi - -"$(dirname "$(realpath "$0")")/download/download_qt.sh" +"${SCRIPT_DIR}/download/download_qt.sh" OPENSSL_LIBS=$(pkg-config --libs openssl) export OPENSSL_LIBS -./configure -prefix /windows/ \ +./configure -prefix "${DEP_PREFIX}" \ -release \ -shared \ - -device-option CROSS_COMPILE=${CROSS} \ + -device-option "CROSS_COMPILE=${MINGW_ARCH}-w64-mingw32-" \ -xplatform win32-g++ \ -openssl \ "$(pkg-config --cflags openssl)" \ @@ -94,5 +74,5 @@ export OPENSSL_LIBS -qt-pcre \ -opengl desktop -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_sodium.sh b/buildscripts/build_sodium.sh index 3274f3830..29fe10636 100755 --- a/buildscripts/build_sodium.sh +++ b/buildscripts/build_sodium.sh @@ -6,39 +6,19 @@ set -euo pipefail -usage() -{ - echo "Download and build sodium for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "sodium" --supported "win32 win64" "$@" -if [[ "$ARCH" == "win64" ]]; then - HOST="x86_64-w64-mingw32" -elif [[ "$ARCH" == "win32" ]]; then - HOST="i686-w64-mingw32" -else - echo "Unexpected arch $ARCH" - usage - exit 1 -fi - -"$(dirname "$(realpath "$0")")/download/download_sodium.sh" +"${SCRIPT_DIR}/download/download_sodium.sh" LDFLAGS="-fstack-protector" \ - ./configure --host="${HOST}" \ - --prefix=/windows \ + ./configure "${HOST_OPTION}" \ + "--prefix=${DEP_PREFIX}" \ --enable-shared \ --disable-static -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_sqlcipher.sh b/buildscripts/build_sqlcipher.sh index e5557f41c..f9a6e1b1a 100755 --- a/buildscripts/build_sqlcipher.sh +++ b/buildscripts/build_sqlcipher.sh @@ -6,47 +6,27 @@ set -euo pipefail -usage() -{ - echo "Download and build sqlcipher for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "sqlcipher" --supported "win32 win64" "$@" -if [[ "$ARCH" == "win64" ]]; then - HOST="x86_64-w64-mingw32" -elif [[ "$ARCH" == "win32" ]]; then - HOST="i686-w64-mingw32" -else - echo "Unexpected arch $ARCH" - usage - exit 1 -fi - -"$(dirname "$(realpath "$0")")/download/download_sqlcipher.sh" +"${SCRIPT_DIR}/download/download_sqlcipher.sh" sed -i s/'if test "$TARGET_EXEEXT" = ".exe"'/'if test ".exe" = ".exe"'/g configure sed -i 's|exec $PWD/mksourceid manifest|exec $PWD/mksourceid.exe manifest|g' tool/mksqlite3h.tcl -./configure --host="${HOST}" \ - --prefix=/windows/ \ +./configure "${HOST_OPTION}" \ + "--prefix=${DEP_PREFIX}" \ --enable-shared \ --disable-static \ --enable-tempstore=yes \ - CFLAGS="-O2 -g0 -DSQLITE_HAS_CODEC -I/windows/include/" \ - LDFLAGS="-lcrypto -lgdi32 -L/windows/lib/" \ + CFLAGS="-O2 -g0 -DSQLITE_HAS_CODEC -I${DEP_PREFIX}/include/" \ + LDFLAGS="-lcrypto -lgdi32 -L${DEP_PREFIX}/lib/" \ LIBS="-lgdi32 -lws2_32" sed -i s/"TEXE = $"/"TEXE = .exe"/ Makefile -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/build_toxcore.sh b/buildscripts/build_toxcore.sh index 48641be7b..6395895e8 100755 --- a/buildscripts/build_toxcore.sh +++ b/buildscripts/build_toxcore.sh @@ -8,6 +8,10 @@ set -euo pipefail readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" +source "${SCRIPT_DIR}/build_utils.sh" + +parse_arch --dep "toxcore and toxext extensions" --supported "win32 win64" "$@" + build_toxcore() { TOXCORE_SRC="$(realpath toxcore)" @@ -16,15 +20,15 @@ build_toxcore() { "${SCRIPT_DIR}/download/download_toxcore.sh" - cmake -DCMAKE_INSTALL_PREFIX=/windows/ \ + cmake "-DCMAKE_INSTALL_PREFIX=${DEP_PREFIX}" \ -DBOOTSTRAP_DAEMON=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_STATIC=OFF \ -DENABLE_SHARED=ON \ - -DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake \ + "${CMAKE_TOOLCHAIN_FILE}" \ . - cmake --build . -- -j$(nproc) + cmake --build . -- "-j${MAKE_JOBS}" cmake --build . --target install popd >/dev/null @@ -38,12 +42,12 @@ build_toxext() { "${SCRIPT_DIR}/download/download_toxext.sh" - cmake -DCMAKE_INSTALL_PREFIX=/windows/ \ + cmake "-DCMAKE_INSTALL_PREFIX=${DEP_PREFIX}" \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake \ + "${CMAKE_TOOLCHAIN_FILE}" \ . - cmake --build . -- -j$(nproc) + cmake --build . -- "-j${MAKE_JOBS}" cmake --build . --target install popd >/dev/null @@ -57,10 +61,11 @@ build_toxext_messages() { "${SCRIPT_DIR}/download/download_toxext_messages.sh" - cmake -DCMAKE_INSTALL_PREFIX=/windows/ \ + cmake "-DCMAKE_INSTALL_PREFIX=${DEP_PREFIX}" \ -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake \ + "${CMAKE_TOOLCHAIN_FILE}" \ . + cmake --build . -- "-j${MAKE_JOBS}" cmake --build . --target install popd >/dev/null diff --git a/buildscripts/build_utils.sh b/buildscripts/build_utils.sh index 8a0cdca32..a58a22262 100644 --- a/buildscripts/build_utils.sh +++ b/buildscripts/build_utils.sh @@ -12,7 +12,18 @@ usage() # doesn't include --dep argument, since that comes from the build script # itself. echo "Download and build $DEP_NAME for the Windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" + echo "Usage: $0 --arch {$1}" +} + +assert_supported() +{ + for supported in $2; do + if [ "$1" == "$supported" ]; then + return + fi + done + usage "$2" + exit 1 } parse_arch() @@ -21,11 +32,14 @@ parse_arch() case $1 in --arch) SCRIPT_ARCH=$2; shift 2 ;; --dep) DEP_NAME=$2; shift 2 ;; + --supported) SUPPORTED=$2; shift 2 ;; -h|--help) usage; exit 1 ;; *) echo "Unexpected argument $1"; usage; exit 1;; esac done + assert_supported "${SCRIPT_ARCH}" "${SUPPORTED}" + if [ "${SCRIPT_ARCH}" == "win32" ] || [ "${SCRIPT_ARCH}" == "win64" ]; then if [ "${SCRIPT_ARCH}" == "win32" ]; then local ARCH="i686" diff --git a/buildscripts/build_vpx.sh b/buildscripts/build_vpx.sh index e2fad46b5..0ea020118 100755 --- a/buildscripts/build_vpx.sh +++ b/buildscripts/build_vpx.sh @@ -6,47 +6,32 @@ set -euo pipefail -usage() -{ - echo "Download and build vpx for the windows cross compiling environment" - echo "Usage: $0 --arch {win64|win32}" -} +readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" -ARCH="" +source "${SCRIPT_DIR}/build_utils.sh" -while (( $# > 0 )); do - case $1 in - --arch) ARCH=$2; shift 2 ;; - -h|--help) usage; exit 1 ;; - *) echo "Unexpected argument $1"; usage; exit 1;; - esac -done +parse_arch --dep "vpx" --supported "win32 win64" "$@" - -if [[ "$ARCH" == "win64" ]]; then +if [[ "$SCRIPT_ARCH" == "win64" ]]; then # There is a bug in gcc that breaks avx512 on 64-bit Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412 # VPX fails to build due to it. # This is a workaround as suggested in https://stackoverflow.com/questions/43152633 ARCH_FLAGS="-fno-asynchronous-unwind-tables" VPX_ARCH="x86_64-win64-gcc" - CROSS="x86_64-w64-mingw32-" -elif [[ "$ARCH" == "win32" ]]; then +elif [[ "$SCRIPT_ARCH" == "win32" ]]; then ARCH_FLAGS="" VPX_ARCH="x86-win32-gcc" - CROSS="i686-w64-mingw32-" else - echo "Unexpected arch $ARCH" - usage exit 1 fi -"$(dirname "$(realpath "$0")")/download/download_vpx.sh" +"${SCRIPT_DIR}/download/download_vpx.sh" -patch -Np1 < "$(dirname "$0")"/patches/vpx.patch +patch -Np1 < "${SCRIPT_DIR}/patches/vpx.patch" -CFLAGS=${ARCH_FLAGS} CROSS="${CROSS}" \ +CFLAGS=${ARCH_FLAGS} CROSS="${MINGW_ARCH}-w64-mingw32-" \ ./configure --target="${VPX_ARCH}" \ - --prefix=/windows/ \ + "--prefix=${DEP_PREFIX}" \ --enable-shared \ --disable-static \ --enable-runtime-cpu-detect \ @@ -55,5 +40,5 @@ CFLAGS=${ARCH_FLAGS} CROSS="${CROSS}" \ --disable-docs \ --disable-unit-tests -make -j $(nproc) +make -j "${MAKE_JOBS}" make install diff --git a/buildscripts/docker/Dockerfile.windows_builder b/buildscripts/docker/Dockerfile.windows_builder index 18e300afc..b77bbf10f 100644 --- a/buildscripts/docker/Dockerfile.windows_builder +++ b/buildscripts/docker/Dockerfile.windows_builder @@ -67,8 +67,6 @@ RUN mkdir -p /src/openssl && \ /build/build_openssl.sh --arch ${SCRIPT_ARCH} && \ rm -fr /src/openssl -env PKG_CONFIG_PATH=/windows/lib/pkgconfig - COPY download/download_qt.sh /build/download/download_qt.sh COPY build_qt_windows.sh /build/build_qt_windows.sh