Skip to content

Build Kernel by LLVM clang #167

Build Kernel by LLVM clang

Build Kernel by LLVM clang #167

name: Build Kernel by LLVM clang
on:
watch:
types: [started]
workflow_dispatch:
jobs:
build:
name: Build Kernel by ${{ github.actor }}
runs-on: ubuntu-20.04
if: github.event.repository.owner.id == github.event.sender.id
env:
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
CCACHE_NOHASHDIR: "true"
CCACHE_HARDLINK: "true"
steps:
- uses: actions/checkout@v4
- name: Prepare Configuration
run: |
CONFIG_ENV=$(cat config.env | grep -w "CONFIG_ENV" | head -n 1 | cut -d "=" -f 2)
echo "KERNEL_SOURCE=$(cat $CONFIG_ENV | grep -w "KERNEL_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_SOURCE_BRANCH=$(cat $CONFIG_ENV | grep -w "KERNEL_SOURCE_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_CONFIG=$(cat $CONFIG_ENV | grep -w "KERNEL_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_IMAGE_NAME=$(cat $CONFIG_ENV | grep -w "KERNEL_IMAGE_NAME" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ARCH=$(cat $CONFIG_ENV | grep -w "ARCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "EXTRA_CMDS=$(cat $CONFIG_ENV | grep -w "EXTRA_CMDS" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV
echo "USE_CUSTOM_CLANG=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_CLANG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_CLANG_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_CLANG_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_CLANG_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_CLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_CMDS=$(cat $CONFIG_ENV | grep -w "CUSTOM_CMDS" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV
echo "CLANG_BRANCH=$(cat $CONFIG_ENV | grep -w "CLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CLANG_VERSION=$(cat $CONFIG_ENV | grep -w "CLANG_VERSION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ENABLE_GCC_ARM64=$(cat $CONFIG_ENV | grep -w "ENABLE_GCC_ARM64" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ENABLE_GCC_ARM32=$(cat $CONFIG_ENV | grep -w "ENABLE_GCC_ARM32" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "USE_CUSTOM_GCC_64=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_GCC_64" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_GCC_64_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_GCC_64_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_GCC_64_BIN=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_64_BIN" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "USE_CUSTOM_GCC_32=$(cat $CONFIG_ENV | grep -w "USE_CUSTOM_GCC_32" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_GCC_32_SOURCE=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_32_SOURCE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_GCC_32_BRANCH=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_32_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_GCC_32_BIN=$(cat $CONFIG_ENV | grep -w "CUSTOM_GCC_32_BIN" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ENABLE_KERNELSU=$(cat $CONFIG_ENV | grep -w "ENABLE_KERNELSU" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNELSU_TAG=$(cat $CONFIG_ENV | grep -w "KERNELSU_TAG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ADD_KPROBES_CONFIG=$(cat $CONFIG_ENV | grep -w "ADD_KPROBES_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "DISABLE-LTO=$(cat $CONFIG_ENV | grep -w "DISABLE-LTO" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ADD_OVERLAYFS_CONFIG=$(cat $CONFIG_ENV | grep -w "ADD_OVERLAYFS_CONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "DISABLE_CC_WERROR=$(cat $CONFIG_ENV | grep -w "DISABLE_CC_WERROR" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ENABLE_CCACHE=$(cat $CONFIG_ENV | grep -w "ENABLE_CCACHE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "NEED_DTBO=$(cat $CONFIG_ENV | grep -w "NEED_DTBO" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "BUILD_BOOT_IMG=$(cat $CONFIG_ENV | grep -w "BUILD_BOOT_IMG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "SOURCE_BOOT_IMAGE=$(cat $CONFIG_ENV | grep -w "SOURCE_BOOT_IMAGE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KSU_EXPECTED_SIZE=$(cat $CONFIG_ENV | grep -w "KSU_EXPECTED_SIZE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KSU_EXPECTED_HASH=$(cat $CONFIG_ENV | grep -w "KSU_EXPECTED_HASH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ENABLE_LXC=$(cat $CONFIG_ENV | grep -w "ENABLE_LXC" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "TCLANG_BRANCH=$(cat $CONFIG_ENV | grep -w "TCLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "LLVM_CLANG_VERSION=$(cat $CONFIG_ENV | grep -w "LLVM_CLANG_VERSION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "ELECTRON_BINUTILS_VERSION1=$(cat $CONFIG_ENV | grep -w "ELECTRON_BINUTILS_VERSION1" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
- name: Set swap to 10G
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- name: Setup build kernel environment
run: |
echo "BUILD_TIME=$(TZ=Asia/Shanghai date "+%Y%m%d%H%M")" >> $GITHUB_ENV
echo "DEVICE=$(echo ${{ env.KERNEL_CONFIG }} | sed 's!vendor/!!;s/_defconfig//;s/_user//;s/-perf//')" >> $GITHUB_ENV
sudo apt-get update
#sudo apt-get install git ccache automake flex lzop bison gperf build-essential zip curl zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip device-tree-compiler python2 python3
sudo apt install -y lld llvm gcc binutils-arm-linux-gnueabi binutils-aarch64-linux-gnu curl wget vim git ccache automake flex lzop bison gperf build-essential zip zlib1g-dev g++-multilib libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng maven libssl-dev pwgen libswitch-perl policycoreutils minicom libxml-sax-base-perl libxml-simple-perl bc libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev xsltproc unzip device-tree-compiler kmod python3 python3-pip
mkdir -p $GITHUB_WORKSPACE/kernel_workspace
- name: Download LLVM-clang and electron-binutils
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir llvm-clang && mkdir binutils
if [ ${{ env.LLVM_CLANG_VERSION }} = 16.0.0 ]; then
wget -O clang16.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar -C llvm-clang/ -xf clang16.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 15.0.6 ]; then
wget -O clang15.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.6/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar -C llvm-clang/ -xf clang15.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 14.0.0 ]; then
wget -O clang14.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar -C llvm-clang/ -xf clang14.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 13.0.0 ]; then
wget -O clang13.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
tar -C llvm-clang/ -xf clang13.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 12.0.0 ]; then
wget -O clang12.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
tar -C llvm-clang/ -xf clang12.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 11.1.0 ]; then
wget -O clang111.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/clang+llvm-11.1.0-x86_64-linux-gnu-ubuntu-20.10.tar.xz
tar -C llvm-clang/ -xf clang111.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 11.0.0 ]; then
wget -O clang11.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
tar -C llvm-clang/ -xf clang11.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 10.0.0 ]; then
wget -O clang10.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
tar -C llvm-clang/ -xf clang10.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 10.0.1 ]; then
wget -O clang101.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/clang+llvm-10.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar -C llvm-clang/ -xf clang101.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 9.0.1 ]; then
wget -O clang901.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/clang+llvm-9.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz
tar -C llvm-clang/ -xf clang901.tar.xz
fi
if [ ${{ env.LLVM_CLANG_VERSION }} = 8.0.1 ]; then
wget -O clang801.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/clang+llvm-8.0.1-x86_64-linux-gnu-ubuntu-14.04.tar.xz
tar -C llvm-clang/ -xf clang801.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.41 ]; then
wget -O binutils241.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.41.tar.xz
tar -C binutils/ -xf binutils241.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.40 ]; then
wget -O binutils240.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.40.tar.xz
tar -C binutils/ -xf binutils240.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.39 ]; then
wget -O binutils239.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.39.tar.xz
tar -C binutils/ -xf binutils239.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.38 ]; then
wget -O binutils238.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.38.tar.xz
tar -C binutils/ -xf binutils238.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.37 ]; then
wget -O binutils237.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.37.tar.xz
tar -C binutils/ -xf binutils237.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.36.1 ]; then
wget -O binutils2361.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.36.1.tar.xz
tar -C binutils/ -xf binutils2361.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.36 ]; then
wget -O binutils236.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.36.tar.xz
tar -C binutils/ -xf binutils236.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.35.2 ]; then
wget -O binutils2352.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/V6/electron-binutils-2.35.2.tar.xz
tar -C binutils/ -xf binutils2352.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.35.1 ]; then
wget -O binutils2351.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/V6/electron-binutils-2.35.1.tar.xz
tar -C binutils/ -xf binutils2351.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.35 ]; then
wget -O binutils235.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/v5/electron-binutils-2.35.tar.xz
tar -C binutils/ -xf binutils235.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.34 ]; then
wget -O binutils234.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/V6/electron-binutils-2.34.tar.xz
tar -C binutils/ -xf binutils234.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.33.1 ]; then
wget -O binutils2331.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/V6/electron-binutils-2.33.1.tar.xz
tar -C binutils/ -xf binutils2331.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.32 ]; then
wget -O binutils232.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/V6/electron-binutils-2.32.tar.xz
tar -C binutils/ -xf binutils232.tar.xz
fi
if [ ${{ env.ELECTRON_BINUTILS_VERSION1 }} = 2.31 ]; then
wget -O binutils231.tar.xz https://github.com/tomxi1997/Electron-binutils-build-for-arm64-x86_64/releases/download/V6/electron-binutils-2.31.tar.xz
tar -C binutils/ -xf binutils231.tar.xz
fi
- name: Download mkbootimg tools
if: env.BUILD_BOOT_IMG == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone https://android.googlesource.com/platform/system/tools/mkbootimg tools -b master-kernel-build-2022 --depth=1
- name: Download kernel source
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone ${{ env.KERNEL_SOURCE }} -b ${{ env.KERNEL_SOURCE_BRANCH }} android-kernel --depth=1
- name: Download source boot image
if: env.BUILD_BOOT_IMG == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
wget -O boot-source.img ${{ env.SOURCE_BOOT_IMAGE }}
if [ -f boot-source.img ]; then
echo "FORMAT_MKBOOTING=$(echo `tools/unpack_bootimg.py --boot_img=boot-source.img --format mkbootimg`)" >> $GITHUB_ENV
echo "HAVE_SOURCE_BOOT_IMAGE=true" >> $GITHUB_ENV
fi
- name: Setup KernelSU
if: env.ENABLE_KERNELSU == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s ${{ env.KERNELSU_TAG }}
echo "UPLOADNAME=-KernelSU" >> $GITHUB_ENV
- name: Setup Configuration for Kernel
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
if [ ${{ env.ADD_KPROBES_CONFIG }} = true ]; then
echo "CONFIG_MODULES=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_KPROBES=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_HAVE_KPROBES=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_KPROBE_EVENTS=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
fi
if [ ${{ env.ADD_OVERLAYFS_CONFIG }} = true ]; then
echo "CONFIG_OVERLAY_FS=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
fi
if [ ${{ env.DISABLE-LTO }} = true ]; then
sed -i 's/CONFIG_LTO=y/CONFIG_LTO=n/' arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
sed -i 's/CONFIG_LTO_CLANG=y/CONFIG_LTO_CLANG=n/' arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
sed -i 's/CONFIG_THINLTO=y/CONFIG_THINLTO=n/' arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_LTO_NONE=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
fi
if [ ${{ env.DISABLE_CC_WERROR }} = true ]; then
echo "CONFIG_CC_WERROR=n" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
fi
- name: Setup LXC
if: env.ENABLE_LXC == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
rm -rf utils
git clone https://github.com/tomxi1997/lxc-docker-support-for-android.git utils
echo 'source "utils/Kconfig"' >> "Kconfig"
echo "CONFIG_DOCKER=y" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
sed -i '/CONFIG_ANDROID_PARANOID_NETWORK/d' arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
echo "# CONFIG_ANDROID_PARANOID_NETWORK is not set" >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
#sed -i '/CONFIG_LOCALVERSION/d' arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
#echo 'CONFIG_LOCALVERSION="-LXC-KernelSU-support_Pdx"' >> arch/${{ env.ARCH }}/configs/${{ env.KERNEL_CONFIG }}
chmod +x $GITHUB_WORKSPACE/kernel_workspace/android-kernel/utils/runcpatch.sh
if [ -f $GITHUB_WORKSPACE/kernel_workspace/android-kernel/kernel/cgroup/cgroup.c ]; then
sh $GITHUB_WORKSPACE/kernel_workspace/android-kernel/utils/runcpatch.sh $GITHUB_WORKSPACE/kernel_workspace/android-kernel/kernel/cgroup/cgroup.c
fi
if [ -f $GITHUB_WORKSPACE/kernel_workspace/android-kernel/kernel/cgroup.c ]; then
sh $GITHUB_WORKSPACE/kernel_workspace/android-kernel/utils/runcpatch.sh $GITHUB_WORKSPACE/kernel_workspace/android-kernel/kernel/cgroup.c
fi
if [ -f $GITHUB_WORKSPACE/kernel_workspace/android-kernel/net/netfilter/xt_qtaguid.c ]; then
patch -p0 < $GITHUB_WORKSPACE/kernel_workspace/android-kernel/utils/xt_qtaguid.patch
fi
- name: Setup ccache
if: env.ENABLE_CCACHE == 'true'
uses: hendrikmuhs/[email protected]
with:
key: build-kernel-${{ env.DEVICE }}${{ env.UPLOADNAME }}
max-size: 2G
- name: Build kernel
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
export PATH=$GITHUB_WORKSPACE/kernel_workspace/llvm-clang/bin:$GITHUB_WORKSPACE/kernel_workspace/binutils/bin:$PATH
export KBUILD_BUILD_HOST=Github-Action
export KBUILD_BUILD_USER=$(echo ${{ github.actor }} | tr A-Z a-z)
if [ ! -z ${{ env.KSU_EXPECTED_SIZE }} ] && [ ! -z ${{ env.KSU_EXPECTED_HASH }} ]; then
export KSU_EXPECTED_SIZE=${{ env.KSU_EXPECTED_SIZE }}
export KSU_EXPECTED_HASH=${{ env.KSU_EXPECTED_HASH }}
fi
make -j$(nproc --all) CC=clang O=out ARCH=${{ env.ARCH }} CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi- ${{ env.EXTRA_CMDS }} ${{ env.KERNEL_CONFIG }}
if [ ${{ env.ENABLE_CCACHE }} = true ]; then
make -j$(nproc --all) CC="ccache clang" O=out ARCH=${{ env.ARCH }} CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi- ${{ env.EXTRA_CMDS }}
else
make -j$(nproc --all) CC=clang O=out ARCH=${{ env.ARCH }} CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi- ${{ env.EXTRA_CMDS }}
fi
- name: Check a kernel output files
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
if [ -f android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} ]; then
echo "CHECK_FILE_IS_OK=true" >> $GITHUB_ENV
else
echo "Kernel output file is empty"
exit 1
fi
if [ ${{ env.NEED_DTBO }} = true ]; then
if [ -f android-kernel/out/arch/${{ env.ARCH }}/boot/dtbo.img ]; then
echo "CHECK_DTBO_IS_OK=true" >> $GITHUB_ENV
else
echo "DTBO image is empty"
exit 1
fi
fi
- name: Make Anykernel3
if: env.CHECK_FILE_IS_OK == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone https://github.com/osm0sis/AnyKernel3
sed -i 's/do.devicecheck=1/do.devicecheck=0/g' AnyKernel3/anykernel.sh
sed -i 's!block=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot;!block=auto;!g' AnyKernel3/anykernel.sh
sed -i 's/is_slot_device=0;/is_slot_device=auto;/g' AnyKernel3/anykernel.sh
cp android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} AnyKernel3/
if [ ${{ env.CHECK_DTBO_IS_OK }} = true ]; then
cp android-kernel/out/arch/${{ env.ARCH }}/boot/dtbo.img AnyKernel3/
fi
rm -rf AnyKernel3/.git* AnyKernel3/README.md
- name: Make boot image
if: env.HAVE_SOURCE_BOOT_IMAGE == 'true' && env.CHECK_FILE_IS_OK == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
tools/unpack_bootimg.py --boot_img boot-source.img
cp android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }} out/kernel
tools/mkbootimg.py ${{ env.FORMAT_MKBOOTING }} -o boot.img
if [ -f boot.img ]; then
echo "MAKE_BOOT_IMAGE_IS_OK=true" >> $GITHUB_ENV
else
echo "Boot image is empty"
exit 1
fi
- name: Upload ${{ env.KERNEL_IMAGE_NAME }}
if: env.CHECK_FILE_IS_OK == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ env.KERNEL_IMAGE_NAME }}${{ env.UPLOADNAME }}-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
path: kernel_workspace/android-kernel/out/arch/${{ env.ARCH }}/boot/${{ env.KERNEL_IMAGE_NAME }}
- name: Upload AnyKernel3
if: env.CHECK_FILE_IS_OK == 'true'
uses: actions/upload-artifact@v4
with:
name: AnyKernel3${{ env.UPLOADNAME }}-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
path: kernel_workspace/AnyKernel3/*
- name: Upload DTBO image
if: env.CHECK_DTBO_IS_OK == 'true'
uses: actions/upload-artifact@v4
with:
name: dtbo-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
path: kernel_workspace/android-kernel/out/arch/${{ env.ARCH }}/boot/dtbo.img
- name: Upload boot image
if: env.MAKE_BOOT_IMAGE_IS_OK == 'true'
uses: actions/upload-artifact@v4
with:
name: boot${{ env.UPLOADNAME }}-${{ env.DEVICE }}-${{ env.BUILD_TIME }}
path: kernel_workspace/boot.img