-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·179 lines (150 loc) · 3.45 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
#!/bin/bash
# Bash Color
green='\033[01;32m'
red='\033[01;31m'
blink_red='\033[05;31m'
restore='\033[0m'
clear
# Number of parallel jobs to run
THREAD="-j$(nproc)"
# Path to executables in LLVM toolchain
CLANG_BIN="/home/utziacre/ClangBuiltLinux/bin"
# GCC toolchain prefix
GCC_PREFIX="/home/utziacre/ClangBuiltLinux/bin/aarch64-linux-gnu-"
# Environment
export PATH="$CLANG_BIN:$PATH"
# Vars
ARCH="arm64"
OS="14.0.0"
SPL="2023-12"
KDIR=`readlink -f .`
RAMFS=`readlink -f $KDIR/ramdisk`
OUT=`readlink -f $KDIR/out`
KMAKE_FLAGS=(
-j"$(nproc)"
ARCH="$ARCH"
O="$OUT"
LLVM=1
LLVM_IAS=1
CC="clang"
CLANG_TRIPLE="aarch64-linux-gnu-"
CROSS_COMPILE="$GCC_PREFIX"
)
# Kernel defconfig
DEFCONFIG="pipa_defconfig"
# Functions
function clean_all {
echo
git clean -fdx >/dev/null 2>&1
}
function make_kernel {
clang -v
make "${KMAKE_FLAGS[@]}" $DEFCONFIG savedefconfig
make "${KMAKE_FLAGS[@]}"
}
function make_bootimg {
echo "Making new boot image..."
mkbootimg \
--kernel $OUT/arch/arm64/boot/Image \
--ramdisk $RAMFS/ramdisk \
--os_version $OS \
--os_patch_level $SPL \
--pagesize 4096 \
--header_version 3 \
-o $OUT/boot.img
}
function make_vendor_bootimg {
echo "Making new vendor_boot image..."
mkbootimg \
--vendor_boot $OUT/vendor_boot.img \
--vendor_ramdisk $RAMFS/vendor_ramdisk \
--dtb $OUT/arch/arm64/boot/dtb \
--vendor_cmdline "androidboot.console=ttyMSM0 androidboot.hardware=qcom androidboot.init_fatal_reboot_target=recovery androidboot.memcg=1 androidboot.usbcontroller=a600000.dwc3 cgroup.memory=nokmem,nosocket console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xa90000 loop.max_part=7 lpm_levels.sleep_disabled=1 msm_rtb.filter=0x237 reboot=panic_warm service_locator.enable=1 swiotlb=2048 buildvariant=user" \
--pagesize 4096 \
--header_version 3
}
function flash_images {
adb reboot fastboot >/dev/null 2>&1
echo "Flashing kernel images..."
fastboot flash dtbo $OUT/arch/arm64/boot/dtbo.img
fastboot flash boot $OUT/boot.img
fastboot flash vendor_boot $OUT/vendor_boot.img
fastboot reboot
}
DATE_START=$(date +"%s")
echo -e "${green}"
echo "-----------------"
echo "Making Kernel: "
echo "-----------------"
echo -e "${restore}"
echo
while read -p "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 "Start building (y/n)? " dchoice
do
case "$dchoice" in
y|Y )
make_kernel || exit 1
make_bootimg
make_vendor_bootimg
break
;;
n|N )
echo
echo
exit 1
;;
* )
echo
echo "Invalid try again!"
echo
;;
esac
done
echo
while read -p "Flash kernel images (y/n)? " dchoice
do
case "$dchoice" in
y|Y )
flash_images
break
;;
n|N )
echo
echo
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