-
Notifications
You must be signed in to change notification settings - Fork 9
/
ci-build
executable file
·122 lines (101 loc) · 2.47 KB
/
ci-build
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
114
115
116
117
118
119
120
121
122
#!/bin/bash
clang_path="${HOME}/cbl/bin/clang"
gcc_path="${HOME}/cbl/bin/aarch64-linux-gnu-"
gcc_32_path="${HOME}/cbl/bin/arm-linux-gnueabi-"
NAME=NekoKernel
version=Snapshot
START=$(date +"%s")
source=`pwd`
date="`date +"%m%d-%H%M"`"
print (){
case ${2} in
"red")
echo -e "\033[31m $1 \033[0m";;
"blue")
echo -e "\033[34m $1 \033[0m";;
"yellow")
echo -e "\033[33m $1 \033[0m";;
"purple")
echo -e "\033[35m $1 \033[0m";;
"sky")
echo -e "\033[36m $1 \033[0m";;
"green")
echo -e "\033[32m $1 \033[0m";;
*)
echo $1
;;
esac
}
args="CC=$clang_path \
CROSS_COMPILE=$gcc_path \
CROSS_COMPILE_ARM32=$gcc_32_path \
-j$(nproc --all) "
clean(){
rm -rf out
}
export KBUILD_BUILD_USER="Incubator"
export KBUILD_BUILD_HOST="Ratoriku"
build_oldcam(){
print "Building OLDCAM version..." blue
make $args lavender_defconfig && make $args
if [ $? -ne 0 ]; then
errored "Error while building for OLDCAM!"
else
export zipname="$NAME-$version-lavender-OLDCAM-$date.zip"
mkzip
fi
}
build_newcam(){
print "Building NEWCAM version..." blue
echo CONFIG_MACH_XIAOMI_NEWCAM=y >> arch/arm64/configs/lavender-defconfig
make $args lavender_defconfig && make $args
if [ $? -ne 0 ]; then
errored "Error while building for NEWCAM!"
else
export zipname="$NAME-$version-lavender-NEWCAM-$date.zip"
mkzip
fi
}
build_qcam(){
print "Building QCAM version..." blue
echo CONFIG_MACH_XIAOMI_QCAM=y >> arch/arm64/configs/lavender-defconfig
make $args lavender_defconfig && make $args
if [ $? -ne 0 ]; then
errored "Error while building for QCAM!"
else
export zipname="$NAME-$version-lavender-QCAM-$date.zip"
mkzip
fi
}
function telegram_notify(){
curl -s https://api.telegram.org/bot"${bot_token}"/sendMessage -d parse_mode="Markdown" -d text="${1}" -d chat_id="${chat_id}"
}
function errored(){
telegram_notify "${1}"
exit 1
}
function telegram_upload(){
curl -s https://api.telegram.org/bot"${bot_token}"/sendDocument -F document=@"${1}" -F chat_id="${chat_id}"
}
mkzip(){
cp -f out/arch/arm64/boot/Image.gz-dtb ${HOME}/AnyKernel3
cd ${HOME}/AnyKernel3
make
mv -f *.zip ${HOME}/$zipname
cd ${HOME}
telegram_upload ${zipname}
cd $source
print "Done! Check your $zipname" green
}
telegram_notify "Start building
Version: $NAME-$version
Date: $date "
START=$(date +"%s")
build_oldcam
# clean
# build_newcam
# clean
# build_qcam
END=$(date +"%s")
KDURTION=$((END - START))
telegram_notify "Done! Cost time $((KDURTION / 60)) min $((KDURTION % 60)) s"