-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
116 lines (93 loc) · 3.5 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
#!/usr/bin/env bash
# shellcheck disable=SC2199
# shellcheck source=/dev/null
#
# Copyright (C) 2020-22 UtsavBalar1231 <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if ! [ -d "$HOME/toolchains/neutron-clang" ]; then
cwd=$(pwd)
mkdir -p "$HOME/toolchains/neutron-clang"
cd "$HOME/toolchains/neutron-clang"
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") -S=05012024
bash <(curl -s "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman") --patch=glibc
cd $cwd
fi
GCC_64_DIR="$HOME/toolchains/neutron-clang"
KBUILD_COMPILER_STRING=$($HOME/toolchains/neutron-clang/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//')
KBUILD_LINKER_STRING=$($HOME/toolchains/neutron-clang/bin/ld.lld --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//' | sed 's/(compatible with [^)]*)//')
export KBUILD_COMPILER_STRING
export KBUILD_LINKER_STRING
DEVICE=$1
if [[ "${DEVICE}" = "monet" ] || [ "${DEVICE}" = "vangogh" ]]; then
DEFCONFIG=milito.config
DEVICE=milito
fi
#
# Enviromental Variables
#
DATE=$(date '+%Y%m%d-%H%M')
# Set our directory
OUT_DIR=out/
VERSION="Skizo-ksu-${DEVICE}-${DATE}"
# Export Zip name
export ZIPNAME="${VERSION}.zip"
# How much kebabs we need? Kanged from @raphielscape :)
if [[ -z "${KEBABS}" ]]; then
COUNT="$(grep -c '^processor' /proc/cpuinfo)"
export KEBABS="$((COUNT + 2))"
fi
echo "Jobs: ${KEBABS}"
ARGS="ARCH=arm64 \
O=${OUT_DIR} \
CC=clang \
LLVM=1 \
LLVM_IAS=1 \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=$GCC_64_DIR/bin/aarch64-linux-gnu- \
CROSS_COMPILE_COMPAT=$GCC_64_DIR/bin/arm-linux-gnueabi- \
-j${KEBABS}"
dts_source=arch/arm64/boot/dts/vendor/qcom
START=$(date +"%s")
# Set compiler Path
export PATH="$HOME/toolchains/neutron-clang/bin:$PATH"
export LD_LIBRARY_PATH=${HOME}/tc/aosp-clang/lib64:$LD_LIBRARY_PATH
echo "------ Starting Compilation ------"
# Make defconfig
make -j${KEBABS} ${ARGS} ${DEFCONFIG}
# Make olddefconfig
cd ${OUT_DIR} || exit
make -j${KEBABS} ${ARGS} CC="ccache clang" HOSTCC="ccache gcc" HOSTCXX="cache g++" olddefconfig
cd ../ || exit
make -j${KEBABS} ${ARGS} CC="ccache clang" HOSTCC="ccache gcc" HOSTCXX="ccache g++" 2>&1 | tee build.log
find ${OUT_DIR}/$dts_source -name '*.dtb' -exec cat {} + >${OUT_DIR}/arch/arm64/boot/dtb
git checkout arch/arm64/boot/dts/vendor &>/dev/null
echo "------ Finishing Build ------"
END=$(date +"%s")
DIFF=$((END - START))
zipname="$VERSION.zip"
if [ -f "out/arch/arm64/boot/Image" ] && [ -f "out/arch/arm64/boot/dtb" ]; then
git clone -q https://github.com/alecchangod/AnyKernel3.git -b ${DEVICE}
cp out/arch/arm64/boot/Image AnyKernel3
cp out/arch/arm64/boot/dtb AnyKernel3
rm -f *zip
cd AnyKernel3
zip -r9 "../${zipname}" * -x '*.git*' README.md *placeholder >> /dev/null
cd ..
rm -rf AnyKernel3
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
echo ""
echo -e ${zipname} " is ready!"
else
echo -e "\n Compilation Failed!"
fi