Browse Source

chore(CI): Use cross_compile_detection in Windows dep build scripts

Deduplicates a lot of arg checking, and further deduplicates future macOS args.

Also give build scripts the ability to use relative call paths, like in
e405868037
reviewable/pr6438/r20
Anthony Bilinski 4 years ago
parent
commit
eb9298a069
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 28
      buildscripts/build_ffmpeg_cross.sh
  2. 33
      buildscripts/build_libexif_cross.sh
  3. 19
      buildscripts/build_msgpack_c_cross.sh
  4. 30
      buildscripts/build_openal_cross.sh
  5. 30
      buildscripts/build_openssl_cross.sh
  6. 28
      buildscripts/build_opus_cross.sh
  7. 26
      buildscripts/build_qrencode_cross.sh
  8. 26
      buildscripts/build_qt_cross.sh
  9. 28
      buildscripts/build_sodium_cross.sh
  10. 30
      buildscripts/build_sqlcipher_cross.sh
  11. 29
      buildscripts/build_toxcore_cross.sh
  12. 31
      buildscripts/build_vpx_cross.sh
  13. 4
      buildscripts/docker/Dockerfile.windows_builder

28
buildscripts/build_ffmpeg_cross.sh

@ -4,29 +4,21 @@ @@ -4,29 +4,21 @@
# Copyright (c) 2017-2021 Maxim Biro <nurupo.contributions@gmail.com>
# Copyright (c) 2021 by The qTox Project Contributors
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build ffmpeg for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_ffmpeg.sh
"${SCRIPT_DIR}/download/download_ffmpeg.sh"
if [ "${ARCH}" == "x86_64" ]; then
FFMPEG_ARCH="x86_64"
@ -38,7 +30,7 @@ fi @@ -38,7 +30,7 @@ fi
--enable-gpl \
--enable-shared \
--disable-static \
--prefix=/windows/ \
"--prefix=${DEP_PREFIX}" \
--target-os="mingw32" \
--cross-prefix="${ARCH}-w64-mingw32-" \
--pkg-config="pkg-config" \
@ -84,5 +76,5 @@ fi @@ -84,5 +76,5 @@ fi
--enable-decoder=mjpeg \
--enable-decoder=rawvideo
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

33
buildscripts/build_libexif_cross.sh

