language: c
sudo: false

env:
  global:
  - KITS=$HOME/kits

branches:
  only:
  - master
  - 2.2
  - 2.3

matrix:
  include:
   # ----------------------------
    - os: linux
      dist: xenial
      compiler: clang
      env: TCLTAG=core-8-branch
    - os: linux
      dist: xenial
      compiler: gcc-7
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env: TCLTAG=core-8-branch
    - os: osx
      osx_image: xcode11.3
      compiler: clang
      env: TCLTAG=core-8-branch
    - os: osx
      osx_image: xcode11.3	
      compiler: gcc-9
      env: TCLTAG=core-8-branch
     # ----------------------------
    - os: linux
      dist: xenial
      compiler: clang
      env: TCLTAG=core-8-7-a3
    - os: linux
      dist: xenial
      compiler: gcc-7
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env: TCLTAG=core-8-7-a3
    - os: osx
      osx_image: xcode11.3
      compiler: clang
      env: TCLTAG=core-8-7-a3
    - os: osx
      osx_image: xcode11.3	
      compiler: gcc-9
      env: TCLTAG=core-8-7-a3
    # ----------------------------
    - os: linux
      dist: xenial
      compiler: clang
      env: TCLTAG=core-8-5-19
    - os: linux
      dist: xenial
      compiler: gcc-7
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env: TCLTAG=core-8-5-19
    - os: osx
      osx_image: xcode11.3
      compiler: clang
      env: TCLTAG=core-8-5-19
    - os: osx
      osx_image: xcode11.3	
      compiler: gcc-9
      env:
       -  TCLTAG=core-8-5-19
   # ----------------------------
    - os: linux
      dist: xenial
      compiler: clang
      env: TCLTAG=core-8-5-branch
    - os: linux
      dist: xenial
      compiler: gcc-7
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env: TCLTAG=core-8-5-branch
    - os: osx
      osx_image: xcode11.3
      compiler: clang
      env: TCLTAG=core-8-5-branch
    - os: osx
      osx_image: xcode11.3	
      compiler: gcc-9
      env:
        - TCLTAG=core-8-5-branch
  # ----------------------------
    - os: linux
      dist: xenial
      compiler: clang
      env: TCLTAG=core-8-6-10
    - os: linux
      dist: xenial
      compiler: gcc-7
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env: TCLTAG=core-8-6-10
    - os: osx
      osx_image: xcode11.3
      compiler: clang
      env: TCLTAG=core-8-6-10
    - os: osx
      osx_image: xcode11.3	
      compiler: gcc-9
      env:
        - TCLTAG=core-8-6-10
  # ----------------------------
    - os: linux
      dist: xenial
      compiler: clang
      env: TCLTAG=core-8-6-branch
    - os: linux
      dist: xenial
      compiler: gcc-7
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env: TCLTAG=core-8-6-branch
    - os: osx
      osx_image: xcode11.3
      compiler: clang
      env: TCLTAG=core-8-6-branch
    - os: osx
      osx_image: xcode11.3	
      compiler: gcc-9
      env: TCLTAG=core-8-6-branch
  allow_failures:
  - env: TCLTAG=core-8-6-branch
  - env: TCLTAG=core-8-5-branch
  - env: TCLTAG=core-8-branch
  fast_finish: true
cache:
  directories:
  - "$KITS"
before_install:
- openssl aes-256-cbc -K $encrypted_8d1065ce6623_key -iv $encrypted_8d1065ce6623_iv -in deploy_key.enc -out ./deploy_key -d
- chmod 600 ./deploy_key
- if echo "$TRAVIS_COMMIT_MESSAGE" | grep -F -q "[skip travis]" ; then echo "[skip
  travis] has been found, exiting" && exit 0 ; else echo "[skip travis] has not been
  found, continuing" ; fi
install:
- mkdir -p $KITS
- if [ $TRAVIS_OS_NAME = linux ]; then URL=http://kitcreator.rkeene.org/kits/c8fe6fba3323b12b924b4a0716609abbaa00822c/tclkit;
  else URL=http://kitcreator.rkeene.org/kits/31eaf9ae17e769609700b41d1d3c9abeda27510d/tclkit;
  fi
- if [ ! -f ${KITS}/tclkit.$TRAVIS_OS_NAME ]; then wget -O ${KITS}/tclkit.$TRAVIS_OS_NAME
  $URL && chmod +x ${KITS}/tclkit.$TRAVIS_OS_NAME; fi
script:
# - python3 -c 'import os,sys; os.set_blocking(sys.stdout.fileno(), True)'
- python2 -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
- $KITS/tclkit.$TRAVIS_OS_NAME apps/build.tcl $HOME $TRAVIS_BUILD_DIR $TCLTAG

after_success:
- TARBALL="nsf_${TRAVIS_BRANCH}_${TCLTAG}_${TRAVIS_OS_NAME}_${CC}_$(date "+%Y%m%d")_${TRAVIS_BUILD_NUMBER}.tgz"
- if [ -d  $HOME/install ]; then tar -C $HOME/install -czf $TARBALL . && scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ./deploy_key $TARBALL sobernig@alice.wu.ac.at:/home/sobernig/builds; fi
