language: c
matrix:
  include:
    - os: linux
      dist: xenial
    - os: linux
      dist: trusty
      env:
        - BUILD_ANDROID=true
    - os: osx
sudo: required
install:
  - >
    if [[ "${TRAVIS_OS_NAME}" == "linux" && -z "${BUILD_ANDROID}" ]]; then
      # Install pulseaudio, portaudio, ALSA, JACK dependencies for
      # corresponding backends.
      # Install Qt5 dependency for alsoft-config.
      sudo apt-get install -qq \
        libpulse-dev \
        portaudio19-dev \
        libasound2-dev \
        libjack-dev \
        qtbase5-dev
    fi
  - >
    if [[ "${TRAVIS_OS_NAME}" == "linux" && "${BUILD_ANDROID}" == "true" ]]; then
      curl -o ~/android-ndk.zip https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip
      unzip -q ~/android-ndk.zip -d ~ \
        'android-ndk-r16b/build/cmake/*' \
        'android-ndk-r16b/build/core/toolchains/arm-linux-androideabi-*/*' \
        'android-ndk-r16b/platforms/android-14/arch-arm/*' \
        'android-ndk-r16b/source.properties' \
        'android-ndk-r16b/sources/android/support/include/*' \
        'android-ndk-r16b/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/*' \
        'android-ndk-r16b/sources/cxx-stl/llvm-libc++/include/*' \
        'android-ndk-r16b/sysroot/*' \
        'android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/*' \
        'android-ndk-r16b/toolchains/llvm/prebuilt/linux-x86_64/*'
    fi
script:
  - >
    if [[ "${TRAVIS_OS_NAME}" == "linux" && -z "${BUILD_ANDROID}" ]]; then
      cmake \
        -DALSOFT_REQUIRE_ALSA=ON \
        -DALSOFT_REQUIRE_OSS=ON \
        -DALSOFT_REQUIRE_PORTAUDIO=ON \
        -DALSOFT_REQUIRE_PULSEAUDIO=ON \
        -DALSOFT_REQUIRE_JACK=ON \
        -DALSOFT_EMBED_HRTF_DATA=YES \
        .
    fi
  - >
    if [[ "${TRAVIS_OS_NAME}" == "linux" && "${BUILD_ANDROID}" == "true" ]]; then
      cmake \
        -DANDROID_STL=c++_shared \
        -DCMAKE_TOOLCHAIN_FILE=~/android-ndk-r16b/build/cmake/android.toolchain.cmake \
        -DALSOFT_REQUIRE_OPENSL=ON \
        -DALSOFT_EMBED_HRTF_DATA=YES \
        .
    fi
  - >
    if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
      cmake \
        -DALSOFT_REQUIRE_COREAUDIO=ON \
        -DALSOFT_EMBED_HRTF_DATA=YES \
        .
    fi
  - make -j2