Newer
Older
#!/bin/bash
#
# Script used by Hudson continious integration server to build SFLphone
#
# Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
XML_RESULTS="cppunitresults.xml"
TEST=0
BUILD=
CODE_ANALYSIS=0
CONFIGDIR=~/.config
SFLCONFDIR=${CONFIGDIR}/sflphone
function run_code_analysis {
# Check if cppcheck is installed on the system
if [ `which cppcheck &>/dev/null ; echo $?` -ne 1 ] ; then
cppcheck . --enable=all --xml --inline-suppr 2> cppcheck-report.xml
function gen_doxygen {
# Check if doxygen is installed on the system
if [ `which doxygen &>/dev/null ; echo $?` -ne 1 ] ; then
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
function launch_unit_test_daemon {
# Run the unit tests for the daemon
pushd daemon/test
# Remove the previous XML test file
rm -rf $XML_RESULTS
./run_tests.sh || exit 1
popd
}
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
}
# Run static analysis code tool
if [ $CODE_ANALYSIS == 1 ]; then
run_code_analysis
fi
make distclean
./autogen.sh
# Compile pjproject first
pushd libs/pjproject
./autogen.sh
./configure
make && make dep
popd
./configure --prefix=/usr
make clean
# Generate documentation
if [ $DOXYGEN == 1 ]; then
gen_doxygen
fi
# Compile unit tests
# 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
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
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
;;
a)
echo "-a was triggered. Static code analysis will be run" >&2
CODE_ANALYSIS=1
;;
d)
echo "-d was triggered. Doxygen documentation will be generated" >&2
DOXYGEN=1
;;
\?)
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
if [ $TEST == 1 ]; then
# launch_unit_test_daemon
launch_functional_test_daemon
fi