From e64fa0c22a137fba07a870b4f195b35b4baae332 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 8 Feb 2026 08:28:39 +0000 Subject: [PATCH] feat: Add iOS Qt build. --- .github/workflows/docker.yml | 60 +++++++++++++++++++++++++++++++ qtox/build_extra_cmake_modules.sh | 2 +- qtox/build_ffmpeg.sh | 12 ++++++- qtox/build_hunspell.sh | 2 +- qtox/build_kimageformats.sh | 2 +- qtox/build_libexif.sh | 2 +- qtox/build_openal.sh | 12 +++++-- qtox/build_openssl.sh | 8 ++++- qtox/build_qrencode.sh | 12 +++++-- qtox/build_qtbase_macos.sh | 22 +++++++++--- qtox/build_qtbase_wasm.sh | 2 +- qtox/build_qtbase_windows.sh | 2 +- qtox/build_qtimageformats.sh | 2 +- qtox/build_qtremoteobjects.sh | 2 +- qtox/build_qtsvg.sh | 2 +- qtox/build_qttools.sh | 2 +- qtox/build_sonnet.sh | 4 +-- qtox/build_sqlcipher.sh | 2 +- qtox/build_tomcrypt.sh | 5 ++- qtox/build_toxcore.sh | 12 +++++-- qtox/build_utils.sh | 29 ++++++++++----- qtox/build_zstd.sh | 12 +++++-- qtox/deps/download_qt.sh | 6 +++- qtox/deps/local_install_deps.sh | 16 +++++++-- 24 files changed, 187 insertions(+), 45 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 38b1809..e23fd54 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -272,6 +272,11 @@ jobs: --dep-prefix /Users/runner/work/deps - name: Build tarball run: tar -zcf qt-static-macos-${{ matrix.arch }}-${{ matrix.macos }}.tar.gz -C /Users/runner/work/deps qt + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: qt-static-macos-${{ matrix.arch }}-${{ matrix.macos }}-qt + path: qt-static-macos-${{ matrix.arch }}-${{ matrix.macos }}.tar.gz - name: Upload tarball to nightly release if: github.event_name == 'push' uses: ncipollo/release-action@v1 @@ -283,3 +288,58 @@ jobs: prerelease: true replacesArtifacts: true artifacts: qt-static-macos-${{ matrix.arch }}-${{ matrix.macos }}.tar.gz + + qt-static-ios: + needs: [update-nightly-tag, qt-static-macos] + strategy: + matrix: + arch: [ios-arm64, iphonesimulator-arm64, iphonesimulator-x86_64] + include: + - arch: ios-arm64 + host_arch: arm64 + - arch: iphonesimulator-arm64 + host_arch: arm64 + - arch: iphonesimulator-x86_64 + host_arch: x86_64 + runs-on: ${{ matrix.host_arch == 'arm64' && 'macos-14' || 'macos-15-intel' }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Download host Qt + uses: actions/download-artifact@v4 + with: + name: qt-static-macos-${{ matrix.host_arch }}-12.0-qt + - name: Extract host Qt + run: | + mkdir -p /Users/runner/work/host-qt + tar -zxf qt-static-macos-${{ matrix.host_arch }}-12.0.tar.gz --strip-components=1 -C /Users/runner/work/host-qt + - name: Cache Qt + id: cache-qt + uses: actions/cache@v4 + with: + path: | + /Users/runner/work/deps/qt + key: ${{ github.job }}-${{ matrix.arch }}-qt + - name: Homebrew dependencies to build dependencies + run: brew bundle --file qtox/deps/Brewfile-static + - name: Build Qt + if: steps.cache-qt.outputs.cache-hit != 'true' + run: qtox/deps/local_install_deps.sh + --arch ${{ matrix.arch }} + --dep-file qtox/deps/qt.depfile + --dep-prefix /Users/runner/work/deps + --host-path /Users/runner/work/host-qt + - name: Build tarball + run: tar -zcf qt-static-${{ matrix.arch }}.tar.gz -C /Users/runner/work/deps qt + - name: Upload tarball to nightly release + if: github.event_name == 'push' + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + tag: nightly + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + prerelease: true + replacesArtifacts: true + artifacts: qt-static-${{ matrix.arch }}.tar.gz diff --git a/qtox/build_extra_cmake_modules.sh b/qtox/build_extra_cmake_modules.sh index 60fa7d4..9956201 100755 --- a/qtox/build_extra_cmake_modules.sh +++ b/qtox/build_extra_cmake_modules.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "extra-cmake-modules" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "extra-cmake-modules" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_extra_cmake_modules.sh" diff --git a/qtox/build_ffmpeg.sh b/qtox/build_ffmpeg.sh index 45b535b..d35cb98 100755 --- a/qtox/build_ffmpeg.sh +++ b/qtox/build_ffmpeg.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "ffmpeg" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "ffmpeg" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" CONFIGURE_FLAGS=() if [ "$LIB_TYPE" = "shared" ]; then @@ -44,6 +44,16 @@ elif [ "$SCRIPT_ARCH" == "wasm" ]; then --ranlib="$EMSDK/upstream/bin/llvm-ranlib" --dep-cc="emcc" ) +elif [[ "$SCRIPT_ARCH" == "ios-"* ]] || [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + FFMPEG_ARCH="${SCRIPT_ARCH#*-}" + if [ "$FFMPEG_ARCH" == "x86_64" ]; then + FFMPEG_ARCH="x86_64" + elif [ "$FFMPEG_ARCH" == "arm64" ]; then + FFMPEG_ARCH="aarch64" + fi + TARGET_OS="darwin" + CROSS_PREFIX="" + CONFIGURE_FLAGS+=(--enable-cross-compile) else FFMPEG_ARCH="" TARGET_OS="" diff --git a/qtox/build_hunspell.sh b/qtox/build_hunspell.sh index 08321b7..2eb5384 100755 --- a/qtox/build_hunspell.sh +++ b/qtox/build_hunspell.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "hunspell" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 win32 win64" "$@" +parse_arch --dep "hunspell" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$LIB_TYPE" = "shared" ]; then ENABLE_STATIC=--disable-static diff --git a/qtox/build_kimageformats.sh b/qtox/build_kimageformats.sh index dcc7b52..3486b8d 100755 --- a/qtox/build_kimageformats.sh +++ b/qtox/build_kimageformats.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "kimageformats" --supported "linux-x86_64 macos-x86_64 macos-arm64 win32 win64" "$@" +parse_arch --dep "kimageformats" --supported "linux-x86_64 macos-x86_64 macos-arm64 win32 win64 ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_kimageformats.sh" diff --git a/qtox/build_libexif.sh b/qtox/build_libexif.sh index 4259008..69e42c1 100755 --- a/qtox/build_libexif.sh +++ b/qtox/build_libexif.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "libexif" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "libexif" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$LIB_TYPE" = "shared" ]; then ENABLE_STATIC=--disable-static diff --git a/qtox/build_openal.sh b/qtox/build_openal.sh index b91ecfe..7657665 100755 --- a/qtox/build_openal.sh +++ b/qtox/build_openal.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "openal" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "openal" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$SCRIPT_ARCH" = "win32" ] || [ "$SCRIPT_ARCH" = "win64" ]; then "$SCRIPT_DIR/download/download_openal.sh" patched @@ -32,13 +32,19 @@ else LIBTYPE=STATIC fi +if [[ "$SCRIPT_ARCH" == "ios-"* ]] || [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + DEPLOYMENT_TARGET="$IOS_MINIMUM_SUPPORTED_VERSION" +else + DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" +fi + export CFLAGS="-fPIC" export CXXFLAGS="-fPIC -std=c++20" "${EMCMAKE[@]}" cmake \ - "$CMAKE_TOOLCHAIN_FILE" \ + "${CMAKE_TOOLCHAIN_FILE[@]}" \ -DCMAKE_INSTALL_PREFIX="$DEP_PREFIX" \ -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$DEPLOYMENT_TARGET" \ -DCMAKE_MACOSX_RPATH="$MACOSX_RPATH" \ -DALSOFT_UTILS=OFF \ -DALSOFT_EXAMPLES=OFF \ diff --git a/qtox/build_openssl.sh b/qtox/build_openssl.sh index 26cf54f..d0268c4 100755 --- a/qtox/build_openssl.sh +++ b/qtox/build_openssl.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "openssl" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "openssl" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$SCRIPT_ARCH" == "win64" ]; then OPENSSL_ARCH="mingw64" @@ -25,6 +25,12 @@ elif [ "$SCRIPT_ARCH" == "macos-x86_64" ]; then elif [ "$SCRIPT_ARCH" == "macos-arm64" ]; then OPENSSL_ARCH="darwin64-arm64-cc" CROSS_COMPILE_ARCH="" +elif [[ "$SCRIPT_ARCH" == "ios-"* ]]; then + OPENSSL_ARCH="ios64-xcrun" + CROSS_COMPILE_ARCH="" +elif [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + OPENSSL_ARCH="iossimulator-xcrun" + CROSS_COMPILE_ARCH="" elif [ "$SCRIPT_ARCH" == "linux-x86_64" ]; then OPENSSL_ARCH="linux-x86_64" CROSS_COMPILE_ARCH="" diff --git a/qtox/build_qrencode.sh b/qtox/build_qrencode.sh index 84819ff..6332c99 100755 --- a/qtox/build_qrencode.sh +++ b/qtox/build_qrencode.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "qrencode" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "qrencode" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$LIB_TYPE" = "shared" ]; then BUILD_SHARED_LIBS=ON @@ -21,11 +21,17 @@ fi "$SCRIPT_DIR/download/download_qrencode.sh" +if [[ "$SCRIPT_ARCH" == "ios-"* ]] || [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + DEPLOYMENT_TARGET="$IOS_MINIMUM_SUPPORTED_VERSION" +else + DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" +fi + "${EMCMAKE[@]}" cmake . \ -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ -DCMAKE_INSTALL_PREFIX="$DEP_PREFIX" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" \ - "$CMAKE_TOOLCHAIN_FILE" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$DEPLOYMENT_TARGET" \ + "${CMAKE_TOOLCHAIN_FILE[@]}" \ -DWITH_TOOLS=OFF \ -DBUILD_SHARED_LIBS="$BUILD_SHARED_LIBS" diff --git a/qtox/build_qtbase_macos.sh b/qtox/build_qtbase_macos.sh index 1cc4bda..49b71cf 100755 --- a/qtox/build_qtbase_macos.sh +++ b/qtox/build_qtbase_macos.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "qtbase" --supported "macos-arm64 macos-x86_64" "$@" +parse_arch --dep "qtbase" --supported "macos-arm64 macos-x86_64 ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_qtbase.sh" @@ -29,15 +29,27 @@ else QT_CONFIGURE_FLAGS+=("-no-force-debug-info") fi -if [ "$MACOS_MINIMUM_SUPPORTED_VERSION" != "10.15" ]; then - QT_CONFIGURE_FLAGS+=("-no-feature-printsupport") +if [[ "$SCRIPT_ARCH" == "ios-"* ]]; then + QT_CONFIGURE_FLAGS+=("-sdk" "iphoneos" "-no-feature-printsupport" "-no-feature-icu" "-no-feature-filesystemwatcher") +elif [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + QT_CONFIGURE_FLAGS+=("-sdk" "iphonesimulator" "-no-feature-printsupport" "-no-feature-icu" "-no-feature-filesystemwatcher") +else + if [ "$MACOS_MINIMUM_SUPPORTED_VERSION" != "10.15" ]; then + QT_CONFIGURE_FLAGS+=("-no-feature-printsupport") + fi +fi + +if [ -n "$QT_HOST_PATH" ]; then + QT_CONFIGURE_FLAGS+=("-qt-host-path" "$QT_HOST_PATH") fi # We want -Werror to catch warnings related to macOS version compatibility. -sed -i '' -e 's/-Wextra/-Wextra -Werror "-Wno-#warnings" -Wno-cast-function-type-mismatch -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-vla-cxx-extension/' cmake/QtCompilerFlags.cmake +# We silence unused-variable because disabling features (like filesystemwatcher) can leave variables unused in Qt's source. +sed -i '' -e 's/-Wextra/-Wextra -Werror "-Wno-#warnings" -Wno-cast-function-type-mismatch -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-unused-variable -Wno-vla-cxx-extension/' cmake/QtCompilerFlags.cmake mkdir _build && pushd _build ../configure \ + -platform macx-clang \ --prefix="$QT_PREFIX" \ -appstore-compliant \ -static \ @@ -61,7 +73,7 @@ mkdir _build && pushd _build -no-openssl \ -- \ -DCMAKE_FIND_ROOT_PATH="$DEP_PREFIX" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" \ + "${CMAKE_TOOLCHAIN_FILE[@]}" \ -Wno-dev cat config.summary cmake --build . diff --git a/qtox/build_qtbase_wasm.sh b/qtox/build_qtbase_wasm.sh index 7a88c6b..81886c1 100755 --- a/qtox/build_qtbase_wasm.sh +++ b/qtox/build_qtbase_wasm.sh @@ -42,7 +42,7 @@ pushd _build -no-glib \ -no-openssl \ -device-option "QT_EMSCRIPTEN_ASYNCIFY=1" \ - -qt-host-path /opt/buildhome/host/qt \ + -qt-host-path "${QT_HOST_PATH:-/opt/buildhome/host/qt}" \ -platform wasm-emscripten \ -feature-thread \ -feature-wasm-simd128 \ diff --git a/qtox/build_qtbase_windows.sh b/qtox/build_qtbase_windows.sh index 81a0b6a..faf99b6 100755 --- a/qtox/build_qtbase_windows.sh +++ b/qtox/build_qtbase_windows.sh @@ -42,7 +42,7 @@ mkdir _build && pushd _build -no-feature-dbus \ -no-opengl \ -device-option "CROSS_COMPILE=$CROSS_COMPILE" \ - -qt-host-path /opt/buildhome/host/qt \ + -qt-host-path "$QT_HOST_PATH" \ -platform linux-g++ \ -xplatform win32-g++ \ -openssl-linked \ diff --git a/qtox/build_qtimageformats.sh b/qtox/build_qtimageformats.sh index 1fedc5c..400104d 100755 --- a/qtox/build_qtimageformats.sh +++ b/qtox/build_qtimageformats.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "qtimageformats" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 wasm" "$@" +parse_arch --dep "qtimageformats" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_qtimageformats.sh" diff --git a/qtox/build_qtremoteobjects.sh b/qtox/build_qtremoteobjects.sh index 07e807c..9544531 100755 --- a/qtox/build_qtremoteobjects.sh +++ b/qtox/build_qtremoteobjects.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "qtremoteobjects" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64" "$@" +parse_arch --dep "qtremoteobjects" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_qtremoteobjects.sh" diff --git a/qtox/build_qtsvg.sh b/qtox/build_qtsvg.sh index 30b6ed7..a6ca063 100755 --- a/qtox/build_qtsvg.sh +++ b/qtox/build_qtsvg.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "qtsvg" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 wasm" "$@" +parse_arch --dep "qtsvg" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_qtsvg.sh" diff --git a/qtox/build_qttools.sh b/qtox/build_qttools.sh index cfbf7b6..b0e430f 100755 --- a/qtox/build_qttools.sh +++ b/qtox/build_qttools.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "qttools" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 wasm" "$@" +parse_arch --dep "qttools" --supported "linux-x86_64 macos-arm64 macos-x86_64 win32 win64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_qttools.sh" diff --git a/qtox/build_sonnet.sh b/qtox/build_sonnet.sh index af133af..cc3127e 100755 --- a/qtox/build_sonnet.sh +++ b/qtox/build_sonnet.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "sonnet" --supported "linux-x86_64 macos-x86_64 macos-arm64 win32 win64 wasm" "$@" +parse_arch --dep "sonnet" --supported "linux-x86_64 macos-x86_64 macos-arm64 win32 win64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_sonnet.sh" @@ -37,7 +37,7 @@ else done < <(find . -name CMakeLists.txt -print0) sed_i -e 's/ MODULE$/ STATIC/g' "${CMAKE_LISTS[@]}" sed_i -e 's/install(TARGETS sonnet_\([^ ]*\) /&EXPORT KF6SonnetTargets/g' "${CMAKE_LISTS[@]}" - if [ "$SCRIPT_ARCH" = "macos-x86_64" ] || [ "$SCRIPT_ARCH" = "macos-arm64" ]; then + if [ "$SCRIPT_ARCH" = "macos-x86_64" ] || [ "$SCRIPT_ARCH" = "macos-arm64" ] || [[ "$SCRIPT_ARCH" == "ios-"* ]] || [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then sed_i -e 's/target_link_libraries(KF6SonnetCore PUBLIC Qt6::Core)/target_link_libraries(KF6SonnetCore PUBLIC Qt6::Core sonnet_hunspell sonnet_nsspellchecker)/' "${CMAKE_LISTS[@]}" else sed_i -e 's/target_link_libraries(KF6SonnetCore PUBLIC Qt6::Core)/target_link_libraries(KF6SonnetCore PUBLIC Qt6::Core sonnet_hunspell)/' "${CMAKE_LISTS[@]}" diff --git a/qtox/build_sqlcipher.sh b/qtox/build_sqlcipher.sh index c0145e1..fb213a4 100755 --- a/qtox/build_sqlcipher.sh +++ b/qtox/build_sqlcipher.sh @@ -13,7 +13,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "sqlcipher" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "sqlcipher" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" "$SCRIPT_DIR/download/download_sqlcipher.sh" diff --git a/qtox/build_tomcrypt.sh b/qtox/build_tomcrypt.sh index 7ba163c..fbec052 100755 --- a/qtox/build_tomcrypt.sh +++ b/qtox/build_tomcrypt.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "tomcrypt" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s ios-i386 ios-x86_64 wasm" "$@" +parse_arch --dep "tomcrypt" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s ios-i386 ios-x86_64 iphonesimulator-arm64 iphonesimulator-x86_64 wasm" "$@" if [ "$LIB_TYPE" = "shared" ]; then MAKEFILE="makefile.shared" @@ -19,5 +19,8 @@ fi "$SCRIPT_DIR/download/download_tomcrypt.sh" +export CFLAGS="-O2 -g0 $CROSS_CFLAG" +export LDFLAGS="$CROSS_LDFLAG" + "${EMMAKE[@]}" make -j "$MAKE_JOBS" -f "$MAKEFILE" library "${EMMAKE[@]}" make install PREFIX="$DEP_PREFIX" diff --git a/qtox/build_toxcore.sh b/qtox/build_toxcore.sh index ddd72a5..bce55dd 100755 --- a/qtox/build_toxcore.sh +++ b/qtox/build_toxcore.sh @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "toxcore" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "toxcore" --supported "linux-x86_64 win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$LIB_TYPE" = "shared" ]; then ENABLE_STATIC=OFF @@ -44,6 +44,12 @@ if [ -n "$SANITIZE" ]; then CMAKE_BUILD_TYPE=Debug fi +if [[ "$SCRIPT_ARCH" == "ios-"* ]] || [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + DEPLOYMENT_TARGET="$IOS_MINIMUM_SUPPORTED_VERSION" +else + DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" +fi + "${EMCMAKE[@]}" cmake \ -DCMAKE_INSTALL_PREFIX="$DEP_PREFIX" \ -DBOOTSTRAP_DAEMON=OFF \ @@ -52,8 +58,8 @@ fi -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ -DENABLE_STATIC="$ENABLE_STATIC" \ -DENABLE_SHARED="$ENABLE_SHARED" \ - "$CMAKE_TOOLCHAIN_FILE" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" \ + "${CMAKE_TOOLCHAIN_FILE[@]}" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$DEPLOYMENT_TARGET" \ -GNinja \ -B_build \ . diff --git a/qtox/build_utils.sh b/qtox/build_utils.sh index 16c004d..77d2bd1 100644 --- a/qtox/build_utils.sh +++ b/qtox/build_utils.sh @@ -33,7 +33,8 @@ parse_arch() { SANITIZE= EXTRA_ARGS=() MACOS_MINIMUM_SUPPORTED_VERSION=12.0 - IOS_MINIMUM_SUPPORTED_VERSION=10.0 + IOS_MINIMUM_SUPPORTED_VERSION=15.0 + QT_HOST_PATH="" while (($# > 0)); do case $1 in @@ -53,6 +54,10 @@ parse_arch() { DEP_PREFIX=$2 shift 2 ;; + --host-path) + QT_HOST_PATH=$2 + shift 2 + ;; --buildtype) BUILD_TYPE=$2 shift 2 @@ -89,10 +94,12 @@ parse_arch() { assert_supported "$SCRIPT_ARCH" "$SUPPORTED" export MACOS_MINIMUM_SUPPORTED_VERSION export IOS_MINIMUM_SUPPORTED_VERSION + export QT_HOST_PATH EMCONFIGURE=() EMMAKE=() EMCMAKE=() + CMAKE_TOOLCHAIN_FILE=() if [ "$SCRIPT_ARCH" == "win32" ] || [ "$SCRIPT_ARCH" == "win64" ]; then if [ "$SCRIPT_ARCH" == "win32" ]; then @@ -107,7 +114,8 @@ parse_arch() { CROSS_CPPFLAG="" CROSS_CXXFLAG="" MAKE_JOBS="$(nproc)" - CMAKE_TOOLCHAIN_FILE="-DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake" + CMAKE_TOOLCHAIN_FILE=("-DCMAKE_TOOLCHAIN_FILE=/build/windows-toolchain.cmake") + QT_HOST_PATH="${QT_HOST_PATH:-/opt/buildhome/host/qt}" elif [ "$SCRIPT_ARCH" == "macos-x86_64" ] || [ "$SCRIPT_ARCH" == "macos-arm64" ]; then DEP_PREFIX="${DEP_PREFIX:-/opt/buildhome}" mkdir -p "$DEP_PREFIX" @@ -118,31 +126,33 @@ parse_arch() { CROSS_CPPFLAG="$MACOS_FLAGS" CROSS_CXXFLAG="$MACOS_FLAGS" MAKE_JOBS="$(sysctl -n hw.ncpu)" - CMAKE_TOOLCHAIN_FILE="" + CMAKE_TOOLCHAIN_FILE=("-DCMAKE_OSX_DEPLOYMENT_TARGET=$MACOS_MINIMUM_SUPPORTED_VERSION") elif [[ "$SCRIPT_ARCH" == "ios-"* ]]; then ARCH="${SCRIPT_ARCH#ios-}" DEP_PREFIX="${DEP_PREFIX:-/opt/buildhome}" mkdir -p "$DEP_PREFIX" HOST_OPTION=("--host=arm64-apple-darwin") - IOS_FLAGS="-miphoneos-version-min=$IOS_MINIMUM_SUPPORTED_VERSION -arch $ARCH -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" + SDK_PATH=$(xcrun --sdk iphoneos --show-sdk-path) + IOS_FLAGS="-miphoneos-version-min=$IOS_MINIMUM_SUPPORTED_VERSION -arch $ARCH -isysroot $SDK_PATH" CROSS_LDFLAG="$IOS_FLAGS" CROSS_CFLAG="$IOS_FLAGS" CROSS_CPPFLAG="$IOS_FLAGS" CROSS_CXXFLAG="$IOS_FLAGS" MAKE_JOBS="$(sysctl -n hw.ncpu)" - CMAKE_TOOLCHAIN_FILE="" + CMAKE_TOOLCHAIN_FILE=("-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_SYSROOT=iphoneos" "-DCMAKE_OSX_ARCHITECTURES=$ARCH" "-DCMAKE_OSX_DEPLOYMENT_TARGET=$IOS_MINIMUM_SUPPORTED_VERSION") elif [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then ARCH="${SCRIPT_ARCH#iphonesimulator-}" DEP_PREFIX="${DEP_PREFIX:-/opt/buildhome}" mkdir -p "$DEP_PREFIX" HOST_OPTION=("--host=arm64-apple-darwin") - IOS_FLAGS="-arch $ARCH -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)" + SDK_PATH=$(xcrun --sdk iphonesimulator --show-sdk-path) + IOS_FLAGS="-arch $ARCH -isysroot $SDK_PATH" CROSS_LDFLAG="$IOS_FLAGS" CROSS_CFLAG="$IOS_FLAGS" CROSS_CPPFLAG="$IOS_FLAGS" CROSS_CXXFLAG="$IOS_FLAGS" MAKE_JOBS="$(sysctl -n hw.ncpu)" - CMAKE_TOOLCHAIN_FILE="" + CMAKE_TOOLCHAIN_FILE=("-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_SYSROOT=iphonesimulator" "-DCMAKE_OSX_ARCHITECTURES=$ARCH" "-DCMAKE_OSX_DEPLOYMENT_TARGET=$IOS_MINIMUM_SUPPORTED_VERSION") elif [[ "$SCRIPT_ARCH" == "linux"* ]]; then DEP_PREFIX="${DEP_PREFIX:-/opt/buildhome}" mkdir -p "$DEP_PREFIX" @@ -152,7 +162,7 @@ parse_arch() { CROSS_CPPFLAG="" CROSS_CXXFLAG="" MAKE_JOBS="$(nproc)" - CMAKE_TOOLCHAIN_FILE="" + CMAKE_TOOLCHAIN_FILE=() elif [ "$SCRIPT_ARCH" == "wasm" ]; then DEP_PREFIX="${DEP_PREFIX:-/opt/buildhome}" mkdir -p "$DEP_PREFIX" @@ -162,12 +172,13 @@ parse_arch() { CROSS_CPPFLAG="" CROSS_CXXFLAG="-s USE_PTHREADS=1" MAKE_JOBS="$(nproc)" - CMAKE_TOOLCHAIN_FILE="" + CMAKE_TOOLCHAIN_FILE=() LIB_TYPE=static source "/opt/buildhome/emsdk/emsdk_env.sh" EMCONFIGURE=(emconfigure) EMMAKE=(emmake) EMCMAKE=(emcmake) + QT_HOST_PATH="${QT_HOST_PATH:-/opt/buildhome/host/qt}" else echo "Unexpected arch $SCRIPT_ARCH" usage "$SUPPORTED" diff --git a/qtox/build_zstd.sh b/qtox/build_zstd.sh index 2fbcbbb..7f8af8c 100755 --- a/qtox/build_zstd.sh +++ b/qtox/build_zstd.sh @@ -9,7 +9,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")" source "$SCRIPT_DIR/build_utils.sh" -parse_arch --dep "zstd" --supported "win32 win64 macos-x86_64 macos-arm64 wasm" "$@" +parse_arch --dep "zstd" --supported "win32 win64 macos-x86_64 macos-arm64 wasm ios-arm64 iphonesimulator-arm64 iphonesimulator-x86_64" "$@" if [ "$LIB_TYPE" = "shared" ]; then ENABLE_STATIC=OFF @@ -19,6 +19,12 @@ else ENABLE_SHARED=OFF fi +if [[ "$SCRIPT_ARCH" == "ios-"* ]] || [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then + DEPLOYMENT_TARGET="$IOS_MINIMUM_SUPPORTED_VERSION" +else + DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" +fi + "$SCRIPT_DIR/download/download_zstd.sh" "${EMCMAKE[@]}" cmake -DCMAKE_INSTALL_PREFIX="$DEP_PREFIX" \ @@ -27,8 +33,8 @@ fi -DZSTD_BUILD_SHARED="$ENABLE_SHARED" \ -DBUILD_SHARED_LIBS="$ENABLE_SHARED" \ -DZSTD_BUILD_PROGRAMS=OFF \ - "$CMAKE_TOOLCHAIN_FILE" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET="$MACOS_MINIMUM_SUPPORTED_VERSION" \ + "${CMAKE_TOOLCHAIN_FILE[@]}" \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="$DEPLOYMENT_TARGET" \ -GNinja \ -B_build \ build/cmake diff --git a/qtox/deps/download_qt.sh b/qtox/deps/download_qt.sh index 94bccef..c87c4da 100755 --- a/qtox/deps/download_qt.sh +++ b/qtox/deps/download_qt.sh @@ -45,4 +45,8 @@ while (($# > 0)); do done mkdir -p "$DEP_PREFIX" -tar -zxf <(curl -L "https://github.com/TokTok/dockerfiles/releases/download/nightly/qt-static-macos-$ARCH-$MACOS_VERSION.tar.gz") -C "$DEP_PREFIX" +if [[ "$ARCH" == "ios-"* ]] || [[ "$ARCH" == "iphonesimulator-"* ]]; then + tar -zxf <(curl -L "https://github.com/TokTok/dockerfiles/releases/download/nightly/qt-static-$ARCH.tar.gz") -C "$DEP_PREFIX" +else + tar -zxf <(curl -L "https://github.com/TokTok/dockerfiles/releases/download/nightly/qt-static-macos-$ARCH-$MACOS_VERSION.tar.gz") -C "$DEP_PREFIX" +fi diff --git a/qtox/deps/local_install_deps.sh b/qtox/deps/local_install_deps.sh index 7a5f053..8416aa5 100755 --- a/qtox/deps/local_install_deps.sh +++ b/qtox/deps/local_install_deps.sh @@ -10,6 +10,7 @@ ARCH="$(uname -m)" BUILD_TYPE="release" SANITIZE="" MACOS_VERSION="12.0" +QT_HOST_PATH="" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" @@ -25,6 +26,7 @@ usage() { echo " --dep-prefix Dependency prefix (default: third_party/deps)" echo " --sanitize Sanitizer (address, thread, undefined)" echo " --macos-version macOS version (default: 12.0)" + echo " --host-path Host Qt path" echo " --help, -h Show this help message" } @@ -54,6 +56,10 @@ while (($# > 0)); do MACOS_VERSION=$2 shift 2 ;; + --host-path) + QT_HOST_PATH=$2 + shift 2 + ;; --help | -h) usage exit 1 @@ -93,13 +99,19 @@ install_deps() { else SCRIPT="$QTOX_DIR/build_$dep.sh" fi + if [[ "$ARCH" == "ios-"* ]] || [[ "$ARCH" == "iphonesimulator-"* ]]; then + SCRIPT_ARCH="$ARCH" + else + SCRIPT_ARCH="$SYSTEM-$ARCH" + fi "$SCRIPT" \ - --arch "$SYSTEM-$ARCH" \ + --arch "$SCRIPT_ARCH" \ --libtype "static" \ --buildtype "$BUILD_TYPE" \ --sanitize "$SANITIZE" \ --prefix "$DEP_PREFIX" \ - --macos "$MACOS_VERSION" + --macos "$MACOS_VERSION" \ + --host-path "$QT_HOST_PATH" popd rm -rf "external/$dep" done