platform: x64

image: Visual Studio 2019

branches:
  only:
    - master
    - 2.2
    - 2.3

environment:
  my_secret:
    secure: ngfIQmr9kcRyopeRyHZG8g==
  MINGW_DIR: mingw64
  MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-win32/seh/x86_64-7.3.0-release-win32-seh-rt_v5-rev0.7z/download
  MINGW_ARCHIVE: x86_64-7.3.0-release-win32-seh-rt_v5-rev0.7z
  TCLKIT_URL: http://kitcreator.rkeene.org/kits/34ac4a331252f9796c31f875e282cb04a01f2743/tclkit.exe
  TCLKIT: tclkit.exe
  matrix:
  - TCLTAG: core-8-6-branch
    TOOLCHAIN: autoconf-tea
  - TCLTAG: core-8-6-branch
    TOOLCHAIN: nmake-tea
  - TCLTAG: core-8-6-12
    TOOLCHAIN: autoconf-tea
  - TCLTAG: core-8-6-12
    TOOLCHAIN: nmake-tea
  - TCLTAG: core-8-5-branch
    TOOLCHAIN: autoconf-tea
  #  - TCLTAG: core-8-5-branch
  #    TOOLCHAIN: nmake-tea
  - TCLTAG: core-8-5-19
    TOOLCHAIN: autoconf-tea
  #  - TCLTAG: core-8-5-19
  #    TOOLCHAIN: nmake-tea	
  - TCLTAG: core-8-7-a5
    TOOLCHAIN: autoconf-tea
  - TCLTAG: core-8-7-a5
    TOOLCHAIN: nmake-tea
  - TCLTAG: core-8-branch
    TOOLCHAIN: autoconf-tea
  - TCLTAG: core-8-branch
    TOOLCHAIN: nmake-tea
  - TCLTAG: trunk
    TOOLCHAIN: autoconf-tea
  - TCLTAG: trunk
    TOOLCHAIN: nmake-tea
matrix:
  allow_failures:
  - TCLTAG: core-8-6-branch
  - TCLTAG: core-8-5-branch
  - TCLTAG: core-8-branch
  - TCLTAG: trunk
  fast_finish: true

install:
  - if "%TOOLCHAIN%" == "nmake-tea" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
  # - appveyor-retry choco install openssh -confirm
  - ps: iex ((New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/appveyor/secure-file/master/install.ps1'))
  - appveyor-tools\secure-file -decrypt deploy_key.appveyor.enc -out deploy_key -secret %my_secret%
  - if not exist "%MINGW_ARCHIVE%" appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%"
  - 7z x -y "%MINGW_ARCHIVE%" > nul
  - if not exist "%TCLKIT%" appveyor DownloadFile "%TCLKIT_URL%" -FileName "%TCLKIT%"
  - dir %MINGW_DIR%

build_script:
  - if "%TOOLCHAIN%" == "autoconf-tea" set CHERE_INVOKING=1
  # - if "%TOOLCHAIN%" == "autoconf-tea" set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%
  # - if "%TOOLCHAIN%" == "autoconf-tea" set PATH=%CD%\%MINGW_DIR%\bin;%PATH%
  - if "%TOOLCHAIN%" == "autoconf-tea" set PATH=C:\msys64\usr\bin;%PATH%
  # Needed to align MSYS and Windows HOME dirs
  - if "%TOOLCHAIN%" == "autoconf-tea" set HOME=C:\Users\appveyor
  # - if "%TOOLCHAIN%" == "autoconf-tea" bash -lc "cd && echo \"export PATH=/c/projects/nsf-2ylk0/mingw64/bin:/c/msys64/usr/bin:\$PATH; \" >> .profile"
  - if "%TOOLCHAIN%" == "autoconf-tea" bash -lc "cd && echo \"export PATH=/c/projects/nsf-2ylk0/mingw64/bin:\$PATH; export MSYSTEM=MINGW64; export MINGW_PREFIX=/c; alias make='/c/msys64/usr/bin/make'; shopt -s expand_aliases; \" >> .profile"
  - if "%TOOLCHAIN%" == "autoconf-tea" bash -lc "sh --version"
  - if "%TOOLCHAIN%" == "autoconf-tea" bash -lc "make --version"
  - dir %CD%
  - tclkit.exe apps/build.tcl %CD% %APPVEYOR_BUILD_FOLDER% %TCLTAG% %TOOLCHAIN%

on_failure:
  - if "%TOOLCHAIN%" == "autoconf-tea" cat tcl\win\config.log

after_build:
- ps: $env:DATESTRING=(get-date -UFormat "%Y%m%d").ToString()
- set TARBALL="nsf_%APPVEYOR_REPO_BRANCH%_%TCLTAG%_win_%TOOLCHAIN%_%DATESTRING%_%APPVEYOR_BUILD_NUMBER%.zip"
- if exist "%CD%\install" 7z a %TARBALL% %CD%\install\* 
- if exist "%TARBALL%" C:\msys64\usr\bin\scp.exe -v -oStrictHostKeyChecking=no -i deploy_key %TARBALL% "sobernig@alice.wu.ac.at:/home/sobernig/builds"

cache:
  - tclkit.exe -> appveyor.yml
  - x86_64-7.3.0-release-win32-seh-rt_v5-rev0.7z -> appveyor.yml
