Skip to content

Commit

Permalink
CI: Support to custom clang
Browse files Browse the repository at this point in the history
Signed-off-by: xiaoleGun <1592501605@qq.com>
  • Loading branch information
xiaoleGun committed Apr 22, 2023
1 parent 45033be commit 03fd32c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/build-kernel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
echo "KERNEL_DEFCONFIG=$(cat config.env | grep "KERNEL_DEFCONFIG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "TARGET_ARCH=$(cat config.env | grep "TARGET_ARCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "KERNEL_FILE=$(cat config.env | grep "KERNEL_FILE" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "USE_CUSTOM_CLANG=$(cat config.env | grep "USE_CUSTOM_CLANG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_CLANG=$(cat config.env | grep "CUSTOM_CLANG" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_CLANG_BRANCH=$(cat config.env | grep "CUSTOM_CLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CUSTOM_CLANG_BUILD_COMMAND=$(cat config.env | grep "CUSTOM_CLANG_BUILD_COMMAND" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV
echo "CLANG_BRANCH=$(cat config.env | grep "CLANG_BRANCH" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "CLANG_VERSION=$(cat config.env | grep "CLANG_VERSION" | head -n 1 | cut -d "=" -f 2)" >> $GITHUB_ENV
echo "BUILD_EXTRA_COMMAND=$(cat config.env | grep "EXTRA_BUILD_COMMAND" | head -n 1 | cut -d ":" -f 2)" >> $GITHUB_ENV
Expand All @@ -40,6 +44,7 @@ jobs:
mkdir -p $GITHUB_WORKSPACE/kernel_workspace
- name: Download Clang-aosp and Gcc-aosp
if: env.USE_CUSTOM_CLANG == 'false'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
mkdir clang-aosp
Expand All @@ -49,6 +54,18 @@ jobs:
wget https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/+archive/refs/tags/android-12.1.0_r27.tar.gz
tar -C gcc-aosp/ -zxvf android-12.1.0_r27.tar.gz
- name: Download Custom-Clang
if: env.USE_CUSTOM_CLANG == 'true'
run: |
cd $GITHUB_WORKSPACE/kernel_workspace
if [[ ${{ env.CUSTOM_CLANG }} =~ github ]]; then
git clone ${{ env.CUSTOM_CLANG }} -b ${{ env.CUSTOM_CLANG_BRANCH }} clang-aosp
else
wget -O clang.zip ${{ env.CUSTOM_CLANG }}
mkdir clang-aosp
unzip clang.zip -d clang-aosp/
fi
- name: Download mkbootimg tools
if: env.MAKE_BOOT_IMAGE == 'true'
run: |
Expand Down Expand Up @@ -98,8 +115,8 @@ jobs:
export PATH=$GITHUB_WORKSPACE/kernel_workspace/clang-aosp/bin:$PATH
export KBUILD_BUILD_HOST=Github-Action
export KBUILD_BUILD_USER=$(echo ${{ github.actor }} | tr A-Z a-z)
make -j$(nproc --all) O=out ARCH=${{ env.TARGET_ARCH }} CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp/bin/aarch64-linux-android- CC=clang ${{ env.BUILD_EXTRA_COMMAND }} ${{ env.KERNEL_DEFCONFIG }}
make -j$(nproc --all) O=out ARCH=${{ env.TARGET_ARCH }} CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp/bin/aarch64-linux-android- CC=clang ${{ env.BUILD_EXTRA_COMMAND }}
make -j$(nproc --all) O=out ARCH=${{ env.TARGET_ARCH }} ${{ env.CUSTOM_BUILD_COMMAND }} CC=clang ${{ env.BUILD_EXTRA_COMMAND }} ${{ env.KERNEL_DEFCONFIG }}
make -j$(nproc --all) O=out ARCH=${{ env.TARGET_ARCH }} ${{ env.CUSTOM_BUILD_COMMAND }} CC=clang ${{ env.BUILD_EXTRA_COMMAND }}
- name: Check a kernel output files
run: |
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ Fork 本仓库到你的储存库然后按照以下内容编辑config.env,之

### Clang

#### Use custom clang

改成true
可以使用除google官方的clang,如[proton-clang](https://github.com/kdrag0n/proton-clang)

#### Custom Clang

支持github仓库或者zip压缩包的直链

#### Custom Clang Commands

都用自定义clang了,自己改改编译器位置应该会吧 :)

#### Clang Branch
由于 [#23](https://github.com/xiaoleGun/KernelSU_Action/issues/23) 的需要,我们提供可自定义Google上游分支的选项,主要的有分支有
| Clang 分支 |
Expand Down
4 changes: 4 additions & 0 deletions config.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ KERNEL_SOURCE_BRANCH=dsu-test
KERNEL_DEFCONFIG=vendor/wayne_defconfig
TARGET_ARCH=arm64
KERNEL_FILE=Image.gz-dtb
USE_CUSTOM_CLANG=false
CUSTOM_CLANG=
CUSTOM_CLANG_BRANCH=
CUSTOM_CLANG_BUILD_COMMAND:CLANG_TRIPLE=aarch64-linux-gnu- CROSS_COMPILE=$GITHUB_WORKSPACE/kernel_workspace/gcc-aosp/bin/aarch64-linux-android-
CLANG_BRANCH=master-kernel-build-2022
CLANG_VERSION=r450784d
EXTRA_BUILD_COMMAND:LD=ld.lld
Expand Down

0 comments on commit 03fd32c

Please sign in to comment.