language: cpp
dist: xenial
osx_image: xcode10.1

env:
  global:
    - SCONS_CACHE="$HOME/.scons_cache"
    - SCONS_CACHE_LIMIT=1024

cache:
  directories:
    - $SCONS_CACHE

matrix:
  include:
    - name: Linux Debug
      os: linux
      compiler: gcc
      env: TARGET=debug PLATFORM=x11
      addons:
        apt:
          sources:
            - llvm-toolchain-xenial-6.0
          packages:
            [scons, pkg-config, build-essential, p7zip-full]

    - name: Linux Release
      os: linux
      compiler: gcc
      addons:
        apt:
          packages:
            [scons, pkg-config, build-essential, p7zip-full]
      env: TARGET=release PLATFORM=x11

install:
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      brew update;
      brew install scons p7zip;
    fi

  - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
      curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.0.5/scons-local-3.0.5.zip;
      unzip scons-local-3.0.5.zip;
    fi

script:
  - if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
      export SCONS="./scons.bat";
      /c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat;
      ./build_libs.bat $TARGET;
    else
      export SCONS="scons";
      ./build_libs.sh $TARGET;
    fi

  - $SCONS platform=$PLATFORM target=$TARGET $SCONS_FLAGS;
