diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 664b528..ea822ba 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -119,10 +119,50 @@ jobs: with: name: tinymesa-whl-${{ matrix.tag }}-${{ matrix.os }} path: dist/ + android: + name: Build tinymesa mesa-25.2.7 on Android arm64 + runs-on: ubuntu-22.04 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup tinymesa + uses: ./.github/actions/setup + - name: Verify Android NDK + shell: bash + run: | + test -x "${ANDROID_SDK_ROOT}/ndk/29.0.14206865/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang" + - name: Clone mesa + run: git clone --depth 1 --branch mesa-25.2.7 https://gitlab.freedesktop.org/mesa/mesa.git ${{ github.workspace }}/mesa + - name: Patch mesa + run: ./apply_patches.py ${{ github.workspace }}/mesa mesa-25.2.7 + - name: Build mesa + 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=${{ github.workspace }}/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: Build wheel + run: | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + VERSION_ARG=(--tag "$GITHUB_REF_NAME") + else + VERSION_ARG=(--sha "${GITHUB_SHA::7}") + fi + + ./build_wheel.py "${VERSION_ARG[@]}" \ + --platform android_30_arm64_v8a \ + mesa-25.2.7 ${{ github.workspace }}/mesa/build/src/tinymesa/libtinymesa.so + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: tinymesa-whl-mesa-25.2.7-android-arm64-v8a + path: dist/ + release: name: Release tinymesa runs-on: ubuntu-22.04 - needs: tinymesa + needs: [ tinymesa, android ] if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') environment: name: pypi diff --git a/README.md b/README.md index 1bafeef..f4d9817 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ libvulkan_lvp.so (interpreter => None) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 + ld-linux-x86-64.so.2 => /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ``` ### tinymesa: ``` @@ -82,3 +83,21 @@ 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 + +Android arm64-v8a wheels require Android 11 (API 30) or newer and currently +ship `libtinymesa.so` with NIR + IR3/freedreno support. NAK is not included, +and `libtinymesa_cpu.so`/LLVMpipe is not built. + +Termux Python currently advertises an Android API 24 platform tag, so plain +`pip install tinymesa` will reject the API 30 wheel even on newer devices. +Install it explicitly with: + +```sh +python -m pip install \ + --platform android_30_arm64_v8a \ + --only-binary=:all: \ + --target "$(python -c 'import sysconfig; print(sysconfig.get_path("purelib"))')" \ + tinymesa +``` 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