language: cpp

git:
  depth: 10

# sudo:required is needed for trusty images
sudo: required
dist: trusty

notifications:
  email: false

branches:
  only:
    - master
    # enable building tags
    - /^v\d+\.\d+(\.\d+)?(-\S*)?$/

cache:
  npm: true
  ccache: true
  apt: true
  directories:
    - test/cache

env:
  global:
   - secure: "hk+32aXXF5t1ApaM2Wjqooz3dx1si907L87WRMkO47WlpJmUUU/Ye+MJk9sViH8MdhOcceocVAmdYl5/WFWOIbDWNlBya9QvXDZyIu2KIre/0QyOCTZbrsif8paBXKIO5O/R4OTvIZ8rvWZsadBdmAT9GSbDhih6FzqXAEgeIYQ="
   - secure: "VE+cFkseFwW4jK6XwkP0yW3h4DixPJ8+Eb3yKcchGZ5iIJxlZ/8i1vKHYxadgPRwSYwPSB14tF70xj2OmiT2keGzZUfphmPXinBaLEhYk+Bde+GZZkoSl5ND109I/LcyNr0nG9dDgtV6pkvFchgchpyP9JnVOOS0+crEZlAz0RE="
   - CCACHE_TEMPDIR=/tmp/.ccache-temp
   - CCACHE_COMPRESS=1
   - CASHER_TIME_OUT=599 # one second less than 10m to avoid 10m timeout error: https://github.com/Project-OSRM/osrm-backend/issues/2742
   - CCACHE_VERSION=3.3.1
   - CMAKE_VERSION=3.7.2
   - MASON="$(pwd)/scripts/mason.sh"
   - ENABLE_NODE_BINDINGS=On
   - NODE="10"

stages:
  - core
  - optional

