# AppVeyor file
# http://www.appveyor.com/docs/appveyor-yml

# clone directory
clone_folder: c:\projects\assimp

clone_depth: 1

# branches to build
branches:
  # whitelist
  only:
    - master

matrix:
  fast_finish: true
    
image:
  - Visual Studio 2013
  #- Visual Studio 2015
  #- Visual Studio 2017
  - Visual Studio 2019
  #- MinGW  
    
platform:
  - Win32
  - x64
  
configuration: Release

install:
  - set PATH=C:\Ruby24-x64\bin;%PATH%
  - set CMAKE_DEFINES -DASSIMP_WERROR=ON
  - if [%COMPILER%]==[MinGW] set PATH=C:\MinGW\bin;%PATH%
  - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" set CMAKE_GENERATOR_NAME=Visual Studio 12 2013
  - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015
  - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" set CMAKE_GENERATOR_NAME=Visual Studio 15 2017
  - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" set CMAKE_GENERATOR_NAME=Visual Studio 16 2019
  - cmake %CMAKE_DEFINES% -G "%CMAKE_GENERATOR_NAME%" -A %platform% .
  # Rename sh.exe as sh.exe in PATH interferes with MinGW  - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" set CMAKE_GENERATOR_NAME=Visual Studio 14 2015

  - rename "C:\Program Files\Git\usr\bin\sh.exe" "sh2.exe"
  - set PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 5"
  - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\packaging\windows-innosetup\vc_redist.x64.exe
  - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/1/d/8/1d8137db-b5bb-4925-8c5d-927424a2e4de/vc_redist.x86.exe -OutFile .\packaging\windows-innosetup\vc_redist.x86.exe
  
cache:
  - code\assimp.dir\%CONFIGURATION%
  - contrib\zlib\zlibstatic.dir\%CONFIGURATION%
  - contrib\zlib\zlib.dir\%CONFIGURATION%
  - tools\assimp_cmd\assimp_cmd.dir\%CONFIGURATION%
  - tools\assimp_view\assimp_viewer.dir\%CONFIGURATION%
  - test\unit.dir\%CONFIGURATION%
  - bin\.mtime_cache
  
before_build:
  - echo NUMBER_OF_PROCESSORS=%NUMBER_OF_PROCESSORS%
  - ruby scripts\AppVeyor\mtime_cache -g scripts\AppVeyor\cacheglobs.txt -c bin\.mtime_cache\cache.json
  
build_script:
  cmake --build . --config Release -- /maxcpucount:2
  
after_build:
  - if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (
        if "%platform%"=="x64" (
            iscc packaging\windows-innosetup\script_x64.iss
        ) else (
            iscc packaging\windows-innosetup\script_x86.iss
        )
    )
  - 7z a assimp.7z bin\%CONFIGURATION%\* lib\%CONFIGURATION%\*

test_script:
  - cmd: bin\%CONFIGURATION%\unit.exe --gtest_output=xml:testout.xml

on_finish:
  - ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\testout.xml))
  
artifacts:
  - path: assimp.7z
    name: assimp_lib