language: cpp
sudo: required
matrix:
  include:
    - os: linux
      compiler: clang
      python: "3.6"
    - os: linux
      dist: xenial
      compiler: gcc
      python: "3.6"
    - os: osx

git:
  depth: 5

addons:
  apt:
    sources:
    # add PPAs with more up-to-date toolchains
    - ubuntu-toolchain-r-test
    - llvm-toolchain-xenial-7
    packages:
    - gcc-8
    - g++-8
    - mesa-common-dev
    - libsdl2-dev
    - libsdl2-image-dev
    - libsdl2-ttf-dev
    - libfreetype6-dev
    - libopenal-dev
    - libvorbis-dev
    - zlib1g-dev
    - libboost-dev
    - libboost-system-dev
    - libboost-filesystem-dev
    - libboost-test-dev
    - libtinyxml-dev
    - libc6
    - libglew-dev
    - pylint
    #- cppcheck

before_install:
  # Linux Build
  # change gcc to version 8
  - if [ $TRAVIS_OS_NAME == linux ]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 20; sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 20; fi
  - if [ $TRAVIS_OS_NAME == linux ]; then sudo update-alternatives --config gcc; sudo update-alternatives --config g++; fi
  # install newer version of pylint, the one fetched with apt-get is broken
  #- if [ $TRAVIS_OS_NAME == linux ]; then sudo pip install pylint; fi
  # Swig
  - if [ $TRAVIS_OS_NAME == linux ]; then sudo add-apt-repository ppa:timsc/swig-3.0.12 -y; sudo apt-get update -q; sudo apt-get install swig; fi
  # MacOS Build
  - if [ $TRAVIS_OS_NAME == osx ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install boost swig sdl2 sdl2_image sdl2_ttf freetype openal-soft tinyxml glew libvorbis python3 python || brew upgrade boost swig sdl2 sdl2_image sdl2_ttf freetype openal-soft tinyxml glew libvorbis python3 python || brew outdated boost swig sdl2 sdl2_image sdl2_ttf freetype openal-soft tinyxml glew libvorbis  python3 python; fi
  - cmake --version

install:
  - git clone --quiet --depth 1 git://github.com/fifengine/fifechan.git
  - if [ $TRAVIS_OS_NAME == linux ]; then mkdir build_fifechan; cd build_fifechan; cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr ../fifechan; fi
  - if [ $TRAVIS_OS_NAME == osx ]; then mkdir build_fifechan; cd build_fifechan; cmake ../fifechan; fi
  - make -j3
  - sudo make install
  - cd ..

script:
  - cd ..
  - if [ $TRAVIS_OS_NAME == linux ]; then mkdir build; cd build; cmake -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_INSTALL_PREFIX:PATH=/usr -Dcegui=OFF ../fifengine; fi
  - if [ $TRAVIS_OS_NAME == osx ]; then mkdir build; cd build; cmake -Dbuild-library=ON -DPYTHON_EXECUTABLE=/usr/local/bin/python3 -Dcegui=OFF ../fifengine; fi
  - ls -alh .
  - make -j3
  - sudo make install

after_script: 
  - cd $TRAVIS_BUILD_DIR
  - python3 -c 'from fife import fife; print(fife.getVersion())'
  - if [ $TRAVIS_OS_NAME == linux ]; then cppcheck --verbose --enable=all --std=posix --std=c++11 --quiet -iengine/core/ext engine/core; fi
  - if [ $TRAVIS_OS_NAME == linux ]; then pylint --rcfile=.pylintrc ./engine/python/fife/; fi

notifications:
  irc: irc.freenode.org#fife
  email: false

#deploy:
#  provider: releases
#  api_key:
#    secure: "TiE1MLzq8DE2vJjiTeWnuhjEM/cH4hQ7yL/SSDkIqTijCY1eiCX6KPE7yDNh9F1SkCfxYyDPTuRc+f1EaAbk073aL56kUTM/bV/4TEcHk4TS40Hcd5aA10gR3XOH3lYwagT2edgXgXLA1cvU1tuwj8stKz1hEnkVlCvFdbvy4qg="
#  file: Fifengine*.tar.gz
#  file_glob: true
#  skip_cleanup: true
#  overwrite: true
#  on:
#    tags: true
