Skip to content

Build Kernel

Build Kernel #5

Workflow file for this run

name: Build Kernel
on:
workflow_dispatch:
inputs:
KERNEL_SOURCE:
description: 'Kernel Source'
required: true
default: 'MangTianYa/kernel_xiaomi_sm8250'
KERNEL_SOURCE_BRANCH:
description: 'Branch'
required: true
default: 'aosp-15'
KERNEL_DEFCONFIG:
description: 'Defconfig'
required: true
default: 'alioth_defconfig'
AOSP_CLANG_BRANCH:
description: 'AOSP Clang branch'
required: true
default: 'main'
AOSP_CLANG_VERSION:
description: 'AOSP Clang version'
required: true
default: 'r530567'
USE_CUSTOM_CLANG:
description: 'Use Custom Clang'
required: true
default: false
type: boolean
CUSTOM_CLANG_URL:
description: 'Custom Clang URL'
required: true
default: 'https://raw.githubusercontent.com/ZyCromerZ/Clang/main/Clang-main-link.txt'
# PERSONAL_TOKEN:
# description: 'Personal access token'
# required: true
# default: ''
ENABLE_KERNELSU:
description: 'Use KernelSU'
required: true
default: true
type: boolean
ENABLE_KERNELSU_DEBUG:
description: 'Use KernelSU Debug'
required: true
default: false
type: boolean
ADD_PATH_UMOUNT:
description: 'Add `path_umount` for KernelSU'
required: true
default: false
type: boolean
jobs:
build:
name: Build Kernel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Configuration
run: |
echo "KERNEL_SOURCE=${{ github.event.inputs.KERNEL_SOURCE }}" >> $GITHUB_ENV
echo "KERNEL_SOURCE_BRANCH=${{ github.event.inputs.KERNEL_SOURCE_BRANCH }}" >> $GITHUB_ENV
echo "KERNEL_DEFCONFIG=${{ github.event.inputs.KERNEL_DEFCONFIG }}" >> $GITHUB_ENV
echo "AOSP_CLANG_BRANCH=${{ github.event.inputs.AOSP_CLANG_BRANCH }}" >> $GITHUB_ENV
echo "AOSP_CLANG_VERSION=${{ github.event.inputs.AOSP_CLANG_VERSION }}" >> $GITHUB_ENV
echo "USE_CUSTOM_CLANG=${{ github.event.inputs.USE_CUSTOM_CLANG }}" >> $GITHUB_ENV
echo "CUSTOM_CLANG_URL=${{ github.event.inputs.CUSTOM_CLANG_URL }}" >> $GITHUB_ENV
# echo "PERSONAL_TOKEN=${{ github.event.inputs.PERSONAL_TOKEN }}" >> $GITHUB_ENV
echo "ENABLE_KERNELSU=${{ github.event.inputs.ENABLE_KERNELSU }}" >> $GITHUB_ENV
echo "ENABLE_KERNELSU_DEBUG=${{ github.event.inputs.ENABLE_KERNELSU_DEBUG }}" >> $GITHUB_ENV
echo "ADD_PATH_UMOUNT=${{ github.event.inputs.ADD_PATH_UMOUNT }}" >> $GITHUB_ENV
- name: Setup Build Environment
run: |
echo "BUILD_TIME=$(TZ=Asia/Shanghai date "+%Y%m%d%H%M")" >> $GITHUB_ENV
echo "DEVICE=$(echo ${{ env.KERNEL_DEFCONFIG }} | sed 's!vendor/!!;s/_defconfig//;s/_user//;s/-perf//')" >> $GITHUB_ENV
sudo apt update
sudo apt install bc make bison build-essential curl flex g++-multilib gcc-multilib git gnupg gperf libfuse-dev lib32readline-dev lib32z1-dev liblz4-tool libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool squashfs-tools xsltproc zlib1g-dev libc6-dev-i386 libncurses6 libncursesw6 lib32ncurses-dev lib32ncurses6 lib32ncursesw6 libncurses5-dev
- name: Download AOSP Clang Toolchain
if: env.USE_CUSTOM_CLANG == 'false'
run: |
wget -q https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/${{ env.AOSP_CLANG_BRANCH }}/clang-${{ env.AOSP_CLANG_VERSION }}.tar.gz -O clang.tar.gz
- name: Download Custom Clang Toolchain
if: env.USE_CUSTOM_CLANG == 'true'
run: |
wget -q $(curl ${{ env.CUSTOM_CLANG_URL }}) -O clang.tar.gz
- name: Extract Clang Toolchain
run: |
mkdir clang
tar -C clang/ -zxf clang.tar.gz
- name: Checkout Kernel
uses: actions/checkout@v4
with:
# token: ${{env.PERSONAL_TOKEN}}
repository: ${{ env.KERNEL_SOURCE }}
ref: ${{ env.KERNEL_SOURCE_BRANCH }}
submodules: recursive
path: kernel-source
- name: Checkout AnyKernel3
uses: actions/checkout@v4
with:
# token: ${{env.PERSONAL_TOKEN}}
repository: sakana164/AnyKernel3_old
path: kernel-source/AnyKernel3
- name: Setup KernelSU
if: env.ENABLE_KERNELSU == 'true'
run: |
cd kernel-source
git config --global user.email "lightsummer233@awainatsu.moe"
git config --global user.name "lightsummer233"
git am ../patch/KernelSU.patch
echo "CONFIG_KSU=y" >> arch/arm64/configs/${{ env.KERNEL_DEFCONFIG }}
curl -LSs "https://raw.githubusercontent.com/lightsummer233/KernelSU/main/kernel/setup.sh" | bash -s main
echo "ENABLE_KERNELSU=-KernelSU" >> $GITHUB_ENV
if [ ${{ env.ENABLE_KERNELSU_DEBUG }} = true ]; then
echo "CONFIG_KSU_DEBUG=y" >> arch/arm64/configs/${{ env.KERNEL_DEFCONFIG }}
fi
if [ ${{ env.ADD_PATH_UMOUNT }} = true ]; then
git am ../patch/KernelSU-path_umount.patch
fi
- name: Build Kernel
run: |
cd kernel-source
export PATH=$GITHUB_WORKSPACE/clang/bin:$PATH
export KBUILD_BUILD_HOST=AL1S
export KBUILD_BUILD_USER=awainatsu
make -j$(nproc --all) O=out ARCH=arm64 CC=clang ${{ env.KERNEL_DEFCONFIG }}
scripts/config --file out/.config \
-e THINLTO \
-e LTO_CLANG \
-d CONFIG_CFI_CLANG \
-d CFI_PERMISSIVE \
-d CFI_CLANG \
-e COMPAT_VDSO \
-e SHADOW_CALL_STACK \
-e SHADOW_CALL_STACK_VMAP \
-e RELR
make -j$(nproc --all) O=out ARCH=arm64 CC=clang LLVM=1 LLVM_IAS=1 \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_COMPAT=arm-linux-gnueabi-
- name: Configuration AnyKernel3
run: |
cd kernel-source
KERNEL_NAME=$(grep "CONFIG_LOCALVERSION=" arch/arm64/configs/vendor/xiaomi/sm8250-common.config | cut -d'-' -f2 | tr -d '"')
sed -i "s/アリエス/$KERNEL_NAME/g" ./AnyKernel3/anykernel.sh
cp out/arch/arm64/boot/Image AnyKernel3
# cp out/arch/arm64/boot/dtbo.img AnyKernel3
# cp out/arch/arm64/boot/dtb AnyKernel3
- name: Upload Kernel
uses: actions/upload-artifact@v4
with:
name: ${{ env.KERNEL_SOURCE_BRANCH }}-kernel-${{ env.DEVICE }}${{ env.ENABLED_KERNELSU }}-${{ env.BUILD_TIME }}
path: |
kernel-source/AnyKernel3/
!kernel-source/AnyKernel3/*.git*
!kernel-source/AnyKernel3/patch
!kernel-source/AnyKernel3/modules
!kernel-source/AnyKernel3/ramdisk
compression-level: 9