msm-4.14/build.sh
Richard Raya 34331a1f71 build.sh: Sync Neutron clang version 18.0.0
Change-Id: Iaedc953706f6033ec4880f3773a93466bd78d2cc
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
2024-09-09 00:01:46 -03:00

77 lines
2.2 KiB
Bash

#!/bin/bash
#
# Compile script for FSociety kernel
# Copyright (C) 2020-2021 Adithya R.
SECONDS=0 # builtin bash timer
ZIPNAME="FSociety-surya-$(date '+%Y%m%d-%H%M').zip"
TC_DIR="$(pwd)/tc/clang-neutron"
AK3_DIR="$(pwd)/android/AnyKernel3"
DEFCONFIG="surya_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
export PATH="$TC_DIR/bin:$PATH"
if ! [ -d "$TC_DIR" ]; then
echo "Neutron Clang not found! Downloading to $TC_DIR..."
mkdir -p "$TC_DIR" && cd "$TC_DIR"
curl -LO "https://raw.githubusercontent.com/Neutron-Toolchains/antman/main/antman"
bash ./antman -S=09092023
cd ../..
fi
if [[ $1 = "-u" || $1 = "--update" ]]; then
cd "$TC_DIR" && bash ./antman -U && cd ../..
fi
if [[ $1 = "-r" || $1 = "--regen" ]]; then
make $DEFCONFIG savedefconfig
cp out/defconfig arch/arm64/configs/$DEFCONFIG
echo -e "\nSuccessfully regenerated defconfig at $DEFCONFIG"
exit
fi
if [[ $1 = "-rf" || $1 = "--regen-full" ]]; then
make $DEFCONFIG
cp out/.config arch/arm64/configs/$DEFCONFIG
echo -e "\nSuccessfully regenerated full defconfig at $DEFCONFIG"
exit
fi
if [[ $1 = "-c" || $1 = "--clean" ]]; then
rm -rf out
fi
echo -e "\nStarting compilation...\n"
make $DEFCONFIG
make -j$(nproc --all) LLVM=1 Image.gz dtb.img dtbo.img 2> >(tee log.txt >&2) || exit $?
kernel="out/arch/arm64/boot/Image.gz"
dtb="out/arch/arm64/boot/dtb.img"
dtbo="out/arch/arm64/boot/dtbo.img"
if [ -f "$kernel" ] && [ -f "$dtb" ] && [ -f "$dtbo" ]; then
echo -e "\nKernel compiled succesfully! Zipping up...\n"
if [ -d "$AK3_DIR" ]; then
cp -r $AK3_DIR AnyKernel3
elif ! git clone -q --depth=1 https://github.com/rd-stuffs/AnyKernel3 -b FSociety; then
echo -e "\nAnyKernel3 repo not found locally and couldn't clone from GitHub! Aborting..."
exit 1
fi
cp $kernel $dtb $dtbo AnyKernel3
cd AnyKernel3
git checkout FSociety &> /dev/null
zip -r9 "../$ZIPNAME" * -x .git modules\* patch\* ramdisk\* README.md *placeholder
cd ..
rm -rf AnyKernel3
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
echo "Zip: $ZIPNAME"
else
echo -e "\nCompilation failed!"
exit 1
fi