language: cpp
dist: bionic

os:
  - linux
  - osx

env:
  - variant=debug
  - variant=release

branches:
  only:
    - master

# container-based builds
sudo: false
cache:
  directories:
    - $HOME/.ccache

# sources  list: https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json,
# packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise
addons:
  apt:
    sources:
    - sourceline: ppa:mhier/libboost-latest
    - ubuntu-toolchain-r-test
    packages:
    - libboost1.68-dev
    - g++-8
    - cmake

install:

  - 'if [[ $TRAVIS_OS_NAME != "osx" ]]; then
      export B2=bjam;
    else
      export B2=b2;
    fi'

  # on linux, pull down a recent version of boost and build boost-build
  - 'if [[ $TRAVIS_OS_NAME == "linux" ]]; then
    cd ..;
    wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.zip;
    unzip -qq boost_1_68_0.zip;
    export BOOST_ROOT=$PWD/boost_1_68_0;
    (cd boost_1_68_0/tools/build/src/engine; ./build.sh);
    export BOOST_BUILD_PATH=$BOOST_ROOT/tools/build;
    export PATH=$BOOST_BUILD_PATH/src/engine/bin.linuxx86_64:$PATH;
    cd libsimulator;
    fi'

  - 'if [ $TRAVIS_OS_NAME == "linux" ]; then echo "using gcc : : ccache g++-8 ;" > ~/user-config.jam; export CXX="g++-8" ; fi'
  - 'if [ $TRAVIS_OS_NAME == "osx" ]; then echo "using darwin : : ccache clang++ : <cxxflags>-std=c++14 <compileflags>-Wno-deprecated-declarations ;" > ~/user-config.jam; fi'
  - if [ $TRAVIS_OS_NAME == "osx" ]; then brew update > /dev/null && brew install ccache boost-build && brew upgrade cmake ; fi
  - ccache -V && ccache --show-stats && ccache --zero-stats

script:
# until we have a version of boost-build that's new enough, disable warnings
# as errors
  - ${B2} --hash -j3 variant=$variant -l900 warnings-as-errors=off
  - mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=$variant .. && make -j3 && make test
  - ccache --show-stats

