Skip to content

Commit 4e69337

Browse files
vbajsbasamaryan
andcommitted
Import scripts
Build scripts is from vantom that has been modified by me [References: PixelOS-Devices-old/kernel_xiaomi_sm6150@3c7a1ba ] Co-authored-by: basamaryan <basam.aryan@gmail.com> Signed-off-by: Yahya Wessam <yahyawessam2002@gmail.com>
1 parent 4f38249 commit 4e69337

3 files changed

Lines changed: 222 additions & 0 deletions

File tree

build.sh

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#!/bin/bash
2+
#
3+
# Compile script for kernel
4+
#
5+
6+
# Initialize flags for options
7+
clean=false
8+
local=false
9+
suonly=false
10+
11+
# Use getopt for parsing long and short options
12+
while [[ $# -gt 0 ]]; do
13+
case "$1" in
14+
-c|--clean)
15+
clean=true
16+
shift
17+
;;
18+
-l|--local)
19+
local=true
20+
shift
21+
;;
22+
-su|--su-only)
23+
suonly=true
24+
shift
25+
;;
26+
*)
27+
echo "Unknown option: $1"
28+
exit 1
29+
;;
30+
esac
31+
done
32+
33+
SECONDS=0 # builtin bash timer
34+
35+
if [ "$local" = true ]; then
36+
ZIPNAME="[AOSP]-Spiteful-sweet-$(date '+%Y%m%d-%H%M').zip"
37+
else
38+
ZIPNAME="[AOSP]-Spiteful-sweet-$(date '+%Y%m%d').zip"
39+
fi
40+
41+
export ARCH=arm64
42+
export KBUILD_BUILD_USER=vbajs
43+
export KBUILD_BUILD_HOST=tbyool
44+
45+
if [ ! -d "$PWD/clang" ]; then
46+
git clone https://gitlab.com/crdroidandroid/android_prebuilts_clang_host_linux-x86_clang-r547379.git --depth=1 -b 15.0 clang
47+
else
48+
echo "Local clang dir found, will not download clang and using that instead"
49+
fi
50+
51+
export PATH="$PWD/clang/bin/:$PATH"
52+
export KBUILD_COMPILER_STRING="$($PWD/clang/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//')"
53+
54+
if [ "$local" = true ]; then
55+
echo -e "\nLocal build, disabling LTO...\n"
56+
patch -p1 < local-build.patch
57+
fi
58+
59+
if [ "$clean" = true ]; then
60+
rm -rf out
61+
echo "Cleaned output folder"
62+
fi
63+
64+
echo -e "\nStarting compilation...\n"
65+
make O=out ARCH=arm64 sweet_defconfig
66+
make -j$(nproc --all) \
67+
O=out \
68+
ARCH=arm64 \
69+
LLVM=1 \
70+
LLVM_IAS=1 \
71+
CROSS_COMPILE=aarch64-linux-gnu- \
72+
CROSS_COMPILE_COMPAT=arm-linux-gnueabi-
73+
74+
kernel="out/arch/arm64/boot/Image.gz"
75+
dtbo="out/arch/arm64/boot/dtbo.img"
76+
dtb="out/arch/arm64/boot/dtb.img"
77+
78+
if [ ! -f "$kernel" ] || [ ! -f "$dtbo" ] || [ ! -f "$dtb" ]; then
79+
echo -e "\nCompilation failed!"
80+
exit 1
81+
fi
82+
83+
if [ "$suonly" = true ]; then
84+
echo -e "\nNot compiling NSU image..."
85+
echo -e "\nKernel compiled successfully! Zipping up...\n"
86+
if [ -d "$AK3_DIR" ]; then
87+
cp -r $AK3_DIR AnyKernel3
88+
else
89+
if ! git clone https://github.com/basamaryan/AnyKernel3.git -b master AnyKernel3; then
90+
echo -e "\nAnyKernel3 repo not found locally and couldn't clone from GitHub! Aborting..."
91+
exit 1
92+
fi
93+
fi
94+
95+
sed -i "s/kernel\.string=.*/kernel.string=Staging build/" AnyKernel3/anykernel.sh
96+
sed -i "s/supported\.versions=.*/supported.versions=11-16/" AnyKernel3/anykernel.sh
97+
98+
cp $kernel AnyKernel3
99+
cp $dtbo AnyKernel3
100+
cp $dtb AnyKernel3
101+
cd AnyKernel3
102+
zip -r9 "../$ZIPNAME" * -x .git README.md
103+
cd ..
104+
rm -rf AnyKernel3
105+
if [ "$local" = true ]; then
106+
git restore arch/arm64/configs/sweet_defconfig
107+
else
108+
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
109+
head=$(git rev-parse --verify HEAD 2>/dev/null); then
110+
HASH="$(echo $head | cut -c1-8)"
111+
fi
112+
./telegram -f $ZIPNAME -C "Completed in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) ! Latest commit: $HASH WARNING: KSU ONLY BUILD!"
113+
fi
114+
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
115+
echo "Zip: $ZIPNAME"
116+
exit 0
117+
fi
118+
119+
echo -e "\n Done compiling KSU, now compiling with disabled KSU.."
120+
mkdir ./out/arch/arm64/boot/ksu/
121+
cp $kernel out/arch/arm64/boot/ksu/Image.gz
122+
ksuboot="out/arch/arm64/boot/ksu/Image.gz"
123+
rm -rf $kernel
124+
patch -p1 < disable_ksu.patch
125+
make O=out ARCH=arm64 sweet_defconfig
126+
make -j$(nproc --all) \
127+
O=out \
128+
ARCH=arm64 \
129+
LLVM=1 \
130+
LLVM_IAS=1 \
131+
CROSS_COMPILE=aarch64-linux-gnu- \
132+
CROSS_COMPILE_COMPAT=arm-linux-gnueabi
133+
134+
if [ ! -f "$kernel" ]; then
135+
echo -e "\nCompilation failed!"
136+
exit 1
137+
fi
138+
139+
echo -e "\nKernel compiled successfully! Zipping up...\n"
140+
mkdir ./out/arch/arm64/boot/nsu
141+
cp $kernel out/arch/arm64/boot/nsu/Image.gz
142+
nsuboot="out/arch/arm64/boot/nsu/Image.gz"
143+
if [ -d "$AK3_DIR" ]; then
144+
cp -r $AK3_DIR AnyKernel3
145+
else
146+
if ! git clone -q https://github.com/tbyool/AnyKernel3.git -b master AnyKernel3; then
147+
echo -e "\nAnyKernel3 repo not found locally and couldn't clone from GitHub! Aborting..."
148+
exit 1
149+
fi
150+
fi
151+
cp $ksuboot AnyKernel3/boot/ksu
152+
cp $nsuboot AnyKernel3/boot/nsu
153+
cp $dtbo AnyKernel3
154+
cp $dtb AnyKernel3
155+
cd AnyKernel3
156+
zip -r9 "../$ZIPNAME" * -x .git README.md
157+
cd ..
158+
rm -rf AnyKernel3
159+
if [ "$local" = true ]; then
160+
git restore arch/arm64/configs/sweet_defconfig
161+
else
162+
if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
163+
head=$(git rev-parse --verify HEAD 2>/dev/null); then
164+
HASH="$(echo $head | cut -c1-8)"
165+
fi
166+
./telegram -f $ZIPNAME -C "Completed in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) ! Latest commit: $HASH"
167+
fi
168+
echo -e "\nCompleted in $((SECONDS / 60)) minute(s) and $((SECONDS % 60)) second(s) !"
169+
echo "Zip: $ZIPNAME"
170+
exit 0
171+

