forked from onettboots/bool-x_xiaomi_raphael
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.sh
executable file
·260 lines (241 loc) · 5.35 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/bash
rm .version
rm build.log
# Bash Color
green='\033[01;32m'
red='\033[01;31m'
blink_red='\033[05;31m'
restore='\033[0m'
clear
# Resources
export CLANG_PATH="$HOME/toolchains/boolx-clang/bin"
export PATH=${CLANG_PATH}:${PATH}
export CLANG_TRIPLE=${CLANG_PATH}/aarch64-linux-gnu-
export CROSS_COMPILE=${CLANG_PATH}/aarch64-linux-gnu-
export CROSS_COMPILE_ARM32=${CLANG_PATH}/arm-linux-gnueabi-
export SUBARCH=arm64
# export DTC_EXT=dtc # we don needed it again
export ARCH=arm64
export CC=$HOME/toolchains/boolx-clang/bin/clang
VER="V1.6-PickAcrut-LGC"
KERNEL_DIR=`pwd`
REPACK_DIR=$HOME/AnyKernel3
ZIP_MOVE=$HOME/Boolx
BASE_AK_VER="Bool-X-Raphael-"
DATE=`date +"%Y%m%d-%H%M"`
AK_VER="$BASE_AK_VER$VER"
ZIP_NAME="$AK_VER"-"$DATE"
TOOLCHAINS=$HOME/toolchains/boolx-clang
CONFIG=out/.config
KERNEL=out/arch/arm64/boot/Image.gz-dtb
DTBO=out/arch/arm64/boot/dtbo.img
#functions
function create_out {
echo
git clone https://github.com/onettboots/boolx_anykernel.git $REPACK_DIR && mkdir $ZIP_MOVE
}
function clean_all {
echo
make clean && make mrproper && rm -rf out
}
function make_config {
echo
make CC=$HOME/toolchains/boolx-clang/bin/clang O=out raphael_defconfig
}
function make_menuconfig {
echo
make CC=$HOME/toolchains/boolx-clang/bin/clang O=out menuconfig
}
function building {
echo
make O=out CC=$HOME/toolchains/boolx-clang/bin/clang LLVM=1 LLVM_IAS=1 KBUILD_BUILD_USER=OnettBoots KBUILD_BUILD_HOST=SuperTermux -j$(grep -c ^processor /proc/cpuinfo)
}
function make_boot {
cp $KERNEL $REPACK_DIR && cp $DTBO $REPACK_DIR/oc
}
function make_zip {
cd $REPACK_DIR
zip -r9 `echo $ZIP_NAME`.zip *
mv `echo $ZIP_NAME`*.zip $ZIP_MOVE
cd $KERNEL_DIR
}
DATE_START=$(date +"%s")
echo -e "${green}"
echo "----------------------"
echo "Checking Toolchains:"
echo "----------------------"
echo -e "${restore}"
if [ -d $TOOLCHAINS ]; then
echo -e "${green}"
echo "Bool-x clang is ready..!!"
echo -e "${restore}"
else
echo -e "${red}"
echo "Downloading toolchains.!!"
while read -p "what your architecture (aarch64/x86)? " cchoice
do
case "$cchoice" in
aarch64|Aarch64 )
echo
echo "Downloading Boolx-clang for Aarch64 host."
git clone https://gitlab.com/onettboots/boolx-clang.git -b Clang-15.0 $TOOLCHAINS
break
;;
x86|X86 )
echo
echo "Downloading Boolx-clang for X86 host."
git clone https://gitlab.com/onettboots/boolx-clang.git -b Clang-17.0_x86 $TOOLCHAINS
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${restore}"
fi
echo -e "${green}"
echo "----------------------------------"
echo "Checking for Anykernel flashable:"
echo "----------------------------------"
echo -e "${restore}"
if [ -d $REPACK_DIR ] && [ -d $ZIP_MOVE ]; then
echo -e "${green}"
echo "Anykernel is ready skipping..!!"
echo -e "${restore}"
else
echo -e "${red}"
echo "Adding Anykernel flashable.!!"
create_out
echo -e "${restore}"
fi
echo -e "${green}"
echo "------------------"
echo "CLEAN OPTIONS:"
echo "------------------"
while read -p "Do you want to clean stuffs (y/n)? " cchoice
do
case "$cchoice" in
y|Y )
echo -e "${red}"
clean_all
echo -e "${restore}"
echo -e "${green}"
echo "All Cleaned now."
echo -e "${restore}"
break
;;
n|N )
break
;;
* )
echo -e "${red}"
echo "Invalid try again!"
echo -e "${restore}"
;;
esac
done
echo -e "${restore}"
if [ -f $CONFIG ]; then
echo -e "${green}"
while read -p "Old config is exist do you want replace with new config ? (y/n)? " cchoice
do
case "$cchoice" in
y|Y )
make_config
echo
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${restore}"
else
echo -e "${green}"
echo -e "${restore}"
fi
if [ -f $CONFIG ]; then
echo -e "${green}"
echo -e "${restore}"
else
echo -e "${green}"
echo "-------------------------------------"
echo "Making Configs:"
echo "-------------------------------------"
echo -e "${restore}"
echo -e "${red}"
make_config
echo -e "${restore}"
fi
if [ -f $CONFIG ]; then
echo -e "${green}"
while read -p "Do you want edit config via menuconfig ? (y/n)? " cchoice
do
case "$cchoice" in
y|Y )
make_menuconfig
echo
break
;;
n|N )
break
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo -e "${restore}"
else
echo -e "${green}"
echo -e "${restore}"
fi
echo -e "${green}"
echo "-----------------"
echo "Building Kernel:"
echo "-----------------"
echo -e "${restore}"
building
echo -e "${green}"
echo "----------------------"
echo "Checking output files"
echo "----------------------"
echo -e "${restore}"
sleep 3
if [ -f $KERNEL ]; then
echo -e "${green}"
echo "------------------------------------------"
echo "Succesed Build, make flashable zip"
echo "------------------------------------------"
echo -e "${restore}"
make_boot
make_zip
cd $ZIP_MOVE
echo -e "${blink_red}"
echo $ZIP_MOVE
echo "------------------------------------------"
echo $ZIP_NAME*.zip
echo "------------------------------------------"
echo -e "${restore}"
else
echo -e "${red}"
echo "-------------------------------------"
echo "Building failed, Fix it and rebuild...!!!"
echo "-------------------------------------"
echo -e "${restore}"
fi
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
echo "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
echo