hudson-sflphone-script.sh 5.15 KB
Newer Older
1
#!/bin/bash -e
2
#
3
#  Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#
#  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
VIDEO=0
41

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

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

54

55
function gen_doxygen {
56 57 58 59 60 61
    # Check if doxygen is installed on the system
    if [ `which doxygen &>/dev/null ; echo $?` -ne 1 ] ; then
        pushd doc/doxygen
        doxygen core-doc.cfg.in
        popd
    fi
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
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
}


105
function build_daemon {
106 107 108 109 110 111 112 113 114 115 116 117 118
    pushd daemon
    # Run static analysis code tool
    if [ $CODE_ANALYSIS == 1 ]; then
        run_code_analysis
    fi

    ./autogen.sh || exit 1
    # Compile pjproject first
    pushd libs
    ./compile_pjsip.sh
    popd

    # Compile the daemon
119
    # Check if video suppport should be enabled
120
    if [ $VIDEO == 1 ]; then
121
      OPTS="--enable-video"
122
    fi
123
    ./configure --prefix=/usr $OPTS
124 125 126 127 128 129 130
    make clean
    make -j
    # Remove the previous XML test file
    rm -rf $XML_RESULTS
    # Compile unit tests
    make check
    popd
131 132 133
}

function build_gnome {
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    # Compile the plugins
    pushd plugins
    ./autogen.sh || exit 1
    ./configure --prefix=/usr
    make -j
    popd

    # Compile the client
    pushd gnome
    ./autogen.sh || exit 1
    ./configure --prefix=/usr
    make clean
    make -j 1
    make check
    popd
149 150
}

151 152 153 154 155 156 157 158 159 160
function build_kde {
   # Compile the KDE client
   pushd kde
   mkdir -p build
   cd build
   cmake ../
   make -j
   popd
}

161

162
if [ "$#" -eq 0 ]; then   # Script needs at least one command-line argument.
163 164 165
    echo "Usage $0 -b select which one to build: daemon or gnome
                  -t enable unit tests after build"
    exit $E_OPTERR
166
fi
167

168 169 170

git clean -f -d -x

171
while getopts ":b: t a v" opt; do
172 173 174 175 176 177 178 179 180 181 182 183 184
    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
            ;;
185 186 187 188
        v)
            # Video support
            echo "-v was triggered. Video support enabled" >&2
            VIDEO=1
189 190 191 192 193 194 195 196 197 198
            ;;
        \?)
            echo "Invalid option: -$OPTARG" >&2
            exit 1
            ;;
        :)
            echo "Option -$OPTARG requires an argument." >&2
            exit 1
            ;;
        esac
199 200 201
done

# Call appropriate build function, with parameters if needed
202
build_$BUILD
203

204 205 206 207
if [ $TEST == 1 ]; then
    launch_functional_test_daemon
fi

208 209
# SUCCESS
exit 0