-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_rom.sh
executable file
·85 lines (70 loc) · 2.43 KB
/
build_rom.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
#!/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"
SYNC="$2"
THREADS="$3"
CLEAN="$4"
LOG="$5"
RELEASE="$6"
# 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 -j"$THREADS"
fi
# Setup environment
echo -e "${bldblu}Setting up build environment ${txtrst}"
. build/envsetup.sh
# Setup ccache
export USE_CCACHE=1
export CCACHE_DIR="/home/tevac/.slimccache"
/usr/bin/ccache -M 50G
# Start compilation with or without log
if [ "$RELEASE" == "release" ]
then
echo -e "${bldblu}Creating a LAST_BUILD_PROP file: when you'll build again new a public (release) version of the rom, the automated Slimcenter changelog creation will track changes from the version you are building now${txtrst}"
export IS_RELEASED_BUILD=true
else
echo -e "${bldblu}Not creating a LAST_BUILD_PROP file: when you'll build again new a public (release) version of the rom, the automated Slimcenter changelog creation will track changes from the last release version you built, not this one${txtrst}"
export IS_RELEASED_BUILD=
fi
# For building recovery
export BUILDING_RECOVERY=false
# Prebuilt chromium
export USE_PREBUILT_CHROMIUM=1
# Fix common out folder not being a common
export ANDROID_FIXUP_COMMON_OUT=true
# Lunch device
echo -e "${bldblu}Lunching device... ${txtrst}"
lunch "slim_$DEVICE-userdebug"
# Clean out folder
if [ "$CLEAN" == "clean" ]
then
echo -e "${bldblu}Cleaning up the OUT folder with make clobber ${txtrst}"
make clobber;
else
echo -e "${bldblu}No make clobber so just make installclean ${txtrst}"
make installclean;
fi
# Remove previous build info
# echo -e "${bldblu}Removing previous build.prop ${txtrst}"
# rm $OUT/system/build.prop;
# Start compilation with or without log
if [ "$LOG" == "log" ]
then
echo -e "${bldblu}Compiling for $DEVICE and saving a build log file ${txtrst}"
make bacon -j"$THREADS" 2>&1 | tee build.log;
else
echo -e "${bldblu}Compiling for $DEVICE without saving a build log file ${txtrst}"
make bacon -j"$THREADS";
fi
# 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}"