2023-11-12 02:26:45 -03:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2023-11-12 02:03:52 -03:00
|
|
|
# Compile script for FSociety kernel
|
2023-11-12 02:26:45 -03:00
|
|
|
# Copyright (C) 2020-2021 Adithya R.
|
|
|
|
|
|
|
|
SECONDS=0 # builtin bash timer
|
2023-11-12 02:03:52 -03:00
|
|
|
ZIPNAME="FSociety-surya-$(date '+%Y%m%d-%H%M').zip"
|
2024-04-18 20:09:47 -03:00
|
|
|
TC_DIR="$(pwd)/tc/clang-neutron"
|
2023-01-08 20:05:49 -03:00
|
|
|
AK3_DIR="$(pwd)/android/AnyKernel3"
|
2023-11-12 02:03:52 -03:00
|
|
|
DEFCONFIG="surya_defconfig"
|
2023-11-12 02:26:45 -03:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2023-11-12 03:42:45 -03:00
|
|
|
if ! [ -d "$TC_DIR" ]; then
|
2024-04-18 20:09:47 -03:00
|
|
|
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"
|
2024-09-07 01:35:43 -03:00
|
|
|
bash ./antman -S=09092023
|
2024-04-18 20:09:47 -03:00
|
|
|
cd ../..
|
2023-11-12 03:42:45 -03:00
|
|
|
fi
|
|
|
|
|
2024-06-26 13:59:16 +02:00
|
|
|
if [[ $1 = "-u" || $1 = "--update" ]]; then
|
|
|
|
cd "$TC_DIR" && bash ./antman -U && cd ../..
|
|
|
|
fi
|
2024-04-18 20:09:47 -03:00
|
|
|
|
2023-11-12 02:26:45 -03:00
|
|
|
if [[ $1 = "-r" || $1 = "--regen" ]]; then
|
2020-12-24 16:29:31 -08:00
|
|
|
make $DEFCONFIG savedefconfig
|
2023-11-12 02:26:45 -03:00
|
|
|
cp out/defconfig arch/arm64/configs/$DEFCONFIG
|
|
|
|
echo -e "\nSuccessfully regenerated defconfig at $DEFCONFIG"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2023-01-11 15:45:43 -03:00
|
|
|
if [[ $1 = "-rf" || $1 = "--regen-full" ]]; then
|
2020-12-24 16:29:31 -08:00
|
|
|
make $DEFCONFIG
|
2023-01-11 15:45:43 -03:00
|
|
|
cp out/.config arch/arm64/configs/$DEFCONFIG
|
|
|
|
echo -e "\nSuccessfully regenerated full defconfig at $DEFCONFIG"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2023-11-12 02:26:45 -03:00
|
|
|
if [[ $1 = "-c" || $1 = "--clean" ]]; then
|
|
|
|
rm -rf out
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\nStarting compilation...\n"
|
2020-12-24 16:29:31 -08:00
|
|
|
make $DEFCONFIG
|
2024-07-03 01:33:43 -03:00
|
|
|
make -j$(nproc --all) LLVM=1 Image.gz dtb.img dtbo.img 2> >(tee log.txt >&2) || exit $?
|
2023-11-12 02:26:45 -03:00
|
|
|
|
|
|
|
kernel="out/arch/arm64/boot/Image.gz"
|
2023-11-12 02:43:08 -03:00
|
|
|
dtb="out/arch/arm64/boot/dtb.img"
|
2023-11-12 02:26:45 -03:00
|
|
|
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
|
2024-04-27 11:16:54 -03:00
|
|
|
elif ! git clone -q --depth=1 https://github.com/rd-stuffs/AnyKernel3 -b FSociety; then
|
2023-11-12 02:26:45 -03:00
|
|
|
echo -e "\nAnyKernel3 repo not found locally and couldn't clone from GitHub! Aborting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-11-12 02:43:08 -03:00
|
|
|
cp $kernel $dtb $dtbo AnyKernel3
|
2023-11-12 02:26:45 -03:00
|
|
|
cd AnyKernel3
|
2023-11-12 02:03:52 -03:00
|
|
|
git checkout FSociety &> /dev/null
|
2024-07-04 12:45:34 -03:00
|
|
|
zip -r9 "../$ZIPNAME" * -x .git modules\* patch\* ramdisk\* README.md *placeholder
|
2023-11-12 02:26:45 -03:00
|
|
|
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
|