version: '{build}'

branches:
  only:
  - v1.x
  - ci-test

image: Visual Studio 2017

environment:
  coverity_token:
    secure: cvo7MHcff1Razyw9WcbJVBrEP8MkGIo7kvJ1RHYFIu0=
  coverity_email:
    secure: ndq7n9R6NhCV8mENhPAH4VTFNUeROGK/uFlqfUVwxAc=

  matrix:
    # VS2015 x86 Development
    - platform: x86
      configuration: Development
      TOOLSET: v140

    # VS2015 x64 Development
    - platform: x64
      configuration: Development
      TOOLSET: v140

    # VS2015 x64 Release
    - platform: x64
      configuration: Release
      TOOLSET: v140

    # VS2017 x64 Development
    - platform: x64
      configuration: Development
      TOOLSET: v141

clone_depth: 50

install:
- ps: $env:PATH = 'C:\MinGW\bin;C:\MinGW\mingw32\bin;C:\MinGW\msys\1.0\bin;' + $env:PATH

build:
  project: renderdoc.sln
  parallel: true
  verbosity: minimal

build_script:
- ps: >-
    Invoke-WebRequest https://renderdoc.org/qrenderdoc_3rdparty.zip -OutFile qrenderdoc_3rdparty.zip

    7z x qrenderdoc_3rdparty.zip

    if ( ($env:APPVEYOR_SCHEDULED_BUILD -eq "True" ) -and ($env:PLATFORM -eq "x64") -and ($env:CONFIGURATION -eq "Development") )
    {
      cov-build.exe --dir cov-int msbuild renderdoc.sln /p:Configuration=Development /p:Platform=x64 /p:PlatformToolset=v140

      nuget.exe install PublishCoverity -ExcludeVersion

      PublishCoverity\tools\PublishCoverity.exe compress -o coverity.zip -i cov-int

      PublishCoverity\tools\PublishCoverity.exe publish `
        -t "$env:coverity_token" `
        -e "$env:coverity_email" `
        -r "$env:APPVEYOR_REPO_NAME" `
        -z coverity.zip `
        -d "AppVeyor scheduled build ($env:APPVEYOR_REPO_COMMIT)." `
        --codeVersion "$env:APPVEYOR_REPO_COMMIT"

      return
    }

    if ( $env:APPVEYOR_SCHEDULED_BUILD -eq "True" )
    {
      return
    }

    msbuild renderdoc.sln /v:m "/p:Configuration=$env:CONFIGURATION" "/p:Platform=$env:PLATFORM" "/p:PlatformToolset=$env:TOOLSET"

test_script:
- ps: $env:testexe = "$env:PLATFORM\$env:CONFIGURATION\renderdoccmd.exe"
- ps: if ( $env:PLATFORM -eq "x86" ) { $env:testexe = "Win32\$env:CONFIGURATION\renderdoccmd.exe" }
- cmd: >-
    "%testexe%" test -t unit