matrix:
  fast_finish: true

  # We override the compiler names here to yield better ccache behavior, which uses this as key
  include:

    # Debug Builds
    - stage: core
      os: linux
      compiler: "format-taginfo-docs"
      env: NODE=10
      sudo: false
      before_install:
      install:
        - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
        - source $NVM_DIR/nvm.sh
        - nvm install $NODE
        - nvm use $NODE
        - npm --version
        - npm ci --ignore-scripts
      script:
        - ./scripts/check_taginfo.py taginfo.json profiles/car.lua
        - ${MASON} install clang-format 3.8.1
        - PATH=$(${MASON} prefix clang-format 3.8.1)/bin:${PATH} ./scripts/format.sh && ./scripts/error_on_dirty.sh
        - node ./scripts/validate_changelog.js
        # See issue 4043
        #- npm run docs && ./scripts/error_on_dirty.sh
      after_success:

    - os: linux
      compiler: "gcc-7-debug-cov"
      addons: &gcc7
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-7', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev', 'lcov']
      env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Debug' ENABLE_COVERAGE=ON CUCUMBER_TIMEOUT=20000
      before_script:
        - cd ${TRAVIS_BUILD_DIR}
        - lcov --directory . --zerocounters # clean cached da files
      after_success:
        # Creating report
        - cd ${TRAVIS_BUILD_DIR}
        - lcov --directory . --capture --output-file coverage.info # capture coverage info
        - lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter out system
        - lcov --list coverage.info #debug info
        # Uploading report to CodeCov
        - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"

    - os: linux
      compiler: "gcc-7-debug-asan"
      addons: &gcc7
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-7', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
      env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Debug' TARGET_ARCH='x86_64-asan' ENABLE_SANITIZER=ON CUCUMBER_TIMEOUT=20000 LSAN_OPTIONS="suppressions=$TRAVIS_BUILD_DIR/scripts/travis/leaksanitizer.conf"

    - os: linux
      compiler: "clang-5.0-debug"
      addons: &clang50
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-5-dev', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' CUCUMBER_TIMEOUT=60000

    - os: linux
      compiler: "mason-linux-debug-asan"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_SANITIZER=ON LSAN_OPTIONS="suppressions=$TRAVIS_BUILD_DIR/scripts/travis/leaksanitizer.conf"

    # Release Builds
    - os: linux
      compiler: "mason-linux-release"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON RUN_CLANG_FORMAT=ON ENABLE_LTO=ON

    - os: linux
      compiler: "gcc-9-release"
      addons: &gcc9
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-9', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
      env: CCOMPILER='gcc-9' CXXCOMPILER='g++-9' BUILD_TYPE='Release' CXXFLAGS='-Wno-cast-function-type'

    - os: linux
      compiler: "gcc-8-release"
      addons: &gcc8
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-8', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
      env: CCOMPILER='gcc-8' CXXCOMPILER='g++-8' BUILD_TYPE='Release' CXXFLAGS='-Wno-cast-function-type'

    - os: linux
      compiler: "gcc-7-release"
      addons: &gcc7
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-7', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
      env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release'

    - os: linux
      compiler: "gcc-7-release-i686"
      env: >
        TARGET_ARCH='i686' CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release'
        CFLAGS='-m32 -msse2 -mfpmath=sse' CXXFLAGS='-m32 -msse2 -mfpmath=sse'

    - os: linux
      compiler: "gcc-5-release"
      addons: &gcc49
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-5', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev', 'ccache']
      env: CCOMPILER='gcc-5' CXXCOMPILER='g++-5' BUILD_TYPE='Release'

    - os: linux
      compiler: "gcc-6-release"
      addons: &gcc49
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-6', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev', 'ccache']
      env: CCOMPILER='gcc-6' CXXCOMPILER='g++-6' BUILD_TYPE='Release'

    - os: osx
      osx_image: xcode9.2
      compiler: "mason-osx-release-node-10"
      # we use the xcode provides clang and don't install our own
      env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="10"
      after_success:
        - ./scripts/travis/publish.sh

    - os: osx
      osx_image: xcode9.2
      compiler: "mason-osx-release-node-8"
      # we use the xcode provides clang and don't install our own
      env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="8"
      after_success:
        - ./scripts/travis/publish.sh

    # Shared Library
    - os: linux
      compiler: "gcc-7-release-shared"
      addons: &gcc7
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['g++-7', 'libbz2-dev', 'libxml2-dev', 'libzip-dev', 'liblua5.2-dev', 'libtbb-dev', 'libboost-all-dev']
      env: CCOMPILER='gcc-7' CXXCOMPILER='g++-7' BUILD_TYPE='Release' BUILD_SHARED_LIBS=ON

    # Node build jobs. These skip running the tests.
    - os: linux
      sudo: false
      compiler: "node-8-mason-linux-release"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="8"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-8-mason-linux-debug"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="8"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-10-mason-linux-release"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="10"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-10-mason-linux-debug"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="10"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: osx
      stage: optional
      osx_image: xcode9.2
      compiler: "mason-osx-release-node-latest"
      # we use the xcode provides clang and don't install our own
      env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="node"
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-latest-mason-linux-release"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-latest-mason-linux-debug"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: osx
      osx_image: xcode9.2
      compiler: "mason-osx-release-node-lts"
      # we use the xcode provides clang and don't install our own
      env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="--lts"
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-lts-mason-linux-release"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

    - os: linux
      sudo: false
      compiler: "node-lts-mason-linux-debug"
      addons:
        apt:
          sources: ['ubuntu-toolchain-r-test']
          packages: ['libstdc++-4.9-dev']
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
      install:
        - pushd ${OSRM_BUILD_DIR}
        - |
          cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
              -DENABLE_MASON=${ENABLE_MASON:-OFF} \
              -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
              -DENABLE_CCACHE=ON \
              -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
              -DENABLE_GLIBC_WORKAROUND=ON
        - make --jobs=${JOBS}
        - popd
      script:
        - npm run nodejs-tests
      after_success:
        - ./scripts/travis/publish.sh

  allow_failures:
    - compiler: "mason-osx-release-node-latest"
      env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="node"
    - compiler: "node-latest-mason-linux-release"
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
    - compiler: "node-latest-mason-linux-debug"
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="node"
    - compiler: "mason-osx-release-node-lts"
      env: ENABLE_MASON=ON BUILD_TYPE='Release' CUCUMBER_TIMEOUT=60000 CCOMPILER='clang' CXXCOMPILER='clang++' ENABLE_ASSERTIONS=ON ENABLE_LTO=ON NODE="--lts"
    - compiler: "node-lts-mason-linux-release"
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Release' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"
    - compiler: "node-lts-mason-linux-debug"
      env: CLANG_VERSION='5.0.0' BUILD_TYPE='Debug' ENABLE_MASON=ON ENABLE_LTO=ON JOBS=3 NODE="--lts"

