From 0a6cfe4358495d621465f6dc8fd1535a69c54410 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco Claraco Date: Fri, 31 May 2019 09:48:51 +0200 Subject: [PATCH 1/2] Add travis CI --- .travis.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ 3 files changed, 103 insertions(+) create mode 100755 .travis.sh create mode 100644 .travis.yml diff --git a/.travis.sh b/.travis.sh new file mode 100755 index 000000000..71c946eb4 --- /dev/null +++ b/.travis.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -e # Make sure any error makes the script to return an error code +set -x # echo + +SOURCE_DIR=`pwd` +BUILD_DIR=build + +#CMAKE_C_FLAGS="-Wall -Wextra -Wabi -O2" +#CMAKE_CXX_FLAGS="-Wall -Wextra -Wabi -O2" + +function build_and_test () +{ + #env + git clean -fd || true + rm -fr $BUILD_DIR || true + mkdir $BUILD_DIR && cd $BUILD_DIR + + if [ ! -z "$GCC_VERSION" ]; then + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 \ + --slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION + sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION + fi + + # gcc is too slow and we have a time limit in Travis CI: selective builds. + if [ "$BUILD_EXAMPLES" == "1" ]; then + GTSAM_BUILD_EXAMPLES_ALWAYS=FALSE + else + GTSAM_BUILD_EXAMPLES_ALWAYS=TRUE + fi + if [ "$RUN_TESTS" == "1" ]; then + GTSAM_BUILD_TESTS=FALSE + else + GTSAM_BUILD_TESTS=TRUE + fi + + cmake $SOURCE_DIR \ + -DGTSAM_BUILD_EXAMPLES_ALWAYS=$GTSAM_BUILD_EXAMPLES_ALWAYS \ + -DGTSAM_BUILD_TESTS=$GTSAM_BUILD_TESTS + + # Actual build: + make -j2 + + # Run tests: + if [ "$RUN_TESTS" == "1" ]; then + make check + fi + + cd $SOURCE_DIR +} + +build_and_test diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..bce676721 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,49 @@ +language: cpp +cache: ccache +sudo: required +dist: xenial + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-8 + - clang-3.8 + - build-essential + - pkg-config + - cmake + - libpython-dev python-numpy + - libboost-all-dev + +before_install: + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update ; fi + +script: + - bash .travis.sh + +env: + global: + - MAKEFLAGS="-j 2" + - CCACHE_SLOPPINESS=pch_defines,time_macros + +matrix: + include: + - compiler: gcc + os: linux + env: BUILD_EXAMPLES=1 + - compiler: gcc + os: linux + env: RUN_TESTS=1 + - compiler: gcc + os: linux + env: BUILD_EXAMPLES=1 GCC_VERSION="8" + - compiler: clang + os: linux + env: BUILD_EXAMPLES=1 + - compiler: gcc + os: osx + env: BUILD_EXAMPLES=1 + - compiler: clang + os: osx + env: RUN_TESTS=1 diff --git a/README.md b/README.md index 720517669..07cf25a40 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/borglab/gtsam.svg?branch=develop)](https://travis-ci.org/borglab/gtsam) + README - Georgia Tech Smoothing and Mapping library =================================================== From f52c69b5a8a3968719b06830d6c0cab77bf5b9cf Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco Claraco Date: Fri, 31 May 2019 13:10:33 +0200 Subject: [PATCH 2/2] fix wrong logic --- .travis.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.sh b/.travis.sh index 71c946eb4..522d82353 100755 --- a/.travis.sh +++ b/.travis.sh @@ -24,14 +24,14 @@ function build_and_test () # gcc is too slow and we have a time limit in Travis CI: selective builds. if [ "$BUILD_EXAMPLES" == "1" ]; then - GTSAM_BUILD_EXAMPLES_ALWAYS=FALSE + GTSAM_BUILD_EXAMPLES_ALWAYS=ON else - GTSAM_BUILD_EXAMPLES_ALWAYS=TRUE + GTSAM_BUILD_EXAMPLES_ALWAYS=OFF fi if [ "$RUN_TESTS" == "1" ]; then - GTSAM_BUILD_TESTS=FALSE + GTSAM_BUILD_TESTS=ON else - GTSAM_BUILD_TESTS=TRUE + GTSAM_BUILD_TESTS=OFF fi cmake $SOURCE_DIR \