-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_kernel.sh
112 lines (94 loc) · 2.24 KB
/
build_kernel.sh
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
#!/bin/bash
#
# Rissu's kernel build script.
#
#
# We decided to use clang-13, or known as clang-r428724 for compiling.
# Also, you can use clang-11/12 if you don't have it.
#
# Target: use it for custom rom
#
# COLORS SHEET
RED='\e[1;31m'
YELLOW='\e[1;33m'
NC='\e[0m'
pr_err() {
echo -e "${RED}[E] $@${NC}";
exit 1;
}
pr_warn() {
echo -e "${YELLOW}[W] $@${NC}";
}
pr_info() {
echo "[I] $@";
}
if [ -d /rsuntk ]; then
pr_info "Rissu environment detected."
export CROSS_COMPILE=/rsuntk/env/google/bin/aarch64-linux-android-
export PATH=/rsuntk/env/clang-13/bin:$PATH
export DEFCONFIG="lineage_defconfig"
else
if [ -z $CROSS_COMPILE ]; then
pr_err "Invalid empty variable for \$CROSS_COMPILE"
fi
if [ -z $PATH ]; then
pr_err "Invalid empty variable for \$PATH"
fi
if [ -z $DEFCONFIG ]; then
pr_warn "Empty variable for \$DEFCONFIG, using yukiprjkt_defconfig as default."
DEFCONFIG="yukiprjkt_defconfig"
fi
fi
# Now support 99.9% LLVM (Why? Because for some weird reason,
# if we didn't include CROSS_COMPILE, it just messed up some file, so we keep it.)
export LLVM=1
export CC=clang
export LD=ld.lld
# For LKM!
export KERNEL_OUT=$(pwd)/out
export ARCH=arm64
export ANDROID_MAJOR_VERSION=r
export PLATFORM_VERSION=11
export KCFLAGS=-w
export CONFIG_SECTION_MISMATCH_WARN_ONLY=y
export CONFIG_WLAN_DRV_BUILD_IN=y
DATE=$(date +'%Y%m%d%H%M%S')
IMAGE="$KERNEL_OUT/arch/$ARCH/boot/Image"
RES="$(pwd)/result"
if [ -z $JOBS ]; then
JOBS=$(nproc --all)
fi
# Build!
__mk_defconfig() {
make -C $(pwd) --jobs $JOBS O=$KERNEL_OUT LLVM=1 CONFIG_WLAN_DRV_BUILD_IN=y CC=clang LD=ld.lld KCFLAGS=-w CONFIG_SECTION_MISMATCH_WARN_ONLY=y $DEFCONFIG
}
__mk_kernel() {
make -C $(pwd) --jobs $JOBS O=$KERNEL_OUT LLVM=1 CONFIG_WLAN_DRV_BUILD_IN=y CC=clang LD=ld.lld KCFLAGS=-w CONFIG_SECTION_MISMATCH_WARN_ONLY=y
}
if [ ! -z $1 ]; then
__mk_defconfig;
else
mk_defconfig_kernel() {
__mk_defconfig;
__mk_kernel;
}
fi
if [ -d $KERNEL_OUT ]; then
pr_warn "An out/ folder detected, Do you wants dirty builds?"
read -p "" OPT;
if [ $OPT = 'y' ] || [ $OPT = 'Y' ]; then
__mk_kernel;
else
rm -rR out;
make clean;
make mrproper;
mk_defconfig_kernel;
fi
else
mk_defconfig_kernel;
fi
if [ -e $IMAGE ]; then
pr_info "Build done."
else
pr_err "Build error."
fi