-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·146 lines (126 loc) · 3.59 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
#!/bin/bash
timestamp=`date +%s`
find -name "build.log.*" | sort -r | tail -n +3 | xargs rm
mv build.log build.log.$timestamp
export ARCH=arm64
export KBUILD_BUILD_USER=BuildUser
export KBUILD_BUILD_HOST=BuildHost
export PLATFORM_VERSION=10.0.0
export KBUILD_COMPILER_STRING="LLVM Clang 9.0"
GCC_ARM64_BIN_PATH=$HOME/Toolchains/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin
GCC_ARM32_BIN_PATH=$HOME/Toolchains/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin
CLANG_BIN_PATH=/usr/lib/llvm-10/bin
BUILD_CROSS_COMPILE=$GCC_ARM64_BIN_PATH/aarch64-none-linux-gnu-
BUILD_CROSS_COMPILE_ARM32=$GCC_ARM32_BIN_PATH/arm-none-linux-gnueabihf-
CLANG_CC=$CLANG_BIN_PATH/clang
GCC_CC="${BUILD_CROSS_COMPILE}gcc"
CLANG_LD=$CLANG_BIN_PATH/ld.lld
GCC_LD="${BUILD_CROSS_COMPILE}ld"
CLANG_LDLTO=$CLANG_BIN_PATH/ld.lld
GCC_LDLTO="${BUILD_CROSS_COMPILE}ld.gold"
CC=$CLANG_CC
LD=$CLANG_LD
LDLTO=$CLANG_LD
BUILD_JOB_NUMBER="$(nproc)"
# BUILD_JOB_NUMBER=1
OUTPUT_ZIP="g970f_kernel"
RDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OUT="${RDIR}/.build"
mkdir -p $OUT
KERNEL_DEFCONFIG=exynos9820-beyond0lte_defconfig
FUNC_BUILD_KERNEL()
{
echo ""
echo "=============================================="
echo "START : FUNC_BUILD_KERNEL"
echo "=============================================="
echo ""
echo "build common config="${KERNEL_DEFCONFIG}""
echo "build model config=SM-G970F"
make -j$BUILD_JOB_NUMBER ARCH=$ARCH \
O=$OUT \
CROSS_COMPILE="${BUILD_CROSS_COMPILE}" \
CROSS_COMPILE_ARM32="${BUILD_CROSS_COMPILE_ARM32}" \
$KERNEL_DEFCONFIG || exit -1
cd $OUT
for var in "$@"
do
if [[ "$var" = "--with-lto-clang" ]] ; then
echo ""
echo "Enable LTO_CLANG"
../scripts/config \
-e CONFIG_LTO \
-e CONFIG_THINLTO \
-d CONFIG_LTO_NONE \
-e CONFIG_LTO_CLANG \
-e CONFIG_CFI_CLANG \
-e CONFIG_CFI_PERMISSIVE \
-e CONFIG_CFI_CLANG_SHADOW \
-e CONFIG_LLVM_POLLY
OUTPUT_ZIP="${OUTPUT_ZIP}.lto"
CC=$CLANG_CC
LD=$CLANG_LD
LDLTO=$CLANG_LDLTO
continue
fi
if [[ "$var" = "--with-lto-gcc" ]] ; then
echo ""
echo "Enable LTO_GCC"
../scripts/config \
-e CONFIG_LTO \
-d CONFIG_LTO_NONE \
-e CONFIG_LTO_GCC
OUTPUT_ZIP="${OUTPUT_ZIP}.lto"
CC=$GCC_CC
LD=$GCC_LD
continue
fi
if [[ "$var" = "--with-supersu" ]] ; then
echo "Enable ASSISTED_SUPERUSER"
../scripts/config \
-e ASSISTED_SUPERUSER
continue
fi
done
echo ""
cd $RDIR
make -j$BUILD_JOB_NUMBER ARCH=$ARCH \
O=$OUT \
CC=$CC \
LD=$LD \
LDLTO=$LDLTO \
CROSS_COMPILE_ARM32="${BUILD_CROSS_COMPILE_ARM32}" \
CROSS_COMPILE="${BUILD_CROSS_COMPILE}" || exit -1
echo ""
echo "================================="
echo "END : FUNC_BUILD_KERNEL"
echo "================================="
echo ""
}
FUNC_BUILD_RAMDISK()
{
cp "${OUT}/arch/${ARCH}/boot/Image" "${RDIR}/aik/split_img/boot.img-zImage"
cd "${RDIR}/aik"
./repackimg.sh --nosudo
}
FUNC_BUILD_ZIP()
{
cd "${RDIR}/out/"
cp "${RDIR}/aik/image-new.img" "${RDIR}/out/boot.img"
cp "${OUT}/arch/arm64/boot/dtb.img" "${RDIR}/out/dtb.img"
cp "${OUT}/arch/arm64/boot/dtbo.img" "${RDIR}/out/dtbo.img"
rm -f "${OUT}/out/system/lib/modules/*.ko"
find ${OUT} -name "*.ko" -not -path "*/out/*" -exec cp -f {} "${RDIR}/out/system/lib/modules/" \;
cd "${RDIR}/out/" && zip "../${OUTPUT_ZIP}.zip" -r *
}
# MAIN FUNCTION
rm -rf ./build.log
(
START_TIME=`date +%s`
FUNC_BUILD_KERNEL "$@"
FUNC_BUILD_RAMDISK
FUNC_BUILD_ZIP
END_TIME=`date +%s`
let "ELAPSED_TIME=${END_TIME}-${START_TIME}"
echo "Total compile time was ${ELAPSED_TIME} seconds"
) 2>&1 | tee -a ./build.log