hudson-sflphone-script.sh 4.99 KB
Newer Older
1 2
#!/bin/bash
#
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#  Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
#
#  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
#
21 22 23 24 25 26 27 28 29 30 31 32 33
#  Additional permission under GNU GPL version 3 section 7:
#
#  If you modify this program, or any covered work, by linking or
#  combining it with the OpenSSL project's OpenSSL library (or a
#  modified version of that library), containing parts covered by the
#  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
#  grants you additional permission to convey the resulting work.
#  Corresponding Source for a non-source form of such a combination
#  shall include the source code for the parts of OpenSSL used as well
#  as that of the covered work.
#

# Script used by Hudson continious integration server to build SFLphone
34

35 36 37 38
XML_RESULTS="cppunitresults.xml"
TEST=0
BUILD=
CODE_ANALYSIS=0
39
DOXYGEN=0
40

41 42 43
CONFIGDIR=~/.config
SFLCONFDIR=${CONFIGDIR}/sflphone

44 45 46
function run_code_analysis {
	# Check if cppcheck is installed on the system
	if [ `which cppcheck &>/dev/null ; echo $?` -ne 1 ] ; then
Emmanuel Milou's avatar
Emmanuel Milou committed
47
		pushd src
48
		cppcheck . --enable=all --xml --inline-suppr 2> cppcheck-report.xml
Emmanuel Milou's avatar
Emmanuel Milou committed
49
		popd
50 51 52
	fi
}

53

54 55 56
function gen_doxygen {
	# Check if doxygen is installed on the system
	if [ `which doxygen &>/dev/null ; echo $?` -ne 1 ] ; then
Emmanuel Milou's avatar
Emmanuel Milou committed
57
		pushd doc/doxygen
58
		doxygen core-doc.cfg.in
Emmanuel Milou's avatar
Emmanuel Milou committed
59
		popd
60 61 62
	fi
}

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
function launch_functional_test_daemon {
        # Run the python functional tests for the daemon

        # make sure no other instance are currently running
        killall sflphoned
        killall sipp

        # make sure the configuration directory created
        CONFDIR=~/.config
        SFLCONFDIR=${CONFDIR}/sflphone

        eval `dbus-launch --auto-syntax`

        if [ ! -d ${CONFDIR} ]; then
            mkdir ${CONFDIR}
        fi

        if [ ! -d ${SFLCONFDIR} ]; then
            mkdir ${SFLCONFDIR}
        fi

        # make sure the most recent version of the configuration
        # is installed
        pushd tools/pysflphone
            cp -f sflphoned.functest.yml ${SFLCONFDIR}
        popd

        # launch sflphone daemon, wait some time for
        # dbus registration to complete
        pushd daemon
            ./src/sflphoned &
            sleep 3
        popd

        # launch the test script
        pushd tools/pysflphone
            nosetests --with-xunit test_sflphone_dbus_interface.py
        popd
}


104
function build_daemon {
Emmanuel Milou's avatar
Emmanuel Milou committed
105 106
	# Compile the daemon
	pushd daemon
107 108 109 110
	# Run static analysis code tool
	if [ $CODE_ANALYSIS == 1 ]; then
		run_code_analysis
	fi
Emmanuel Milou's avatar
Emmanuel Milou committed
111 112 113 114 115 116 117 118 119 120
	make distclean
	./autogen.sh
	# Compile pjproject first
	pushd libs/pjproject
	./autogen.sh
	./configure
	make && make dep
	popd
	./configure --prefix=/usr
	make clean
121
	# Compile src code
Emmanuel Milou's avatar
Emmanuel Milou committed
122
	make -j
123 124
	# Remove the previous XML test file
	rm -rf $XML_RESULTS
125
	# Compile unit tests
Emmanuel Milou's avatar
Emmanuel Milou committed
126 127
	make check
	popd
128 129 130
}

function build_gnome {
131 132
	# Compile the daemon
	pushd daemon
Emmanuel Milou's avatar
Emmanuel Milou committed
133
  killall sflphoned
134 135 136 137 138 139 140 141 142 143 144 145
	make distclean
	./autogen.sh
  # Compile pjproject first
	pushd libs/pjproject
	./autogen.sh
	./configure
	make && make dep
	popd
	./configure --prefix=/usr
	make clean
	# Compile src code
	make -j
Emmanuel Milou's avatar
Emmanuel Milou committed
146
  ./src/sflphoned&
147 148
	popd

Emmanuel Milou's avatar
Emmanuel Milou committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
	# Compile the plugins
	pushd plugins
	make distclean
	./autogen.sh
	./configure --prefix=/usr
	make -j
	popd

	# Compile the client
	pushd gnome
	make distclean
	./autogen.sh
	./configure --prefix=/usr
	make clean
	make -j 1
	make check
	popd
166 167
}

168 169 170 171 172 173 174 175 176 177
function build_kde {
   # Compile the KDE client
   pushd kde
   mkdir -p build
   cd build
   cmake ../
   make -j
   popd
}

Emmanuel Milou's avatar
Emmanuel Milou committed
178

179 180 181 182
if [ "$#" -eq 0 ]; then   # Script needs at least one command-line argument.
	echo "Usage $0 -b select which one to build: daemon or gnome
				  -t enable unit tests after build"
	exit $E_OPTERR
Emmanuel Milou's avatar
Emmanuel Milou committed
183
fi
184

185 186 187

git clean -f -d -x

188
while getopts ":b: t a d" opt; do
189 190 191 192 193 194 195 196 197
	case $opt in
		b)
			echo "-b was triggered. Parameter: $OPTARG" >&2
			BUILD=$OPTARG
			;;
		t)
			echo "-t was triggered. Tests will be run" >&2
			TEST=1
			;;
198 199 200 201
		a)
			echo "-a was triggered. Static code analysis will be run" >&2
			CODE_ANALYSIS=1
			;;
202 203 204 205
		d)
			echo "-d was triggered. Doxygen documentation will be generated" >&2
			DOXYGEN=1
			;;
206 207 208 209 210 211 212 213 214 215 216 217
		\?)
			echo "Invalid option: -$OPTARG" >&2
			exit 1
			;;
		:)
			echo "Option -$OPTARG requires an argument." >&2
			exit 1
			;;
		esac
done

# Call appropriate build function, with parameters if needed
218
build_$BUILD
219

220 221 222 223
if [ $TEST == 1 ]; then
    launch_functional_test_daemon
fi

224 225
# SUCCESS
exit 0