environment:
  global:
      QTDIRS: bearer iconengines imageformats platforms printsupport sqldrivers
      QTLIBS: Qt5CLucene Qt5Core Qt5Gui Qt5Help Qt5Network Qt5PrintSupport Qt5Sql Qt5Widgets Qt5Xml
      LOG4CPP_FILE: 'log4cpp_null_build.zip'

  matrix:
    - ENGAUGE_RELEASE: 1
      BUILD_TYPE: X86
      FFTW_VER: 'fftw-3.3.5-dll32'
      LOG4CPP_VER: 'lib32'
      RESULTDIR: engauge-build
      VCLIBS: MSVCP140.dll VCRUNTIME140.dll
    - ENGAUGE_RELEASE: 1
      BUILD_TYPE: X64
      FFTW_VER: 'fftw-3.3.5-dll64'
      LOG4CPP_VER: 'lib64'
      RESULTDIR: engauge-build-x64
      VCLIBS: MSVCP140.dll VCRUNTIME140.dll

install:
  - C:\"Program Files (x86)"\"Microsoft Visual Studio 14.0"\VC\vcvarsall.bat %BUILD_TYPE%
# Qt configurations are listed at https://www.appveyor.com/docs/build-environment/#qt
  - IF %BUILD_TYPE% == X86 (set QTDIR=C:\Qt\5.11.3\msvc2015) ELSE (set QTDIR=C:\Qt\5.11.3\msvc2015_64)
  - set PATH=%PATH%;%QTDIR%\bin
  - cd %APPVEYOR_BUILD_FOLDER%
  - 7z x %APPVEYOR_BUILD_FOLDER%\dev\windows\appveyor\%LOG4CPP_FILE% -aoa
  - mkdir %FFTW_VER%
  - cd %FFTW_VER%
  - 7z x %APPVEYOR_BUILD_FOLDER%\dev\windows\appveyor\%FFTW_VER%.zip -aoa
  - lib /machine:%BUILD_TYPE% /def:libfftw3-3.def
  - lib /machine:%BUILD_TYPE% /def:libfftw3f-3.def
  - lib /machine:%BUILD_TYPE% /def:libfftw3l-3.def
  - mkdir include
  - mkdir lib
  - move fftw3.h include
  - move *dll lib
  - move *def lib
  - move *lib lib

build_script:
  - cd %APPVEYOR_BUILD_FOLDER%
  - set LOG4CPP_HOME=%APPVEYOR_BUILD_FOLDER%\%LOG4CPP_VER%
  - set FFTW_HOME=%APPVEYOR_BUILD_FOLDER%\%FFTW_VER%
  - qmake engauge.pro "CONFIG+=%ENGAUGE_CONFIG%"
  - nmake

after_build:
  - cd %APPVEYOR_BUILD_FOLDER%
  - mkdir %RESULTDIR%
  - mkdir %RESULTDIR%\documentation
  - for %%I in (%QTDIRS%) do mkdir %RESULTDIR%\%%I
#  - copy %QTDIR%\plugins\platforms\qwindows*.dll engauge-build\platforms
  - if defined ENGAUGE_RELEASE (for %%I in (%QTDIRS%) do copy %QTDIR%\plugins\%%I\*.dll %RESULTDIR%\%%I)
  - if defined ENGAUGE_RELEASE (for %%I in (%QTLIBS%) do copy %QTDIR%\bin\%%I.dll %RESULTDIR%)
  - if defined ENGAUGE_RELEASE (del /S *d.dll)
# *d.* also includes PDB files
#  - if not defined ENGAUGE_RELEASE (for %%I in (%QTDIRS%) do copy %QTDIR%\plugins\%%I\*d.* %RESULTDIR%\%%I)
#  - if not defined ENGAUGE_RELEASE (for %%I in (%QTLIBS%) do copy %QTDIR%\bin\%%I*d.* %RESULTDIR%)
  - if not defined ENGAUGE_RELEASE (for %%I in (%QTDIRS%) do copy %QTDIR%\plugins\%%I\*d.dll %RESULTDIR%\%%I)
  - if not defined ENGAUGE_RELEASE (for %%I in (%QTLIBS%) do copy %QTDIR%\bin\%%I*d.dll %RESULTDIR%)
  - IF %BUILD_TYPE% == X86 (set VCLIBDIR=%WINDIR%\SysWOW64) ELSE (set VCLIBDIR=%WINDIR%\system32)
  - for %%I in (%VCLIBS%) do copy %VCLIBDIR%\%%I %RESULTDIR%
  - copy bin\engauge.exe %RESULTDIR%
  - copy %LOG4CPP_VER%\lib\log4cpp.dll %RESULTDIR%
  - copy %FFTW_VER%\lib\libfftw3-3.dll %RESULTDIR%
  - copy LICENSE %RESULTDIR%
  - cd %APPVEYOR_BUILD_FOLDER%\help
  - qcollectiongenerator engauge.qhcp -o engauge.qhc
  - move engauge.qch ..\%RESULTDIR%\documentation
  - move engauge.qhc ..\%RESULTDIR%\documentation
  - cd ..
  - 7z a %RESULTDIR%.7z %RESULTDIR%

artifacts:
  - path: engauge-build*.7z
    name: engauge-build-result
