-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-kernel.lto
executable file
·74 lines (60 loc) · 2.16 KB
/
build-kernel.lto
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
#!/bin/bash
#
# Usage: ~/bin/build-kernel $device $log
#
device="$1"
log="$2"
source ~/bin/helper
export USE_CCACHE=1
/usr/bin/ccache -M 20G
DATE_START=$(date +"%s")
MONTH=$(date -d "$D" '+%m')
YEAR=$(date -d "$D" '+%Y')
OS="10.0.0"
SPL="${YEAR}-${MONTH}"
rm -rf ~/out-lto/arch/arm64/boot/dts/xiaomi/
command make O=~/out-lto \
ARCH=arm64 \
vendor/lineage_${device}_defconfig
export PATH=~/losq/prebuilts-master/clang/host/linux-x86/clang-r383902/bin:~/losq/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin:~/losq/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/:~/bin/toolchain/dtc:${PATH}
export LD_LIBRARY_PATH=~/losq/prebuilts-master/clang/host/linux-x86/clang-r383902:$LD_LIBRARY_PATH
command make -j4 O=~/out-lto \
ARCH=arm64 \
CC=clang \
AR="llvm-ar" \
NM="llvm-nm" \
OBJCOPY="llvm-objcopy" \
OBJDUMP="llvm-objdump" \
STRIP="llvm-strip" \
LD=ld.lld \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=aarch64-linux-android- \
CROSS_COMPILE_ARM32=arm-linux-androideabi- \
DTC_EXT=dtc \
2>&1 | tee ~/${log}
cd ~/out-lto/
if [ -f arch/arm64/boot/Image.gz-dtb ] ;then
find ~/out-lto/arch/arm64/boot/dts -name '*.dtb' -exec cat {} + > /tmp/${device}.dtb
~/losq/out/host/linux-x86/bin/mkbootimg \
--kernel ~/out-lto/arch/arm64/boot/Image.gz-dtb \
--cmdline 'androidboot.hardware=qcom androidboot.console=ttyMSM0 service_locator.enable=1 swiotlb=1 earlycon=msm_geni_serial,0x880000 loop.max_part=7 cgroup.memory=nokmem,nosocket androidboot.vbmeta.avb_version=1.0' \
--base 0x00000000 \
--pagesize 4096 \
--kernel_offset 0x00008000 \
--second_offset 0x00f00000 \
--tags_offset 0x00000100 \
--dtb /tmp/${device}.dtb \
--os_version $OS \
--os_patch_level $SPL \
-o ~/out-lto/boot.img
file ~/out-lto/boot.img
~/losq/system/libufdt/utils/src/mkdtboimg.py create ~/out-lto/dtbo-pre.img \
--page_size=4096 \
`find ~/out-lto/arch/arm64/boot/dts/xiaomi \
-type f -name '*.dtbo' | sort`
file ~/out-lto/dtbo-pre.img
header "Build Completed in:"
DATE_END=$(date +"%s")
DIFF=$(($DATE_END - $DATE_START))
success "Time: $(($DIFF / 60)) minute(s) and $(($DIFF % 60)) seconds."
fi