name: android
on: 
  push:
    paths: 
      - ".github/workflows/android.yml"
      - "cmake/**"
      - "CMakeLists.txt"
      - "tile/**"
      - "third_party/**"
  
  pull_request:
    paths: 
      - ".github/workflows/android.yml"
      - "cmake/**"
      - "CMakeLists.txt"
      - "tile/**"
      - "third_party/**"
  
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        build_arch: ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
    env:
      TILE_CMAKE_OPTIONS: |
        -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_LATEST_HOME/build/cmake/android.toolchain.cmake \
        -DANDROID_PLATFORM=android-21 \
        -DCMAKE_INSTALL_PREFIX=install \
        -DCMAKE_BUILD_TYPE=Release \
        -DNCNN_VULKAN=ON \

    steps:
    - uses: actions/checkout@v4
      with: 
        submodules: true
    - name: install-tools
      run: |
        apt-get update -y
        apt-get install -y ninja-build

    - name: build
      run: |
        mkdir build && cd build
        cmake -GNinja .. ${{ env.TILE_CMAKE_OPTIONS}} -DCMAKE_ABI="${{matrix.build_arch}}" -DANDROID_ARM_NEON=ON 
        cmake --build . -j $(nproc)
