forked from Yash089610/android_kernel_msm8953_mido
-
Notifications
You must be signed in to change notification settings - Fork 1
/
clang.sh
executable file
·161 lines (132 loc) · 3.02 KB
/
clang.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
rm .version
# Bash Color
green='\033[01;32m'
red='\033[01;31m'
blink_red='\033[05;31m'
restore='\033[0m'
clear
# Resources
THREAD="-j$(grep -c ^processor /proc/cpuinfo)"
KERNEL="Image"
DTBIMAGE="dtb"
DEFCONFIG="revolt_defconfig"
## Always ARM64
ARCH=arm64
## Always use all threads
THREADS=$(nproc --all)
## clang specific values
CTRIPLE=aarch64-linux-gnu-
# Clang TC
CC=~/Android/kernel/tc/clang/flash-clang-7.x/bin/clang
#Compiler string
export KBUILD_COMPILER_STRING="$(${CC} --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')"
# Kernel Details
VER=".EAS-R11"
# Paths
KERNEL_DIR=`pwd`
REPACK_DIR=~/Android/kernel/AnyKernel2/
PATCH_DIR=~/Android/kernel/AnyKernel2/patch
MODULES_DIR=~/Android/kernel/AnyKernel2/modules
ZIP_MOVE=~/Android/kernel/AK-releases/
ZIMAGE_DIR=~/Android/kernel/EAS/arch/arm64/boot
# Unset CROSS_COMPILE and CCOMPILE if they're set
[[ ! -z ${CROSS_COMPILE} ]] && unset CROSS_COMPILE
[[ ! -z ${CCOMPILE} ]] && unset CCOMPILE
# Use ccache when available
if false; then
[[ $(which ccache > /dev/null 2>&1; echo $?) -eq 0 ]] && CCOMPILE+="ccache "
fi
# Whenever you're high enough to run this script
CCOMPILE+=aarch64-linux-gnu-
# Functions
function clean_all {
cd $REPACK_DIR
rm -r *
git reset --hard && git clean -f -d
cd $KERNEL_DIR
make clean && make mrproper
}
function make_kernel {
echo
make $DEFCONFIG
make ARCH=${ARCH} CC="ccache ${CC}" CLANG_TRIPLE=${CTRIPLE} \
CROSS_COMPILE="${CCOMPILE}" -j${THREADS}
}
function make_zip {
cd $REPACK_DIR
mkdir kernel
mkdir treble-supported
mkdir treble-unsupported
cp $KERNEL_DIR/arch/arm64/boot/dts/qcom/msm8953-qrd-sku3-mido-nontreble.dtb $REPACK_DIR/treble-unsupported/
cp $KERNEL_DIR/arch/arm64/boot/dts/qcom/msm8953-qrd-sku3-mido-treble.dtb $REPACK_DIR/treble-supported/
cp $KERNEL_DIR/arch/arm64/boot/Image.gz $REPACK_DIR/kernel/
zip -r9 `echo $ZIP_NAME`.zip *
cp *.zip $ZIP_MOVE
cd $KERNEL_DIR
}
DATE_START=$(date +"%s")
echo -e "${green}"
echo "-----------------"
echo "Making REVOLT Kernel:"
echo "-----------------"
echo -e "${restore}"
# Vars
BASE_AK_VER="REVOLT"
DATE=`date +"%Y%m%d-%H%M"`
AK_VER="$BASE_AK_VER$VER"
ZIP_NAME="$AK_VER"-"$DATE"
export LOCALVERSION=~`echo $AK_VER`
export LOCALVERSION=~`echo $AK_VER`
export ARCH=arm64
export SUBARCH=arm64
export KBUILD_BUILD_USER=NATO66613
export KBUILD_BUILD_HOST=PENTAGON
echo
while read -p "Do you want to clean stuffs (y/n)? " cchoice
do
case "$cchoice" in
y|Y )
clean_all
echo
echo "All Cleaned now."
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo
while read -p "Do you want to build?" dchoice
do
case "$dchoice" in
y|Y )
make_kernel
make_zip
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${green}"
echo "-------------------"
echo "Build Completed in:"
echo "-------------------"
echo -e "${restore}"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
echo