language: cpp
branches:
  only:
    - master
    - coverity_scan
    - /openmw-.*$/
env:
  global:
   # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
   #   via the "travis encrypt" command using the project repo's public key
   - secure: "jybGzAdUbqt9vWR/GEnRd96BgAi/7Zd1+2HK68j/i/8+/1YH2XxLOy4Jv/DUBhBlJIkxs/Xv8dRcUlFOclZDHX1d/9Qnsqd3oUVkD7k1y7cTOWy9TBQaE/v/kZo3LpzA3xPwwthrb0BvqIbOfIELi5fS5s8ba85WFRg3AX70wWE="
addons:
  apt:
    sources:
      - sourceline: 'ppa:openmw/openmw'
      - ubuntu-toolchain-r-test
      - llvm-toolchain-trusty-7
    packages: [
      # Dev
      cmake, clang-7, clang-tools-7, gcc-8, g++-8,
      # Boost
      libboost-filesystem-dev, libboost-program-options-dev, libboost-system-dev,
      # FFmpeg
      libavcodec-dev, libavformat-dev, libavutil-dev, libswscale-dev,
      # Audio, Video and Misc. deps
      libsdl2-dev, libqt4-dev, libopenal-dev, libunshield-dev, libtinyxml-dev,
      # The other ones from OpenMW ppa
      libbullet-dev, libswresample-dev, libopenscenegraph-3.4-dev, libmygui-dev
    ]

  coverity_scan:
    project:
      name: "OpenMW/openmw"
      description: "<Your project description here>"
    notification_email: 720642+scrawl@users.noreply.github.com
    build_command_prepend: "cmake . -DBUILD_UNITTESTS=FALSE -DBUILD_OPENCS=FALSE -DBUILD_BSATOOL=FALSE -DBUILD_ESMTOOL=FALSE -DBUILD_LAUNCHER=FALSE -DBUILD_MWINIIMPORTER=FALSE -DBUILD_WIZARD=FALSE"
    build_command:   "make -j3"
    branch_pattern: coverity_scan
matrix:
  include:
    - name: OpenMW (all) on MacOS xcode9.4
      os: osx
      osx_image: xcode9.4
    - name: OpenMW (all) on Ubuntu Trusty GCC-8
      os: linux
      dist: trusty
      sudo: required
      env:
        - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
    - name: OpenMW (openmw) on Ubuntu Trusty Clang-7 with Static Analysis
      os: linux
      dist: trusty
      sudo: required
      env:
        - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
        - ANALYZE="scan-build-7 --use-cc clang-7 --use-c++ clang++-7"
        - BUILD_OPENMW_CS="OFF"
      compiler: clang
    - name: OpenMW (openmw-cs) on Ubuntu Trusty Clang-7 with Static Analysis
      os: linux
      dist: trusty
      sudo: required
      env:
      - MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
      - ANALYZE="scan-build-7 --use-cc clang-7 --use-c++ clang++-7"
      - BUILD_OPENMW="OFF"
      compiler: clang
#   allow_failures:
#    - name: OpenMW (openmw) on Ubuntu Trusty Clang-7 with Static Analysis

before_install:
    - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then eval "${MATRIX_EVAL}"; fi
    - ./CI/before_install.${TRAVIS_OS_NAME}.sh
before_script:
    - ./CI/before_script.${TRAVIS_OS_NAME}.sh
script:
 - cd ./build
 - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE} make -j3; fi
 - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then make package; fi
 - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./openmw_test_suite; fi
 - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then cd .. && ./CI/check_tabs.sh; fi
 - cd "${TRAVIS_BUILD_DIR}"
deploy:
 provider: script
 script: ./CI/deploy.osx.sh
 skip_cleanup: true
 on:
  branch: master
  condition: "$TRAVIS_EVENT_TYPE = cron && $TRAVIS_OS_NAME = osx"
  repo: OpenMW/openmw
notifications:
  email:
    recipients:
      - corrmage+travis-ci@gmail.com
    on_success: change
    on_failure: always
  irc:
    channels:
      - "chat.freenode.net#openmw"
    on_success: change
    on_failure: always
    use_notice: true