0 | |
#! /bin/bash
|
|
0 |
#!/bin/bash
|
|
1 |
set -ev
|
1 | 2 |
|
2 | |
# Travis cpp jobs construct a matrix based on environment variables
|
3 | |
# (and the value of 'compiler'). In order to test multiple builds
|
4 | |
# (release/debug/cpplint/cppcheck), this uses a TRAVIS_TARGET env
|
5 | |
# var to do the right thing.
|
|
3 |
# Set compiler to GCC 4.8 here, as Travis overrides the global variables.
|
|
4 |
export CC=gcc-4.8 CXX=g++-4.8
|
6 | 5 |
|
7 | |
function travis_make()
|
8 | |
{
|
9 | |
mkdir $1 && cd $1
|
|
6 |
if [ ${TRAVIS_TARGET} == CPPCHECK ]; then
|
|
7 |
# grab a pre-built cppcheck from s3
|
|
8 |
wget https://s3.amazonaws.com/kylo-pl-bucket/pcre-8.36_install.tar.bz2
|
|
9 |
tar xjvf pcre-8.36_install.tar.bz2 --strip 1 -C $USERDIR
|
|
10 |
wget https://s3.amazonaws.com/kylo-pl-bucket/cppcheck-1.69_install.tar.bz2
|
|
11 |
tar xjvf cppcheck-1.69_install.tar.bz2 --strip 1 -C $USERDIR
|
|
12 |
elif [ ${TRAVIS_TARGET} == DOXYGEN ]; then
|
|
13 |
# grab a pre-built doxygen 1.8.7 from s3
|
|
14 |
wget https://s3.amazonaws.com/kylo-pl-bucket/doxygen_install.tar.bz2
|
|
15 |
tar xjvf doxygen_install.tar.bz2 --strip 1 -C $USERDIR
|
|
16 |
elif [ ${TRAVIS_TARGET} == DEBUG ]; then
|
|
17 |
# Install coveralls.io update utility
|
|
18 |
pip install --user cpp-coveralls
|
|
19 |
fi
|
10 | 20 |
|
11 | |
# Set compiler to GCC 4.8 here, as Travis overrides the global variables.
|
12 | |
export CC=gcc-4.8 CXX=g++-4.8
|
13 | |
# Generate build files
|
14 | |
[ $1 == "debug" ] && export CMAKE_VARS="-DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=ON"
|
15 | |
cmake $CMAKE_VARS ..
|
16 | |
if [ $? -ne 0 ]; then
|
17 | |
echo "cmake failed."
|
18 | |
exit 1
|
19 | |
fi
|
|
21 |
# Generate build files
|
|
22 |
if [ ${TRAVIS_TARGET} == DEBUG ]; then
|
|
23 |
cmake -DCMAKE_BUILD_TYPE=Debug -DCOVERALLS=ON .
|
|
24 |
else
|
|
25 |
cmake .
|
|
26 |
fi
|
20 | 27 |
|
21 | |
# Build facter
|
22 | |
if [ $1 == "cpplint" ]; then
|
23 | |
export MAKE_TARGET="cpplint"
|
24 | |
elif [ $1 == "cppcheck" ]; then
|
25 | |
export MAKE_TARGET="cppcheck"
|
26 | |
else
|
27 | |
export MAKE_TARGET="all"
|
28 | |
fi
|
29 | |
make $MAKE_TARGET -j2
|
30 | |
if [ $? -ne 0 ]; then
|
31 | |
echo "build failed."
|
32 | |
exit 1
|
33 | |
fi
|
|
28 |
if [ ${TRAVIS_TARGET} == CPPLINT ]; then
|
|
29 |
make cpplint
|
|
30 |
elif [ ${TRAVIS_TARGET} == DOXYGEN ]; then
|
|
31 |
# Build docs
|
|
32 |
pushd lib
|
|
33 |
doxygen 2>&1 | ( ! grep . )
|
|
34 |
ruby docs/generate.rb > /tmp/facts.md
|
|
35 |
popd
|
|
36 |
elif [ ${TRAVIS_TARGET} == CPPCHECK ]; then
|
|
37 |
make cppcheck
|
|
38 |
else
|
|
39 |
make -j2
|
34 | 40 |
|
35 | |
# Run tests if not doing cpplint/cppcheck
|
36 | |
if [ $1 == "cpplint" ]; then
|
37 | |
# Verify documentation
|
38 | |
pushd ../lib
|
39 | |
doxygen 2>&1 | ( ! grep . )
|
40 | |
if [ $? -ne 0 ]; then
|
41 | |
echo "documentation failed."
|
42 | |
exit 1
|
43 | |
fi
|
44 | |
ruby docs/generate.rb > /tmp/facts.md
|
45 | |
if [ $? -ne 0 ]; then
|
46 | |
echo "fact documentation failed."
|
47 | |
exit 1
|
48 | |
fi
|
49 | |
popd
|
50 | |
elif [ $1 != "cppcheck" ]; then
|
51 | |
# Install the bundle before testing
|
52 | |
bundle install --gemfile=../lib/Gemfile
|
53 | |
if [ $? -ne 0 ]; then
|
54 | |
echo "bundle install failed."
|
55 | |
exit 1
|
56 | |
fi
|
|
41 |
# Install the bundle before testing
|
|
42 |
bundle install --gemfile=lib/Gemfile
|
|
43 |
make test ARGS=-V
|
57 | 44 |
|
58 | |
LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so ctest -V 2>&1 | c++filt
|
59 | |
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
60 | |
echo "tests reported an error."
|
61 | |
exit 1
|
62 | |
fi
|
|
45 |
# Make sure installation succeeds
|
|
46 |
make DESTDIR=$USERDIR install
|
63 | 47 |
|
64 | |
if [ $1 == "debug" ]; then
|
65 | |
coveralls --gcov gcov-4.8 --gcov-options '\-lp' -r .. >/dev/null
|
66 | |
fi
|
|
48 |
if [ ${TRAVIS_TARGET} == DEBUG ]; then
|
|
49 |
coveralls --gcov gcov-4.8 --gcov-options '\-lp' -r .. >/dev/null
|
|
50 |
fi
|
|
51 |
fi
|
67 | 52 |
|
68 | |
# Make sure installation succeeds
|
69 | |
make DESTDIR=$USERDIR install
|
70 | |
if [ $? -ne 0 ]; then
|
71 | |
echo "install failed."
|
72 | |
exit 1
|
73 | |
fi
|
74 | |
fi
|
75 | |
}
|
76 | |
|
77 | |
case $TRAVIS_TARGET in
|
78 | |
"CPPLINT" ) travis_make cpplint ;;
|
79 | |
"CPPCHECK" ) travis_make cppcheck ;;
|
80 | |
"RELEASE" ) travis_make release ;;
|
81 | |
"DEBUG" ) travis_make debug ;;
|
82 | |
*) echo "Nothing to do!"
|
83 | |
esac
|