environment:
  matrix:
  - ARCH: "i686"
    JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
    
  - ARCH: "x86_64"
    JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

skip_branch_with_pr: true

skip_commits:
# Add [av skip] to commit messages for docfixes, etc to reduce load on queue
  message: /\[av skip\]/

notifications:
  - provider: Email
    on_build_success: false
    on_build_failure: false
    on_build_status_changed: false

# fetch repository as zip archive
shallow_clone: true
# set clone depth
clone_depth: 5

init:
# Carriage returns are bad
  - git config --global core.autocrlf input
  - ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"

install:
# Download and install most recent cygwin
  - appveyor DownloadFile https://cygwin.com/setup-x86_64.exe -FileName C:\projects\cygwin-setup-x86_64.exe
  - C:\projects\cygwin-setup-x86_64.exe -q -g -P make,mingw64-i686-gcc-core,mingw64-x86_64-gcc-core
# Download most recent Julia Windows binary
  - appveyor DownloadFile %JULIA_URL% -FileName C:\projects\julia-binary.exe
# Clear most of PATH to avoid picking up unwanted dependencies
  - set PATH="C:\Program Files\7-Zip"

build_script:
  - C:\cygwin64\bin\sh -lc "make -C $(cygpath $APPVEYOR_BUILD_FOLDER) CC=$ARCH-w64-mingw32-gcc"

after_build:
  - ps: $env:VERSION = If ($env:APPVEYOR_REPO_TAG -eq "true") {$env:APPVEYOR_REPO_TAG_NAME} Else {$env:APPVEYOR_REPO_COMMIT.Substring(0, 10)}
  - 7z a libRmath-julia-%ARCH%-%VERSION%.zip %APPVEYOR_BUILD_FOLDER%\src\libRmath-julia.dll

before_test:
# Run installer silently, output to C:\projects\julia
  - C:\projects\julia-binary.exe /S /D=C:\projects\julia
  - C:\projects\julia\bin\julia -e "versioninfo()"

test_script:
# Run test file
  - C:\projects\julia\bin\julia test.jl

artifacts:
  - path: libRmath-julia-*.zip

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