version: "{build}"

branches:
    only:
        - master
        - /openmw-.*$/
        - appveyor

environment:
    matrix:
        - msvc: 2017
          APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
        - msvc: 2019
          APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

platform:
    - x64

configuration:
#    - Debug
    - Release
#    - RelWithDebInfo

# We want the git revision for versioning,
# so shallow clones don't work.
clone_depth: 1

cache:
    - C:\projects\openmw\deps\Bullet-2.89-msvc2017-win64-double.7z
    - C:\projects\openmw\deps\MyGUI-3.4.1-msvc2017-win64.7z
    - C:\projects\openmw\deps\MyGUI-3.4.1-msvc2019-win64.7z
    - C:\projects\openmw\deps\OSGoS-3.6.5-b02abe2-msvc2017-win64.7z
    - C:\projects\openmw\deps\OSGoS-3.6.5-b02abe2-msvc2019-win64.7z
    - C:\projects\openmw\deps\ffmpeg-4.2.2-dev-win64.zip
    - C:\projects\openmw\deps\ffmpeg-4.2.2-win64.zip
    - C:\projects\openmw\deps\OpenAL-Soft-1.20.1.zip
    - C:\projects\openmw\deps\SDL2-2.0.18.zip

clone_folder: C:\projects\openmw

install:
    - set PATH=C:\Program Files\Git\mingw64\bin;%PATH%

before_build:
    - cmd: git submodule update --init --recursive
    - cmd: sh %APPVEYOR_BUILD_FOLDER%\CI\before_script.msvc.sh -c %configuration% -p %PLATFORM% -v %msvc% -V -i %APPVEYOR_BUILD_FOLDER%\install

build_script:
    - cmd: if %PLATFORM%==x64 set build=MSVC%msvc%_64
    - cmd: msbuild %build%\OpenMW.sln /t:Build /p:Configuration=%configuration% /m:2 /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
    - cmd: cmake --install %build% --config %configuration%

after_build:
    - cmd: if %PLATFORM%==x64 7z a OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%.zip %APPVEYOR_BUILD_FOLDER%\install -xr"!*.pdb"
    #- cmd: if %PLATFORM%==x64 7z a OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%_pdb.zip %APPVEYOR_BUILD_FOLDER%\MSVC%msvc%_64\%configuration%\*.pdb

test: off

#notifications:
#    - provider: Email
#    to:
#        -
#    on_build_failure: true
#    on_build_status_changed: true

artifacts:
  - path: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%.zip
    name: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%
  #- path: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%_pdb.zip
  #  name: OpenMW_MSVC%msvc%_%platform%_%appveyor_pull_request_number%_%appveyor_pull_request_head_commit%_pdb
