name: C/C++ CI

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: Install aria2
      run: sudo apt install aria2 -y

    - name: Install LLVM
      run: sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
    
    - name: Set up Android NDK r23b
      run: | 
        aria2c -o android-ndk-r23b-linux.zip https://dl.google.com/android/repository/android-ndk-r23b-linux.zip
        unzip -q android-ndk-r23b-linux.zip
      
    - name: Build
      run: |
        android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android22-clang++ -Wall -Werror -nostdlib -c -O3 -o handle.o main.cpp
        android-ndk-r23b/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android22-clang -DMyRelease -Wall -Werror -L ./rootfs/system/lib64 -landroidappmusic -lstoreservicescore -lmediaplatform -lc++_shared -O3 -Wall -o rootfs/system/bin/main handle.o test.c
        clang -O3 -Wall -o wrapper wrapper.c

    - name: Upload artifact
      uses: actions/upload-artifact@v4
      with:
        name: Wrapper.x86_64
        path: |
          rootfs
          handle.o
          wrapper
