Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
build: IMMENSITY - X Release 3.0.0
Browse files Browse the repository at this point in the history
Change-Id: I4f4b68fdff885f334a711903130c786e792fae4f
Signed-off-by: UtsavBalar1231 <utsavbalar1231@gmail.com>
  • Loading branch information
UtsavBalar1231 committed May 2, 2022
1 parent 963e5ab commit 05fd9d0
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ steps:
from_secret: bot_api_key
PD_API_KEY:
from_secret: pd_api_key
TYPE: REL-2.0.1
TYPE: REL-3.0.0
DEVICE: alioth
KBUILD_BUILD_USER: UtsavTheCunt
KBUILD_BUILD_HOST: CuntsSpace
Expand All @@ -38,7 +38,7 @@ steps:
from_secret: bot_api_key
PD_API_KEY:
from_secret: pd_api_key
TYPE: REL-2.0.1
TYPE: REL-3.0.0
DEVICE: apollo
KBUILD_BUILD_USER: UtsavTheCunt
KBUILD_BUILD_HOST: CuntsSpace
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://cloud.drone.io/api/badges/UtsavBalar1231/kernel_xiaomi_sm8250/status.svg?ref=refs/heads/android12-stable)](https://cloud.drone.io/UtsavBalar1231/kernel_xiaomi_sm8250)
![Commits Count](https://img.shields.io/github/commits-since/UtsavBalar1231/kernel_xiaomi_sm8250/1.0.0/android12-stable)
![Commits Count](https://img.shields.io/github/commits-since/UtsavBalar1231/kernel_xiaomi_sm8250/2.0.0/android12-stable)
[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FUtsavBalar1231%2Fkernel_xiaomi_sm8250&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com)
![Downloads](https://img.shields.io/github/downloads/UtsavBalar1231/kernel_xiaomi_sm8250/1.0.0/total)
![Downloads](https://img.shields.io/github/downloads/UtsavBalar1231/kernel_xiaomi_sm8250/2.0.0/total)

![logo](https://github.com/UtsavBalar1231/xda-stuff/raw/master/banner.png "logo was here")

Expand Down
306 changes: 306 additions & 0 deletions scripts/build_kernel
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
2 changes: 1 addition & 1 deletion scripts/update_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export KERNEL_CFG
export OUT_DIR

# Set compiler PATH
PATH=$HOME/gas64:$HOME/aosp-clang/bin:$PATH
PATH=$HOME/gas:$HOME/clang/bin:$PATH

BUILD="make O=$OUT_DIR \
ARCH=arm64 \
Expand Down

0 comments on commit 05fd9d0

Please sign in to comment.