forked from thecatvoid/actions_kernel_build
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild
executable file
·55 lines (41 loc) · 1.76 KB
/
build
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
#!/bin/sh
set -e -x
# Kernel Source
KERNEL_SOURCE="https://github.com/carlodandan/android_kernel_realme_sm7125"
KERNEL_BRANCH="A13"
KERNEL_DEFCONFIG="vendor/atoll-perf_defconfig"
# Prebuilt Clang Toolchain (AOSP)
CLANG_URL="https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+archive/refs/heads/master-kernel-build-2021/clang-r416183b.tar.gz"
# Prebuilt GCC Utilities (AOSP)
GCC_x64="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9"
GCC_x32="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9"
GCC_BRANCH="master-kernel-build-2021"
# Setup make Command
make_fun() {
make O=out ARCH=arm64 CC=clang HOSTCC=clang DTC=dtc \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-androidkernel- "$@"
}
# Work Path
WORK="${HOME}/work"
# Kernel Folder Name
KERNEL="myKernel"
# Kernel Source Path
KERNEL_SRC="${WORK}/${KERNEL}"
# Prepare Directory
mkdir -p "${WORK}"
cd "${WORK}" || exit 1
# Cloning all the Necessary files
if [ ! -d clang ]; then mkdir clang && curl -Lsq "${CLANG_URL}" -o clang.tgz && tar -xzf clang.tgz -C clang; fi
[ ! -d x64 ] && git clone --depth=1 "${GCC_x64}" -b "${GCC_BRANCH}" ./x64
[ ! -d x32 ] && git clone --depth=1 "${GCC_x32}" -b "${GCC_BRANCH}" ./x32
[ ! -d "${KERNEL}" ] && git clone --depth=1 "${KERNEL_SOURCE}" -b "${KERNEL_BRANCH}" "${KERNEL}"
# Setting Toolchain Path
PATH="${WORK}/clang/bin:${WORK}/x64/bin:${WORK}/x32/bin:/bin"
# Enter Kernel root directory
cd "${KERNEL_SRC}" || exit 1
# KernelSU - Disable if not building one.
# curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -
# Start Compiling Kernel
make_fun "${KERNEL_DEFCONFIG}"
make_fun -j"$(nproc --all)" 2>&1 | tee build.log