msm-4.14/build.sh
Richard Raya fa60e2d29c build.sh: Switch to Slim LLVM 19
Change-Id: I1d20fe92febb772b0b2d337e4b5a9e237b5f5fac
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
2024-11-18 18:24:07 -03:00

76 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-19"
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 "Slim LLVM not found! Cloning to $TC_DIR..."
if ! git clone --depth=1 -b 19 https://github.com/rd-stuffs/prebuilts_clang-standalone.git "$TC_DIR"; then
echo "Cloning failed! Aborting..."
exit 1
fi
if ! [ -f "$TC_DIR/bin/clang-19" ]; then
gunzip "$TC_DIR/bin/clang-19.gz"
fi
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