diff --git a/.github/workflows/suyu-android-build.yml b/.github/workflows/suyu-android-build.yml new file mode 100644 index 0000000..2e06270 --- /dev/null +++ b/.github/workflows/suyu-android-build.yml @@ -0,0 +1,65 @@ +name: suyu-android-build + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + suyu_android_build: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Download suyu source code + run: | + cd ${{ github.workspace }} + git clone https://gitlab.com/suyu-emu/suyu.git --recursive + cd suyu + git checkout dev + + - id: version + name: Get version + run: | + echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT + cd ${{ github.workspace }}/suyu + echo "hash=$(git log -1 --pretty=format:%H)" >> $GITHUB_OUTPUT + echo "short_hash=$(git describe --always --long)" >> $GITHUB_OUTPUT + + - name: Set up cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ~/.ccache + key: ${{ runner.os }}-android-${{ steps.version.outputs.hash }} + restore-keys: | + ${{ runner.os }}-android- + + - name: Prepare environment + run: | + sudo apt-get install ccache glslang-dev glslang-tools + + - name: Build Android + run: | + export NDK_CCACHE="$(which ccache)" + ccache -s + cd ${{ github.workspace }}/suyu/src/android + chmod +x ./gradlew + ./gradlew "assembleMainlineRelease" + mv app/build/outputs/apk/mainline/release/app-mainline-release.apk ${{ github.workspace }}/suyu-${{ steps.version.outputs.date }}-${{ steps.version.outputs.short_hash }}.apk + ccache -s + + - name: Release + uses: softprops/action-gh-release@v2 + with: + name: ${{ steps.version.outputs.date }} + body: 非suyu官方每日构建版本,dev分支构建,不提供任何更新说明,遇到任何问题请前往https://gitlab.com/suyu-emu/suyu/-/issues + tag_name: ${{ steps.version.outputs.date }} + files: ${{ github.workspace }}/suyu-${{ steps.version.outputs.date }}-${{ steps.version.outputs.short_hash }}.apk diff --git a/.github/workflows/turnip_ci.yml b/.github/workflows/turnip_ci.yml new file mode 100644 index 0000000..7e98789 --- /dev/null +++ b/.github/workflows/turnip_ci.yml @@ -0,0 +1,46 @@ +name: Release "turnip" + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +jobs: + start_building_turnip: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: { ref: alpha } + + - name: Prepare environment + run: | + sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list + sudo apt update + sudo apt build-dep mesa -y + sudo sed -i 's/jammy/mantic/g' /etc/apt/sources.list + sudo apt update + sudo apt install meson + + - name: Execute build script + run: bash ./turnip_builder.sh + + - name: Set current date + id: set_date + run: echo "::set-output name=current_date::$(date '+%Y%m%d')" + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.0 + with: + name: Upload meson and ninja logs for debugging + path: | + turnip_workdir/ninja_log + turnip_workdir/mesa-main/build-android-aarch64/meson-logs/meson-log.txt + + - name: Release ${{ steps.set_date.outputs.current_date }} + uses: softprops/action-gh-release@v1 + with: + body: Turnip Android module + tag_name: github_run + name: ${{ steps.set_date.outputs.current_date }} + files: | + turnip_workdir/turnip_${{ steps.set_date.outputs.current_date }}.zip diff --git a/turnip_builder.sh b/turnip_builder.sh new file mode 100644 index 0000000..264aa16 --- /dev/null +++ b/turnip_builder.sh @@ -0,0 +1,138 @@ +#!/bin/sh +green='\033[0;32m' +red='\033[0;31m' +nocolor='\033[0m' +deps="meson ninja patchelf unzip curl pip flex bison zip" +workdir="$(pwd)/turnip_workdir" +driverdir="$workdir/turnip_module" +ndkver="android-ndk-r25c" +clear + + + +echo "Checking system for required Dependencies ..." +for deps_chk in $deps; + do + sleep 0.25 + if command -v $deps_chk >/dev/null 2>&1 ; then + echo -e "$green - $deps_chk found $nocolor" + else + echo -e "$red - $deps_chk not found, can't countinue. $nocolor" + deps_missing=1 + fi; + done + + if [ "$deps_missing" == "1" ] + then echo "Please install missing dependencies" && exit 1 + fi + + + +echo "Installing python Mako dependency (if missing) ..." $'\n' +pip install mako &> /dev/null + + + +echo "Creating and entering to work directory ..." $'\n' +mkdir -p $workdir && cd $workdir + + + +echo "Downloading android-ndk from google server (~506 MB) ..." $'\n' +curl https://dl.google.com/android/repository/"$ndkver"-linux.zip --output "$ndkver"-linux.zip &> /dev/null +### +echo "Exracting android-ndk to a folder ..." $'\n' +unzip "$ndkver"-linux.zip &> /dev/null + + + +echo "Downloading mesa source (~30 MB) ..." $'\n' +curl https://gitlab.freedesktop.org/mesa/mesa/-/archive/main/mesa-main.zip --output mesa-main.zip &> /dev/null +### +echo "Exracting mesa source to a folder ..." $'\n' +unzip mesa-main.zip &> /dev/null +cd mesa-main + + + +echo "Creating meson cross file ..." $'\n' +ndk="$workdir/$ndkver/toolchains/llvm/prebuilt/linux-x86_64/bin" +cat <"android-aarch64" +[binaries] +ar = '$ndk/llvm-ar' +c = ['ccache', '$ndk/aarch64-linux-android31-clang'] +cpp = ['ccache', '$ndk/aarch64-linux-android31-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++'] +c_ld = 'lld' +cpp_ld = 'lld' +strip = '$ndk/aarch64-linux-android-strip' +pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=NDKDIR/pkgconfig', '/usr/bin/pkg-config'] +[host_machine] +system = 'android' +cpu_family = 'aarch64' +cpu = 'armv8' +endian = 'little' +EOF + + + +echo "Generating build files ..." $'\n' +meson build-android-aarch64 --cross-file $workdir/mesa-main/android-aarch64 -Dbuildtype=release -Dplatforms=android -Dplatform-sdk-version=31 -Dandroid-stub=true -Dgallium-drivers= -Dvulkan-drivers=freedreno -Dfreedreno-kmds=kgsl -Db_lto=true &> $workdir/meson_log + + + +echo "Compiling build files ..." $'\n' +ninja -C build-android-aarch64 &> $workdir/ninja_log + + + +echo "Using patchelf to match soname ..." $'\n' +cp $workdir/mesa-main/build-android-aarch64/src/freedreno/vulkan/libvulkan_freedreno.so $workdir +cp $workdir/mesa-main/build-android-aarch64/src/android_stub/libhardware.so $workdir +cp $workdir/mesa-main/build-android-aarch64/src/android_stub/libsync.so $workdir +cp $workdir/mesa-main/build-android-aarch64/src/android_stub/libbacktrace.so $workdir +cd $workdir +patchelf --set-soname vulkan.adreno.so libvulkan_freedreno.so +mv libvulkan_freedreno.so vulkan.adreno.so + + + +if ! [ -a vulkan.adreno.so ]; then + echo -e "$red Build failed! $nocolor" && exit 1 +fi + + + +echo "Prepare magisk module structure ..." $'\n' +mkdir -p $driverdir +cd $driverdir + + +cat <"meta.json" +{ + "schemaVersion": 1, + "name": "Mesa Turnip Adreno Driver Daily", + "description": "Open-source Vulkan driver build from mesa drivers repo", + "author": "ImpXada", + "packageVersion": "T-Alpha", + "vendor": "Mesa", + "driverVersion": "mesa-main", + "minApi": 31, + "libraryName": "vulkan.adreno.so" +} +EOF + + +echo "Copy necessary files from work directory ..." $'\n' +cp $workdir/vulkan.adreno.so $driverdir +cp $workdir/libhardware.so $driverdir +cp $workdir/libsync.so $driverdir +cp $workdir/libbacktrace.so $driverdir + + +current_date=$(date "+%Y%m%d") +echo "Packing files in to magisk module ..." $'\n' +zip -r $workdir/turnip_$current_date.zip * &> /dev/null +if ! [ -a $workdir/turnip_$current_date.zip ]; + then echo -e "$red-Packing failed!$nocolor" && exit 1 + else echo -e "$green-All done, you can take your module from here;$nocolor" && echo $workdir/turnip_$current_date.zip +fi