This repository was archived by the owner on Jun 28, 2021. It is now read-only.
forked from adiatul16/aosp-building
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·96 lines (88 loc) · 3.28 KB
/
build
File metadata and controls
executable file
·96 lines (88 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
source ${CIRRUS_WORKING_DIR}/rb.conf
cd ${ROM_FOLDER}
PID=$$
if [ "${ENABLE_BUILD_CCACHE_ONLY}" = true ]; then
{
sleep 100m
kill $PID
} &
echo "ENABLED CCACHE ONLY BUILD MODE!, ROM BUILD SCRIPT WONT EXECUTE!, DISABLE IT IN CONFIG TO BUILD ROMs!"
# Build ccache
echo "Starting ccache build..."
source build/envsetup.sh
lunch "${ROM}"_"${DEVICE}"-"${TARGET}"
${MAKE_COMMAND}
exit 0
else
:
fi
# Build rom
source build/envsetup.sh
lunch "${ROM}"_"${DEVICE}"-"${TARGET}"
if [ "${SEND_BUILD_MESSAGES_TO_TG}" = true ]; then
BUILD_START_DATE=$(date +"%Y%m%d")
BUILD_START=$(date +"%s")
# Report to tg group/channel
read -r -d '' MESSAGE <<-_EOL_
<strong>Build Started!</strong>
<strong>@</strong> $(date "+%I:%M%p") ($(date +"%Z%:z"))
<strong>CPUs :</strong> $(nproc --all) <strong>|</strong> <strong>RAM :</strong> $(awk '/MemTotal/ { printf "%.1f \n", $2/1024/1024 }' /proc/meminfo)GB
<strong>Building :</strong> ${ROM_NAME}
<strong>Build Type :</strong> ${BUILD_TYPE}
<strong>Device :</strong> ${DEVICE}
<strong>Target :</strong> ${TARGET}
_EOL_
curl -s -X POST -d chat_id="${CHAT_ID}" -d parse_mode=html -d text="${MESSAGE}" -d disable_web_page_preview="true" https://api.telegram.org/bot"${BOT_TOKEN}"/sendMessage
fi
# Precompile Metalava if enabled in config
if [ "${PRECOMPILE_METALAVA}" = true ]; then
echo "PreCompiling Metalava!"
make api-stubs-docs ${BUILD_JOBS}
make hiddenapi-lists-docs ${BUILD_JOBS}
make system-api-stubs-docs ${BUILD_JOBS}
# make test-api-stubs-docs ${BUILD_JOBS}
fi
# Start the build
if [ "${SEND_BUILD_MESSAGES_TO_TG}" = true ]; then
${MAKE_COMMAND} 2>&1 | tee "${ROM}"-build.log
else
${MAKE_COMMAND}
fi
# Build failed!
if [ ! -f "${OUT}"/*"${TYPE}"*.zip ]; then
echo "Build failed!"
# Send msg to telegram
if [ "${SEND_BUILD_MESSAGES_TO_TG}" = true ]; then
read -r -d '' MESSAGE <<-_EOL_
<strong>BUILD FAILED!</strong>
_EOL_
curl -s -X POST -d chat_id="${CHAT_ID}" -d parse_mode=html -d text="${MESSAGE}" https://api.telegram.org/bot"${BOT_TOKEN}"/sendMessage
curl -F chat_id="${CHAT_ID}" -F document=@"${ROM_FOLDER}"/"${ROM}"-build.log -F caption="" https://api.telegram.org/bot"${BOT_TOKEN}"/sendDocument
fi
exit 1
fi
# Build Sucessfull!
echo "Build sucessfull!"
if [ "${SEND_BUILD_MESSAGES_TO_TG}" = true ]; then
BUILD_END=$(date +"%s")
DIFF=$((BUILD_END - BUILD_START))
# Send msg to telegram
read -r -d '' MESSAGE <<-_EOL_
<strong>BUILD SUCCESSFULL!</strong>
<strong>Time :</strong> $((DIFF / 60)) minutes and $((DIFF % 60)) seconds
<strong>Date :</strong> $(date +"%Y-%m-%d")
_EOL_
curl -s -X POST -d chat_id="${CHAT_ID}" -d parse_mode=html -d text="${MESSAGE}" -d disable_web_page_preview="true" https://api.telegram.org/bot"${BOT_TOKEN}"/sendMessage
curl -F chat_id="${CHAT_ID}" -F document=@"${ROM_FOLDER}"/"${ROM}"-build.log -F caption="" https://api.telegram.org/bot"${BOT_TOKEN}"/sendDocument
fi
# Copy build artifacts to ci dir for uploading on ci
cp ${OUT}/*.zip ${CIRRUS_WORKING_DIR}/build_artifacts/
if [ "${GEN_OTA_ARTIFACTS}" = true ]; then
echo "Generating json file for ota!"
cp ${CIRRUS_WORKING_DIR}/createjson ${ROM_FOLDER}/
cd ${ROM_FOLDER}
bash createjson
cp ${ROM_FOLDER}/tissot.json ${CIRRUS_WORKING_DIR}/build_artifacts/
cp ${OUT}/changelog_tissot.txt ${CIRRUS_WORKING_DIR}/build_artifacts/
fi