language: cpp
sudo: required

script:
 - "bash -ex .travis-ci.sh"

addons:
  apt:
    packages: &base_pkg
      #base packages for all builds
      - gdb
      - libasound2-dev 
      - libusb-dev 
      - libftdi-dev 
      - shared-mime-info 
      - libudev-dev 
      - libmad0-dev 
      - libsndfile1-dev 
      - liblo-dev
      - libfftw3-dev
 # Needed for `xmllint`
      - libxml2-utils
    packages: &qt5_pkg
      - *base_pkg
      - qt56-meta-minimal
      - qt56script
      - qt56multimedia
      - qt56serialport
      - g++-7
    packages: &qmlui_pkg
      - *base_pkg
      - libpulse-dev
      - qt510-meta-minimal
      - qt510declarative
      - qt510quickcontrols2
      - qt5103d
      - qt510svg
      - qt510multimedia
      - qt510serialport
      - g++-7

matrix:
  fast_finish: true
  include:
    - os: linux
      dist: trusty
      compiler: gcc
      env: TASK='compile' QT='qt5'
      addons:
        apt:
          sources:
           - ubuntu-toolchain-r-test
           - sourceline: 'ppa:beineri/opt-qt562-trusty'
          packages:
           - *qt5_pkg
    - os: linux
      dist: trusty
      compiler: gcc
      env: TASK='compile' QT='qt5qml'
      addons:
        apt:
          sources:
           - ubuntu-toolchain-r-test
           - sourceline: 'ppa:beineri/opt-qt-5.10.1-trusty'
          packages:
           - *qmlui_pkg
    - os: linux
      dist: trusty
      compiler: gcc
      env: TASK='coverage' QT='qt5'
      addons:
        apt:
          sources:
           - ubuntu-toolchain-r-test
           - sourceline: 'ppa:beineri/opt-qt562-trusty'
          packages:
           - *qt5_pkg
           - lcov

cache:
  apt: true

before_install:
 - if [ "$QT" = "qt5" ]; then export QMAKE=/opt/qt56/bin/qmake; fi
 - if [ "$QT" = "qt5qml" ]; then export QMAKE=/opt/qt510/bin/qmake; fi
 - if [ "$TASK" = "coverage" ]; then gem install coveralls-lcov; fi
#Report the qmake version
 - $QMAKE -v
#Remove the old g++/gcc to ensure we're using the latest ones
 - if [ "$CXX" = "g++" ]; then sudo rm /usr/bin/gcc; sudo ln -s /usr/bin/gcc-7 /usr/bin/gcc; fi
 - if [ "$CXX" = "g++" ]; then sudo rm /usr/bin/g++; sudo ln -s /usr/bin/g++-7 /usr/bin/g++; export CXX="g++-7" CC="gcc-7"; fi
#Report the compiler version
 - $CXX --version
 # Start xvfb so UI tests don't fail
 - "export DISPLAY=:99.0"
 - "sh -e /etc/init.d/xvfb start"

after_success:
 - if [ "$TASK" = "coverage" ]; then coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage/coverage.info; fi
