platform:
  - x64

os: Visual Studio 2017

clone_depth: 5

skip_tags: true

matrix:
  fast_finish: false

skip_commits:
# Add [av skip] to commit messages
  message: /\[av skip\]/

environment:
  global:
    CONDA_INSTALL_LOCN_32: "C:\\Miniconda36"
    CONDA_INSTALL_LOCN_64: "C:\\Miniconda36-x64"
    VCVARSALL: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat"
  matrix:
    - COMPILER: gcc
      ARCH: 64
    - COMPILER: cl
      ARCH: 64
    - COMPILER: gcc
      ARCH: 32
    - COMPILER: cl
      ARCH: 32

install:
  - if [%COMPILER%]==[gcc] set "PATH=C:\msys64\mingw%ARCH%\bin;%PATH%"
  - if [%COMPILER%]==[gcc] set "CMAKE_PREFIX_PATH=C:\msys64\mingw%ARCH%"
  - if [%COMPILER%]==[gcc] del /F /Q "C:\Program Files\Git\usr\bin\sh.exe"
  - dir "C:\msys64\mingw%ARCH%\lib"
  - dir "C:\msys64\mingw%ARCH%\bin"

  - if [%COMPILER%]==[cl] if [%ARCH%]==[64] set "CONDA_INSTALL_LOCN=%CONDA_INSTALL_LOCN_64%"
  - if [%COMPILER%]==[cl] if [%ARCH%]==[32] set "CONDA_INSTALL_LOCN=%CONDA_INSTALL_LOCN_32%"
  - if [%COMPILER%]==[cl] set "LIB=%CONDA_INSTALL_LOCN%\Library\lib;%LIB%"
  - if [%COMPILER%]==[cl] set "CPATH=%CONDA_INSTALL_LOCN%\Library\include;%CPATH%"
  - if [%COMPILER%]==[cl] call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
  - if [%COMPILER%]==[cl] if [%ARCH%]==[64] call "%VCVARSALL%" x64
  - if [%COMPILER%]==[cl] if [%ARCH%]==[32] call "%VCVARSALL%" x86
  - if [%COMPILER%]==[cl] conda config --add channels conda-forge --force
  - if [%COMPILER%]==[cl] conda install --yes --quiet mpir=3.0.0 mpfr=4.* pthreads-win32 ninja
  - if [%COMPILER%]==[cl] set "CFLAGS=/wd4146 /wd4018 /wd4267 /wd4244"
  - cd .. && git clone https://github.com/wbhart/flint2 && cd flint2 && mkdir build && cd build
  - if [%COMPILER%]==[gcc] cmake -G "MinGW Makefiles" -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="C:\msys64\mingw%ARCH%" ..
  - if [%COMPILER%]==[cl] cmake -G "Ninja" -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%CONDA_INSTALL_LOCN%\Library" ..
  - cmake --build . --target install -- -j2
  - cd ../../arb

before_build:
  - ps: if (-Not (Test-Path .\build)) { mkdir build }

  - cd build
  - if [%COMPILER%]==[gcc] cmake -G "MinGW Makefiles" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..
  - if [%COMPILER%]==[cl] cmake -G "Ninja" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release ..

build_script:
  - cmake --build . -- -j2

test_script:
  - set "ARB_TEST_MULTIPLIER=0.1"
  - ctest -j3 --output-on-failure --timeout 600

#on_finish:
#  - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
