Build Android #68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Android | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| arch: ["aarch64"] | |
| fail-fast: false | |
| name: "Build for ${{matrix.arch}}" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set Up Environment | |
| run: | | |
| sudo apt update | |
| sudo apt-get install -y libxrandr-dev libxxf86vm-dev libxcb-*-dev libx11-xcb-dev libxfixes-dev libx11-dev | |
| sudo apt-get install glslang-tools libclc-18-dev libclc-18 gcc-13-aarch64-linux-gnu | |
| pip3 install mako meson ninja | |
| - name: Set ndkver,sdkver and work_dir | |
| run: | | |
| # to support Android 14+ r27d is needed. | |
| echo "NDK_VER=android-ndk-r27d" >> $GITHUB_ENV | |
| #echo "SDK_VER=29" >> $GITHUB_ENV | |
| echo "WORK_DIR=$(pwd)" >> $GITHUB_ENV | |
| echo "MESA_VER=mesa-25.2.1" >> $GITHUB_ENV | |
| - name: Download and extract NDK/Mesa | |
| run: | | |
| echo "Downloading android-ndk from google server ..." | |
| curl https://dl.google.com/android/repository/${NDK_VER}-linux.zip --output ${NDK_VER}-linux.zip &> /dev/null | |
| echo "Extracting android-ndk to a folder ..." | |
| unzip ${NDK_VER}-linux.zip &> /dev/null | |
| echo "Cloing vndk v34..." | |
| git clone -b sdk-release --depth=1 https://android.googlesource.com/platform/prebuilts/vndk/v34 || true | |
| mkdir -p ${WORK_DIR}/${NDK_VER}/prebuilt/vndk/ | |
| cp -r v34 ${WORK_DIR}/${NDK_VER}/prebuilt/vndk/ | |
| ls ${WORK_DIR}/${NDK_VER}/prebuilt/vndk | |
| ls ${WORK_DIR}/${NDK_VER}/prebuilt/vndk/v34/ | |
| echo "Get Mesa Repository ..." | |
| # | |
| # it is very annoying to deal with static build libdrm and host libdrm conflict | |
| # so from now on dont use pkgconfig any more and do not manually compile libdrm. | |
| # minigbm and mesa will do its job by compile as subproject and link with it. | |
| # the trade off is libdrm need compile 2 times. | |
| # | |
| #git clone https://gitlab.freedesktop.org/mesa/drm.git | |
| git clone --depth 1 --branch ${MESA_VER} https://gitlab.freedesktop.org/mesa/mesa.git | |
| cd mesa | |
| git remote add 99degree https://github.com/99degree/mesa.git | |
| git fetch 99degree local-${MESA_VER} | |
| git merge 99degree/local-${MESA_VER} | |
| cd .. | |
| git clone --depth 1 https://android.googlesource.com/platform/external/minigbm | |
| cd minigbm | |
| git remote add 99degree https://github.com/99degree/minigbm.git | |
| git fetch 99degree local-main | |
| git merge 99degree/local-main | |
| cd .. | |
| git clone --depth 1 https://android.googlesource.com/platform/system/core | |
| echo "Ready!!!" | |
| - name: Build | |
| run: | | |
| envsubst <android-${{matrix.arch}}>build-crossfile | |
| #cd drm | |
| #meson setup "build-android" \ | |
| # --prefix=/tmp/drm-static \ | |
| # --cross-file "../build-crossfile-drm" \ | |
| # -Ddefault_library=static \ | |
| # -Dintel=disabled \ | |
| # -Dradeon=disabled \ | |
| # -Damdgpu=disabled \ | |
| # -Dnouveau=disabled \ | |
| # -Dvmwgfx=disabled \ | |
| # -Dfreedreno=enabled \ | |
| # -Dvc4=disabled \ | |
| # -Detnaviv=disabled \ | |
| # -Dfreedreno-kgsl=true | |
| #ninja -C "build-android" install | |
| #cd .. | |
| envsubst <android-${{matrix.arch}}>build-crossfile | |
| cd minigbm | |
| # Makefile method is not useded here, meson instead. | |
| #OUT='/tmp/minigbm/output' \ | |
| #LDFLAGS='-L/tmp/drm-static/lib/' \ | |
| #ARCH=arm64 \ | |
| #CFLAGS='-DDRV_MSM -D__ANDROID__ -I/tmp/drm-static/include -I${WORK_DIR}/${NDK_VER}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/ -I${WORK_DIR}/core/libcutils/include_outside_system/' \ | |
| #CC='${WORK_DIR}/${NDK_VER}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android34-clang' make || true | |
| # | |
| # Use meson!!! | |
| # a nice plus is build libdrm as many backend as possible | |
| # | |
| meson setup build-android \ | |
| --prefix=/tmp/minigbm \ | |
| -Dndk_root=${WORK_DIR}/${NDK_VER} \ | |
| --cross-file ../build-crossfile \ | |
| --force-fallback-for=libdrm \ | |
| -Ddefault_library=static \ | |
| -Dlibdrm:freedreno-kgsl=true \ | |
| -Dlibdrm:intel=auto \ | |
| -Dlibdrm:radeon=auto \ | |
| -Dlibdrm:amdgpu=auto \ | |
| -Dlibdrm:nouveau=auto \ | |
| -Dlibdrm:vmwgfx=enabled \ | |
| -Dlibdrm:omap=enabled \ | |
| -Dlibdrm:freedreno=enabled \ | |
| -Dlibdrm:tegra=enabled \ | |
| -Dlibdrm:etnaviv=enabled \ | |
| -Dlibdrm:exynos=enabled \ | |
| -Dlibdrm:vc4=enabled | |
| ninja -C build-android install | |
| #find /tmp/minigbm -name "libminigbm*" -exec cp {} /tmp/minigbm \; || true | |
| cd .. | |
| #envsubst <android-${{matrix.arch}}>build-crossfile | |
| cd mesa | |
| meson setup "build-android" \ | |
| --prefix=/tmp/mesa \ | |
| --cross-file "../build-crossfile" \ | |
| -Dallow-fallback-for=libdrm \ | |
| -Dplatforms=android \ | |
| -Dplatform-sdk-version=34 \ | |
| -Dandroid-stub=true \ | |
| -Dandroid-libbacktrace=disabled \ | |
| -Dandroid-strict=false \ | |
| -Dxlib-lease=disabled \ | |
| -Degl=true \ | |
| -Dgbm=false \ | |
| -Dglx=disabled \ | |
| -Dllvm=false \ | |
| -Dopengl=true \ | |
| -Dgles1=true \ | |
| -Dgles2=true \ | |
| -Dvulkan-drivers=freedreno \ | |
| -Dtools=drm-shim \ | |
| -Dgallium-drivers=zink,freedreno \ | |
| -Dfreedreno-kmds=kgsl,msm \ | |
| -Dmesa-clc=auto \ | |
| -Dbuildtype=release | |
| #-Dgallium-opencl=disabled \ | |
| #-Dgallium-rusticl=false \ | |
| ninja -C "build-android" install | |
| mkdir /tmp/mesa/output | |
| mkdir /tmp/mesa/drm_shim | |
| cd /tmp/mesa/lib | |
| ls -a | |
| cp libOSMesa.so /tmp/mesa/output/libOSMesa_8.so || true | |
| cp libxatracker.so /tmp/mesa/output/libxatracker.so || true | |
| cp libfreedreno_noop_drm_shim.so /tmp/mesa/drm_shim/libfreedreno_noop_drm_shim.so || true | |
| # cp libpanfrost_noop_drm_shim.so /tmp/mesa/drm_shim/libpanfrost_noop_drm_shim.so || true | |
| cd .. | |
| find -name '*.so' -exec cp {} /tmp/mesa/output/ \; || true | |
| - name: Upload Mesa libraries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libOSMesa_${{matrix.arch}} | |
| path: /tmp/mesa/output/*.so | |
| - name: Upload drm_shim tools libraries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Noop_drm_shim_${{matrix.arch}} | |
| path: /tmp/mesa/drm_shim/* | |
| - name: Upload minigbm libraries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: minigbm_${{matrix.arch}} | |
| path: /tmp/minigbm/lib/*.so |