sudo: required
language: rust
rust:
  - stable
  - beta
  - nightly
os:
  - linux
  - osx
matrix:
  allow_failures:
    - rust: nightly
addons:
  apt:
    packages:
      - build-essential
before_install:
  # Without rustfmt, bindgen puts everything on one line and any warnings dump so many logs they break Travis
  # See https://github.com/rust-lang/rust-bindgen/issues/1600
  - rustup component add rustfmt
  - if [[ $TRAVIS_OS_NAME == 'linux' ]]; then ./.travis/install_linux.sh; fi
  - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew update; fi
  - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then brew install yasm; fi

script: |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    # Current Travis Ubuntu version uses libav which doesn't come with libswresample
    cargo build --verbose --no-default-features --features "avcodec avfilter avformat avresample swscale" &&
    cargo test  --verbose --no-default-features --features "avcodec avfilter avformat avresample swscale"
  else
    travis_wait cargo build --verbose --features "build"
    cargo test  --verbose --features "build"
  fi

after_failure:
  - find /usr -type f 2>/dev/null | grep -E 'lib(avcodec/version|avcodec/avcodec).h$' | xargs -I THEFILE -- sh -c 'echo "=== THEFILE ==="; cat THEFILE'
