-
Notifications
You must be signed in to change notification settings - Fork 492
/
build.sh
executable file
·78 lines (60 loc) · 1.71 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
#!/bin/bash
set -e
function log {
local logStart="#"
local sourceLen=${#BASH_SOURCE[@]}
for ((i=$sourceLen-1; i>0; --i)); do
logStart="$logStart [$(basename ${BASH_SOURCE[$i]})]"
done
echo "$logStart $@"
}
function handle_bad_config {
log "Please read BUILDING.txt for more info."
log "BUILD FAILED"
exit 1
}
function no_device_running_create_one {
if ! adb devices | grep -w -q 'device'; then
create_emulator_with_no_gui
fi
}
function create_emulator_with_no_gui {
log "Creating emulator..."
echo yes | android update sdk --filter sysimg-17 --no-ui --force > /dev/null
echo no | android create avd --force -n test -t android-17 --abi armeabi-v7a
emulator -avd test -no-skin -no-audio -no-window &
chmod +x ci/wait_for_emulator.sh
ci/wait_for_emulator.sh
adb shell input keyevent 82
log "Complete!"
}
function kill_running_emulator {
log "Killing emulator..."
adb -s emulator-5554 emu kill
log "Done!"
}
log "Checking config..."
localPropsFile=local.properties
if [[ -z $ANDROID_HOME ]]; then
log "environment variable ANDROID_HOME is not set."
if [[ ! -f $localPropsFile ]]; then
log "File not found: $localPropsFile"
handle_bad_config
fi
if ! grep -q '^sdk\.dir=' $localPropsFile; then
log "value 'sdk.dir' not set in file '$localPropsFile'."
handle_bad_config
fi
fi
log "Config looks OK."
log "Building smssync..."
./gradlew clean assemble
log "Smssync built."
# test build requires a running emulator. Create and run and emulator
log "About to build test app"
no_device_running_create_one
log "Building test app..."
./gradlew clean connectedInstrumentTest --continue
log "Test app built."
log "BUILD COMPLETE"
exit 0