# Copyright (c) 2012-2019 Sebastien Rombauts (sebastien.rombauts@gmail.com)

# request for Ubuntu 14.04 Trusty VM
sudo: true
dist: trusty

cache:
  apt: true

# NOTE: no language, so that we can set CXX and CC env vars as required
#language: cpp

matrix:
  include:
    # gcc default (4.8)
    - compiler: gcc
      env:
        - CC=gcc
        - CXX=g++
        - CXXFLAGS="-Wall -Wextra -pedantic"
    # gcc 4.9 std=default
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-4.9
      env:
        - CC=gcc-4.9
        - CXX=g++-4.9
        - CXXFLAGS="-Wall -Wextra -pedantic"
    # gcc 5 std=c++03
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
        - CC=gcc-5
        - CXX=g++-5
        - CXXFLAGS="-std=c++03 -Wall -Wextra -pedantic"
    # gcc 5 std=c++11
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
        - CC=gcc-5
        - CXX=g++-5
        - CXXFLAGS="-std=c++11 -Wall -Wextra -pedantic"
    # gcc 5 default
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
        - CC=gcc-5
        - CXX=g++-5
        - CXXFLAGS="-Wall -Wextra -pedantic"
    # gcc 5 std=c++11
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
        - CC=gcc-5
        - CXX=g++-5
        - CXXFLAGS="-std=c++11 -Wall -Wextra -pedantic"
    # gcc 5 std=c++14
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
        - CC=gcc-5
        - CXX=g++-5
        - CXXFLAGS="-std=c++14 -Wall -Wextra -pedantic"
    # gcc 5 std=c++1z
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-5
      env:
        - CC=gcc-5
        - CXX=g++-5
        - CXXFLAGS="-std=c++1z -Wall -Wextra -pedantic"
    # gcc 6.5 std=c++14 (default standard)
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-6
      env:
        - CC=gcc-6
        - CXX=g++-6
        - CXXFLAGS="-std=c++14 -Wall -Wextra -pedantic"
    # gcc 6.5 std=c++1z
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-6
      env:
        - CC=gcc-6
        - CXX=g++-6
        - CXXFLAGS="-std=c++1z -Wall -Wextra -pedantic"
    # gcc 7.4 std=c++14 (default standard)
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env:
        - CC=gcc-7
        - CXX=g++-7
        - CXXFLAGS="-std=c++14 -Wall -Wextra -pedantic"
    # gcc 7.4 std=c++17
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env:
        - CC=gcc-7
        - CXX=g++-7
        - CXXFLAGS="-std=c++17 -Wall -Wextra -pedantic"
    # gcc 8 std=c++14 (default standard)
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-8
      env:
        - CC=gcc-8
        - CXX=g++-8
        - CXXFLAGS="-std=c++14 -Wall -Wextra -pedantic"
    # gcc 8 std=c++17
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-8
      env:
        - CC=gcc-8
        - CXX=g++-8
        - CXXFLAGS="-std=c++17 -Wall -Wextra -pedantic"
    # gcc 8 std=c++2a
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-8
      env:
        - CC=gcc-8
        - CXX=g++-8
        - CXXFLAGS="-std=c++2a -Wall -Wextra -pedantic"
    # gcc 9 std=c++14 (default standard)
    - compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-9
      env:
        - CC=gcc-9
        - CXX=g++-9
        - CXXFLAGS="-std=c++14 -Wall -Wextra -pedantic"
# TODO: issue with ExecuteMany and Bind helper function
#    # gcc 9 std=c++17
#    - compiler: gcc
#      addons:
#        apt:
#          sources:
#            - ubuntu-toolchain-r-test
#          packages:
#            - g++-9
#      env:
#        - CC=gcc-9
#        - CXX=g++-9
#        - CXXFLAGS="-std=c++17 -Wall -Wextra -pedantic"
#    # gcc 9 std=c++2a
#    - compiler: gcc
#      addons:
#        apt:
#          sources:
#            - ubuntu-toolchain-r-test
#          packages:
#            - g++-9
#      env:
#        - CC=gcc-9
#        - CXX=g++-9
#        - CXXFLAGS="-std=c++2a -Wall -Wextra -pedantic"
    # clang default
    - compiler: clang
      env:
        - CC=clang
        - CXX=clang++
    # os x
    - compiler: clang
      os: osx
      env:
        - CC=clang
        - CXX=clang
        - CXXFLAGS=-lstdc++

before_install:
  # coveralls test coverage:
  - if [[ "$CXX" == "g++" ]]; then pip install --user cpp-coveralls ; fi

# scripts to run before build
before_script:
  - mkdir build
  - cd build
  - cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..

# build examples, and run tests (ie make & make test)
script:
  - cmake --build .
  - ctest --verbose --output-on-failure

# generate and publish GCov coveralls results
after_success:
  - if [[ "$CXX" == "g++" ]]; then coveralls --root .. -e examples -e googletest -e sqlite3 -e tests -E ".*feature_tests.*" -E ".*CompilerId.*" --gcov-options '\-lp' ; fi
