SDL/.github/workflows/android.yml

110 lines
4.6 KiB
YAML
Raw Permalink Normal View History

name: Build (Android)
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
android:
name: ${{ matrix.platform.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
2024-03-11 13:16:20 -06:00
- { name: "Android.mk" }
- { name: "CMake", cmake: 1, android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64", artifact: "SDL-android-arm64", apk-artifact: "SDL-android-apks-arm64" }
- { name: "CMake (lean and mean)", cmake: 1, cppflags: "-DSDL_LEAN_AND_MEAN=1", android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64", artifact: "SDL-lean-android-arm64", apk-artifact: "SDL-lean-android-apks-arm64" }
steps:
2024-01-25 18:33:20 -07:00
- uses: actions/checkout@v4
- uses: nttld/setup-ndk@v1
id: setup_ndk
with:
2023-11-22 11:22:31 -07:00
local-cache: true
2022-07-23 09:29:08 -06:00
ndk-version: r21e
- name: Build (Android.mk)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'Android.mk') }}
run: |
./build-scripts/androidbuildlibs.sh
- uses: actions/setup-java@v4
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
with:
distribution: 'temurin'
java-version: '11'
- name: Setup (CMake)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
sudo apt-get update
sudo apt-get install ninja-build pkg-config
- name: Configure (CMake)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
cmake -S . -B build \
2024-03-11 13:16:20 -06:00
-DCMAKE_C_FLAGS="${{ matrix.platform.cppflags }}" \
-DCMAKE_CXX_FLAGS="${{ matrix.platform.cppflags }}" \
-Wdeprecated -Wdev -Werror \
-DCMAKE_TOOLCHAIN_FILE=${{ steps.setup_ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
-DSDL_WERROR=ON \
-DSDL_TESTS=ON \
-DSDL_INSTALL_TESTS=ON \
-DSDL_CLANG_TIDY=ON \
-DANDROID_PLATFORM=${{ matrix.platform.android_platform }} \
-DANDROID_ABI=${{ matrix.platform.android_abi }} \
-DSDL_SHARED=ON \
-DSDL_STATIC=ON \
-DSDL_STATIC_PIC=ON \
-DSDL_VENDOR_INFO="Github Workflow" \
-DCMAKE_INSTALL_PREFIX=prefix \
-DCMAKE_BUILD_TYPE=Release \
-GNinja
- name: Build (CMake)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
cmake --build build --config Release --parallel --verbose
- name: Build test apk's (CMake)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
cmake --build build --config Release --parallel --verbose --target testautomation-apk testaudiocapture-apk testcontroller-apk testmultiaudio-apk testsprite-apk
- name: Install (CMake)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
cmake --install build --config Release
echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
( cd prefix; find ) | LC_ALL=C sort -u
- name: Package (CPack)
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
cmake --build build/ --config Release --target package
- name: Verify CMake configuration files
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
cmake -S cmake/test -B cmake_config_build -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=${{ steps.setup_ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=${{ matrix.platform.android_platform }} \
-DANDROID_ABI=${{ matrix.platform.android_abi }} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }}
cmake --build cmake_config_build --verbose
- name: Verify sdl3.pc
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
run: |
export CC="${{ steps.setup_ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=${{ matrix.platform.arch }}-none-linux-androideabi${{ matrix.platform.android_platform }}"
export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
cmake/test/test_pkgconfig.sh
2024-01-25 18:33:20 -07:00
- uses: actions/upload-artifact@v4
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
with:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: build/dist/SDL3*
2024-01-25 18:33:20 -07:00
- uses: actions/upload-artifact@v4
2024-03-11 13:16:20 -06:00
if: ${{ contains(matrix.platform.name, 'CMake') }}
with:
if-no-files-found: error
name: ${{ matrix.platform.apk-artifact }}
path: build/test/*.apk