Use command line argument for script so that cache names are not polluted by environment variables. This should allow ccache to use caches from build stage for testing stage.
parent
87ab40d48d
commit
f09d118eb8
81
.travis.sh
81
.travis.sh
|
@ -1,46 +1,85 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# common tasks before either build or test
|
||||||
|
function prepare ()
|
||||||
|
{
|
||||||
set -e # Make sure any error makes the script to return an error code
|
set -e # Make sure any error makes the script to return an error code
|
||||||
set -x # echo
|
set -x # echo
|
||||||
|
|
||||||
SOURCE_DIR=`pwd`
|
SOURCE_DIR=`pwd`
|
||||||
BUILD_DIR=build
|
BUILD_DIR=build
|
||||||
|
|
||||||
#CMAKE_C_FLAGS="-Wall -Wextra -Wabi -O2"
|
|
||||||
#CMAKE_CXX_FLAGS="-Wall -Wextra -Wabi -O2"
|
|
||||||
|
|
||||||
function build_and_test ()
|
|
||||||
{
|
|
||||||
#env
|
#env
|
||||||
git clean -fd || true
|
git clean -fd || true
|
||||||
rm -fr $BUILD_DIR || true
|
rm -fr $BUILD_DIR || true
|
||||||
mkdir $BUILD_DIR && cd $BUILD_DIR
|
mkdir $BUILD_DIR && cd $BUILD_DIR
|
||||||
|
|
||||||
|
if [ -z "$CMAKE_BUILD_TYPE" ]; then
|
||||||
|
CMAKE_BUILD_TYPE=Debug
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$GTSAM_ALLOW_DEPRECATED_SINCE_V4" ]; then
|
||||||
|
GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -z "$GCC_VERSION" ]; then
|
if [ ! -z "$GCC_VERSION" ]; then
|
||||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 \
|
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$GCC_VERSION 60 \
|
||||||
--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION
|
--slave /usr/bin/g++ g++ /usr/bin/g++-$GCC_VERSION
|
||||||
sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION
|
sudo update-alternatives --set gcc /usr/bin/gcc-$GCC_VERSION
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
cmake $SOURCE_DIR \
|
# common tasks after either build or test
|
||||||
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
|
function finish ()
|
||||||
-DGTSAM_BUILD_TESTS=$GTSAM_BUILD_TESTS \
|
{
|
||||||
-DGTSAM_BUILD_UNSTABLE=$GTSAM_BUILD_UNSTABLE \
|
|
||||||
-DGTSAM_BUILD_EXAMPLES_ALWAYS=$GTSAM_BUILD_EXAMPLES_ALWAYS \
|
|
||||||
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=$GTSAM_ALLOW_DEPRECATED_SINCE_V4
|
|
||||||
|
|
||||||
# Actual build:
|
|
||||||
make -j2
|
|
||||||
|
|
||||||
# Run tests:
|
|
||||||
if [ "$GTSAM_BUILD_TESTS" == "ON" ]; then
|
|
||||||
make check
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Print ccache stats
|
# Print ccache stats
|
||||||
ccache -s
|
ccache -s
|
||||||
|
|
||||||
cd $SOURCE_DIR
|
cd $SOURCE_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
build_and_test
|
# compile the code with the intent of populating the cache
|
||||||
|
function build ()
|
||||||
|
{
|
||||||
|
prepare
|
||||||
|
|
||||||
|
cmake $SOURCE_DIR \
|
||||||
|
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
|
||||||
|
-DGTSAM_BUILD_TESTS=OFF \
|
||||||
|
-DGTSAM_BUILD_UNSTABLE=ON \
|
||||||
|
-DGTSAM_BUILD_EXAMPLES_ALWAYS=ON \
|
||||||
|
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=$GTSAM_ALLOW_DEPRECATED_SINCE_V4
|
||||||
|
|
||||||
|
# Actual build:
|
||||||
|
make -j2
|
||||||
|
|
||||||
|
finish
|
||||||
|
}
|
||||||
|
|
||||||
|
# run the tests
|
||||||
|
function test ()
|
||||||
|
{
|
||||||
|
prepare
|
||||||
|
|
||||||
|
cmake $SOURCE_DIR \
|
||||||
|
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
|
||||||
|
-DGTSAM_BUILD_TESTS=ON \
|
||||||
|
-DGTSAM_BUILD_UNSTABLE=ON \
|
||||||
|
-DGTSAM_BUILD_EXAMPLES_ALWAYS=OFF \
|
||||||
|
-DGTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
|
||||||
|
|
||||||
|
# Actual build:
|
||||||
|
make -j2 check
|
||||||
|
|
||||||
|
finish
|
||||||
|
}
|
||||||
|
|
||||||
|
# select between build or test
|
||||||
|
case $1 in
|
||||||
|
-b)
|
||||||
|
build
|
||||||
|
;;
|
||||||
|
-t)
|
||||||
|
test
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
35
.travis.yml
35
.travis.yml
|
@ -23,9 +23,6 @@ install:
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache ; fi
|
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache ; fi
|
||||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PATH="/usr/local/opt/ccache/libexec:$PATH" ; fi
|
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PATH="/usr/local/opt/ccache/libexec:$PATH" ; fi
|
||||||
|
|
||||||
script:
|
|
||||||
- bash .travis.sh
|
|
||||||
|
|
||||||
# We first do the compile stage specified below, then the matrix expansion specified after.
|
# We first do the compile stage specified below, then the matrix expansion specified after.
|
||||||
stages:
|
stages:
|
||||||
- compile
|
- compile
|
||||||
|
@ -38,43 +35,52 @@ jobs:
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: osx
|
os: osx
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Debug
|
||||||
|
script: bash .travis.sh -b
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: osx
|
os: osx
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: CMAKE_BUILD_TYPE=Release GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Release
|
||||||
|
script: bash .travis.sh -b
|
||||||
# on Mac, CLANG
|
# on Mac, CLANG
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: osx
|
os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Debug
|
||||||
|
script: bash .travis.sh -b
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: osx
|
os: osx
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: CMAKE_BUILD_TYPE=Release GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Release
|
||||||
|
script: bash .travis.sh -b
|
||||||
# on Linux, GCC
|
# on Linux, GCC
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: linux
|
os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Debug
|
||||||
|
script: bash .travis.sh -b
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: linux
|
os: linux
|
||||||
compiler: gcc
|
compiler: gcc
|
||||||
env: CMAKE_BUILD_TYPE=Release GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Release
|
||||||
|
script: bash .travis.sh -b
|
||||||
# on Linux, CLANG
|
# on Linux, CLANG
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: linux
|
os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: CMAKE_BUILD_TYPE=Debug GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Debug
|
||||||
|
script: bash .travis.sh -b
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: linux
|
os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: CMAKE_BUILD_TYPE=Release GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Release
|
||||||
|
script: bash .travis.sh -b
|
||||||
# on Linux, with deprecated ON to make sure that path still compiles
|
# on Linux, with deprecated ON to make sure that path still compiles
|
||||||
- stage: compile
|
- stage: compile
|
||||||
os: linux
|
os: linux
|
||||||
compiler: clang
|
compiler: clang
|
||||||
env: GTSAM_ALLOW_DEPRECATED_SINCE_V4=ON GTSAM_BUILD_TESTS=OFF GTSAM_BUILD_EXAMPLES_ALWAYS=ON
|
env: CMAKE_BUILD_TYPE=Debug GTSAM_ALLOW_DEPRECATED_SINCE_V4=ON
|
||||||
|
script: bash .travis.sh -b
|
||||||
|
|
||||||
# Matrix configuration:
|
# Matrix configuration:
|
||||||
os:
|
os:
|
||||||
|
@ -87,13 +93,12 @@ env:
|
||||||
global:
|
global:
|
||||||
- MAKEFLAGS="-j2"
|
- MAKEFLAGS="-j2"
|
||||||
- CCACHE_SLOPPINESS=pch_defines,time_macros
|
- CCACHE_SLOPPINESS=pch_defines,time_macros
|
||||||
- GTSAM_BUILD_UNSTABLE=ON
|
|
||||||
- GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
|
- GTSAM_ALLOW_DEPRECATED_SINCE_V4=OFF
|
||||||
- GTSAM_BUILD_EXAMPLES_ALWAYS=OFF
|
|
||||||
- GTSAM_BUILD_TESTS=ON
|
|
||||||
matrix:
|
matrix:
|
||||||
- CMAKE_BUILD_TYPE=Debug
|
- CMAKE_BUILD_TYPE=Debug
|
||||||
- CMAKE_BUILD_TYPE=Release
|
- CMAKE_BUILD_TYPE=Release
|
||||||
|
script:
|
||||||
|
- bash .travis.sh -t
|
||||||
|
|
||||||
# Uncomment this if you want to exclude clang on linux
|
# Uncomment this if you want to exclude clang on linux
|
||||||
# matrix:
|
# matrix:
|
||||||
|
|
Loading…
Reference in New Issue