########################################################################
## Travis CI config for SoapyRTLSDR
##
## * installs rtl-sdr from PPA
## * installs SoapySDR from source
## * confirms build and install
## * checks that drivers load
########################################################################

sudo: required
dist: trusty

language: cpp
compiler: gcc

env:
  global:
    - INSTALL_PREFIX=/usr/local
    - SOAPY_SDR_BRANCH=master
  matrix:
    - BUILD_TYPE=Debug
    - BUILD_TYPE=Release

before_install:
  # regular ubuntu packages
  - sudo add-apt-repository main
  - sudo add-apt-repository universe

  # driver development files from ppa
  - sudo add-apt-repository -y ppa:myriadrf/drivers

  # update after package changes
  - sudo apt-get update

install:
  #sdr development files
  - sudo apt-get install --no-install-recommends -q -y librtlsdr-dev

  # install SoapySDR from source
  - git clone https://github.com/pothosware/SoapySDR.git
  - pushd SoapySDR
  - git checkout ${SOAPY_SDR_BRANCH}
  - mkdir build && cd build
  - cmake ../ -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_PYTHON=OFF -DENABLE_PYTHON3=OFF
  - make && sudo make install
  - popd

script:
  - mkdir build && cd build
  - cmake ../ -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
  - make && sudo make install
  # print info about the install
  - export LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib:${LD_LIBRARY_PATH}
  - export PATH=${INSTALL_PREFIX}/bin:${PATH}
  - SoapySDRUtil --info
  - SoapySDRUtil --check=rtlsdr