local-build.patch

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
diff --git a/arch/arm64/configs/sweet_defconfig b/arch/arm64/configs/sweet_defconfig
2+
index 857e712c3082..7fe62510c3b7 100644
3+
--- a/arch/arm64/configs/sweet_defconfig
4+
+++ b/arch/arm64/configs/sweet_defconfig
5+
@@ -281,13 +280,11 @@ CONFIG_CC_STACKPROTECTOR=y
6+
# CONFIG_CC_STACKPROTECTOR_REGULAR is not set
7+
CONFIG_CC_STACKPROTECTOR_STRONG=y
8+
CONFIG_THIN_ARCHIVES=y
9+
-CONFIG_LTO=y
10+
+# CONFIG_LTO is not set
11+
CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
12+
CONFIG_ARCH_SUPPORTS_THINLTO=y
13+
-# CONFIG_THINLTO is not set
14+
-# CONFIG_LTO_NONE is not set
15+
-CONFIG_LTO_CLANG=y
16+
-# CONFIG_CFI_CLANG is not set
17+
+CONFIG_LTO_NONE=y
18+
+# CONFIG_LTO_CLANG is not set
19+
CONFIG_ARCH_SUPPORTS_SHADOW_CALL_STACK=y
20+
CONFIG_ROP_PROTECTION_NONE=y
21+
# CONFIG_SHADOW_CALL_STACK is not set

merge_tags.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import subprocess
2+
import sys
3+
4+
def merge_tag(repo_url, repo_name, subtree_path, tag):
5+
fetch_cmd = f"git fetch {repo_url} {tag}"
6+
merge_cmd = f"git merge -X subtree={subtree_path} FETCH_HEAD --log=99999999"
7+
8+
try:
9+
subprocess.run(fetch_cmd, shell=True, check=True)
10+
print(f"Successfully fetched {repo_name} tag: {tag}")
11+
subprocess.run(merge_cmd, shell=True, check=True)
12+
print(f"Successfully merged {repo_name} tag: {tag}")
13+
except subprocess.CalledProcessError as e:
14+
print(f"Error fetching or merging {repo_name} tag: {tag}")
15+
print(e.output.decode())
16+
sys.exit(1)
17+
18+
# Repositories to merge
19+
repos = [
20+
("https://git.codelinaro.org/clo/la/kernel/msm-4.14", "msm-4.14", ""),
21+
("https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/qcacld-3.0", "qcacld-3.0", "drivers/staging/qcacld-3.0"),
22+
("https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/fw-api", "fw-api", "drivers/staging/fw-api"),
23+
("https://git.codelinaro.org/clo/la/platform/vendor/qcom-opensource/wlan/qca-wifi-host-cmn", "qca-wifi-host-cmn", "drivers/staging/qca-wifi-host-cmn"),
24+
("https://git.codelinaro.org/clo/la/platform/vendor/opensource/audio-kernel", "techpacka", "techpack/audio")
25+
]
26+
27+
tag = input("Enter the tag to merge: ")
28+
29+
for repo_url, repo_name, subtree_path in repos:
30+
merge_tag(repo_url, repo_name, subtree_path, tag)

0 commit comments

Comments
 (0)