forked from Haydar011/cirrus-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
80 lines (71 loc) · 2.44 KB
/
build
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
#!/bin/bash
cd /tmp/rom # Depends on where source got synced
. /tmp/ci/function && check_build_type
# Normal build steps
. /tmp/ci/build.sh
case "$build_type" in
R|r)
export _JAVA_OPTIONS="-Xmx10g"
esac
export CCACHE_DIR=/tmp/ccache
export CCACHE_EXEC=$(which ccache)
export USE_CCACHE=1
ccache -M 15G
ccache -o compression=true
ccache -z
# check how much time sync took
sync_time
# compile plox
case "$build_type" in
V|v) # Lets Make Vendor / System
SECONDS=0
make vendorimage -j$(nproc --all)
vendor_time=$(($SECONDS / 60))
sleeps=$((113 - ($vendor_time + $sync_time)))m
make systemimage -j$(nproc --all) | tee build.log &
sleep $sleeps
kill %1
if [ -e "/tmp/rom/build.log" ] && [ $(tail -n 90 /tmp/rom/build.log | grep -o -e 'build stopped' -e 'FAILED: ' | head -n 1) ]; then
echo "" > /tmp/abort_loop.txt # will use it as guard for failed builds
fi
;;
S|s) # Lets Make System
sleeps=$((113 - $sync_time))m
make systemimage -j$(nproc --all) | tee build.log &
sleep $sleeps
kill %1
if [ -e "/tmp/rom/build.log" ] && [ $(tail -n 90 /tmp/rom/build.log | grep -o -e 'build stopped' -e 'FAILED: ' | head -n 1) ]; then
echo "" > /tmp/abort_loop.txt # will use it as guard for failed builds
fi
;;
R|r) # Lets Make Full Rom
compile_plox | tee build.log
if [ ! -e out/target/product/*/*2022*.zip ]; then # to bypass OOM kill
sed -i 's/-j$(nproc --all)/-j7/' /tmp/ci/build.sh
. /tmp/ci/build.sh # run again to update values before starting compilation
compile_plox # simply re-run the build with less threads
fi
if [ ! -e out/target/product/*/*2022*.zip ]; then
sed -i 's/-j7/-j6/' /tmp/ci/build.sh
. /tmp/ci/build.sh
compile_plox # just incase if -1 thread didnt help
fi
if [ -e "/tmp/rom/build.log" ] && [ $(tail -n 90 /tmp/rom/build.log | grep -o -e 'build stopped' -e 'FAILED: ' | head -n 1) ]; then
echo "" > /tmp/abort_loop.txt # will use it as guard for failed builds
fi
esac
if [ -e out/target/product/$device_codename/system.img ]; then
echo "R" > /tmp/build_type.txt
else
echo "S" > /tmp/build_type.txt
fi
cd out/target/product/$device_codename/
ls *2022*zip && upload *2022*zip
if [ ! -e /tmp/rom/out/target/product/*/*2022*.zip ]; then
# don't send this again if bg loop already done this when it was stuck in sleep
if [ ! -e /tmp/abort.txt ]; then
tg "Stop Compiling $build_type To Collect Cache
Status: $progress"
fi
fi
ccache -s # Let's print ccache statistics finally