language: cpp

sudo: enabled

compiler:
  - gcc

matrix:
  include:
    - os: linux
      name: Ubuntu 16.04
      dist: xenial
      env:
      - BADGE=Ubuntu_16.04
      - MAKE=make
    - os: linux
      name: Ubuntu 18.04
      dist: bionic
      env:
      - BADGE=Ubuntu_18.04
      - MAKE=make
      - TESTMCX=1
    - os: linux
      name: Ubuntu 20.04
      dist: focal
      env:
      - BADGE=Ubuntu_20.04
      - MAKE=make
      - TESTMCX=1
    - os: linux
      name: Ubuntu 22.04
      dist: jammy
      env:
      - BADGE=Ubuntu_22.04
      - MAKE=make
      - TESTMCX=1
    - os: windows
      name: Windows
      env:
      - BADGE=Windows
      - MAKE=mingw32-make
    - os: osx
      name: OSX
      env:
      - BADGE=OSX
      - MAKE=make

before_install:
  - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install ocl-icd-libopencl1 opencl-headers ocl-icd-opencl-dev liboctave-dev; fi
  - if [ "$TESTMCX" = "1" ]; then sudo apt-get install libpocl2 pocl-opencl-icd valgrind; fi
  - if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install opencl-intel-cpu-runtime; fi

addons:
  apt:
    packages:
    - ocl-icd-libopencl1
    - opencl-headers
    - ocl-icd-opencl-dev
    - liboctave-dev
    update: true

script:
    - if [ "$TRAVIS_OS_NAME" = "linux" ]; then ${MAKE} -C src oct; fi
    - if [ "$TRAVIS_OS_NAME" = "linux" ]; then ${MAKE} -C src clean; fi
    - ${MAKE} -C src
    - if [ "$TRAVIS_OS_NAME" = "osx" ] || [ "$TESTMCX" = "1" ]; then cd test && ./testmcx.sh -n 1e5; fi
