diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 664b528..9cf1d4f 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -10,6 +10,7 @@ on: paths: - '.github/**' - 'meson.build' + - 'android.ini' tags: - 'v*' - 'rusticl*' @@ -72,11 +73,13 @@ jobs: tinymesa: name: Build tinymesa ${{ matrix.tag }} on ${{ matrix.os }} - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os == 'android' && 'ubuntu-22.04' || matrix.os }} + permissions: + contents: write strategy: fail-fast: false matrix: - os: [ ubuntu-22.04, ubuntu-22.04-arm, macos-14 ] + os: [ ubuntu-22.04, ubuntu-22.04-arm, macos-14, android ] tag: [ mesa-25.2.7 ] steps: - name: Checkout repository @@ -88,14 +91,23 @@ jobs: - name: Patch mesa run: ./apply_patches.py ${{ github.workspace }}/mesa ${{ matrix.tag }} - name: Build mesa + if: matrix.os != 'android' shell: bash run: | cd ${{ github.workspace }}/mesa export CLANG_PATH=$(which clang-20) meson setup build/ -Db_staticpic=true -Dgallium-drivers=llvmpipe -Dplatforms="[]" -Dglx=disabled -Dvulkan-drivers=swrast,nouveau,freedreno -Dopengl=false -Degl=disabled -Dgbm=disabled -Dvideo-codecs="[]" meson compile -C build tinymesa tinymesa_cpu + - name: Build mesa (Android) + if: matrix.os == 'android' + shell: bash + run: | + export PATH="$ANDROID_SDK_ROOT/ndk/29.0.14206865/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH" + cd ${{ github.workspace }}/mesa + meson setup build/ --cross-file=../android.ini -Db_staticpic=true -Dplatforms=android -Dplatform-sdk-version=30 -Dandroid-stub=true -Dandroid-libbacktrace=disabled -Dgallium-drivers="[]" -Dvulkan-drivers=freedreno -Dfreedreno-kmds=kgsl -Dllvm=disabled -Dshader-cache=disabled -Dzstd=disabled -Dzlib=disabled -Dopengl=false -Degl=disabled -Dgbm=disabled -Dvideo-codecs="[]" + meson compile -C build tinymesa - name: Polyfill glibc - if: runner.os == 'Linux' + if: runner.os == 'Linux' && matrix.os != 'android' run: | # can't go earlier than 2.32 because of __libc_single_threaded@GLIBC_2.32 polyfill-glibc --target-glibc=2.32 ${{ github.workspace }}/mesa/build/src/tinymesa/libtinymesa*.so @@ -108,9 +120,10 @@ jobs: fi ./build_wheel.py "${VERSION_ARG[@]}" \ - --platform ${{ matrix.os == 'ubuntu-22.04' && 'manylinux_2_32_x86_64' || matrix.os == 'ubuntu-22.04-arm' && 'manylinux_2_32_aarch64' || 'macosx_14_0_arm64' }} \ + --platform ${{ matrix.os == 'android' && 'android_30_arm64_v8a' || matrix.os == 'ubuntu-22.04' && 'manylinux_2_32_x86_64' || matrix.os == 'ubuntu-22.04-arm' && 'manylinux_2_32_aarch64' || 'macosx_14_0_arm64' }} \ ${{ matrix.tag }} ${{ github.workspace }}/mesa/build/src/tinymesa/libtinymesa*${{ runner.os == 'macOS' && '.dylib' || '.so' }} - name: Test loading with ctypes + if: matrix.os != 'android' run: | pip install dist/*.whl python3 -c "from ctypes import CDLL; from tinymesa import libtinymesa, libtinymesa_cpu; CDLL(libtinymesa).glsl_type_singleton_init_or_ref(), CDLL(libtinymesa_cpu).glsl_type_singleton_init_or_ref()" @@ -119,6 +132,21 @@ jobs: with: name: tinymesa-whl-${{ matrix.tag }}-${{ matrix.os }} path: dist/ + - name: Upload Android library + if: matrix.os == 'android' + uses: actions/upload-artifact@v4 + with: + name: tinymesa-${{ matrix.tag }}-android-arm64-v8a + path: mesa/build/src/tinymesa/libtinymesa.so + - name: Attach Android library to GitHub release + if: matrix.os == 'android' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + env: + GH_TOKEN: ${{ github.token }} + run: | + cp mesa/build/src/tinymesa/libtinymesa.so libtinymesa-android-arm64-v8a.so + gh release view android > /dev/null 2>&1 || + gh release create android --target "$GITHUB_SHA" --title "Android arm64" --notes "Updated on tinymesa version releases." --latest=false + gh release upload android libtinymesa-android-arm64-v8a.so --clobber release: name: Release tinymesa runs-on: ubuntu-22.04 diff --git a/README.md b/README.md index 1bafeef..160ecca 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,14 @@ all these symbols, but in addition, a subset of symbols from `gallium` (see release notes), and as a result depends on LLVM-20. Builds are automatically generated upon new releases of mesa (checked daily). + +### Android (Termux) + +On arm64 Termux with Android 11 (API 30) or newer, download `libtinymesa.so` +into Termux's library directory. The Android build includes NIR and +IR3/freedreno, but not NAK or LLVMpipe. + +```sh +curl -fL "https://github.com/sirhcm/tinymesa/releases/download/android/libtinymesa-android-arm64-v8a.so" \ + -o "$PREFIX/lib/libtinymesa.so" +``` diff --git a/android.ini b/android.ini new file mode 100644 index 0000000..6f5d3b3 --- /dev/null +++ b/android.ini @@ -0,0 +1,14 @@ +[binaries] +ar = 'llvm-ar' +c = 'aarch64-linux-android30-clang' +cpp = 'aarch64-linux-android30-clang++' +strip = 'llvm-strip' + +[host_machine] +system = 'android' +cpu_family = 'aarch64' +cpu = 'armv8' +endian = 'little' + +[properties] +needs_exe_wrapper = true diff --git a/meson.build b/meson.build index 5e182ec..2fab834 100644 --- a/meson.build +++ b/meson.build @@ -52,6 +52,10 @@ foreach sym : ir3_symbols ir3_link_args += '-Wl,-u,' + symbol_prefix + sym endforeach -shared_library('tinymesa', link_whole : [ _libnir ], link_args : nak_link_args+ir3_link_args, link_with : [ libfreedreno_ir3, libfreedreno_common ], dependencies : [ idep_nak ]) -shared_library('tinymesa_cpu', link_whole : [ _libnir ], link_args : lvp_link_args+nak_link_args+ir3_link_args, link_with : [ libfreedreno_ir3, libfreedreno_common, libgallium ], dependencies : [ idep_nak ]) +if host_machine.system() == 'android' + shared_library('tinymesa', link_whole : [ _libnir ], link_args : ir3_link_args, link_with : [ libfreedreno_ir3, libfreedreno_common ]) +else + shared_library('tinymesa', link_whole : [ _libnir ], link_args : nak_link_args+ir3_link_args, link_with : [ libfreedreno_ir3, libfreedreno_common ], dependencies : [ idep_nak ]) + shared_library('tinymesa_cpu', link_whole : [ _libnir ], link_args : lvp_link_args+nak_link_args+ir3_link_args, link_with : [ libfreedreno_ir3, libfreedreno_common, libgallium ], dependencies : [ idep_nak ]) +endif