sudo: false

# Using c here rather than cpp to avoid Travis exporting CXX after matrix env
language: c

git:
  depth: 10

addons:
  apt:
    sources:
    - ubuntu-toolchain-r-test
    - llvm-toolchain-precise-3.5
    packages:
     - clang-3.5

# don't re-build for tags so that [publish binary] is not re-run
# https://github.com/travis-ci/travis-ci/issues/1532
branches:
  except:
    - /^v[0-9]/

matrix:
  include:
     # Linux
     - os: linux
       compiler: clang
       env: NODE_VERSION="5"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     - os: linux
       compiler: clang
       env: NODE_VERSION="4"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     - os: linux
       compiler: clang
       env: NODE_VERSION="iojs-3.1.0"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     - os: linux
       compiler: clang
       env: NODE_VERSION="iojs-2.4.0"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     - os: linux
       compiler: clang
       env: NODE_VERSION="iojs-1.8.4"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     - os: linux
       compiler: clang
       env: NODE_VERSION="0.12.7"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     - os: linux
       compiler: clang
       env: NODE_VERSION="0.10.40"
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5']
     # test building against external sqlite
     - os: linux
       compiler: clang
       env: NODE_VERSION="0.10.40" EXTERNAL_SQLITE=true PUBLISHABLE=false
       addons:
         apt:
            sources: [ 'ubuntu-toolchain-r-test','llvm-toolchain-precise-3.5', 'gcc-multilib', 'g++-multilib', 'libsqlite3-dev:i386' ]
            packages: [ 'clang-3.5','libsqlite3-dev']
     # OS X
     - os: osx
       compiler: clang
       env: NODE_VERSION="5" COVERAGE=true PUBLISHABLE=false # node abi 47
     - os: osx
       compiler: clang
       env: NODE_VERSION="5" # node abi 47
     - os: osx
       compiler: clang
       env: NODE_VERSION="4" # node abi 46
     - os: osx
       compiler: clang
       env: NODE_VERSION="iojs-3.1.0" # node abi 46
     - os: osx
       compiler: clang
       env: NODE_VERSION="iojs-2.4.0" # node abi 44
     - os: osx
       compiler: clang
       env: NODE_VERSION="iojs-1.8.4" # node abi 43
     - os: osx
       compiler: clang
       env: NODE_VERSION="0.12.7" # node abi 14
     - os: osx
       compiler: clang
       env: NODE_VERSION="0.10.40" # node abi 11

env:
  global:
    - JOBS: "8"
    - secure: PifMOSnn+mWR1RUptXse+fLvWiTrzg0R/mazO7RWhXHWBKv0uAJ/qV3dI0GIRBLtjG10Iy+tT5RNh1TIbBzB9Y67wMcGvylUPG1+3EOKoBMEPnOD9AgCEQw4SOXfGPx0cq2N6ueSKieCgu1yKN9Wq7XCbE+zTk/DiRNIdLirVoo=
    - secure: cc4esJY1vPXL31IeumAJoKWDDO2BTGFiltwfO1jbTbiV7QT911QUjTUasxXIVpOaHNCpxSTyevPwwTWfzt2EtF92Lli+qhQ2bbzMiDSBZstSrHdAe62Ai2M1oYYUwk/0cABB/2nO9uRyYwITCxpTSNzZBrYhn3C29WqBhPeVDmM=

before_install:
- export PUBLISHABLE=${PUBLISHABLE:-true}
- export COVERAGE=${COVERAGE:-false}
- if [[ $(uname -s) == 'Linux' ]]; then
    export CXX="clang++-3.5";
    export CC="clang-3.5";
    export PYTHONPATH=$(pwd)/py-local/lib/python2.7/site-packages;
  else
    export PYTHONPATH=$(pwd)/py-local/lib/python/site-packages;
  fi;
- scripts/validate_tag.sh
- source ./scripts/install_node.sh ${NODE_VERSION}

install:
# put node-pre-gyp on path
- export PATH=./node_modules/.bin/:$PATH

before_script:
# get commit message
- export COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n')
- if [[ ${COVERAGE} == true ]]; then
     if [[ $(uname -s) == 'Linux' ]]; then
       PYTHONUSERBASE=$(pwd)/py-local pip install --user cpp-coveralls;
     else
       PYTHONUSERBASE=$(pwd)/py-local easy_install --user cpp-coveralls;
     fi;
   fi

script:
- if [[ "${NODE_VERSION}" ]]; then ./scripts/build_against_node.sh; fi;
# disabled for now: need to port to sudo:false
#- if [[ "${NODE_WEBKIT}" ]]; then ./scripts/build_against_node_webkit.sh; fi;