@ -4,39 +4,28 @@ @@ -4,39 +4,28 @@
# Copyright (c) 2017-2021 Maxim Biro <nurupo.contributions@gmail.com>
# Copyright (c) 2021 by The qTox Project Contributors
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "$SCRIPT_DIR"/cross_compile_detection.sh
usage()
{
echo "Download and build libexif for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
set -euo pipefail
parse_arch "$@"
"$(dirname $0)"/download/download_libexif.sh
"${SCRIPT_DIR}/download/download_libexif.sh"
CFLAGS="-O2 -g0" ./configure --host="${ARCH}-w64-mingw32" \
--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

19
buildscripts/build_msgpack_c_cross.sh

@ -5,11 +5,24 @@ @@ -5,11 +5,24 @@
set -euo pipefail
"$(dirname "$0")"/download/download_msgpack_c.sh
SCRIPT_DIR=$(dirname $(realpath "$0"))
cmake -DCMAKE_INSTALL_PREFIX=/windows/ \
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build qrencode for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
parse_arch "$@"
"${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 \
.

30
buildscripts/build_openal_cross.sh

@ -6,41 +6,31 @@ @@ -6,41 +6,31 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build openal for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_openal.sh
"${SCRIPT_DIR}/download/download_openal.sh"
patch -p1 < "$(dirname "$0")"/patches/openal-cmake-3-11.patch
patch -p1 < "${SCRIPT_DIR}/patches/openal-cmake-3-11.patch"
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 \
"${CMAKE_TOOLCHAIN_FILE}" \
-DDSOUND_INCLUDE_DIR=/usr/${ARCH}-w64-mingw32/include \
-DDSOUND_LIBRARY=/usr/${ARCH}-w64-mingw32/lib/libdsound.a \
.
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

30
buildscripts/build_openssl_cross.sh

@ -6,29 +6,19 @@ @@ -6,29 +6,19 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "$SCRIPT_DIR"/cross_compile_detection.sh
usage()
{
echo "Download and build openssl for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_openssl.sh
"${SCRIPT_DIR}/download/download_openssl.sh"
if [[ "$ARCH" == "x86_64" ]]; then
OPENSSL_ARCH="mingw64"
@ -39,11 +29,11 @@ else @@ -39,11 +29,11 @@ else
exit 1
fi
./Configure --prefix=/windows/ \
--openssldir=/windows/ssl \
./Configure "--prefix=${DEP_PREFIX}" \
"--openssldir=${DEP_PREFIX}/ssl" \
shared \
$OPENSSL_ARCH \
--cross-compile-prefix=${ARCH}-w64-mingw32-
"${CROSS_COMPILE_ARCH}"
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

28
buildscripts/build_opus_cross.sh

@ -6,37 +6,27 @@ @@ -6,37 +6,27 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build opus for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_opus.sh
"${SCRIPT_DIR}/download/download_opus.sh"
LDFLAGS="-fstack-protector" CFLAGS="-O2 -g0" \
./configure --host="${ARCH}-w64-mingw32" \
--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

26
buildscripts/build_qrencode_cross.sh

@ -6,36 +6,26 @@ @@ -6,36 +6,26 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build qrencode for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_qrencode.sh
"${SCRIPT_DIR}/download/download_qrencode.sh"
cmake . \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/windows \
"-DCMAKE_INSTALL_PREFIX=${DEP_PREFIX}" \
"${CMAKE_TOOLCHAIN_FILE}" \
-DWITH_TOOLS=OFF \
-DBUILD_SHARED_LIBS=ON
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

26
buildscripts/build_qt_cross.sh

@ -6,34 +6,24 @@ @@ -6,34 +6,24 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build qt for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$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=${ARCH}-w64-mingw32- \
@ -90,5 +80,5 @@ export OPENSSL_LIBS @@ -90,5 +80,5 @@ export OPENSSL_LIBS
-qt-pcre \
-opengl desktop
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

28
buildscripts/build_sodium_cross.sh

@ -6,35 +6,25 @@ @@ -6,35 +6,25 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "$SCRIPT_DIR"/cross_compile_detection.sh
usage()
{
echo "Download and build sodium for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_sodium.sh
"${SCRIPT_DIR}/download/download_sodium.sh"
LDFLAGS="-fstack-protector" \
./configure --host="${ARCH}-w64-mingw32" \
--prefix=/windows \
./configure "${HOST_OPTION}" \
"--prefix=${DEP_PREFIX}" \
--enable-shared \
--disable-static
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

30
buildscripts/build_sqlcipher_cross.sh

@ -6,43 +6,33 @@ @@ -6,43 +6,33 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build sqlcipher for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/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="${ARCH}-w64-mingw32" \
--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

29
buildscripts/build_toxcore_cross.sh

@ -6,23 +6,29 @@ @@ -6,23 +6,29 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
parse_arch "$@"
build_toxcore() {
TOXCORE_SRC="$(realpath toxcore)"
mkdir -p "$TOXCORE_SRC"
pushd $TOXCORE_SRC >/dev/null || exit 1
"$(dirname "$0")"/download/download_toxcore.sh
"${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
@ -34,14 +40,14 @@ build_toxext() { @@ -34,14 +40,14 @@ build_toxext() {
mkdir -p "$TOXEXT_SRC"
pushd $TOXEXT_SRC >/dev/null || exit 1
"$(dirname "$0")"/download/download_toxext.sh
"${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
@ -53,12 +59,13 @@ build_toxext_messages() { @@ -53,12 +59,13 @@ build_toxext_messages() {
mkdir -p "$TOXEXT_MESSAGES_SRC"
pushd $TOXEXT_MESSAGES_SRC > /dev/null || exit 1
"$(dirname "$0")"/download/download_toxext_messages.sh
"${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

31
buildscripts/build_vpx_cross.sh

@ -6,29 +6,19 @@ @@ -6,29 +6,19 @@
set -euo pipefail
SCRIPT_DIR=$(dirname $(realpath "$0"))
source "${SCRIPT_DIR}/cross_compile_detection.sh"
usage()
{
echo "Download and build vpx for the windows cross compiling environment"
echo "Usage: $0 --arch {x86_64|i686}"
}
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" != "i686" ] && [ "$ARCH" != "x86_64" ]; then
echo "Unexpected arch $ARCH"
usage
exit 1
fi
parse_arch "$@"
"$(dirname "$0")"/download/download_vpx.sh
"${SCRIPT_DIR}/download/download_vpx.sh"
# 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.
@ -45,9 +35,10 @@ fi @@ -45,9 +35,10 @@ fi
patch -Np1 < "$(dirname "$0")"/patches/vpx-windows.patch
CFLAGS=${ARCH_FLAGS} CROSS="${ARCH}-w64-mingw32-" \
./configure --target="${VPX_ARCH}" \
--prefix=/windows/ \
CFLAGS=${ARCH_FLAGS} CROSS="${CROSS_ARG}" \
./configure \
${TARGET} \
"--prefix=${DEP_PREFIX}" \
--enable-shared \
--disable-static \
--enable-runtime-cpu-detect \
@ -56,5 +47,5 @@ CFLAGS=${ARCH_FLAGS} CROSS="${ARCH}-w64-mingw32-" \ @@ -56,5 +47,5 @@ CFLAGS=${ARCH_FLAGS} CROSS="${ARCH}-w64-mingw32-" \
--disable-docs \
--disable-unit-tests
make -j $(nproc)
make -j "${MAKE_JOBS}"
make install

4
buildscripts/docker/Dockerfile.windows_builder

@ -66,8 +66,6 @@ RUN mkdir -p /src/openssl && \ @@ -66,8 +66,6 @@ RUN mkdir -p /src/openssl && \
/build/build_openssl_cross.sh --arch ${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_cross.sh /build/build_qt_cross.sh
@ -172,7 +170,7 @@ COPY download/download_toxext_messages.sh /build/download/download_toxext_messag @@ -172,7 +170,7 @@ COPY download/download_toxext_messages.sh /build/download/download_toxext_messag
COPY build_toxcore_cross.sh /build/build_toxcore_cross.sh
RUN mkdir -p /src/tox && \
cd /src/tox && \
/build/build_toxcore_cross.sh && \
/build/build_toxcore_cross.sh --arch ${ARCH} && \
rm -fr /src/tox
RUN mkdir /export && \

Loading…
Cancel
Save