-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
91 lines (81 loc) · 2.44 KB
/
build.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
#!/bin/bash
# Thanks to clhex for the script (Github username: clhexftw)
kernel_dir="${PWD}"
CCACHE=$(command -v ccache)
objdir="${kernel_dir}/out"
anykernel=$HOME/anykernel
builddir="${kernel_dir}/build"
ZIMAGE=$kernel_dir/out/arch/arm64/boot/Image
kernel_name="SkylineKernel_vayu_KernelSU"
zip_name="$kernel_name$(date +"%Y%m%d").zip"
CLANG_DIR=$HOME/tc/clang-latest
export CONFIG_FILE="vayu_user_defconfig"
export ARCH="arm64"
export KBUILD_BUILD_HOST=gxc2356
export KBUILD_BUILD_USER=home
export PATH="$CLANG_DIR/bin:$PATH"
if ! [ -d "$CLANG_DIR" ]; then
echo "Toolchain not found! Cloning to $CLANG_DIR..."
if ! git clone -q --depth=1 --single-branch https://gitlab.com/crdroidandroid/android_prebuilts_clang_host_linux-x86_clang-r510928.git -b 14.0 $CLANG_DIR; then
echo "Cloning failed! Aborting..."
exit 1
fi
fi
# Colors
NC='\033[0m'
RED='\033[0;31m'
LRD='\033[1;31m'
LGR='\033[1;32m'
make_defconfig()
{
START=$(date +"%s")
echo -e ${LGR} "########### Generating Defconfig ############${NC}"
make -s ARCH=${ARCH} O=${objdir} ${CONFIG_FILE} -j$(nproc --all)
}
compile()
{
cd ${kernel_dir}
echo -e ${LGR} "######### Compiling kernel #########${NC}"
make -j$(nproc --all) \
O=out \
ARCH=${ARCH}\
CC="ccache clang" \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi- \
CROSS_COMPILE_COMPAT=arm-linux-gnueabi- \
AR=llvm-ar \
LLVM_NM=llvm-nm \
OBJCOPY=llvm-objcopy \
LD=ld.lld NM=llvm-nm \
LLVM=1 \
LLVM_IAS=1
}
completion()
{
cd ${objdir}
COMPILED_IMAGE=arch/arm64/boot/Image
COMPILED_DTBO=arch/arm64/boot/dtbo.img
if [[ -f ${COMPILED_IMAGE} && ${COMPILED_DTBO} ]]; then
git clone -q https://github.com/GXC2356/AnyKernel3.git -b ksu $anykernel
mv -f $ZIMAGE ${COMPILED_DTBO} $anykernel
cd $anykernel
find . -name "*.zip" -type f
find . -name "*.zip" -type f -delete
zip -r AnyKernel.zip *
mv AnyKernel.zip $zip_name
mv $anykernel/$zip_name $HOME/$zip_name
rm -rf $anykernel
END=$(date +"%s")
DIFF=$(($END - $START))
echo -e ${RED} "############################################"
echo -e ${RED} "## BUILD COMPLETED!!! UPLOADING... ##"
echo -e ${RED} "############################################${NC}"
exit 0
fi
}
git submodule init
git submodule update --remote --merge
make_defconfig
compile
completion
cd ${kernel_dir}