#
# Copyright (c) 2008-2014 the Urho3D project.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

language: cpp
compiler: gcc
env:
  global:
    - secure: DE9IUM+pIV757GU0ccfDJhA752442pKu3DyBthrzHW9+GbsqbfuJOx045CYNN5vOWutFPC0A51B9WxhLNpXXqD3mfU8MhP1gkF7SskrHvcAPrCyfdqZf1Q8XDP5phm2KbHhhwxQMYmmicd6yj8DPNy2wRoSgPSDp/ZUDk51XZDU=
    - secure: AfoHc5tpnYoI2TVGUeE9Xdru+15pd5N4YzO7EWvwmMnrHtNO3retrmKOGpnIyfbP2BeWRTW/z+BI4G0RrfvubjHu2us4wRh6Jq8+UZohBBkM+ldTnyqYHX97q+6ScWBWZGg7dpthd1x/7fmds8dSRzustHUhI7RzPbWEMQH1DGI=
    - DISPLAY=:99.0
    - NUMJOBS=3
  matrix:
    - LINUX=1   URHO3D_LIB_TYPE=STATIC SITE_UPDATE=1
    - LINUX=1   URHO3D_LIB_TYPE=SHARED
    - WINDOWS=1 URHO3D_LIB_TYPE=STATIC
    - WINDOWS=1 URHO3D_LIB_TYPE=SHARED
    - WINDOWS=1 URHO3D_LIB_TYPE=STATIC URHO3D_OPENGL=0
    - WINDOWS=1 URHO3D_LIB_TYPE=SHARED URHO3D_OPENGL=0
    - LINUX=1   URHO3D_LIB_TYPE=STATIC URHO3D_64BIT=0
    - LINUX=1   URHO3D_LIB_TYPE=SHARED URHO3D_64BIT=0
    - WINDOWS=1 URHO3D_LIB_TYPE=STATIC URHO3D_64BIT=0
    - WINDOWS=1 URHO3D_LIB_TYPE=SHARED URHO3D_64BIT=0
    - WINDOWS=1 URHO3D_LIB_TYPE=STATIC URHO3D_64BIT=0 URHO3D_OPENGL=0
    - WINDOWS=1 URHO3D_LIB_TYPE=SHARED URHO3D_64BIT=0 URHO3D_OPENGL=0
matrix:
  fast_finish: true
  include:
    - compiler: clang
      env: LINUX=1 URHO3D_LIB_TYPE=STATIC
    - compiler: clang
      env: LINUX=1 URHO3D_LIB_TYPE=SHARED
    - compiler: clang
      env: LINUX=1 URHO3D_LIB_TYPE=STATIC URHO3D_64BIT=0
    - compiler: clang
      env: LINUX=1 URHO3D_LIB_TYPE=SHARED URHO3D_64BIT=0
before_install:
  - free -tm
  - mem=($(free -m |head -2 |tail -1)); if [ ${mem[6]} -eq 0 ]; then export BAD_VM=1; fi
  - export TAG=$(git describe --exact-match $TRAVIS_COMMIT 2>/dev/null); if [[ $TAG =~ [[:digit:]]+\.[[:digit:]]+ ]]; then export RELEASE_TAG=$TAG; fi
  - if [ $RELEASE_TAG ] || ([ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]); then export SITE_UPDATE_ON_MASTER_COMMIT=$SITE_UPDATE; export COMMIT_MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT); if [ "$CC" == "gcc" ] && ([ $RELEASE_TAG ] || echo $COMMIT_MESSAGE |grep -cq '\[ci package\]'); then export PACKAGE_UPLOAD=1; fi; fi
  - if [ "$SITE_UPDATE_ON_MASTER_COMMIT" -o "$PACKAGE_UPLOAD" ]; then travis_retry sudo add-apt-repository ppa:george-edison55/precise-backports -y; fi
  - travis_retry sudo apt-get update -q -y
install:
  - travis_retry sudo apt-get install -q -y --no-install-recommends libasound2-dev
  - if [ $LINUX ]; then if [ "$URHO3D_64BIT" == "0" ]; then travis_retry sudo apt-get remove -q -y gvfs-daemons && travis_retry sudo apt-get install -q -y libxrandr-dev:i386 libglapi-mesa:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev:i386 libxext-dev:i386 libxrender-dev:i386 g++-multilib && export CMAKE_PREFIX_PATH=/usr/lib/i386-linux-gnu; else bash -e /etc/init.d/xvfb start; fi && if [ $PACKAGE_UPLOAD ]; then travis_retry sudo apt-get install -q -y rpm; fi; fi
  - if [ $WINDOWS ]; then if [ "$URHO3D_64BIT" == "0" ]; then travis_retry sudo apt-get install -q -y gcc-mingw-w64-i686 g++-mingw-w64-i686 binutils-mingw-w64-i686 && export ARCH=i686; else travis_retry sudo apt-get install -q -y gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 binutils-mingw-w64-x86-64 && export ARCH=x86_64; fi && travis_retry sudo apt-get install -q -y g++-multilib && export MINGW_PREFIX=/usr/bin/${ARCH}-w64-mingw32; fi
  - if [ "$SITE_UPDATE_ON_MASTER_COMMIT" -o "$PACKAGE_UPLOAD" ]; then travis_retry sudo apt-get install -q -y --no-install-recommends doxygen graphviz; fi
  - free -tm
script: rake ci
after_success:
  - if [ $SITE_UPDATE_ON_MASTER_COMMIT ]; then rake ci_site_update && rake ci_rebase; fi
  - if [ $PACKAGE_UPLOAD ]; then rake ci_package_upload; fi

# vi: set ts=2 sw=2 expandtab:
