-
Notifications
You must be signed in to change notification settings - Fork 0
/
rombuild
executable file
·258 lines (244 loc) · 7.06 KB
/
rombuild
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#
# Copyright (C) 2012 Erez A. Korn
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
MY_BUILD_VARIANT=userdebug
if [ "$CUSTOM_BUILD_DATE" = "" ]; then
CUSTOM_BUILD_DATE="`date -u +%s`"
fi
echo "Building for `date -u --date=@$CUSTOM_BUILD_DATE`"
for i in $@
do
case $i in
maguro)
MY_MAGURO=yes
;;
s)
MY_I9000=yes
;;
i9000)
MY_I9000=yes
;;
i9100)
MY_I9100=yes
;;
s2)
MY_I9100=yes
;;
p1)
MY_P1=yes
;;
i9300)
MY_I9300=yes
;;
s3)
MY_I9300=yes
;;
d2att)
MY_D2ATT=yes
;;
a200)
MY_A200=yes
;;
emulator)
MY_EMULATOR=yes
;;
--sync)
MY_SYNC_REPO=yes
;;
--interactive)
MY_INTERACTIVE=yes
;;
--all)
MY_MAGURO=yes
MY_I9000=yes
MY_I9100=yes
MY_I9300=yes
MY_D2ATT=yes
MY_P1=yes
MY_ALL=yes
;;
--slow)
MY_BUILD_SPEED=slow
;;
--slowest)
MY_BUILD_SPEED=slowest
;;
--fast)
MY_BUILD_SPEED=fast
;;
--faster)
MY_BUILD_SPEED=faster
;;
--fastest)
MY_BUILD_SPEED=fastest
;;
--eng)
MY_BUILD_VARIANT=eng
;;
*)
echo "Unknown option: $i"
exit 1
;;
esac
done
if [ "$MY_INTERACTIVE" == "yes" ] && [ "$MY_ALL" == "yes" ]; then
echo "Can't use --all in conjunction with --interactive"
exit 1
fi
echo "********************************"
echo "Building ROM with configuration:"
if [ "$MY_SYNC_REPO" = "yes" ]; then
echo "- Synchronizing repo"
else
echo "- no repo sync"
fi
if [ "$MY_P1" = "yes" ]; then
echo "- Samsung Galaxy Tab (OG)"
fi
if [ "$MY_I9000" = "yes" ]; then
echo "- Samsung Galaxy S"
fi
if [ "$MY_I9100" = "yes" ]; then
echo "- Samsung Galaxy S II"
fi
if [ "$MY_I9300" = "yes" ]; then
echo "- Samsung Galaxy S III"
fi
if [ "$MY_D2ATT" = "yes" ]; then
echo "- Samsung Galaxy S III - AT&T"
fi
if [ "$MY_MAGURO" = "yes" ]; then
echo "- Google Galaxy Nexus"
fi
if [ "$MY_A200" = "yes" ]; then
echo "- Acer Iconia Tab A200"
fi
if [ "$MY_EMULATOR" = "yes" ]; then
echo "- Emulator Image"
fi
if [ "$MY_BUILD_VARIANT" = "eng" ]; then
echo "- building ENG version"
fi
if [ "$MY_BUILD_SPEED" = "slowest" ]; then
echo "- 1 build thread"
elif [ "$MY_BUILD_SPEED" = "slow" ]; then
echo "- 2 build threads"
elif [ "$MY_BUILD_SPEED" = "fast" ]; then
echo "- 11 build threads"
elif [ "$MY_BUILD_SPEED" = "faster" ]; then
echo "- 14 build threads"
elif [ "$MY_BUILD_SPEED" = "fastest" ]; then
echo "- 16 build threads"
else
echo "- 8 build threads"
fi
echo -n "Do you wish to proceed? "
read MY_ANSWER
if [ "$MY_ANSWER" != "yes" ] && [ "$MY_ANSWER" != "y" ]; then
exit
fi
cd ~
LONG_HOSTNAME=$HOSTNAME
export HOSTNAME=$SHORT_HOSTNAME
. ~/bin/rom-env-setup
cd $ROM_TOP_DIR
if [ "$MY_SYNC_REPO" = "yes" ]; then
printf "*******************\nSynchronizing repo\n\n\n"
romsync
if [ "$?" != "0" ]; then
echo "something went wrong with repo sync"
export HOSTNAME=$LONG_HOSTNAME
exit 1
fi
printf "*******************\nRepository Updated\n\n\n"
sleep 5
fi
mkdir -p $ANDROID_TOP_DIR/build/files/emulator/system
function maketarget () {
printf "*******************\nBuilding $MY_CURRENT_TARGET\n\n\n"
if [ "$MY_BUILD_SPEED" = "slowest" ]; then
MY_BUILD_CMD="make -j1"
elif [ "$MY_BUILD_SPEED" = "slow" ]; then
MY_BUILD_CMD="mka -j2"
elif [ "$MY_BUILD_SPEED" = "fast" ]; then
MY_BUILD_CMD="mka -j11"
elif [ "$MY_BUILD_SPEED" = "faster" ]; then
MY_BUILD_CMD="mka -j14"
elif [ "$MY_BUILD_SPEED" = "fastest" ]; then
MY_BUILD_CMD="mka -j16"
else
MY_BUILD_CMD="mka -j8"
fi
mv $ROM_TOP_DIR/bootable/recovery/Android.oldmk $ROM_TOP_DIR/bootable/recovery/Android.mk 2> /dev/null
if [ $MY_CURRENT_TARGET = emulator ]; then
MY_CURRENT_TARGET=generic
mv $ROM_TOP_DIR/bootable/recovery/Android.mk $ROM_TOP_DIR/bootable/recovery/Android.oldmk
lunch full-eng
elif [ $MY_BUILD_VARIANT = "eng" ]; then
lunch cm_$MY_CURRENT_TARGET-eng
else
lunch $MY_CURRENT_TARGET
fi
rm $ROM_TOP_DIR/out/target/product/$MY_CURRENT_TARGET/system/build.prop
if [ $MY_CURRENT_TARGET != generic ]; then
MY_BUILD_CMD="$MY_BUILD_CMD bacon"
fi
$MY_BUILD_CMD 2>&1 | tee $ANDROID_TOP_DIR/build/$TARGET_PRODUCT-log.txt
MY_BUILD_RESULT=$?
if [ "$MY_BUILD_RESULT" = "0" ] && [ $MY_CURRENT_TARGET != generic ]; then
touch -c -t `date --date=@$CUSTOM_BUILD_DATE +%Y%m%d%H%M\.%S` $ROM_TOP_DIR/out/target/product/$MY_CURRENT_TARGET/Sapir*
mv $ROM_TOP_DIR/out/target/product/$MY_CURRENT_TARGET/Sapir* $ANDROID_TOP_DIR/build/files/
elif [ "$MY_BUILD_RESULT" = "0" ] && [ $MY_CURRENT_TARGET = generic ]; then
mv $ROM_TOP_DIR/out/target/product/$MY_CURRENT_TARGET/*.img $ANDROID_TOP_DIR/build/files/emulator/
mv $ROM_TOP_DIR/out/target/product/$MY_CURRENT_TARGET/system/build.prop $ANDROID_TOP_DIR/build/files/emulator/system/
fi
echo "$TARGET_PRODUCT build has been performed" > $ANDROID_TOP_DIR/build/$TARGET_PRODUCT.build
echo "Code was $MY_BUILD_RESULT" >> $ANDROID_TOP_DIR/build/$TARGET_PRODUCT.build
tail -3 $ANDROID_TOP_DIR/build/$TARGET_PRODUCT-log.txt >> $ANDROID_TOP_DIR/build/$TARGET_PRODUCT.build
mail_files --user $BUILDER_EMAIL -pass $MY_PASS --server=smtp.gmail.com:587 --from $BUILDER_EMAIL --to $BUILDER_EMAIL --subject "$TARGET_PRODUCT Build" --attach $ANDROID_TOP_DIR/build/$TARGET_PRODUCT-log.txt --body-plain "`cat $ANDROID_TOP_DIR/build/$TARGET_PRODUCT.build`"
}
if [ "$MY_P1" = "yes" ]; then
MY_CURRENT_TARGET=p1
maketarget
fi
if [ "$MY_D2ATT" = "yes" ]; then
MY_CURRENT_TARGET=d2att
maketarget
fi
if [ "$MY_I9300" = "yes" ]; then
MY_CURRENT_TARGET=i9300
maketarget
fi
if [ "$MY_I9100" = "yes" ]; then
MY_CURRENT_TARGET=i9100
maketarget
fi
if [ "$MY_MAGURO" = "yes" ]; then
MY_CURRENT_TARGET=maguro
maketarget
fi
if [ "$MY_A200" = "yes" ]; then
MY_CURRENT_TARGET=a200
maketarget
fi
if [ "$MY_I9000" = "yes" ]; then
MY_CURRENT_TARGET=galaxysmtd
maketarget
fi
if [ "$MY_EMULATOR" = "yes" ]; then
MY_CURRENT_TARGET=emulator
maketarget
fi
export HOST_NAME=$LONG_HOSTNAME