# Travis-CI configuration file for SuperTuxKart
#
# Configuration manual:
# http://docs.travis-ci.com/user/build-configuration/
#
# Heavily borrowed from SuperTuxKart's travis.yml.
#
# SuperTuxKart's travis.yml file can be found here:
# https://github.com/supertuxkart/stk-code/blob/master/.travis.yml
# License: https://github.com/supertuxkart/stk-code/blob/master/COPYING
#

language: cpp

compiler:
  - gcc
  - clang

matrix:
  fast_finish: true

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: "eVEyzIVjDlB16EPkXmj74tyF9pgX34kpgvBUMXJJ+hduuPwaGC6vl8T164fNQUIua2Z2/PqxmTLJRR3n5Bbkdf859NdX+4JUzc3SoFEKlgcLMYnOQeuimUAiMKxe4vmC4sub5LZVFsp9ORzVYkXgiMBnxiD5GuYxvZPy1lCaH9E="
    - CMAKE_VERSION=3.3.2 SDL2_VERSION=2.0.3 SDL2IMAGE_VERSION=2.0.0 GLBINDING_VERSION=1.1.0
  matrix:
    - BUILD_TYPE="Debug"
    - BUILD_TYPE="Release"
    - USE_GLBINDING=OFF
    # glbinding fails to compile on clang:
    #- USE_GLBINDING=ON
 
before_install:
  - sudo apt-get update -qq
  - sudo apt-get install build-essential libogg-dev libvorbis-dev libphysfs-dev libglew-dev libopenal-dev libboost-all-dev

  # Current gcc that supports C++ 11 features
  - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
  - sudo apt-get update -qq
  - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.9; fi
  - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi

  # CMake
  - wget http://www.cmake.org/files/v3.3/cmake-$CMAKE_VERSION.tar.gz -O - | tar xz
  - (cd cmake-$CMAKE_VERSION && cmake . && make -j3 && sudo make install)

  # SDL dependencies
  - wget http://libsdl.org/release/SDL2-$SDL2_VERSION.tar.gz -O - | tar xz
  - (cd SDL2-$SDL2_VERSION && ./configure --prefix=/usr && make -j3 && sudo make install)
  - wget http://www.libsdl.org/projects/SDL_image/release/SDL2_image-$SDL2IMAGE_VERSION.tar.gz -O - | tar xz
  - (cd SDL2_image-$SDL2IMAGE_VERSION && ./configure --prefix=/usr && make -j3 && sudo make install)

  # Try building with GLBinding
  # Note: glbindings ./configure needs to be run twice in order to generate a makefile
  - if [ "$USE_GLBINDING" = "ON" ]; then
    wget https://github.com/cginternals/glbinding/archive/v$GLBINDING_VERSION.tar.gz -O - | tar xz;
    cd glbinding-$GLBINDING_VERSION && ./configure --prefix=/usr && ./configure --prefix=/usr;
    cd build && make -j3 && sudo make install;
    cd ../..;
    fi

script:
  # Clean from previous Travis build
  - git clean -f
  # Then build:
  - mkdir "build-$BUILD_TYPE"
  - cd "build-$BUILD_TYPE"
  - cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWARNINGS=ON -DWERROR=ON -DGLBINDING_ENABLED=$USE_GLBINDING
  - make VERBOSE=1 -j3

addons:
  coverity_scan:
    project:
      name: "SuperTux/supertux"
      description: "Build submitted via Travis CI"
    notification_email: supertux-commit@lists.lethargik.org
    build_command_prepend: "cmake . && make clean"
    build_command:   "make -j 3"
    branch_pattern: coverity_scan

notifications:
  email:
    - supertux-commit@lists.lethargik.org
