android.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. name: Build (Android)
  2. on: [push, pull_request]
  3. concurrency:
  4. group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
  5. cancel-in-progress: true
  6. jobs:
  7. android:
  8. name: ${{ matrix.platform.name }}
  9. runs-on: ubuntu-latest
  10. strategy:
  11. fail-fast: false
  12. matrix:
  13. platform:
  14. - { name: Android.mk }
  15. - { name: CMake, cmake: 1, android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64", artifact: "SDL-android-arm64", apk-artifact: "SDL-android-apks-arm64" }
  16. steps:
  17. - uses: actions/checkout@v4
  18. - uses: nttld/setup-ndk@v1
  19. id: setup_ndk
  20. with:
  21. local-cache: true
  22. ndk-version: r21e
  23. - name: Build (Android.mk)
  24. if: ${{ matrix.platform.name == 'Android.mk' }}
  25. run: |
  26. ./build-scripts/androidbuildlibs.sh
  27. - uses: actions/setup-java@v4
  28. if: ${{ matrix.platform.name == 'CMake' }}
  29. with:
  30. distribution: 'temurin'
  31. java-version: '11'
  32. - name: Setup (CMake)
  33. if: ${{ matrix.platform.name == 'CMake' }}
  34. run: |
  35. sudo apt-get update
  36. sudo apt-get install ninja-build pkg-config
  37. - name: Configure (CMake)
  38. if: ${{ matrix.platform.name == 'CMake' }}
  39. run: |
  40. cmake -S . -B build \
  41. -Wdeprecated -Wdev -Werror \
  42. -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup_ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
  43. -DSDL_WERROR=ON \
  44. -DSDL_TESTS=ON \
  45. -DSDL_INSTALL_TESTS=ON \
  46. -DSDL_CLANG_TIDY=ON \
  47. -DANDROID_PLATFORM=${{ matrix.platform.android_platform }} \
  48. -DANDROID_ABI=${{ matrix.platform.android_abi }} \
  49. -DSDL_SHARED=ON \
  50. -DSDL_STATIC=ON \
  51. -DSDL_STATIC_PIC=ON \
  52. -DSDL_VENDOR_INFO="Github Workflow" \
  53. -DCMAKE_INSTALL_PREFIX=prefix \
  54. -DCMAKE_BUILD_TYPE=Release \
  55. -GNinja
  56. - name: Build (CMake)
  57. if: ${{ matrix.platform.name == 'CMake' }}
  58. run: |
  59. cmake --build build --config Release --parallel --verbose
  60. - name: Build test apk's (CMake)
  61. if: ${{ matrix.platform.name == 'CMake' }}
  62. run: |
  63. cmake --build build --config Release --parallel --verbose --target testaudiocapture-apk testcontroller-apk testmultiaudio-apk testsprite-apk
  64. - name: Install (CMake)
  65. if: ${{ matrix.platform.name == 'CMake' }}
  66. run: |
  67. cmake --install build --config Release
  68. echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
  69. ( cd prefix; find ) | LC_ALL=C sort -u
  70. - name: Package (CPack)
  71. if: ${{ matrix.platform.name == 'CMake' }}
  72. run: |
  73. cmake --build build/ --config Release --target package
  74. - name: Verify CMake configuration files
  75. if: ${{ matrix.platform.name == 'CMake' }}
  76. run: |
  77. cmake -S cmake/test -B cmake_config_build -G Ninja \
  78. -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup_ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
  79. -DANDROID_PLATFORM=${{ matrix.platform.android_platform }} \
  80. -DANDROID_ABI=${{ matrix.platform.android_abi }} \
  81. -DCMAKE_BUILD_TYPE=Release \
  82. -DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }}
  83. cmake --build cmake_config_build --verbose
  84. - name: Verify sdl3.pc
  85. if: ${{ matrix.platform.name == 'CMake' }}
  86. run: |
  87. 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 }}"
  88. export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
  89. cmake/test/test_pkgconfig.sh
  90. - uses: actions/upload-artifact@v4
  91. if: ${{ matrix.platform.name == 'CMake' }}
  92. with:
  93. if-no-files-found: error
  94. name: ${{ matrix.platform.artifact }}
  95. path: build/dist/SDL3*
  96. - uses: actions/upload-artifact@v4
  97. if: ${{ matrix.platform.name == 'CMake' }}
  98. with:
  99. if-no-files-found: error
  100. name: ${{ matrix.platform.apk-artifact }}
  101. path: build/test/*.apk