forked from NativeScript/android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·82 lines (68 loc) · 3.26 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
78
79
80
81
82
#!/usr/bin/env bash
###############################################################################################
# Android Runtime build script for CI.
# This file is used by the CI only and it's not meant for regular development.
###############################################################################################
echo "Ensure adb is in PATH"
export PATH="$ANDROID_HOME/platform-tools:$PATH"
adb version
echo "Update submodule"
git submodule update --init
echo "Cleanup old build and test artefacts"
rm -rf consoleLog.txt
rm -rf test-app/dist/*.xml
echo "Stopping running emulators if any"
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
./gradlew cleanRuntime
if [ "$1" != 'unit_tests_only' ]; then
echo "Building Android Runtime with paramerter packageVersion: $ANDROID_PACKAGE_VERSION and commit: $GIT_COMMIT"
if [ "$NO_CCACHE" == 'true' ]; then
./gradlew -PpackageVersion=$ANDROID_PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT -PnoCCache
else
./gradlew -PpackageVersion=$ANDROID_PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT
fi
cp dist/tns-android-*.tgz dist/tns-android.tgz
else
echo "Building Android Runtime for x86 unit tests with paramerter packageVersion: $ANDROID_PACKAGE_VERSION and commit: $GIT_COMMIT"
if [ "$NO_CCACHE" == 'true' ]; then
./gradlew -PpackageVersion=$ANDROID_PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT -PskipUnoptimized -PonlyX86 -PnoCCache
else
./gradlew -PpackageVersion=$ANDROID_PACKAGE_VERSION -PgitCommitVersion=$GIT_COMMIT -PskipUnoptimized -PonlyX86
fi
cp dist/tns-android-*.tgz dist/tns-android.tgz
fi
if [ "$2" != '' ]; then
listOfEmulators=$2
else
listOfEmulators="Emulator-Api28-Google Emulator-Api23-Default Emulator-Api19-Default"
fi
# Run static binding generator unit tests
./gradlew runSbgTests
for emulator in $listOfEmulators; do
echo "Start emulator $emulator"
$ANDROID_HOME/emulator/emulator -avd ${emulator} -verbose -wipe-data -gpu on&
find ~/.android/avd/${emulator}.avd -type f -name 'config.ini' -exec cat {} +
echo "Run Android Runtime unit tests for $emulator"
$ANDROID_HOME/platform-tools/adb wait-for-device
$ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat -c
$ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog.txt&
$ANDROID_HOME/platform-tools/adb -s emulator-5554 logcat > consoleLog$emulator.txt&
if [ "$1" != 'unit_tests_only' ]; then
./gradlew runtests
else
./gradlew runtests -PonlyX86
fi
echo "Rename unit test result"
(
cd ./test-app/dist
mv android_unit_test_results.xml $emulator.xml
)
echo "Stopping running emulators"
for KILLPID in `ps ax | grep 'emulator' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
for KILLPID in `ps ax | grep 'qemu' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
for KILLPID in `ps ax | grep 'adb' | grep -v 'grep' | awk ' { print $1;}'`; do kill -9 $KILLPID; done
done
echo $cwd
cd $cwd