android.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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", ndk-build: 1 }
  15. - { name: "Gradle", gradle: 1 }
  16. - { name: "CMake", cmake: 1, android_abi: "arm64-v8a", android_platform: 23, arch: "aarch64", artifact: "SDL-android-arm64", apk-artifact: "SDL-android-apks-arm64" }
  17. - { 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" }
  18. steps:
  19. - uses: actions/checkout@v4
  20. - uses: nttld/setup-ndk@v1
  21. if: ${{ matrix.platform.cmake || matrix.platform.ndk-build }}
  22. id: setup_ndk
  23. with:
  24. local-cache: true
  25. ndk-version: r21e
  26. - name: Build (Android.mk)
  27. if: ${{ matrix.platform.ndk-build }}
  28. run: |
  29. ./build-scripts/androidbuildlibs.sh
  30. - uses: actions/setup-java@v4
  31. if: ${{ matrix.platform.cmake || matrix.platform.gradle }}
  32. with:
  33. distribution: 'temurin'
  34. java-version: '17'
  35. - name: Create Gradle project
  36. if: ${{ matrix.platform.gradle }}
  37. run: |
  38. build-scripts/androidbuild.sh org.libsdl.testspriteminimal test/testspriteminimal.c test/icon.h
  39. echo ""
  40. echo "Project contents:"
  41. echo ""
  42. find "build/org.libsdl.testspriteminimal"
  43. - name: Build app (Gradle & ndk-build)
  44. if: ${{ matrix.platform.gradle }}
  45. run: |
  46. cd build/org.libsdl.testspriteminimal
  47. ./gradlew -i assembleRelease
  48. - name: Build app (Gradle & CMake)
  49. if: ${{ matrix.platform.gradle }}
  50. run: |
  51. cd build/org.libsdl.testspriteminimal
  52. ./gradlew -i assembleRelease -PBUILD_WITH_CMAKE=1
  53. # - name: Build library (Gradle)
  54. # if: ${{ matrix.platform.gradle }}
  55. # run: |
  56. # cd build/org.libsdl.testspriteminimal
  57. # ./gradlew -i assembleRelease -PBUILD_AS_LIBRARY=1
  58. - name: Setup (CMake)
  59. if: ${{ matrix.platform.cmake }}
  60. run: |
  61. sudo apt-get update
  62. sudo apt-get install ninja-build pkg-config
  63. - name: Configure (CMake)
  64. if: ${{ matrix.platform.cmake }}
  65. run: |
  66. cmake -S . -B build \
  67. -DCMAKE_C_FLAGS="${{ matrix.platform.cppflags }}" \
  68. -DCMAKE_CXX_FLAGS="${{ matrix.platform.cppflags }}" \
  69. -Wdeprecated -Wdev -Werror \
  70. -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup_ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
  71. -DSDL_WERROR=ON \
  72. -DSDL_TESTS=ON \
  73. -DSDL_INSTALL_TESTS=ON \
  74. -DSDL_CLANG_TIDY=ON \
  75. -DSDL_DISABLE_INSTALL_DOCS=OFF \
  76. -DANDROID_PLATFORM=${{ matrix.platform.android_platform }} \
  77. -DANDROID_ABI=${{ matrix.platform.android_abi }} \
  78. -DSDL_SHARED=ON \
  79. -DSDL_STATIC=ON \
  80. -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  81. -DSDL_VENDOR_INFO="Github Workflow" \
  82. -DCMAKE_INSTALL_PREFIX=prefix \
  83. -DCMAKE_BUILD_TYPE=Release \
  84. -GNinja
  85. - name: Build (CMake)
  86. if: ${{ matrix.platform.cmake }}
  87. run: |
  88. cmake --build build --config Release --parallel --verbose
  89. - name: Build test apk's (CMake)
  90. if: ${{ matrix.platform.cmake }}
  91. run: |
  92. cmake --build build --config Release --parallel \
  93. --target \
  94. testaudiorecording-apk \
  95. testautomation-apk \
  96. testcontroller-apk \
  97. testmultiaudio-apk \
  98. testsprite-apk \
  99. --verbose
  100. - name: Install (CMake)
  101. if: ${{ matrix.platform.cmake }}
  102. run: |
  103. cmake --install build --config Release
  104. echo "SDL3_DIR=$(pwd)/prefix" >> $GITHUB_ENV
  105. ( cd prefix; find ) | LC_ALL=C sort -u
  106. - name: Package (CPack)
  107. if: ${{ matrix.platform.cmake }}
  108. run: |
  109. cmake --build build/ --config Release --target package
  110. - name: Verify CMake configuration files
  111. if: ${{ matrix.platform.cmake }}
  112. run: |
  113. cmake -S cmake/test -B cmake_config_build -G Ninja \
  114. -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup_ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake \
  115. -DANDROID_PLATFORM=${{ matrix.platform.android_platform }} \
  116. -DANDROID_ABI=${{ matrix.platform.android_abi }} \
  117. -DCMAKE_BUILD_TYPE=Release \
  118. -DCMAKE_PREFIX_PATH=${{ env.SDL3_DIR }}
  119. cmake --build cmake_config_build --verbose
  120. - name: Verify sdl3.pc
  121. if: ${{ matrix.platform.cmake }}
  122. run: |
  123. 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 }}"
  124. export PKG_CONFIG_PATH=${{ env.SDL3_DIR }}/lib/pkgconfig
  125. cmake/test/test_pkgconfig.sh
  126. - uses: actions/upload-artifact@v4
  127. if: ${{ matrix.platform.cmake }}
  128. with:
  129. if-no-files-found: error
  130. name: ${{ matrix.platform.artifact }}
  131. path: build/dist/SDL3*
  132. - uses: actions/upload-artifact@v4
  133. if: ${{ matrix.platform.cmake }}
  134. with:
  135. if-no-files-found: error
  136. name: ${{ matrix.platform.apk-artifact }}
  137. path: build/test/*.apk