-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-script
executable file
·147 lines (129 loc) · 3.81 KB
/
build-script
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# Import from paranoid
# Edit By Xilence2210
# get current path
reldir=`dirname $0`
cd $reldir
DIR=`pwd`
# 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
bldblu=${txtbld}$(tput setaf 4) # blue
bldcya=${txtbld}$(tput setaf 6) # cyan
txtrst=$(tput sgr0) # Reset
THREADS="16"
DEVICE="$1"
SYNC="$2"
EXTRAS="$3"
VLINE=67
ADDON=packages/apps/HALO
if [ "kylin$DEVICE" == "kylin" ]
then
clear
echo " "
echo "==================================================="
echo " "
echo " KyLin OS Build Script"
echo " -------------------"
echo " "
echo " 请在使用前设置输出路径"
echo " 使用'gedit kl'或者'vim kl'编辑脚本的"
echo " 第 $VLINE 行,去掉#号并设置路径即可!"
echo " "
echo " 用法: './kl [Device] {Variable}'"
echo " Device - 设备名"
echo " Variable - 参数"
echo " 参数如下:"
echo " fix :如果上次编译遇到错误,则使用此参数快速编译"
echo " clean :在开始编译前执行命令 'make installclean' "
echo " sync :在开始编译前执行同步命令 'repo sync' "
echo " "
echo " 例如 './kl maguro sync clean'"
echo " 则表示 '编译maguro,在开始前同步并清理'"
echo " "
echo " Usage: './kl [Device] {Variable}'"
echo " Device - your device name"
echo " Variable - functions"
echo " fix :start build without any cleanning for fix build"
echo " clean :run 'make installclean' before build"
echo " sync :run 'repo sync' before build"
echo " "
echo " e.g './kl maguro sync clean'"
echo " "
exit 0
fi
# if you set another OUT_DIR,set this before use.
# OUT_DIR=/kylin/out/target/product/$DEVICE
if [ "kl$OUT_DIR" == "kl" ]
then
echo -e "请设置编译输出路径在该脚本的$VLINE行!"
echo -e "please specify correct OUT_DIR in THIS SCRIPT at line $VLINE !"
exit 0
elif [ ! -d "$OUT_DIR" ]
then
mkdir -p $OUT_DIR
fi
# we don't allow scrollback buffer
echo -e '\0033\0143'
clear
echo -e "${cya}Building ${bldcya}KyLin OS Project ${txtrst}";
# setup environment
echo -e "${bldblu}Setting up environment ${txtrst}"
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
# set ccache due to your disk space,set it at your own risk
prebuilts/misc/linux-x86/ccache/ccache -M 15G
. build/envsetup.sh
# lunch device
echo -e ""
echo -e "${bldblu}Lunching device ${txtrst}"
lunch kylin_$DEVICE-userdebug
fix_count=0
# excute with vars
echo -e ""
for var in $* ; do
if [ "$var" == "sync" ]
then
echo -e "${bldblu}Fetching latest sources ${txtrst}"
if [ -d "$ADDON" ]
then
echo -e "fetching add-on repo"
echo -e "change this at script line 28"
cd $ADDON
git pull
cd $DIR
echo -e "=============================================="
fi
repo sync
echo -e ""
elif [ "$var" == "clean" ]
then
echo -e "${bldblu}Clearing previous build info ${txtrst}"
mka installclean
elif [ "$var" == "fix" ]
then
echo -e "skip for remove build.prop"
fix_count=1
fi
done
if [ "$fix_count" == "0" ]
then
echo -e "removing build.prop"
rm -f $OUT_DIR/system/build.prop
fi
echo -e ""
echo -e "${bldblu}Starting compilation ${txtrst}"
# get time of startup
res1=$(date +%s.%N)
# start compilation
mka bacon
echo -e ""
# finished? 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}"
# make a alarm
echo $'\a'