Fix WSA Kernel build (#267)

1. Use ubuntu-20.04
1. Use LLVM 12
1. Fix build cache
1. Fix KernelSU version
This commit is contained in:
Howard Wu
2023-02-22 09:20:37 +08:00
committed by GitHub
parent 349fd09440
commit 0c3731b0bd

View File

@@ -3,52 +3,44 @@ on:
push: push:
branches: ["main"] branches: ["main"]
paths: paths:
- '.github/workflows/build-WSA-5.10.117-kernel.yml' - ".github/workflows/build-WSA-5.10.117-kernel.yml"
- 'kernel/**' - "kernel/**"
pull_request: pull_request:
branches: ["main"] branches: ["main"]
paths: paths:
- 'kernel/**' - "kernel/**"
workflow_call: workflow_call:
workflow_dispatch:
jobs: jobs:
build: build:
strategy: strategy:
matrix: matrix:
arch: [x86_64, arm64]
version: [5.10.117.2]
include: include:
- version: 5.10.117.2 - file_name: "bzImage"
arch: "x86_64"
out_file: "arch/x86/boot/bzImage"
kernel_make_cmd: "bzImage"
make_config: "config-wsa" make_config: "config-wsa"
date: "20220906" arch: x86_64
- version: 5.10.117.2 - file_name: "Image"
arch: "arm64" cross_compile: "aarch64-linux-gnu"
out_file: "arch/arm64/boot/Image"
kernel_make_cmd: "ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu Image"
make_config: "config-wsa-arm64" make_config: "config-wsa-arm64"
date: "20220906" arch: arm64
name: Build WSA-Kernel-${{ matrix.version }}-${{ matrix.arch }} name: Build WSA-Kernel-${{ matrix.version }}-${{ matrix.arch }}
runs-on: ubuntu-18.04 runs-on: ubuntu-20.04
env: env:
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion" CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
CCACHE_NOHASHDIR: "true" CCACHE_NOHASHDIR: "true"
CCACHE_MAXSIZE: "2G" CCACHE_MAXSIZE: "2G"
CCACHE_HARDLINK: "true" CCACHE_HARDLINK: "true"
steps:
- uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-WSA-Kernel-${{ matrix.version }}-${{ matrix.arch }}
append-timestamp: false
save: ${{ github.event_name != 'pull_request' }}
- uses: actions/checkout@v3
with:
path: KernelSU
- name: Install LLVM steps:
- name: Install Build Tools
run: | run: |
sudo apt update
sudo apt install -y --no-install-recommends bc bison build-essential ca-certificates flex git gnupg libelf-dev libssl-dev lsb-release software-properties-common wget libncurses-dev binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu nuget sudo apt install -y --no-install-recommends bc bison build-essential ca-certificates flex git gnupg libelf-dev libssl-dev lsb-release software-properties-common wget libncurses-dev binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu nuget
export LLVM_VERSION=10 export LLVM_VERSION=12
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh $LLVM_VERSION sudo ./llvm.sh $LLVM_VERSION
@@ -63,37 +55,49 @@ jobs:
sudo ln -s --force /usr/bin/llvm-readelf-$LLVM_VERSION /usr/bin/llvm-readelf sudo ln -s --force /usr/bin/llvm-readelf-$LLVM_VERSION /usr/bin/llvm-readelf
sudo ln -s --force /usr/bin/clang++-$LLVM_VERSION /usr/bin/clang++ sudo ln -s --force /usr/bin/clang++-$LLVM_VERSION /usr/bin/clang++
- name: Download kernel source - name: Checkout KernelSU
uses: actions/checkout@v3
with:
path: KernelSU
ref: main
fetch-depth: 0
- name: Setup kernel source
uses: actions/checkout@v3
with:
repository: microsoft/WSA-Linux-Kernel
ref: android-lts/latte/${{ matrix.version }}
path: WSA-Linux-Kernel
- name: Setup Ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: WSA-Kernel-${{ matrix.version }}-${{ matrix.arch }}
save: ${{ github.event_name != 'pull_request' }}
- name: Setup KernelSU
working-directory: WSA-Linux-Kernel
run: | run: |
cd $GITHUB_WORKSPACE echo "[+] KernelSU setup"
KERNEL_ROOT=$GITHUB_WORKSPACE/WSA-Linux-Kernel KERNEL_ROOT=$GITHUB_WORKSPACE/WSA-Linux-Kernel
echo "[+] 克隆远程仓库 WSA-Linux-Kernel..."
git clone https://github.com/microsoft/WSA-Linux-Kernel
cd WSA-Linux-Kernel && git checkout android-lts/latte/${{ matrix.version }}
echo "[+] 切换到分支 android-lts/latte/${{ matrix.version }}"
echo "[+] 导入 KernelSU"
echo "[+] KERNEL_ROOT: $KERNEL_ROOT" echo "[+] KERNEL_ROOT: $KERNEL_ROOT"
echo "[+] 复制 kernel su driver 到路径:$KERNEL_ROOT/drivers" echo "[+] Copy KernelSU driver to $KERNEL_ROOT/drivers"
ln -sf $GITHUB_WORKSPACE/KernelSU/kernel $KERNEL_ROOT/drivers/kernelsu ln -sf $GITHUB_WORKSPACE/KernelSU/kernel $KERNEL_ROOT/drivers/kernelsu
echo "[+] Add KernelSU driver to Makefile"
DRIVER_MAKEFILE=$KERNEL_ROOT/drivers/Makefile DRIVER_MAKEFILE=$KERNEL_ROOT/drivers/Makefile
echo "[+] 添加 kernel su driver 到文件:$DRIVER_MAKEFILE"
grep -q "kernelsu" $DRIVER_MAKEFILE || echo "obj-y += kernelsu/" >> $DRIVER_MAKEFILE grep -q "kernelsu" $DRIVER_MAKEFILE || echo "obj-y += kernelsu/" >> $DRIVER_MAKEFILE
echo "[+] KernelSU 导入完成" echo "[+] Apply KernelSU patches"
cd $KERNEL_ROOT && git apply $GITHUB_WORKSPACE/KernelSU/.github/patches/5.10/*.patch cd $KERNEL_ROOT && git apply $GITHUB_WORKSPACE/KernelSU/.github/patches/5.10/*.patch
cd - echo "[+] KernelSU setup done."
- name: Build Kernel - name: Build Kernel
working-directory: WSA-Linux-Kernel working-directory: WSA-Linux-Kernel
run: | run: |
KERNEL_ROOT=$GITHUB_WORKSPACE/WSA-Linux-Kernel cp configs/wsa/${{ matrix.make_config }}-5.10 .config
echo "[+] 构建 kernel" make -j`nproc` LLVM=1 ARCH=${{ matrix.arch }} CROSS_COMPILE=${{ matrix.cross_compile }} ${{ matrix.file_name }} CCACHE="/usr/bin/ccache"
cp configs/wsa/${{ matrix.make_config }}-5.10 $KERNEL_ROOT/.config
echo "[+] 复制配置文件 configs/wsa/${{ matrix.make_config }}-5.10 到 $KERNEL_ROOT/.config"
echo "执行: make -j`nproc` LLVM=1 ${{ matrix.kernel_make_cmd }}"
make -j`nproc` LLVM=1 ${{ matrix.kernel_make_cmd }} CCACHE="/usr/bin/ccache"
- name: Upload kernel-${{ matrix.arch }}-${{ matrix.version }} - name: Upload kernel-${{ matrix.arch }}-${{ matrix.version }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: kernel-WSA-${{ matrix.arch }}-${{ matrix.version }}-${{ matrix.date }} name: kernel-WSA-${{ matrix.arch }}-${{ matrix.version }}
path: WSA-Linux-Kernel/${{ matrix.out_file }} path: WSA-Linux-Kernel/arch/${{ matrix.arch }}/boot/${{ matrix.file_name }}