-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild-miui.sh
62 lines (58 loc) · 2.33 KB
/
build-miui.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
echo -e "\nStarting compilation...\n"
# Setup and apply patch KernelSU in root dir
if ! [ -d "$KERNEL_DIR"/KernelSU ]; then
curl -LSs "https://raw.githubusercontent.com/tiann/KernelSU/main/kernel/setup.sh" | bash -s main
git apply KernelSU-hook.patch
else
echo -e "Setup KernelSU failed, stopped build now..."
exit 1
fi
# ENV
CONFIG=vendor/sixteen_defconfig
KERNEL_DIR=$(pwd)
PARENT_DIR="$(dirname "$KERNEL_DIR")"
KERN_IMG="$HOME/out-new-R/out/arch/arm64/boot/Image.gz-dtb"
export KBUILD_BUILD_USER="elang"
export KBUILD_BUILD_HOST="kyvangkaelang"
export PATH="$HOME/toolchain/Sixteen_Clang/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/toolchain/Sixteen_Clang/lib:$LD_LIBRARY_PATH"
export KBUILD_COMPILER_STRING="$($HOME/toolchain/Sixteen_Clang/bin/clang --version | head -n 1 | perl -pe 's/\((?:http|git).*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//' -e 's/^.*clang/clang/')"
export out=$HOME/out-new-R-miui
# Functions
clang_build () {
make -j$(nproc --all) O=$out \
ARCH=arm64 \
CC="clang" \
AR="llvm-ar" \
NM="llvm-nm" \
LD="ld.lld" \
AS="llvm-as" \
OBJCOPY="llvm-objcopy" \
OBJDUMP="llvm-objdump" \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi-
}
# Build kernel
make O=$out ARCH=arm64 $CONFIG > /dev/null
echo -e "${bold}Compiling with CLANG${normal}\n$KBUILD_COMPILER_STRING"
echo -e "\nCompiling $ZIPNAME\n"
clang_build
if [ -f "$out/arch/arm64/boot/Image.gz" ] && [ -f "$out/arch/arm64/boot/dtbo.img" ] && [ -f "$out/arch/arm64/boot/dts/qcom/trinket.dtb" ]; then
echo -e "\nKernel compiled succesfully! Zipping up...\n"
ZIPNAME="SixTeen•Kernel•MIUI•KSU•Ginkgo•Willow-$(date '+%Y%m%d-%H%M').zip"
if [ ! -d AnyKernel3 ]; then
git clone -q https://github.com/Kyvangka1610/AnyKernel3.git
fi;
cp -f $out/arch/arm64/boot/Image.gz AnyKernel3
cp -f $out/arch/arm64/boot/dtbo.img AnyKernel3
cp -f $out/arch/arm64/boot/dts/qcom/trinket.dtb AnyKernel3/dtb
cd AnyKernel3
zip -r9 "$HOME/$ZIPNAME" *
cd ..
rm -rf AnyKernel3
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
echo -e "Zip: $ZIPNAME\n"
else
echo -e "\nCompilation failed!\n"
fi;