-
Notifications
You must be signed in to change notification settings - Fork 49
/
build_apk.sh
executable file
·63 lines (52 loc) · 1.45 KB
/
build_apk.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
#!/bin/bash
# Colorize and add text parameters
grn=$(tput setaf 2) # green
txtbld=$(tput bold) # Bold
bldgrn=${txtbld}$(tput setaf 2) # green
bldblu=${txtbld}$(tput setaf 4) # blue
txtrst=$(tput sgr0) # Reset
DEVICE="$1"
USERDEBUG="$2"
SYNC="$3"
CLEAN="$4"
APK="$5"
# Time of build startup
res1=$(date +%s.%N)
# Sync with latest sources
if [ "$SYNC" == "sync" ]
then
echo -e "${bldblu}Syncing latest sources ${txtrst}"
repo sync
fi
# Setup environment
echo -e "${bldblu}Setting up build environment ${txtrst}"
. build/envsetup.sh
# Setup ccache
export USE_CCACHE=1
export CCACHE_DIR="/home/ezio/ANDROID/ccache"
/usr/bin/ccache -M 25G
# Set the device
echo -e "Setting the device... ${txtrst}"
if [ "$USERDEBUG" == "debug" ]
then
breakfast "$DEVICE-userdebug"
else
breakfast "$DEVICE-user"
fi
# Clean out folder
if [ "$CLEAN" == "clean" ]
then
echo -e "${bldblu}Cleaning up the OUT folder with make clobber ${txtrst}"
make clean;
else
echo -e "${bldblu}No make clobber so just make installclean ${txtrst}"
make installclean;
fi
# Start compilation and save a log
echo -e "${bldblu}Compiling $APK apk for $DEVICE and saving a build-apk log file ${txtrst}"
make $APK 2>&1 | tee build-apk.log;
# Get elapsed time
res2=$(date +%s.%N)
echo "${bldgrn}Total time elapsed: ${txtrst}${grn}$(echo "($res2 - $res1) / 60"|bc ) minutes ($(echo "$res2 - $res1"|bc ) seconds) ${txtrst}"
#kill java if it's hanging on
pkill java