-
Notifications
You must be signed in to change notification settings - Fork 2
125 lines (107 loc) · 6.22 KB
/
build-AB-clang1207.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
name: 乐金V60 谷歌clang12.0.7
on:
workflow_dispatch:
jobs:
build:
name:
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
steps:
- uses: actions/checkout@v3
- name: 环境变量配置
run: |
cat config.env | grep KERNEL_SOURCE= >> $GITHUB_ENV
cat config.env | grep KERNEL_SOURCE_BRANCH= >> $GITHUB_ENV
cat config.env | grep KERNEL_CONFIG= >> $GITHUB_ENV
cat config.env | grep KERNEL_ZIP_NAME= >> $GITHUB_ENV
cat config.env | grep LLVM_CONFIG= >> $GITHUB_ENV
cat config.env | grep KERNEL_IMAGE_NAME= >> $GITHUB_ENV
cat config.env | grep NEED_DTBO= >> $GITHUB_ENV
cat config.env | grep SWITCH_PYTHON= >> $GITHUB_ENV
cat config.env | grep ENABLE_KVM= >> $GITHUB_ENV
cat config.env | grep ENABLE_LXC_DOCKER= >> $GITHUB_ENV
cat config.env | grep ENABLE_KERNELSU= >> $GITHUB_ENV
cat config.env | grep KERNELSU_TAG= >> $GITHUB_ENV
- name: 构建编译内核环境
run: |
sudo apt-get update
sudo -E apt-get -y -qq install git make bc bison ccache openssl zip kmod cpio flex libelf-dev curl libssl-dev libtfm-dev wget device-tree-compiler ca-certificates python3 python2 binutils binutils-aarch64-linux-gnu binutils-arm-linux-gnueabi
mkdir -p $GITHUB_WORKSPACE/kernel_workspace
- name: 切换python2.7
if: env.SWITCH_PYTHON == 'true'
run: |
sudo rm -f /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
- name: 下载clang-aosp编译器
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir clang-aosp
git clone -q --depth=1 --single-branch https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86 -b android12-release clang-aosp
mkdir gcc-aosp-aarch64
git clone -q --depth=1 --single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9 -b android-13.0.0_r0.122 gcc-aosp-aarch64
mkdir gcc-aosp-arm32
git clone -q --depth=1 --single-branch https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 -b android-13.0.0_r0.122 gcc-aosp-arm32
mkdir dtc-aosp
git clone -q --depth=1 --single-branch https://android.googlesource.com/platform/prebuilts/misc -b android13-release dtc-aosp
- name: 下载内核源码
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone ${{ env.KERNEL_SOURCE }} -b ${{ env.KERNEL_SOURCE_BRANCH }} android-kernel --depth=1
- name: 配置 ksu
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 }}
- name: 开启kvm
if: env.ENABLE_KVM == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
echo "CONFIG_VIRTUALIZATION=y" >> android-kernel/arch/arm64/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_KVM=y" >> android-kernel/arch/arm64/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_VHOST_NET=y" >> android-kernel/arch/arm64/configs/${{ env.KERNEL_CONFIG }}
echo "CONFIG_VHOST_CROSS_ENDIAN_LEGACY=y" >> android-kernel/arch/arm64/configs/${{ env.KERNEL_CONFIG }}
- name: 设置ccache缓存
uses: hendrikmuhs/[email protected]
with:
key: build-kernel-mido-kernel
max-size: 2G
- name: 开始编译内核
run: |
cd $GITHUB_WORKSPACE/kernel_workspace/android-kernel
export PATH=$GITHUB_WORKSPACE/kernel_workspace/clang-aosp/clang-r416183b1/bin:$PATH
export DTC_EXT=$GITHUB_WORKSPACE/kernel_workspace/dtc-aosp/linux-x86/dtc/dtc
export KBUILD_BUILD_HOST=timelm
export KBUILD_BUILD_USER=FodorZee
make -j$(nproc --all) O=out ARCH=arm64 ${{ env.KERNEL_CONFIG }}
if [ ${{env.LLVM_CONFIG}}=y ]; then
make -j$(nproc --all) CC="ccache clang" CXX=clang++ O=out ARCH=arm64 CLANG_TRIPLE="aarch64-linux-gnu-" CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp-aarch64/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp-arm32/bin/arm-linux-gnueabi- DTC_EXT=${DTC_EXT} LD=ld.lld AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf OBJSIZE=llvm-size STRIP=llvm-strip LDGOLD=aarch64-linux-gnu-ld.gold LLVM_AR=llvm-ar LLVM_DIS=llvm-dis LLVM=1 LLVM_IAS=1
else
make -j$(nproc --all) CC="ccache clang" CXX=clang++ O=out ARCH=arm64 CLANG_TRIPLE="aarch64-linux-gnu-" CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp-aarch64/bin/aarch64-linux-gnu- CROSS_COMPILE_ARM32=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp-arm32/bin/arm-linux-gnueabi- DTC_EXT=${DTC_EXT} LD=ld.lld AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump READELF=llvm-readelf OBJSIZE=llvm-size STRIP=llvm-strip LDGOLD=aarch64-linux-gnu-ld.gold LLVM_AR=llvm-ar LLVM_DIS=llvm-dis
fi
- name: 准备打包内核
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
git clone https://github.com/IminatoPo/AnyKernel3
cp android-kernel/out/arch/arm64/boot/${{ env.KERNEL_IMAGE_NAME }} AnyKernel3/
if [ ${{ env.NEED_DTBO }} = true ]; then
echo "NEED=true" >> $GITHUB_ENV
if [ -f android-kernel/out/arch/arm64/boot/dtbo.img ]; then
echo "DTBO_EXIST=true" >> $GITHUB_ENV
fi
fi
if [ ${{ env.DTBO_EXIST }} = true ]; then
cp android-kernel/out/arch/arm64/boot/dtbo.img AnyKernel3/
fi
rm -rf AnyKernel3/.git* AnyKernel3/README.md
rm -rf AnyKernel3/ramdisk AnyKernel3/modules AnyKernel3/patch
- name: 上传内核
uses: actions/upload-artifact@v3
with:
name: ${{ env.KERNEL_ZIP_NAME }}
path: kernel_workspace/AnyKernel3/*
- name: 上传dtbo镜像
if: env.DTBO_EXSIT == 'true' && env.NEED == 'true'
uses: actions/upload-artifact@v3
with:
name: dtbo-image
path: kernel_workspace/android-kernel/out/arch/arm64/boot/dtbo.img