forked from xiaomi-mt6833-dev/kernel_xiaomi_mt6833
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·113 lines (93 loc) · 2.77 KB
/
build.sh
File metadata and controls
executable file
·113 lines (93 loc) · 2.77 KB
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
#!/bin/bash
# Compile script for Aqua kernel
# Remove out directory
rm -rf out/arch/arm64/boot
# Prebuild hacks
rm -rf .config .config.old .tmp_versions
rm -rf include/generated include/config
rm -rf arch/arm64/include/generated
rm -rf vmlinux* System.map modules.builtin*
rm -f Module.symvers modules.order
rm -rf scripts/kconfig/.tmp*
# Date/Time
SECONDS=0
DATE=$(date '+%Y%m%d-%H%M')
# Toolchain
TC_DIR="$HOME/toolchains/ZyC-clang-22.0.0"
CURRENT_DIR=$(pwd)
# Device Configs
DEVICE="everpal"
DEFCONFIG="${DEVICE}_defconfig"
ZIPNAME="AquaKernel-${DATE}.zip"
# Ensure the toolchain is available
if [ ! -d "$TC_DIR" ]; then
mkdir -p "$TC_DIR" && cd "$TC_DIR" || exit
wget https://github.com/ZyCromerZ/Clang/releases/download/22.0.0git-20250928-release/Clang-22.0.0git-20250928.tar.gz \
&& tar xvf Clang-22.0.0git-20250928.tar.gz \
&& rm -rf Clang-22.0.0git-20250928.tar.gz
cd "$CURRENT_DIR" || exit
fi
export PATH="$TC_DIR/bin:$PATH"
export CC=clang
export LD=ld.lld
echo
echo "Using compiler:"
clang --version
echo
# Process options
CLEAN_BUILD=false
INCLUDE_KSU=false
for arg in "$@"; do
case $arg in
--clean)
CLEAN_BUILD=true
;;
--with-ksu)
INCLUDE_KSU=true
;;
--redo-ksu)
rm -f .ksu_applied
INCLUDE_KSU=true
;;
esac
done
# Perform clean build if specified
[ "$CLEAN_BUILD" = true ] && rm -rf out
[ -f .ksu_applied ] && echo "Including KernelSU Next!"
# Include KernelSU if specified
if [[ "$INCLUDE_KSU" = true && ! -f .ksu_applied ]]; then
echo "Including KernelSU Next!"
git clone https://github.com/Addster09/EverpalPatches --depth=1
for patch in EverpalPatches/KSUPatches/000*.patch; do
patch -p1 < "$patch"
done
rm -rf EverpalPatches
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -s legacy_susfs
touch .ksu_applied
fi
# Compilation process
mkdir -p out
make O=out ARCH=arm64 "$DEFCONFIG"
echo -e "\nStarting compilation...\n"
if \
make -j$(nproc --all) O=out \
ARCH=arm64 \
CC="ccache clang" \
LLVM=1 \
LLVM_IAS=1 \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi- \
KCFLAGS="-Wno-error=default-const-init-var-unsafe" \
Image.gz dtbs; \
then
echo -e "\nKernel compiled successfully! Zipping up...\n"
# Clone AnyKernel3 and create zip
git clone -q --depth=1 https://github.com/Addster09/AnyKernel3 AnyKernel3
cp out/arch/arm64/boot/Image.gz AnyKernel3
(cd AnyKernel3 && zip -r9 "../$ZIPNAME" * -x '*.git*' README.md '*placeholder')
rm -rf AnyKernel3
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s)!"
echo "Zip: $ZIPNAME"
else
echo -e "\nCompilation failed!"
fi