Skip to content

Commit

Permalink
Build all Travis CI targets with CMake:
Browse files Browse the repository at this point in the history
* Skip release and coverage targets for push builds
  • Loading branch information
wilsonianb committed Jun 29, 2016
1 parent b5413c1 commit f5fd22a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,22 @@ matrix:
include:
# GCC/Coverage
- compiler: gcc
env: GCC_VER=5 VARIANT=coverage ADDRESS_MODEL=64
env:
- GCC_VER=5
- VARIANT=coverage
- ADDRESS_MODEL=64
- BUILD_SYSTEM=cmake
- PATH=$PWD/cmake/bin:$PATH
addons: &ao_gcc5
apt:
sources: ['ubuntu-toolchain-r-test']
packages: *gcc5_pkgs

# GCC/Debug/CMake
# GCC/Release/Autobahn
- compiler: gcc
env:
- GCC_VER=5
- VARIANT=debug
- VARIANT=release
- ADDRESS_MODEL=64
- BUILD_SYSTEM=cmake
- PATH=$PWD/cmake/bin:$PATH
Expand All @@ -63,7 +68,9 @@ matrix:
- VARIANT=usan
- CLANG_VER=3.8
- ADDRESS_MODEL=64
- UBSAN_OPTIONS='print_stacktrace=1'
- UBSAN_OPTIONS='print_stacktrace=1'
- BUILD_SYSTEM=cmake
- PATH=$PWD/cmake/bin:$PATH
- PATH=$PWD/llvm-$LLVM_VERSION/bin:$PATH
addons: *ao_gcc5

Expand All @@ -74,6 +81,8 @@ matrix:
- VARIANT=asan
- CLANG_VER=3.8
- ADDRESS_MODEL=64
- BUILD_SYSTEM=cmake
- PATH=$PWD/cmake/bin:$PATH
- PATH=$PWD/llvm-$LLVM_VERSION/bin:$PATH
addons: *ao_gcc5

Expand Down
23 changes: 22 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,28 @@ else()
find_package(Threads)

set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -std=c++11 -Wall -Wpedantic")
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wpedantic")
endif()

if (${VARIANT} STREQUAL "coverage")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
elseif (${VARIANT} STREQUAL "asan")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
elseif (${VARIANT} STREQUAL "usan")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
elseif (${VARIANT} STREQUAL "debug")
set(CMAKE_BUILD_TYPE DEBUG)
elseif (${VARIANT} STREQUAL "release")
set(CMAKE_BUILD_TYPE RELEASE)
endif()

message ("cxx Flags: " ${CMAKE_CXX_FLAGS})
Expand Down
28 changes: 11 additions & 17 deletions scripts/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ else
export PATH=$VALGRIND_ROOT/bin:$LCOV_ROOT/usr/bin:$PATH
fi

MAIN_BRANCH="0"
# For builds not triggered by a pull request TRAVIS_BRANCH is the name of the
# branch currently being built; whereas for builds triggered by a pull request
# it is the name of the branch targeted by the pull request (in many cases this
# will be master).
if [[ $TRAVIS_BRANCH == "master" || $TRAVIS_BRANCH == "develop" ]]; then
MAIN_BRANCH="1"
fi

num_jobs="1"
if [[ $(uname) == "Darwin" ]]; then
num_jobs=$(sysctl -n hw.physicalcpu)
Expand All @@ -42,11 +33,16 @@ elif [[ $(uname -s) == "Linux" ]]; then
fi
fi

if [[ $TRAVIS_PULL_REQUEST == "false" &&
( $VARIANT == "coverage" || $VARIANT == "release" ) ]]; then
echo "skipping target for non-pull request build"
exit 0
fi

echo "using toolset: $CC"
echo "using variant: $VARIANT"
echo "using address-model: $ADDRESS_MODEL"
echo "using PATH: $PATH"
echo "using MAIN_BRANCH: $MAIN_BRANCH"
echo "using BOOST_ROOT: $BOOST_ROOT"

#################################### HELPERS ###################################
Expand Down Expand Up @@ -85,7 +81,7 @@ function build_beast {
function build_beast_cmake {
mkdir -p build
pushd build > /dev/null
cmake -DCMAKE_BUILD_TYPE=${VARIANT^} ..
cmake -DVARIANT=${VARIANT} ..
make -j${num_jobs}
mkdir -p ../bin/$VARIANT
find . -executable -type f -exec cp {} ../bin/$VARIANT/. \;
Expand Down Expand Up @@ -133,12 +129,7 @@ if [[ $VARIANT == "coverage" ]]; then
lcov --no-external -c -i -d . -o baseline.info > /dev/null

# Perform test
if [[ $MAIN_BRANCH == "1" ]]; then
run_tests_with_valgrind
run_autobahn_test_suite
else
run_tests
fi
run_tests

# Create test coverage data file
lcov --no-external -c -d . -o testrun.info > /dev/null
Expand All @@ -154,6 +145,9 @@ if [[ $VARIANT == "coverage" ]]; then

# Clean up these stragglers so BOOST_ROOT cache is clean
find $BOOST_ROOT/bin.v2 -name "*.gcda" | xargs rm -f
elif [[ $VARIANT == "release" ]]; then
run_tests_with_valgrind
run_autobahn_test_suite
else
run_tests_with_debugger
fi

0 comments on commit f5fd22a

Please sign in to comment.