language: cpp
branches:
  only:
    - master
    - /openmw-.*$/
cache: ccache
addons:
  apt:
    sources:
      - sourceline: 'ppa:openmw/openmw'
    packages: [
      # Dev
      build-essential, cmake, clang-tools-9, ccache,
      # Boost
      libboost-filesystem-dev, libboost-iostreams-dev, libboost-program-options-dev, libboost-system-dev,
      # FFmpeg
      libavcodec-dev, libavformat-dev, libavutil-dev, libswresample-dev, libswscale-dev,
      # Audio, Video and Misc. deps
      libsdl2-dev, libqt5opengl5-dev, libopenal-dev, libunshield-dev, libtinyxml-dev, liblz4-dev,
      # The other ones from OpenMW ppa
      libbullet-dev, libopenscenegraph-dev, libmygui-dev
    ]
matrix:
  include:
    - name: OpenMW (all) on MacOS 10.15 with Xcode 11.6
      os: osx
      osx_image: xcode11.6
    - name: OpenMW (all) on Ubuntu Focal with GCC
      os: linux
      dist: focal
    - name: OpenMW (tests only) on Ubuntu Focal with GCC
      os: linux
      dist: focal
      env:
        - BUILD_TESTS_ONLY: 1
    - name: OpenMW (openmw) on Ubuntu Focal with Clang's Static Analysis
      os: linux
      dist: focal
      env:
        - MATRIX_EVAL="CC=clang-9 && CXX=clang++-9"
        - ANALYZE="scan-build-9 --force-analyze-debug-code --use-cc clang-9 --use-c++ clang++-9"
      compiler: clang

before_install:
    - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then eval "${MATRIX_EVAL}"; fi
    - ./CI/before_install.${TRAVIS_OS_NAME}.sh
before_script:
    - ccache -z
    - ./CI/before_script.${TRAVIS_OS_NAME}.sh
script:
 - cd ./build
 - ${ANALYZE} make -j3;
 - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then make package; fi
 - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ../CI/check_package.osx.sh; fi
 - if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${BUILD_TESTS_ONLY}" ]; then ./openmw_test_suite; fi
 - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then cd .. && ./CI/check_tabs.sh; fi
 - cd "${TRAVIS_BUILD_DIR}"
 - ccache -s
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:
    if: repository_slug = OpenMW/openmw AND branch = master
    recipients:
      - corrmage+travis-ci@gmail.com
    on_success: change
    on_failure: always
  irc:
    if: repository_slug = OpenMW/openmw AND branch = master
    channels:
      - "chat.freenode.net#openmw"
    on_success: change
    on_failure: always
    use_notice: true