before_install:
  - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
  - source $NVM_DIR/nvm.sh
  - nvm install $NODE
  - nvm use $NODE
  - node --version
  - if [[ ! -z $TARGET_ARCH ]] ; then source ./scripts/travis/before_install.$TARGET_ARCH.sh ; fi
  - |
    if [[ -z $JOBS ]]; then
      if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
        export JOBS=$((`nproc` + 1))
      elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
        export JOBS=$((`sysctl -n hw.ncpu` + 1))
      fi
    fi
  - |
    if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
      sudo mdutil -i off /
    fi
  - export PACKAGE_JSON_VERSION=$(node -e "console.log(require('./package.json').version)")
  - export PUBLISH=$([[ "${TRAVIS_TAG:-}" == "v${PACKAGE_JSON_VERSION}" ]] && echo "On" || echo "Off")
  - echo "Using ${JOBS} jobs"
  - npm ci --ignore-scripts
    # Bootstrap cmake to be able to run mason
  - CMAKE_URL="https://mason-binaries.s3.amazonaws.com/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}.tar.gz"
  - CMAKE_DIR="mason_packages/${TRAVIS_OS_NAME}-x86_64/cmake/${CMAKE_VERSION}"
  - mkdir -p ${CMAKE_DIR}
  - travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C ${CMAKE_DIR} || travis_terminate 1
  - export PATH=${CMAKE_DIR}/bin:${PATH}
  - ${MASON} install tbb 2017_U7 && export LD_LIBRARY_PATH=$(${MASON} prefix tbb 2017_U7)/lib/:${LD_LIBRARY_PATH}
  - ${MASON} install ccache ${CCACHE_VERSION} && export PATH=$(${MASON} prefix ccache ${CCACHE_VERSION})/bin:${PATH}
  - |
    if [[ ! -z ${CLANG_VERSION} ]]; then
      export CCOMPILER='clang'
      export CXXCOMPILER='clang++'
      ${MASON} install clang++ ${CLANG_VERSION} && export PATH=$(${MASON} prefix clang++ ${CLANG_VERSION})/bin:${PATH} || travis_terminate 1
      # we only enable lto for release builds
      # and therefore don't need to us ld.gold or llvm tools for linking
      # for debug builds
      if [[ ${BUILD_TYPE} == 'Release' ]]; then
        ${MASON} install binutils 2.27 && export PATH=$(${MASON} prefix binutils 2.27)/bin:${PATH} || travis_terminate 1
      fi
    fi
  - ccache --max-size=256M  # limiting the cache's size to roughly the previous job's object sizes
  - export OSRM_INSTALL_DIR="$(pwd)/install-osrm"
  - export OSRM_BUILD_DIR="$(pwd)/build-osrm"
  - export CC=${CCOMPILER} CXX=${CXXCOMPILER}
  - mkdir ${OSRM_BUILD_DIR}

install:
  - pushd ${OSRM_BUILD_DIR}
  - |
    cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
             -DENABLE_MASON=${ENABLE_MASON:-OFF} \
             -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS:-OFF} \
             -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-OFF} \
             -DENABLE_COVERAGE=${ENABLE_COVERAGE:-OFF} \
             -DENABLE_NODE_BINDINGS=${ENABLE_NODE_BINDINGS:-OFF} \
             -DENABLE_SANITIZER=${ENABLE_SANITIZER:-OFF} \
             -DBUILD_TOOLS=ON \
             -DENABLE_CCACHE=ON \
             -DCMAKE_INSTALL_PREFIX=${OSRM_INSTALL_DIR} \
             -DENABLE_GLIBC_WORKAROUND=${ENABLE_GLIBC_WORKAROUND:-OFF}
  - echo "travis_fold:start:MAKE"
  - make --jobs=${JOBS}
  - make tests --jobs=${JOBS}
  - make benchmarks --jobs=${JOBS}
  - echo "travis_fold:end:MAKE"
  - ccache -s
  - sudo make install
  - |
    if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${OSRM_INSTALL_DIR}/lib
    fi
  - popd
  - mkdir example/build && pushd example/build
  - export PKG_CONFIG_PATH=${OSRM_INSTALL_DIR}/lib/pkgconfig
  - cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
  - make --jobs=${JOBS}
  - popd

script:
  - if [[ $TARGET_ARCH == armhf ]] ; then echo "Skip tests for $TARGET_ARCH" && exit 0 ; fi
  - make -C test/data benchmark
  - ./example/build/osrm-example test/data/mld/monaco.osrm
  # All tests assume to be run from the build directory
  - pushd ${OSRM_BUILD_DIR}
  - ./unit_tests/library-tests
  - ./unit_tests/extractor-tests
  - ./unit_tests/contractor-tests
  - ./unit_tests/engine-tests
  - ./unit_tests/util-tests
  - ./unit_tests/server-tests
  - ./unit_tests/partitioner-tests
  - |
    if [ -z "${ENABLE_SANITIZER}" ] && [ "$TARGET_ARCH" != "i686" ]; then
      npm run nodejs-tests
    fi
  - |
  - popd
  - npm test