# Copyright 2016, 2017 Peter Dimov
# Copyright 2019 Andrey Semashev
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)

language: cpp

sudo: false

python: "2.7"

branches:
  only:
    - master
    - develop
    - /feature\/.*/

env:
  matrix:
    - BOGUS_JOB=true

matrix:

  exclude:
    - env: BOGUS_JOB=true

  include:
# gcc, Linux
    - os: linux
      dist: trusty
      compiler: gcc-4.4
      env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
      addons:
        apt:
          packages:
            - g++-4.4
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: trusty
      compiler: gcc-4.6
      env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
      addons:
        apt:
          packages:
            - g++-4.6
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: trusty
      compiler: gcc-4.7
      env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-4.7
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      compiler: gcc-4.8
      env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-4.8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      compiler: gcc-4.9
      env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
      addons:
        apt:
          packages:
            - g++-4.9
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      compiler: gcc-5
      env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - g++-5
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      compiler: gcc-6
      env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - g++-6
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      compiler: gcc-7
      env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
      addons:
        apt:
          packages:
            - g++-7
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: xenial
      compiler: gcc-8
      env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
      addons:
        apt:
          packages:
            - g++-8
          sources:
            - ubuntu-toolchain-r-test

    - os: linux
      dist: bionic
      compiler: gcc-9
      env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
      addons:
        apt:
          packages:
            - g++-9
          sources:
            - sourceline: "ppa:ubuntu-toolchain-r/test"

# clang, Linux
    - os: linux
      dist: trusty
      compiler: clang-3.5
      env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
      addons:
        apt:
          packages:
            - clang-3.5
            - libstdc++-4.9-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.5 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: trusty
      compiler: clang-3.6
      env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - clang-3.6
            - libstdc++-5-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.6 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: trusty
      compiler: clang-3.7
      env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - clang-3.7
            - libstdc++-5-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.7 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-3.8
      env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - clang-3.8
            - libstdc++-6-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.8 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-3.9
      env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - clang-3.9
            - libstdc++-6-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-4
      env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - clang-4.0
            - libstdc++-6-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-5
      env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
      addons:
        apt:
          packages:
            - clang-5.0
            - libstdc++-7-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-6
      env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
      addons:
        apt:
          packages:
            - clang-6.0
            - libstdc++-8-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-7
      env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
      addons:
        apt:
          packages:
            - clang-7
            - libstdc++-8-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-8
      env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
      addons:
        apt:
          packages:
            - clang-8
            - libstdc++-8-dev
          sources:
            - ubuntu-toolchain-r-test
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-9
      env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
      addons:
        apt:
          packages:
            - clang-9
            - libstdc++-9-dev
          sources:
            - sourceline: "ppa:ubuntu-toolchain-r/test"
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

    - os: linux
      dist: xenial
      compiler: clang-libc++
      env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a CXXFLAGS="-stdlib=libc++" LINKFLAGS="-stdlib=libc++"
      addons:
        apt:
          packages:
            - clang-9
            - libc++-9-dev
            - libc++abi-9-dev
          sources:
            - sourceline: "ppa:ubuntu-toolchain-r/test"
            - sourceline: "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main"
              key_url: "https://apt.llvm.org/llvm-snapshot.gpg.key"

# clang, OS X
# OS X builds are slow on Travis CI
#    - os: osx
#      env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
#      osx_image: xcode9.4
#
#    - os: osx
#      env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
#      osx_image: xcode10.3

    - os: osx
      env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17
      osx_image: xcode11.2

install:
  - GIT_FETCH_JOBS=8
  - BOOST_BRANCH=develop
  - if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
  - cd ..
  - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
  - cd boost-root
  - git submodule init tools/build
  - git submodule init tools/boost_install
  - git submodule init libs/headers
  - git submodule init libs/assert
  - git submodule init libs/config
  - git submodule init libs/core
  - git submodule init libs/io
  - git submodule init libs/preprocessor
  - git submodule init libs/static_assert
  - git submodule init libs/throw_exception
  - git submodule init libs/type_traits
  - git submodule init libs/container_hash
  - git submodule init libs/integer
  - git submodule init libs/detail
  - git submodule update --jobs $GIT_FETCH_JOBS
  - cp -r $TRAVIS_BUILD_DIR/* libs/utility
  - ./bootstrap.sh
  - ./b2 headers

script:
  - |-
    echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
  - BUILD_JOBS=`(nproc || sysctl -n hw.ncpu) 2> /dev/null`
  - ./b2 -j $BUILD_JOBS libs/utility/test toolset=$TOOLSET cxxstd=$CXXSTD ${CXXFLAGS:+cxxflags="$CXXFLAGS"} ${LINKFLAGS:+linkflags="$LINKFLAGS"}

notifications:
  email:
    on_success: always
