version: "{build} ~ {branch}"

os: Visual Studio 2017

branches:
  only:
    - staging
    - trying
    - master

environment:
  matrix:
    - CHANNEL: stable
      ARCH: x86_64
      ABI: msvc
      TARGET: x86_64-pc-windows-msvc

cache:
  - 'C:\Users\appveyor\.cargo'
  - target
  - wapm-cli-target

install:
  # # Install LLVM
  # - mkdir C:\projects\deps
  # - cd C:\projects\deps
  # - appveyor DownloadFile http://prereleases.llvm.org/win-snapshots/LLVM-7.0.0-r336178-win64.exe -FileName llvm.exe
  # - 7z x llvm.exe -oC:\projects\deps\llvm
  # # - set "PATH=%PATH%;C:\projects\deps\llvm\bin"
  # - set "LLD_LINK=C:\projects\deps\llvm\bin\lld-link.exe"
  # - set "LLVM_SYS_70_PREFIX=C:\projects\deps\llvm"
  # - cd "%APPVEYOR_BUILD_FOLDER%"

  # Install Rust
  # uncomment these lines if the cache is cleared, or if we must re-install rust for some reason
  # - appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
  # - rustup-init.exe -yv --default-host %target%
  - set PATH=%PATH%;C:\\Libraries\\llvm-5.0.0\\bin;%USERPROFILE%\.cargo\bin
  - rustup default stable-%target%
  - rustup update
  - rustc -vV
  - cargo -vV

  # Install InnoSetup
  - appveyor-retry appveyor DownloadFile https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-08-22-is.exe
  - 2017-08-22-is.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
  - set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH%
# uncomment to RDP to appveyor
#  - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

build_script:
  - cargo build --release --verbose
  # Now we build wapm
  - git submodule init
  - git submodule update
  # Cache wapm cli target in dir above to prevent breaking git submodule on windows
  - if not exist wapm-cli-target mkdir wapm-cli-target
  - move wapm-cli-target wapm-cli
  - cd wapm-cli
  - rename wapm-cli-target target
  - cd ..
  - cargo build --release --manifest-path wapm-cli/Cargo.toml --features telemetry
  - cd wapm-cli
  - rename target wapm-cli-target
  - cd ..
  - move wapm-cli\wapm-cli-target wapm-cli-target
  - cargo build --release --manifest-path lib/runtime-c-api/Cargo.toml

test_script:
  - cargo test --manifest-path lib/spectests/Cargo.toml --features clif

before_deploy:
  - cd ./src/installer
  - iscc wasmer.iss
  - copy /y .\WasmerInstaller.exe ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
  - appveyor PushArtifact ..\..\WasmerInstaller-%APPVEYOR_REPO_TAG_NAME%.exe
  - cd ..\..\

matrix:
  fast_finish: true

deploy:
  description: 'WasmerInstaller'
  artifact: /.*\.exe/
  auth_token:
    secure: BbreGNDJy20922za7OhJG5TERzfX+dJSBQwttNTJkLvszbqMov6hhAtRb3P45hpf
  provider: GitHub
  on:
    branch: master
    appveyor_repo_tag: true
