-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·82 lines (77 loc) · 1.94 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
#!/bin/bash
# Thanks to clhex for the script (Github username: clhexftw)
kernel_dir="${PWD}"
CCACHE=$(command -v ccache)
objdir="${kernel_dir}/out"
builddir="${kernel_dir}/build"
ZIMAGE=$kernel_dir/out/arch/arm64/boot/Image
CLANG_DIR=$HOME/tc/clang
export CONFIG_FILE="vayu_user_defconfig"
export ARCH="arm64"
export KBUILD_BUILD_HOST=ccrlll
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-r522817.git -b 14.0 $CLANG_DIR; then
echo "Cloning failed! Aborting..."
exit 1
fi
fi
# Colors
NC='\033[0m'
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" \
AR="llvm-ar" \
NM="llvm-nm" \
LD="ld.lld" \
OBJCOPY="llvm-objcopy" \
OBJDUMP="llvm-objdump" \
STRIP="llvm-strip" \
CROSS_COMPILE="aarch64-linux-gnu-" \
CROSS_COMPILE_ARM32="arm-linux-gnueabi-" \
CROSS_COMPILE_COMPAT="arm-linux-gnueabi-" \
LLVM=1 \
LLVM_IAS=1
}
completion()
{
cd ${objdir}
COMPILED_IMAGE=arch/arm64/boot/Image
COMPILED_DTBO=arch/arm64/boot/dtbo.img
COMPILED_DTB=arch/arm64/boot/dtb.img
if [[ -f ${COMPILED_IMAGE} && ${COMPILED_DTBO} && ${COMPILED_DTB} ]]; then
echo -e ${LGR}"#### build completed successfully (hh:mm:ss) ####"${NC}
else
echo -e ${LRD}"#### failed to build some targets (hh:mm:ss) ####"${NC}
fi
}
zipping()
{
cd ${kernel_dir}
if [ -f "zip.sh" ]; then
chmod +x zip.sh
./zip.sh
else
echo -e ${LRD}"Skipping:${NC} zip.sh do not exist"
fi
}
make_defconfig
compile
completion
zipping
cd ${kernel_dir}