This repository has been archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.sh
executable file
·130 lines (108 loc) · 3.37 KB
/
build.sh
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# get current path
reldir=`dirname $0`
cd $reldir
DIR=`pwd`
# get OS (linux / Mac OS x)
OUT_TARGET_HOST=`uname -a | grep Darwin`
# Colorize and add text parameters
red=$(tput setaf 1) # red
grn=$(tput setaf 2) # green
cya=$(tput setaf 6) # cyan
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldgrn=${txtbld}$(tput setaf 2) # green
bldylw=${txtbld}$(tput setaf 3) # yellow
bldblu=${txtbld}$(tput setaf 4) # blue
bldppl=${txtbld}$(tput setaf 5) # purple
bldcya=${txtbld}$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
THREADS="16"
DEVICE="$1"
EXTRAS="$2"
# get current version
MAJOR=$(cat $DIR/vendor/pac/config/pac_common.mk | grep 'PAC_VERSION_MAJOR = *' | sed 's/PAC_VERSION_MAJOR = //g')
MINOR=$(cat $DIR/vendor/pac/config/pac_common.mk | grep 'PAC_VERSION_MINOR = *' | sed 's/PAC_VERSION_MINOR = //g')
MAINTENANCE=$(cat $DIR/vendor/pac/config/pac_common.mk | grep 'PAC_VERSION_MAINTENANCE = *' | sed 's/PAC_VERSION_MAINTENANCE = //g')
VERSION=$MAJOR.$MINOR.$MAINTENANCE
# if we have not extras, reduce parameter index by 1
if [ "$EXTRAS" == "true" ] || [ "$EXTRAS" == "false" ]
then
SYNC="$2"
UPLOAD="$3"
else
SYNC="$3"
UPLOAD="$4"
fi
# get time of startup
if [ -z "$OUT_TARGET_HOST" ]
then
res1=$(date +%s.%N)
else
res1=$(gdate +%s.%N)
fi
# we don't allow scrollback buffer
echo -e '\0033\0143'
clear
echo -e "${cya}Building ${bldgrn}P ${bldppl}A ${bldblu}C ${bldylw}v$VERSION ${txtrst}";
# PAC device dependencies
echo -e ""
echo -e "${bldblu}Looking for PAC product dependencies ${txtrst}${cya}"
./vendor/pac/tools/getdependencies.py $DEVICE
echo -e "${txtrst}"
# decide what command to execute
case "$EXTRAS" in
threads)
echo -e "${bldblu}Please write desired threads followed by [ENTER] ${txtrst}"
read threads
THREADS=$threads;;
clean)
echo -e ""
echo -e "${bldblu}Cleaning intermediates and output files ${txtrst}"
make clean > /dev/null;;
esac
# download prebuilt files
echo -e ""
echo -e "${bldblu}Downloading prebuilts ${txtrst}"
cd vendor/cm
./get-prebuilts
cd ./../..
echo -e ""
# sync with latest sources
echo -e ""
if [ "$SYNC" == "true" ]
then
echo -e "${bldblu}Fetching latest sources ${txtrst}"
repo sync -j"$THREADS"
echo -e ""
fi
rm -f out/target/product/*/obj/KERNEL_OBJ/.version
# setup environment
echo -e "${bldblu}Setting up environment ${txtrst}"
. build/envsetup.sh
# lunch device
echo -e ""
echo -e "${bldblu}Lunching device ${txtrst}"
lunch "pac_$DEVICE-userdebug";
echo -e ""
echo -e "${bldblu}Starting compilation ${txtrst}"
# start compilation
mka bacon
echo -e ""
# squisher
./vendor/pac/tools/squisher
# cleanup unused built
rm -f out/target/product/*/cm-*.*
rm -f out/target/product/*/pac_*-ota-eng.*.zip
# finished? get elapsed time
if [ -z "$OUT_TARGET_HOST" ]
then
res2=$(date +%s.%N)
else
res2=$(gdate +%s.%N)
fi
echo "${bldgrn}Total time elapsed: ${txtrst}${grn}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
echo "************************************************************************"
echo "${bldylw}Please Remember that this source is currently for Private builds ONLY!${txtrst}"
echo "${bldylw}Public builds will be welcomed after nightlies begin. Thankyou.${txtrst}"
echo "************************************************************************"