From e10a29d78f71c7c45fe4de58c4a0242726d4da33 Mon Sep 17 00:00:00 2001 From: Tadej Novak Date: Sat, 23 Dec 2023 10:08:06 +0100 Subject: [PATCH] Add Android and iOS support (#86) --- .github/workflows/Android.yml | 161 +++++++++++++++++++--------------- .github/workflows/iOS.yml | 109 ++++++++++++----------- examples/quick/CMakeLists.txt | 15 ++++ 3 files changed, 162 insertions(+), 123 deletions(-) diff --git a/.github/workflows/Android.yml b/.github/workflows/Android.yml index 30c73c2..7c959f7 100644 --- a/.github/workflows/Android.yml +++ b/.github/workflows/Android.yml @@ -1,59 +1,72 @@ -name: Android Qt6 CI +name: Android CI on: workflow_dispatch: - # push: - # branches: - # - main - # tags: - # - '**' - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/iOS.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" - - # pull_request: - # branches: - # - main - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/iOS.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" + push: + branches: + - main + tags: + - "**" + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/iOS.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" + + pull_request: + branches: + - main + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/iOS.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" concurrency: # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} -env: - QT_VERSION: 6.5.3 - jobs: build: - name: Build QMapLibre for ${{ matrix.config.abi }} + name: Build QMapLibre for Android (Qt${{ matrix.qt_version}}, ${{ matrix.abi }}) runs-on: ubuntu-22.04 strategy: matrix: - config: - - abi: x86 + include: + - qt_version: 6.5.3 + abi: x86 + arch: android_x86 + - qt_version: 6.5.3 + abi: x86_64 + arch: android_x86_64 + - qt_version: 6.5.3 + abi: armeabi-v7a + arch: android_armv7 + - qt_version: 6.5.3 + abi: arm64-v8a + arch: android_arm64_v8a + - qt_version: 6.6.0 + abi: x86 arch: android_x86 - - abi: x86_64 + - qt_version: 6.6.0 + abi: x86_64 arch: android_x86_64 - - abi: armeabi-v7a + - qt_version: 6.6.0 + abi: armeabi-v7a arch: android_armv7 - - abi: arm64-v8a + - qt_version: 6.6.0 + abi: arm64-v8a arch: android_arm64_v8a steps: @@ -69,7 +82,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} modules: qtlocation qtpositioning set-env: false @@ -78,13 +91,13 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} target: android - arch: ${{ matrix.config.arch }} + arch: ${{ matrix.arch }} modules: qtlocation qtpositioning - name: Fix Qt release - if: ${{ matrix.config.abi }} == 'armeabi-v7a' + if: ${{ matrix.abi }} == 'armeabi-v7a' run: | chmod +x "$Qt6_DIR/bin/qt-cmake" sed -i "s/C:\/Qt\/Qt-${QT_VERSION}/\/usr\/local\/Qt-${QT_VERSION}/g" "$Qt6_DIR/lib/cmake/Qt6BuildInternals/QtBuildInternalsExtra.cmake" @@ -101,12 +114,12 @@ jobs: - name: Set up ccache uses: hendrikmuhs/ccache-action@v1 with: - key: Android_QMapLibre_${{ matrix.config.abi }} + key: Android_QMapLibre_${{ matrix.qt_version }}_${{ matrix.abi }} max-size: 200M - name: Build QMapLibre env: - ANDROID_ABI: ${{ matrix.config.abi }} + ANDROID_ABI: ${{ matrix.abi }} run: | mkdir build && cd build qt-cmake ../source/ \ @@ -117,68 +130,72 @@ jobs: -DCMAKE_INSTALL_PREFIX="../install" \ -DQT_HOST_PATH="$(readlink -f "$Qt6_DIR/../gcc_64")" ninja - ninja test ninja install - - name: Create artifacts + - name: Compress installation run: | pushd install tar cjvf ../QMapLibre_Android.tar.bz2 * popd - name: Upload artifacts - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: - name: QMapLibre_Android_${{ matrix.config.abi }} - path: install/home/runner/work/QMapLibre + name: QMapLibre_Android_${{ matrix.qt_version }}_${{ matrix.abi }} + path: QMapLibre_Android.tar.bz2 combine: name: Combine QMapLibre runs-on: ubuntu-22.04 needs: build + strategy: + matrix: + qt_version: [6.5.3, 6.6.0] steps: - name: Download artifacts for x86 - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_x86 - path: install-x86 + name: QMapLibre_Android_${{ matrix.qt_version}}_x86 + path: x86 - name: Download artifacts for x86_64 - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_x86_64 - path: install-x86_64 + name: QMapLibre_Android_${{ matrix.qt_version}}_x86_64 + path: x86_64 - name: Download artifacts for armeabi-v7a - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_armeabi-v7a - path: install-armeabi-v7a + name: QMapLibre_Android_${{ matrix.qt_version}}_armeabi-v7a + path: armeabi-v7a - name: Download artifacts for arm64-v8a - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: - name: QMapLibre_Android_arm64-v8a - path: install-arm64-v8a + name: QMapLibre_Android_${{ matrix.qt_version}}_arm64-v8a + path: arm64-v8a - name: Combine artifacts run: | - cp -r install-arm64-v8a install - cp -r install-armeabi-v7a/Qt/${QT_VERSION}/* install/Qt/${QT_VERSION}/ - cp -r install-x86/Qt/${QT_VERSION}/* install/Qt/${QT_VERSION}/ - cp -r install-x86_64/Qt/${QT_VERSION}/* install/Qt/${QT_VERSION}/ + mkdir install && pushd install + tar xf ../x86/QMapLibre_Android.tar.bz2 + tar xf ../x86_64/QMapLibre_Android.tar.bz2 + tar xf ../armeabi-v7a/QMapLibre_Android.tar.bz2 + tar xf ../arm64-v8a/QMapLibre_Android.tar.bz2 + popd - name: Create artifacts run: | pushd install - tar cjvf ../QMapLibre_Android.tar.bz2 Qt + tar cjvf ../QMapLibre_Android.tar.bz2 * popd - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: QMapLibre_Android + name: QMapLibre_Android_${{ matrix.qt_version}} path: QMapLibre_Android.tar.bz2 release: @@ -188,22 +205,26 @@ jobs: needs: combine permissions: contents: write + strategy: + matrix: + qt_version: [6.5.3, 6.6.0] steps: - name: Download artifacts uses: actions/download-artifact@v4 with: - name: QMapLibre_Android + name: QMapLibre_Android_${{ matrix.qt_version }} - name: Make tarball env: TAG_NAME: ${{ github.ref_name }} + QT_VERSION: ${{ matrix.qt_version }} run: | mv QMapLibre_Android.tar.bz2 QMapLibre_${TAG_NAME}_Qt${QT_VERSION}_Android.tar.bz2 - name: Release uses: ncipollo/release-action@v1 with: - artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ env.QT_VERSION }}_Android.tar.bz2 + artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_Android.tar.bz2 allowUpdates: true draft: true diff --git a/.github/workflows/iOS.yml b/.github/workflows/iOS.yml index f3784c4..e68bfd7 100644 --- a/.github/workflows/iOS.yml +++ b/.github/workflows/iOS.yml @@ -1,49 +1,56 @@ -name: iOS Qt6 CI +name: iOS CI on: workflow_dispatch: - # push: - # branches: - # - main - # tags: - # - '**' - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/Android.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" - - # pull_request: - # branches: - # - main - # paths-ignore: - # - ".gitignore" - # - "README.md" - # # ignore CI for other platforms - # - ".github/FUNDING.yml" - # - ".github/actions/**" - # - ".github/workflows/Android.yml" - # - ".github/workflows/Linux.yml" - # - ".github/workflows/macOS.yml" - # - ".github/workflows/Windows.yml" + push: + branches: + - main + tags: + - "**" + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/Android.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" + + pull_request: + branches: + - main + paths-ignore: + - ".gitignore" + - "README.md" + # ignore CI for other platforms + - ".github/FUNDING.yml" + - ".github/actions/**" + - ".github/workflows/Android.yml" + - ".github/workflows/Linux.yml" + - ".github/workflows/macOS.yml" + - ".github/workflows/Windows.yml" concurrency: # cancel jobs on PRs only group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} -env: - QT_VERSION: 6.5.3 - jobs: - build-plugin: - name: Build QMapLibre + build: + name: Build QMapLibre for iOS (Qt${{ matrix.qt_version}}) runs-on: macos-13 + strategy: + matrix: + include: + - qt_version: 6.5.3 + deployment_target: 14.0 + - qt_version: 6.6.0 + deployment_target: 14.0 + + env: + DEPLOYMENT_TARGET: ${{ matrix.deployment_target }} steps: - name: Checkout @@ -62,7 +69,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} target: desktop modules: qtlocation qtpositioning set-env: false @@ -71,7 +78,7 @@ jobs: uses: jurplel/install-qt-action@v3 with: aqtversion: ==3.1.* - version: ${{ env.QT_VERSION }} + version: ${{ matrix.qt_version }} target: ios modules: qtlocation qtpositioning @@ -81,7 +88,7 @@ jobs: - name: Set up ccache uses: hendrikmuhs/ccache-action@v1 with: - key: iOS_QMapLibre + key: iOS_QMapLibre_${{ matrix.qt_version }} max-size: 200M - name: Use latest version of ccache @@ -91,7 +98,6 @@ jobs: - name: Build QMapLibre run: | - export CCACHE_LOGFILE="../ccache.log" mkdir build && cd build qt-cmake ../source/ \ -G"Ninja Multi-Config" \ @@ -100,53 +106,50 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ -DCMAKE_INSTALL_PREFIX="../install" \ -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \ - -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET="${DEPLOYMENT_TARGET}" \ -DQT_HOST_PATH="$(readlink -f "$Qt6_DIR/../macos")" ninja - ninja test ninja install - - name: Upload ccache.log - uses: actions/upload-artifact@v4 - with: - name: ccache_iOS - path: ccache.log - - - name: Create artifacts + - name: Compress installation run: | pushd install tar cjvf ../QMapLibre_iOS.tar.bz2 * popd - - name: Upload artifacts + - name: Upload installation uses: actions/upload-artifact@v4 with: - name: QMapLibre_iOS + name: QMapLibre_iOS_${{ matrix.qt_version }} path: QMapLibre_iOS.tar.bz2 release: name: Release QMapLibre if: github.ref_type == 'tag' runs-on: macos-13 - needs: build-plugin + needs: build permissions: contents: write + strategy: + matrix: + qt_version: [6.5.3, 6.6.0] steps: - name: Download artifacts uses: actions/download-artifact@v4 with: - name: QMapLibre_iOS + name: QMapLibre_iOS_${{ matrix.qt_version }} - name: Make tarball env: TAG_NAME: ${{ github.ref_name }} + QT_VERSION: ${{ matrix.qt_version }} run: | mv QMapLibre_iOS.tar.bz2 QMapLibre_${TAG_NAME}_Qt${QT_VERSION}_iOS.tar.bz2 - name: Release uses: ncipollo/release-action@v1 with: - artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ env.QT_VERSION }}_iOS.tar.bz2 + artifacts: QMapLibre_${{ github.ref_name }}_Qt${{ matrix.qt_version }}_iOS.tar.bz2 allowUpdates: true draft: true diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt index 03b3999..f282fa4 100644 --- a/examples/quick/CMakeLists.txt +++ b/examples/quick/CMakeLists.txt @@ -9,6 +9,10 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(Qt6 REQUIRED COMPONENTS Quick REQUIRED) qt_standard_project_setup() +if(QT_KNOWN_POLICY_QTP0002) + qt_policy(SET QTP0002 NEW) +endif() + find_package(QMapLibre COMPONENTS Location REQUIRED) qt_add_executable( @@ -49,4 +53,15 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_dependencies(deploy QMapLibreExampleQuick) +elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android") + include(FetchContent) + FetchContent_Declare( + android_openssl + DOWNLOAD_EXTRACT_TIMESTAMP true + URL https://github.com/KDAB/android_openssl/archive/refs/heads/master.zip + ) + FetchContent_MakeAvailable(android_openssl) + include(${android_openssl_SOURCE_DIR}/android_openssl.cmake) + + add_android_openssl_libraries(QMapLibreExampleQuick) endif()