hudson-sflphone-script.sh 5.02 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

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

44
function run_code_analysis {
Tristan Matthews's avatar
Tristan Matthews committed
45 46 47 48 49 50
    # 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
51 52
}

53

54
function gen_doxygen {
Tristan Matthews's avatar
Tristan Matthews committed
55 56 57 58 59 60
    # 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
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 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 {
Tristan Matthews's avatar
Tristan Matthews committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    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
    ./configure --prefix=/usr
    make clean
    make -j
    # Remove the previous XML test file
    rm -rf $XML_RESULTS
    # Compile unit tests
    make check
    popd
126 127 128
}

function build_gnome {
Tristan Matthews's avatar
Tristan Matthews committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    # 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
144 145
}

146 147 148 149 150 151 152 153 154 155
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
156

157
if [ "$#" -eq 0 ]; then   # Script needs at least one command-line argument.
Tristan Matthews's avatar
Tristan Matthews committed
158 159 160
    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
161
fi
162

163 164 165

git clean -f -d -x

166
while getopts ":b: t a d" opt; do
Tristan Matthews's avatar
Tristan Matthews committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
    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
193 194 195
done

# Call appropriate build function, with parameters if needed
196
build_$BUILD
197

198 199 200 201
if [ $TEST == 1 ]; then
    launch_functional_test_daemon
fi

202 203
# SUCCESS
exit 0