os:
 - linux
 - osx

matrix:
 allow_failures:
  - os: osx
  - compiler: clang
 exclude:
# Don't build using gcc on mac
  - os: osx
    compiler: gcc
# Don't try to do Coverity builds on mac   
  - os: osx
    env: COVERITY=1
# Only do coverity build on Linux when the compiler is gcc
  - os: linux
    compiler: clang
    env: COVERITY=1
  
compiler: 
- gcc
- clang

before_script: 
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo add-apt-repository ppa:boost-latest/ppa -y; fi
- echo $CXX
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "clang++" ]]; then sudo add-apt-repository ppa:h-rayflood/llvm -y; fi
- echo $CXX
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "clang++" ]]; then sudo apt-get install --allow-unauthenticated clang-3.5; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get update; fi
- echo $CXX
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "clang++" ]]; then export CXX="clang++-3.4"; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "clang++" ]]; then export CXX="clang++-3.4"; fi

- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then sudo apt-get install gcc-4.9; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then sudo apt-get install g++-4.9; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then sudo update-alternatives --config gcc; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then sudo update-alternatives --config g++; fi

- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install boost1.55; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libvorbis-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libalut-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libfreetype6-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libfreeimage-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install zlib1g-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libzzip-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libois-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install libglu-dev; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/ogre-build_1.9.0-1_amd64.deb; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo dpkg -i ogre-build_1.9.0-1_amd64.deb; fi

- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew update; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew outdated wget || brew upgrade wget; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/OgreDependencies_OSX_libc._20130610.zip; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/NVIDIA_Cg.tgz; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then wget https://github.com/paulsapps/Ogre1.9/releases/download/1.9.0/OgreSDK.zip; fi

- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then unzip OgreSDK.zip >> OgreSDK_extract.log; fi

#- if [ "$TRAVIS_OS_NAME" == "osx" ]; then hdiutil attach OgreSDK_v1-9-0.dmg; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then ls; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then ls /Volumes; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then ls /Users/travis/build/q-gears/q-gears/OgreSDK; fi

#- if [ "$TRAVIS_OS_NAME" == "osx" ]; then sudo installer -pkg /Volumes/OgreSDK/OgreSDK/OgreSDK.pkg -target /usr/local/; fi
#- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew outdated boost || brew upgrade boost; fi
#- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew outdated ois || brew upgrade ois; fi

#- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew outdated scp || brew outdated scp; fi
- $CXX --version

before_install: 
script: 
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo tar xfzC NVIDIA_Cg.tgz /; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cginfo; fi

# fix broken SDK
#- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo cp /Volumes/OgreSDK/OgreSDK/include/OGRE/Overlay/OgreTextAreaOverlayElement.h /Volumes/OgreSDK/OgreSDK/lib/macosx/Release/OgreOverlay.framework/Versions/1.9.0/Headers/OgreTextAreaOverlayElement.h; fi

- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then unzip OgreDependencies_OSX_libc._20130610.zip >> extract.log; fi

- mkdir build_qgears
- cd build_qgears


- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cmake ..; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export OGRE_HOME=/Users/travis/build/q-gears/q-gears/OgreSDK; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export OGRE_SDK=/Users/travis/build/q-gears/q-gears/OgreSDK; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export OIS_HOME=/Users/travis/build/q-gears/q-gears/Dependencies; fi

- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export C_FLAGS=-m32; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CXX_FLAGS=-m32; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export L_FLAGS=-m32; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export LD_FLAGS=-m32; fi

- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd ..; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd Dependencies; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd luajit; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir build; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cd build; fi

- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake -G"Unix Makefiles" ..; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cmake ..; fi



- if [[ ${COVERITY_SCAN_BRANCH} != 1 ]]; then make -j2; fi
- if [[ ${COVERITY_SCAN_BRANCH} != 1 ]]; then cpack -C Release; fi
language: cpp
after_success: 
- hash=`git rev-parse HEAD`
- rm ~/.ssh/known_hosts
- rm ~/.ssh/config
- echo "-----BEGIN RSA PRIVATE KEY-----" >  ~/.ssh/id_rsa
- echo $KEY01 >> ~/.ssh/id_rsa
- echo $KEY02 >> ~/.ssh/id_rsa
- echo $KEY03 >> ~/.ssh/id_rsa
- echo $KEY04 >> ~/.ssh/id_rsa
- echo $KEY05 >> ~/.ssh/id_rsa
- echo $KEY06 >> ~/.ssh/id_rsa
- echo $KEY07 >> ~/.ssh/id_rsa
- echo $KEY08 >> ~/.ssh/id_rsa
- echo $KEY09 >> ~/.ssh/id_rsa
- echo $KEY10 >> ~/.ssh/id_rsa
- echo $KEY11 >> ~/.ssh/id_rsa
- echo $KEY12 >> ~/.ssh/id_rsa
- echo $KEY13 >> ~/.ssh/id_rsa
- echo $KEY14 >> ~/.ssh/id_rsa
- echo $KEY15 >> ~/.ssh/id_rsa
- echo $KEY16 >> ~/.ssh/id_rsa
- echo $KEY17 >> ~/.ssh/id_rsa
- echo $KEY18 >> ~/.ssh/id_rsa
- echo $KEY19 >> ~/.ssh/id_rsa
- echo $KEY20 >> ~/.ssh/id_rsa
- echo $KEY21 >> ~/.ssh/id_rsa
- echo $KEY22 >> ~/.ssh/id_rsa
- echo $KEY23 >> ~/.ssh/id_rsa
- echo $KEY24 >> ~/.ssh/id_rsa
- echo $KEY25 >> ~/.ssh/id_rsa
- echo "-----END RSA PRIVATE KEY-----" >>  ~/.ssh/id_rsa
- chmod 400 ~/.ssh/id_rsa
- chmod 700 ~/.ssh
- md5sum ~/.ssh/id_rsa

- if [[ $TRAVIS_PULL_REQUEST == 'false' && ${COVERITY_SCAN_BRANCH} != 1 && "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then ssh -o StrictHostKeyChecking=no paul@itscovarr.com mkdir -p /var/www/storage/qgears/$hash/linux/ fi
- if [[ $TRAVIS_PULL_REQUEST == 'false' && ${COVERITY_SCAN_BRANCH} != 1 && "$TRAVIS_OS_NAME" == "linux" && "$CXX" == "g++" ]]; then scp -o StrictHostKeyChecking=no ~/build/q-gears/q-gears/build_qgears/*.deb paul@itscovarr.com:/var/www/storage/qgears/$hash/linux/ fi

- if [[ $TRAVIS_PULL_REQUEST == 'false' && ${COVERITY_SCAN_BRANCH} != 1 && "$TRAVIS_OS_NAME" == "osx" && "$CXX" == "clang" ]]; then ssh -o StrictHostKeyChecking=no paul@itscovarr.com mkdir -p /var/www/storage/qgears/$hash/mac/ fi


notifications: 
  on_failure: always
  irc: irc.esper.net#qhimm.com
  on_success: change
  skip_join: true
addons:
  coverity_scan:
    project:
      name: "q-gears/q-gears"
      description: "Build submitted via Travis CI"
    notification_email: coverityscan@paulsapps.com
    build_command_prepend: "mkdir qgears_build; cd qgears_build; cmake .."
    build_command: "make -j4"
    branch_pattern: coverity_scan
env: 
  global: 
  - secure: "PUtlviIMOxgXYfBiAW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