-
Notifications
You must be signed in to change notification settings - Fork 3
174 lines (159 loc) · 6.66 KB
/
build-kernel.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Build Kernel
on:
workflow_dispatch:
inputs:
KERNEL_SOURCE:
description: 'Kernel Source'
required: true
default: 'lightsummer233/kernel_xiaomi_sm8250'
KERNEL_SOURCE_BRANCH:
description: 'Branch'
required: true
default: 'aries'
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: lightsummer233/AnyKernel3
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