This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I4f4b68fdff885f334a711903130c786e792fae4f Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
- Loading branch information
1 parent
963e5ab
commit 05fd9d0
Showing
4 changed files
with
311 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,306 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2199 | ||
# shellcheck source=/dev/null | ||
# | ||
# Copyright (C) 2020-22 UtsavBalar1231 <utsavbalar1231@gmail.com> | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
KBUILD_COMPILER_STRING=$(${HOME}/clang/bin/clang --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//') | ||
KBUILD_LINKER_STRING=$(${HOME}/clang/bin/ld.lld --version | head -n 1 | perl -pe 's/\(http.*?\)//gs' | sed -e 's/ */ /g' -e 's/[[:space:]]*$//' | sed 's/(compatible with [^)]*)//') | ||
export KBUILD_COMPILER_STRING | ||
export KBUILD_LINKER_STRING | ||
|
||
# | ||
# Enviromental Variables | ||
# | ||
|
||
DATE=$(date +"%Y-%m-%d-%H%M") | ||
DEVICE="alioth" | ||
|
||
# Set our directory | ||
OUT_DIR=out/ | ||
|
||
# Select LTO or non LTO builds | ||
if [[ "$@" =~ "lto"* ]]; then | ||
VERSION="IMMENSITY-X-${DEVICE^^}-LTO-${DATE}" | ||
else | ||
VERSION="IMMENSITY-X-${DEVICE^^}-${DATE}" | ||
fi | ||
|
||
# Export Zip name | ||
export ZIPNAME="${VERSION}.zip" | ||
|
||
# How much kebabs we need? Kanged from @raphielscape :) | ||
if [[ -z "${KEBABS}" ]]; then | ||
COUNT="$(grep -c '^processor' /proc/cpuinfo)" | ||
export KEBABS="$((COUNT + 2))" | ||
fi | ||
|
||
echo "Jobs: ${KEBABS}" | ||
|
||
ARGS="ARCH=arm64 \ | ||
O=${OUT_DIR} \ | ||
LLVM=1 \ | ||
CLANG_TRIPLE=aarch64-linux-gnu- \ | ||
CROSS_COMPILE=aarch64-linux-gnu- \ | ||
CROSS_COMPILE_COMPAT=arm-linux-gnueabi- \ | ||
-j${KEBABS}" | ||
|
||
dts_source=arch/arm64/boot/dts/vendor/qcom | ||
# Correct panel dimensions on MIUI builds | ||
function miui_fix_dimens() { | ||
sed -i 's/<70>/<695>/g' $dts_source/dsi-panel-j3s-37-02-0a-dsc-video.dtsi | ||
sed -i 's/<70>/<695>/g' $dts_source/dsi-panel-j11-38-08-0a-fhd-cmd.dtsi | ||
sed -i 's/<70>/<695>/g' $dts_source/dsi-panel-k11a-38-08-0a-dsc-cmd.dtsi | ||
sed -i 's/<71>/<710>/g' $dts_source/dsi-panel-j1s* | ||
sed -i 's/<71>/<710>/g' $dts_source/dsi-panel-j2* | ||
sed -i 's/<155>/<1544>/g' $dts_source/dsi-panel-j3s-37-02-0a-dsc-video.dtsi | ||
sed -i 's/<155>/<1545>/g' $dts_source/dsi-panel-j11-38-08-0a-fhd-cmd.dtsi | ||
sed -i 's/<155>/<1546>/g' $dts_source/dsi-panel-k11a-38-08-0a-dsc-cmd.dtsi | ||
sed -i 's/<154>/<1537>/g' $dts_source/dsi-panel-j1s* | ||
sed -i 's/<154>/<1537>/g' $dts_source/dsi-panel-j2* | ||
} | ||
|
||
# Enable back mi smartfps while disabling qsync min refresh-rate | ||
function miui_fix_fps() { | ||
sed -i 's/qcom,mdss-dsi-qsync-min-refresh-rate/\/\/qcom,mdss-dsi-qsync-min-refresh-rate/g' $dts_source/dsi-panel* | ||
sed -i 's/\/\/ mi,mdss-dsi-smart-fps-max_framerate/mi,mdss-dsi-smart-fps-max_framerate/g' $dts_source/dsi-panel* | ||
sed -i 's/\/\/ mi,mdss-dsi-pan-enable-smart-fps/mi,mdss-dsi-pan-enable-smart-fps/g' $dts_source/dsi-panel* | ||
sed -i 's/\/\/ qcom,mdss-dsi-pan-enable-smart-fps/qcom,mdss-dsi-pan-enable-smart-fps/g' $dts_source/dsi-panel* | ||
} | ||
|
||
# Enable back refresh rates supported on MIUI | ||
function miui_fix_dfps() { | ||
sed -i 's/120 90 60/120 90 60 50 30/g' $dts_source/dsi-panel-g7a-37-02-0a-dsc-video.dtsi | ||
sed -i 's/120 90 60/120 90 60 50 30/g' $dts_source/dsi-panel-g7a-37-02-0b-dsc-video.dtsi | ||
sed -i 's/120 90 60/120 90 60 50 30/g' $dts_source/dsi-panel-g7a-36-02-0c-dsc-video.dtsi | ||
sed -i 's/144 120 90 60/144 120 90 60 50 48 30/g' $dts_source/dsi-panel-j3s-37-02-0a-dsc-video.dtsi | ||
} | ||
|
||
# Enable back brightness control from dtsi | ||
function miui_fix_fod() { | ||
sed -i 's/\/\/39 01 00 00 01 00 03 51 03 FF/39 01 00 00 01 00 03 51 03 FF/g' $dts_source/dsi-panel-j11-38-08-0a-fhd-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 03 FF/39 01 00 00 00 00 03 51 03 FF/g' $dts_source/dsi-panel-j11-38-08-0a-fhd-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 05 51 0F 8F 00 00/39 00 00 00 00 00 05 51 0F 8F 00 00/g' $dts_source/dsi-panel-j1s-42-02-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 05 51 07 FF 00 00/39 01 00 00 00 00 05 51 07 FF 00 00/g' $dts_source/dsi-panel-j1s-42-02-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 05 51 0F 8F 00 00/39 00 00 00 00 00 05 51 0F 8F 00 00/g' $dts_source/dsi-panel-j1s-42-02-0a-mp-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 05 51 07 FF 00 00/39 01 00 00 00 00 05 51 07 FF 00 00/g' $dts_source/dsi-panel-j1s-42-02-0a-mp-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 0F FF/39 01 00 00 00 00 03 51 0F FF/g' $dts_source/dsi-panel-j1u-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 07 FF/39 01 00 00 00 00 03 51 07 FF/g' $dts_source/dsi-panel-j1u-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 00 00/39 01 00 00 00 00 03 51 00 00/g' $dts_source/dsi-panel-j2-38-0c-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 00 00/39 01 00 00 00 00 03 51 00 00/g' $dts_source/dsi-panel-j2-38-0c-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 0F FF/39 01 00 00 00 00 03 51 0F FF/g' $dts_source/dsi-panel-j2-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 07 FF/39 01 00 00 00 00 03 51 07 FF/g' $dts_source/dsi-panel-j2-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 05 51 0F 8F 00 00/39 00 00 00 00 00 05 51 0F 8F 00 00/g' $dts_source/dsi-panel-j2-mp-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 05 51 07 FF 00 00/39 01 00 00 00 00 05 51 07 FF 00 00/g' $dts_source/dsi-panel-j2-mp-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 0F FF/39 01 00 00 00 00 03 51 0F FF/g' $dts_source/dsi-panel-j2-p1-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 07 FF/39 01 00 00 00 00 03 51 07 FF/g' $dts_source/dsi-panel-j2-p1-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 03 51 0D FF/39 00 00 00 00 00 03 51 0D FF/g' $dts_source/dsi-panel-j2-p2-1-38-0c-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 11 00 03 51 03 FF/39 01 00 00 11 00 03 51 03 FF/g' $dts_source/dsi-panel-j2-p2-1-38-0c-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 05 51 0F 8F 00 00/39 00 00 00 00 00 05 51 0F 8F 00 00/g' $dts_source/dsi-panel-j2-p2-1-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 05 51 07 FF 00 00/39 01 00 00 00 00 05 51 07 FF 00 00/g' $dts_source/dsi-panel-j2-p2-1-42-02-0b-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 05 51 0F 8F 00 00/39 00 00 00 00 00 05 51 0F 8F 00 00/g' $dts_source/dsi-panel-j2s-mp-42-02-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 05 51 07 FF 00 00/39 01 00 00 00 00 05 51 07 FF 00 00/g' $dts_source/dsi-panel-j2s-mp-42-02-0a-dsc-cmd.dtsi | ||
sed -i 's/\/\/39 00 00 00 00 00 03 51 03 FF/39 00 00 00 00 00 03 51 03 FF/g' $dts_source/dsi-panel-j9-38-0a-0a-fhd-video.dtsi | ||
sed -i 's/\/\/39 01 00 00 00 00 03 51 03 FF/39 01 00 00 00 00 03 51 03 FF/g' $dts_source/dsi-panel-j9-38-0a-0a-fhd-video.dtsi | ||
} | ||
|
||
function tg_post_error() { | ||
curl -s -X POST https://api.telegram.org/bot"${BOT_API_KEY}"/sendMessage -d text="Error in $1 build!!" -d chat_id="${CI_CHANNEL_ID}" | ||
curl -F chat_id="${CI_CHANNEL_ID}" -F document=@"$(pwd)/build.log" https://api.telegram.org/bot"${BOT_API_KEY}"/sendDocument | ||
exit 1 | ||
} | ||
|
||
function enable_lto() { | ||
scripts/config --file ${OUT_DIR}/.config \ | ||
-e LTO_CLANG | ||
|
||
# Make olddefconfig | ||
cd ${OUT_DIR} || exit | ||
make -j${KEBABS} ${ARGS} olddefconfig | ||
cd ../ || exit | ||
} | ||
|
||
function disable_lto() { | ||
scripts/config --file ${OUT_DIR}/.config \ | ||
-d LTO_CLANG | ||
|
||
# Make olddefconfig | ||
cd ${OUT_DIR} || exit | ||
make -j${KEBABS} ${ARGS} olddefconfig | ||
cd ../ || exit | ||
} | ||
|
||
START=$(date +"%s") | ||
|
||
# Set compiler Path | ||
PATH=${HOME}/gas:${HOME}/clang/bin/:$PATH | ||
export LD_LIBRARY_PATH=${HOME}/clang/lib64:$LD_LIBRARY_PATH | ||
|
||
# Make defconfig | ||
make -j${KEBABS} ${ARGS} "${DEVICE}"_defconfig | ||
|
||
# Enable LTO | ||
if [[ "$@" =~ "lto"* ]]; then | ||
enable_lto | ||
fi | ||
|
||
# # AOSP Build | ||
# echo "------ Stating AOSP Build ------" | ||
# os=aosp | ||
# make -j${KEBABS} ${ARGS} 2>&1 | tee build.log | ||
# find ${OUT_DIR}/$dts_source -name '*.dtb' -exec cat {} + > ${OUT_DIR}/arch/arm64/boot/dtb | ||
|
||
# mkdir -p anykernel/kernels/$os | ||
# # Import Anykernel3 folder | ||
# if [[ -f ${OUT_DIR}/arch/arm64/boot/Image.gz ]]; then | ||
# cp ${OUT_DIR}/arch/arm64/boot/Image.gz anykernel/kernels/$os | ||
# else | ||
# if [[ -f ${OUT_DIR}/arch/arm64/boot/Image ]]; then | ||
# cp ${OUT_DIR}/arch/arm64/boot/Image anykernel/kernels/$os | ||
# else | ||
# tg_post_error aosp | ||
# fi | ||
# fi | ||
# cp ${OUT_DIR}/arch/arm64/boot/dtb anykernel/kernels/$os | ||
# cp ${OUT_DIR}/arch/arm64/boot/dtbo.img anykernel/kernels/$os | ||
# echo "------ Finishing AOSP Build ------" | ||
|
||
# MIUI Build | ||
echo "------ Starting MIUI Build ------" | ||
os=miui | ||
|
||
# Make defconfig | ||
make -j${KEBABS} ${ARGS} "${DEVICE}"_defconfig | ||
|
||
scripts/config --file ${OUT_DIR}/.config \ | ||
-d LOCALVERSION_AUTO \ | ||
-d TOUCHSCREEN_COMMON \ | ||
--set-str STATIC_USERMODEHELPER_PATH /system/bin/micd \ | ||
-e BOOT_INFO \ | ||
-e BINDER_OPT \ | ||
-e DEBUG_KERNEL \ | ||
-e IPC_LOGGING \ | ||
-e KPERFEVENTS \ | ||
-e LAST_TOUCH_EVENTS \ | ||
-e MIGT \ | ||
-e MIHW \ | ||
-e MILLET \ | ||
-e MIUI_DRM_WAKE_OPT \ | ||
-e MIUI_ZRAM_MEMORY_TRACKING \ | ||
-e MI_RECLAIM \ | ||
-e PERF_HUMANTASK \ | ||
-e TASK_DELAY_ACCT | ||
|
||
# FIXME: disable LTO on MIUI | ||
if [[ "$@" =~ "lto"* ]]; then | ||
disable_lto | ||
fi | ||
|
||
# Make olddefconfig | ||
cd ${OUT_DIR} || exit | ||
make -j${KEBABS} ${ARGS} CC="ccache clang" HOSTCC="ccache gcc" HOSTCXX="cache g++" olddefconfig | ||
cd ../ || exit | ||
|
||
miui_fix_dimens | ||
miui_fix_fps | ||
miui_fix_dfps | ||
miui_fix_fod | ||
|
||
make -j${KEBABS} ${ARGS} CC="ccache clang" HOSTCC="ccache gcc" HOSTCXX="ccache g++" 2>&1 | tee build.log | ||
|
||
find ${OUT_DIR}/$dts_source -name '*.dtb' -exec cat {} + >${OUT_DIR}/arch/arm64/boot/dtb | ||
|
||
mkdir -p anykernel/kernels/$os | ||
# Import Anykernel3 folder | ||
if [[ -f ${OUT_DIR}/arch/arm64/boot/Image.gz ]]; then | ||
cp ${OUT_DIR}/arch/arm64/boot/Image.gz anykernel/kernels/$os | ||
else | ||
if [[ -f ${OUT_DIR}/arch/arm64/boot/Image ]]; then | ||
cp ${OUT_DIR}/arch/arm64/boot/Image anykernel/kernels/$os | ||
else | ||
tg_post_error miui | ||
fi | ||
fi | ||
cp ${OUT_DIR}/arch/arm64/boot/dtb anykernel/kernels/$os | ||
cp ${OUT_DIR}/arch/arm64/boot/dtbo.img anykernel/kernels/$os | ||
|
||
git checkout arch/arm64/boot/dts/vendor &>/dev/null | ||
echo "------ Finishing MIUI Build ------" | ||
|
||
# # AOSPA Build | ||
# echo "------ Starting AOSPA Build ------" | ||
# os=aospa | ||
|
||
# # Make defconfig | ||
# make -j${KEBABS} ${ARGS} "${DEVICE}"_defconfig | ||
|
||
# scripts/config --file ${OUT_DIR}/.config \ | ||
# -d SDCARD_FS \ | ||
# -e UNICODE | ||
|
||
# # Enable LTO | ||
# if [[ "$@" =~ "lto"* ]]; then | ||
# enable_lto | ||
# fi | ||
|
||
# # Make olddefconfig | ||
# cd ${OUT_DIR} || exit | ||
# make -j${KEBABS} ${ARGS} olddefconfig | ||
# cd ../ || exit | ||
|
||
# make -j${KEBABS} ${ARGS} 2>&1 | tee build.log | ||
|
||
# find ${OUT_DIR}/$dts_source -name '*.dtb' -exec cat {} + > ${OUT_DIR}/arch/arm64/boot/dtb | ||
|
||
# mkdir -p anykernel/kernels/$os | ||
# # Import Anykernel3 folder | ||
# if [[ -f ${OUT_DIR}/arch/arm64/boot/Image.gz ]]; then | ||
# cp ${OUT_DIR}/arch/arm64/boot/Image.gz anykernel/kernels/$os | ||
# else | ||
# if [[ -f ${OUT_DIR}/arch/arm64/boot/Image ]]; then | ||
# cp ${OUT_DIR}/arch/arm64/boot/Image anykernel/kernels/$os | ||
# else | ||
# tg_post_error aospa | ||
# fi | ||
# fi | ||
# cp ${OUT_DIR}/arch/arm64/boot/dtb anykernel/kernels/$os | ||
# cp ${OUT_DIR}/arch/arm64/boot/dtbo.img anykernel/kernels/$os | ||
# echo "------ Finishing AOSPA Build ------" | ||
|
||
END=$(date +"%s") | ||
DIFF=$((END - START)) | ||
|
||
cd anykernel || exit | ||
zip -r9 "${ZIPNAME}" ./* -x .git .gitignore ./*.zip | ||
|
||
#RESPONSE=$(curl -# -F "name=${ZIPNAME}" -F "file=@${ZIPNAME}" -u :"${PD_API_KEY}" https://pixeldrain.com/api/file) | ||
#FILEID=$(echo $RESPONSE | grep -Po '(?<="id":")[^"]*') | ||
|
||
CHECKER=$(find ./ -maxdepth 1 -type f -name ${ZIPNAME} -printf "%s\n") | ||
if (($((CHECKER / 1048576)) > 5)); then | ||
curl -s -X POST https://api.telegram.org/bot"${BOT_API_KEY}"/sendMessage -d text="✅ Kernel compiled successfully in $((DIFF / 60)) minute(s) and $((DIFF % 60)) seconds for ${DEVICE}" -d chat_id="${CI_CHANNEL_ID}" -d parse_mode=HTML | ||
# curl -s -X POST https://api.telegram.org/bot"${BOT_API_KEY}"/sendMessage -d text="Kernel build link: https://pixeldrain.com/u/$FILEID" -d chat_id="${CI_CHANNEL_ID}" -d parse_mode=HTML | ||
curl -F chat_id="${CI_CHANNEL_ID}" -F document=@"$(pwd)/${ZIPNAME}" https://api.telegram.org/bot"${BOT_API_KEY}"/sendDocument | ||
else | ||
tg_post_error | ||
fi | ||
cd "$(pwd)" || exit | ||
|
||
# Cleanup | ||
rm -fr anykernel/ | ||
rm -fr ${OUT_DIR}/arch/arm64/boot/dtb | ||
rm -fr ${OUT_DIR}/arch/arm64/boot/dtbo.img | ||
rm -fr ${OUT_DIR}/arch/arm64/boot/Image.gz | ||
rm -fr ${OUT_DIR}/arch/arm64/boot/Image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters