version: 4.12.3.{build}

environment:
    MSYSTEM: MSYS
    PATH: C:\msys64\mingw32\bin;C:\msys64\usr\bin;C:\Windows\System32;C:\Windows;%PATH%
    QMAKESPEC: win32-g++

platform:
  - x86

configuration:
  - Release

install:
    #- pacman --noconfirm -Sy
    #- pacman --noconfirm --needed -S pacman-mirrors
    #- pacman --noconfirm -Sy
    - pacman --noconfirm --needed -S unzip mingw32/mingw-w64-i686-libmad mingw32/mingw-w64-i686-libsndfile mingw32/mingw-w64-i686-flac mingw32/mingw-w64-i686-fftw mingw32/mingw-w64-i686-nsis
    - wget http://repo.msys2.org/mingw/i686/mingw-w64-i686-gcc-libs-7.4.0-1-any.pkg.tar.xz -P /c/projects
    - wget http://repo.msys2.org/mingw/i686/mingw-w64-i686-gcc-7.4.0-1-any.pkg.tar.xz -P /c/projects
    - wget http://www.qlcplus.org/misc/mingw-w64-i686-qt5-5.6.2-4-any.pkg.tar.xz -P /c/projects
    - pacman --noconfirm -Rdd mingw-w64-i686-gcc
    - pacman --noconfirm -Rdd mingw-w64-i686-gcc-libs
    - pacman --noconfirm --needed -U /c/projects/mingw-w64-i686-gcc-libs-7.4.0-1-any.pkg.tar.xz
    - pacman --noconfirm --needed -U /c/projects/mingw-w64-i686-gcc-7.4.0-1-any.pkg.tar.xz
    - pacman --noconfirm --needed -U /c/projects/mingw-w64-i686-qt5-5.6.2-4-any.pkg.tar.xz

build_script:
    - ps: >-
        bash -c @'
          set -e
          # stdin seems to be invalid on appveyor, so set it to null
          exec 0</dev/null 2>&1
          export
          gcc -v
          qmake -v
          # get and prepare the D2XX SDK
          mkdir -p /c/Qt/D2XXSDK
          wget http://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.24%20WHQL%20Certified.zip -O /c/Qt/D2XXSDK/cdm.zip
          cd /c/Qt/D2XXSDK
          unzip cdm.zip
          cd i386
          gendef.exe - ftd2xx.dll > ftd2xx.def
          dlltool -k --input-def ftd2xx.def --dllname ftd2xx.dll --output-lib libftd2xx.a
          cd /c/projects/qlcplus
          # disable the test units, since we won't run them
          sed -i -e 's/  SUBDIRS += test/#SUBDIRS += test/g' engine/engine.pro
          sed -i -e 's/SUBDIRS += test/#SUBDIRS += test/g' ui/ui.pro
          sed -i -e 's/ SUBDIRS              += velleman/#SUBDIRS += velleman/g' plugins/plugins.pro
          sed -i -e 's/  SUBDIRS += test/#SUBDIRS += test/g' plugins/artnet/artnet.pro
          sed -i -e 's/SUBDIRS += test/#SUBDIRS += test/g' plugins/enttecwing/enttecwing.pro
          sed -i -e 's/SUBDIRS += test/#SUBDIRS += test/g' plugins/midi/midi.pro
          qmake FORCECONFIG=release
          make
          echo 'Silently installing QLC+...'
          make install -s
          cp *.qm /c/qlcplus
          cd /c/qlcplus
          sed -i -e 's/Qt/projects/g' qlcplus4Qt5.nsi
          makensis -X'SetCompressor /FINAL lzma' qlcplus4Qt5.nsi
          #set CURRDATE=`date +%Y%m%d`
          mv QLC+_*.exe /c/projects/qlcplus/QLC+_$APPVEYOR_BUILD_VERSION.exe
          ls /c/projects/qlcplus/*.exe
          exit 0
        '@

artifacts:
  - path: QLC+_$(APPVEYOR_BUILD_VERSION).exe
    name: qlcplus_4_12_3
