-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-knightwalker-X00TD.sh
56 lines (48 loc) · 1.86 KB
/
build-knightwalker-X00TD.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
export PATH="$HOME/zyc-clang/bin:$PATH"
export LD_LIBRARY_PATH="$HOME/zyc-clang/lib"
SECONDS=0
ZIPNAME="KnightWalker-KSU-$(date '+%Y%m%d-%H%M').zip"
DEFCONFIG="asus/X00TD-ksu_defconfig"
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
head=$(git rev-parse --verify HEAD 2>/dev/null); then
ZIPNAME="${ZIPNAME::-4}-$(echo $head | cut -c1-8).zip"
fi
if ! [ -d "$HOME/zyc-clang" ]; then
echo "ZyC Clang not found! Cloning..."
wget -q $(curl https://raw.githubusercontent.com/ZyCromerZ/Clang/main/Clang-14-link.txt 2>/dev/null) -O "ZyC-Clang-14.tar.gz"
mkdir ~/zyc-clang
tar -xf ZyC-Clang-14.tar.gz -C ~/zyc-clang
rm -rf ZyC-Clang-14.tar.gz
fi
export BUILD_USERNAME=wo1966
export BUILD_HOSTNAME=remix
export KBUILD_BUILD_USER=wo1966
export KBUILD_BUILD_HOST=remix
if [[ $1 = "-r" || $1 = "--regen" ]]; then
make O=out ARCH=arm64 $DEFCONFIG savedefconfig
cp out/defconfig arch/arm64/configs/$DEFCONFIG
echo -e "\nRegened defconfig succesfully!"
exit
fi
if [[ $1 = "-c" || $1 = "--clean" ]]; then
echo -e "\nClean build!"
rm -rf out
fi
mkdir -p out
make O=out ARCH=arm64 $DEFCONFIG
echo -e "\nStarting compilation...\n"
make -j$(nproc --all) O=out ARCH=arm64 CC=clang LD=ld.lld AR=llvm-ar AS=llvm-as NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi- CLANG_TRIPLE=aarch64-linux-gnu- Image.gz-dtb
if [ -f "out/arch/arm64/boot/Image.gz-dtb" ]; then
echo -e "\nKernel compiled succesfully! Zipping up...\n"
git clone -q https://github.com/Whot1966/AnyKernel3 -b X00TD/KnightWalker-KSU
cp out/arch/arm64/boot/Image.gz-dtb AnyKernel3
cd AnyKernel3
zip -r9 "../$ZIPNAME" * -x '*.git*' README.md *placeholder
cd ..
rm -rf AnyKernel3
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
echo "Zip: $ZIPNAME"
rm -rf out/arch/arm64/boot
else
echo -e "\nCompilation failed!"
fi