os:
  - linux
  - osx
dist:
  - trusty
language: cpp
compiler:
  - gcc
  - clang
env:
  matrix:
    - ARGS=""
  global:
    - CTEST_OUTPUT_ON_FAILURE=1
    - TESTARGS="-DMYSQL_TESTING=on -DPSQL_TESTING=ON -DMYSQL_USER=root -DPSQL_USER=postgres -DPSQL_PASSWORD= -DODBC_TESTING=ON -DODBC_DSN=ODBCTest" 
before_script:
  - if [ -f /usr/share/libmyodbc/odbcinst.ini ] ; then cp /usr/share/libmyodbc/odbcinst.ini ~/.odbcinst.ini ; fi
  - cp tests/odbc.ini ~/.odbc.ini
  - if [ $TRAVIS_OS_NAME = linux ] ; then if [ $CC = clang ] ; then export CXX=clang++-5.0 ; export CC=clang-5.0 ; else export CXX=g++-7 ; export CC=gcc-7 ; fi ; fi
  - if [ $TRAVIS_OS_NAME = linux ] ; then psql -c 'create database smsd;' -U postgres ; fi
  - if [ $TRAVIS_OS_NAME = linux ] ; then mysql -uroot -e "create database smsd;" ; fi
  - if [ $TRAVIS_OS_NAME = linux ] ; then mysql -uroot -e "SET PASSWORD = PASSWORD('smsd')" ; fi
  - if [ $TRAVIS_OS_NAME != linux ] ; then export TESTARGS= ; fi
  - mkdir _build
  - cd _build
  - ln -s ../codecov.yml .
script:
  - cmake .. -DCMAKE_C_COMPILER=$CC -DENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Continuous -DONLINE_TESTING=ON $TESTARGS $ARGS
  - make || travis_terminate 1
  - make test
after_success:
  - make gcov
  - bash <(curl -s https://codecov.io/bash) -X gcov -F $TRAVIS_OS_NAME
# use docker based faster build
sudo: false
# install build dependencies and enable Coverity scan
addons:
  apt:
    sources:
      - llvm-toolchain-trusty-5.0 # llvm 5.0
      - ubuntu-toolchain-r-test # gcc backports
    packages:
    - libbluetooth-dev
    - libusb-1.0-0-dev
    - libgudev-1.0-dev
    - unixodbc-dev
    - libdbi-dev
    - libdbd-sqlite3
    - libdbd-mysql
    - libdbd-pgsql
    - cmake
    - cmake-data
    - clang-5.0
    - llvm-5.0
    - gcc-7
    - g++-7
    - libmyodbc
matrix:
  exclude:
    - os: osx
      compiler: gcc
  include:
    - os: linux
      compiler: gcc
      env: ARGS="-DENABLE_GETOPT=OFF"
    - os: linux
      compiler: gcc
      env: ARGS="-DUSE_WCHAR_T=OFF"
services:
  - mysql
  - postgresql
