-
Notifications
You must be signed in to change notification settings - Fork 13
/
build
111 lines (94 loc) · 2.78 KB
/
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
#!/usr/bin/env bash
# Copyright (C) 2021 Oktapra Amtono <oktapra.amtono@gmail.com>
# Kernel Build Script
# Kernel Directory
KERNEL_DIR=$PWD
# Kernel Release Version
RELEASE_VERSION="_r4"
# Device Name
if [[ "$*" =~ "whyred" ]]; then
DEVICE="whyred"
export LOCALVERSION="$RELEASE_VERSION"
elif [[ "$*" =~ "tulip" ]]; then
DEVICE="tulip"
export LOCALVERSION="$RELEASE_VERSION"
elif [[ "$*" =~ "lavender" ]]; then
DEVICE="lavender"
export LOCALVERSION="$RELEASE_VERSION"
elif [[ "$*" =~ "a26x" ]]; then
DEVICE="a26x"
export LOCALVERSION="$RELEASE_VERSION"
fi
# if building OverClock Version
if [[ "$*" =~ "oc" ]]; then
export LOCALVERSION="$RELEASE_VERSION-OC"
fi
# Setup Environtment
export TZ="Asia/Jakarta"
KERNEL_IMG=$KERNEL_DIR/out/arch/arm64/boot/Image.gz-dtb
SOURCE="$(git rev-parse --abbrev-ref HEAD)"
AK3_DIR=$KERNEL_DIR/ak3-$DEVICE/
if [[ "$*" =~ "clang" ]]; then
# Clang Setup
CLANG_DIR="$KERNEL_DIR/clang"
export PATH="$KERNEL_DIR/clang/bin:$PATH"
KBUILD_COMPILER_STRING="$("$CLANG_DIR"/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g')"
export KBUILD_COMPILER_STRING
fi
export SOURCE
export ARCH=arm64
export SUBARCH=arm64
export KBUILD_BUILD_USER="okta_10"
export KBUILD_BUILD_HOST="dockerci"
# Telegram
TELEGRAM=Telegram/telegram
sendInfo() {
"${TELEGRAM}" -c "${CHANNEL_ID}" -H -D \
"$(
for POST in "${@}"; do
echo "${POST}"
done
)"
}
sendKernel() {
"${TELEGRAM}" -f "$(echo "$AK3_DIR"/*.zip)" \
-c "${CHANNEL_ID}" -H \
"# <code>$DEVICE</code> # <code>md5: $(md5sum "$AK3_DIR"/*.zip | cut -d' ' -f1)</code> # <code>Build Took : $(("$DIFF" / 60)) Minute, $(("$DIFF" % 60)) Second</code>"
}
# Start Count
BUILD_START=$(date +"%s")
# Export Defconfig
make O=out mystic-"$DEVICE"_defconfig
# Start Compile
if [[ "$*" =~ "clang" ]]; then
make -j"$(nproc --all)" O=out \
CC=clang \
AR=llvm-ar \
NM=llvm-nm \
OBJCOPY=llvm-objcopy \
OBJDUMP=llvm-objdump \
STRIP=llvm-strip \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_ARM32=arm-linux-gnueabi-
elif [[ "$*" =~ "gcc" ]]; then
export CROSS_COMPILE="$KERNEL_DIR/arm64/bin/aarch64-elf-"
export CROSS_COMPILE_ARM32="$KERNEL_DIR/arm32/bin/arm-eabi-"
make -j"$(nproc --all)" O=out ARCH=arm64
fi
# If build error
if ! [ -a "$KERNEL_IMG" ]; then
sendInfo "<b>Failed building kernel for <code>$DEVICE</code> Please fix it...!</b>"
exit 1
fi
# End Count and Calculate Total Build Time
BUILD_END=$(date +"%s")
DIFF=$(( BUILD_END - BUILD_START ))
# Make zip
cp -r "$KERNEL_IMG" "$AK3_DIR"/
cd "$AK3_DIR" || exit
zip -r9 Mystic-"$DEVICE""$LOCALVERSION".zip ./*
cd "$KERNEL_DIR" || exit
sendKernel
rm -rf out/arch/arm64/boot/
rm -rf out/.version
rm -rf "$AK3_DIR"/*.zip