blob: d729b112c438c8f55a0e69dee8f2b2bdd539192a [file] [log] [blame]
Alexandre Savarda4f33d72012-08-29 17:03:23 -04001#!/bin/bash
2#
3# Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
4#
5# Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20#
21# Additional permission under GNU GPL version 3 section 7:
22#
23# If you modify this program, or any covered work, by linking or
24# combining it with the OpenSSL project's OpenSSL library (or a
25# modified version of that library), containing parts covered by the
26# terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
27# grants you additional permission to convey the resulting work.
28# Corresponding Source for a non-source form of such a combination
29# shall include the source code for the parts of OpenSSL used as well
30# as that of the covered work.
31#
32
33# Script used by Jenkins continious integration server to build and
34# test sflphone-android project
35
36#
37# Make sure that:
38# Download android_ndk_
39# android_sdk_
40# Install java runtime engine, ant
41# Required dependencies
42# sudo apt-get install libglfw-dev
43
44# Setup environment variables
alisioncfec4d02013-07-05 09:23:07 -040045export ANDROID_NDK=$HOME/android-buildtools/ndk
46export ANDROID_SDK=$HOME/android-buildtools/sdk
47export ANDROID_HOME=$HOME/android-buildtools/sdk
Alexandre Savarda4f33d72012-08-29 17:03:23 -040048export ANDROID_SWT=$ANDROID_SDK/tools/lib/x86_64
49
50ANDROID_SDK_TOOLS=$ANDROID_SDK/tools
51
52export PATH=$PATH:$ANDROID_NDK
53export PATH=$PATH:$ANDROID_SDK
54export PATH=$PATH:$ANDROID_SDK/platform-tools
55export PATH=$PATH:$ANDROID_SDK_TOOLS
56
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040057VIRTUAL_DEVICE_ID=31
58VIRTUAL_DEVICE_ABI=armeabi-v7a
Alexandre Savarda4f33d72012-08-29 17:03:23 -040059VIRTUAL_DEVICE_NAME=sflphone-android
60
61ANDROID_PROJECT_PATH=$HOME/sflphone/sflphone-android
62
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040063ANDROID_SFLPHONE_BIN=bin/SFLPhoneHome-debug.apk
Alexandre Savard523c3482012-08-30 09:57:50 -040064ANDROID_SFLPHONE_TEST_SUITE=tests/bin/sflphoneTest-debug.apk
65
66ANDROID_TEST_PACKAGE=com.savoirfairelinux.sflphone.tests
67ANDROID_TEST_RUNNNER=android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040068
Alexandre Savarda4f33d72012-08-29 17:03:23 -040069print_help() {
70 echo "Init sflphone-android test server, run test suite
71 Options:
72 -h Print this help message
73 -i Init test server environment (should be run only once)
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040074 -l Launch the emulator
Alexandre Savarda4f33d72012-08-29 17:03:23 -040075 -b Build the application, do not run the test suite
Alexandre Savardc0865ef2012-08-30 17:27:14 -040076 -t Build the test suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -040077 -r Run the full test suite, priorly build the application"
78}
79
80init_build_server() {
81 android delete avd --name $VIRTUAL_DEVICE_NAME
82
83 echo "Create a new android virtual device, overwrite precendent one"
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040084 android create avd -n $VIRTUAL_DEVICE_NAME -t $VIRTUAL_DEVICE_ID -f -b $VIRTUAL_DEVICE_ABI
Alexandre Savarda4f33d72012-08-29 17:03:23 -040085}
86
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040087launch_emulator() {
Alexandre Savarda4f33d72012-08-29 17:03:23 -040088 echo "Terminate any currently running emulator"
89 killall emulator-arm -u $USER
90
91 # build_sflphone_android
92 echo "List of currently available android virtual devices"
93 android list avd
94
95 echo "Launching the android emulator using \"$VIRTUAL_DEVICE_NAME\" avd"
96 emulator -avd $VIRTUAL_DEVICE_NAME -audio none -gpu off -partition-size 256 -no-window &
97
98 echo "Waiting for device ..."
99 adb wait-for-device
100
101 echo "List of devices currently running"
102 adb devices
103
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400104# adb push launch-sflphone.sh /data/data
105# adb shell sh /data/data/launch-sflphone.sh
106}
107
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400108build_sflphone_android() {
109 # android update project --target $VIRTUAL_DEVICE_ID --path $ANDROID_PROJECT_PATH
alisionf4571d92013-07-04 17:11:35 -0400110 echo "Compile pjandroid stack"
111 pushd jni/pjproject-android/android
112 ./configure-android --disable-sound --disable-oss --disable-video --enable-ext-sound --disable-speex-aec --disable-g711-codec --disable-l16-codec --disable-gsm-codec --disable-g722-codec --disable-g7221-codec --disable-speex-codec --disable-ilbc-codec --disable-sdl --disable-ffmpeg --disable-v4l
113 make dep && make
114 popd
115
alisione93ccd22013-07-04 17:28:44 -0400116 ./make-swig.sh
117 ./make-glue.sh
118
119
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400120
121 echo "Build JNI related libraries"
122 # ndk-build clean
alisioncfec4d02013-07-05 09:23:07 -0400123 $ANDROID_NDK/ndk-build
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400124
125 echo "Build Java application"
alisione93ccd22013-07-04 17:28:44 -0400126 ant update project -p .
Alexandre Savardf0dcca02012-08-31 13:54:10 -0400127 ant clean
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400128 ant debug
129
alisionf4571d92013-07-04 17:11:35 -0400130 # echo "Upload sflphone on the virtual device"
131 #adb install -r $ANDROID_SFLPHONE_BIN
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400132 # ./adb-push-sflphone.sh
133}
134
135build_sflphone_test_suite() {
136 echo "Build test suite"
137 pushd tests
138 ant debug
139 popd
Alexandre Savard523c3482012-08-30 09:57:50 -0400140
141 echo "Upload test suite on the virtual devices"
Alexandre Savard4d6a52a2012-08-30 11:18:09 -0400142 adb install -r $ANDROID_SFLPHONE_TEST_SUITE
Alexandre Savard523c3482012-08-30 09:57:50 -0400143}
144
145run_test_suite() {
146 adb shell am instrument -w com.savoirfairelinux.sflphone.tests/android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400147}
148
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400149if [ "$#" -eq 0 ]; then
150 print_help
151fi
152
Alexandre Savard974363d2012-08-30 15:20:49 -0400153while getopts "hilbrt" opts; do
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400154 case $opts in
155 h)
156 print_help
157 ;;
158 i)
159 init_build_server
160 ;;
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400161 l)
162 launch_emulator
163 ;;
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400164 b)
165 build_sflphone_android
Alexandre Savard974363d2012-08-30 15:20:49 -0400166 ;;
167 t)
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400168 build_sflphone_test_suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400169 ;;
170 r)
171 run_test_suite
172 ;;
173 *)
174 print_help
175 ;;
176 esac
177done