install:
  - cmd: >-
      if not exist c:\installers mkdir c:\installers

      mkdir c:\temp

      if not exist c:\installers\nasm-2.10.01-win32.zip curl -fSL -o c:\installers\nasm-2.10.01-win32.zip https://nasm.us/pub/nasm/releasebuilds/2.10.01/win32/nasm-2.10.01-win32.zip

      7z x c:\installers\nasm-2.10.01-win32.zip -oc:\ > c:\installers\nasm.install.log

      if not exist c:\installers\i686-6.4.0-release-posix-dwarf-rt_v5-rev0.7z curl -fSL -o c:\installers\i686-6.4.0-release-posix-dwarf-rt_v5-rev0.7z "https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/6.4.0/threads-posix/dwarf/i686-6.4.0-release-posix-dwarf-rt_v5-rev0.7z"

      md "c:\Program Files (x86)\mingw-w64\i686-6.4.0-posix-dwarf-rt_v5-rev0"

      7z x c:\installers\i686-6.4.0-release-posix-dwarf-rt_v5-rev0.7z -o"c:\Program Files (x86)\mingw-w64\i686-6.4.0-posix-dwarf-rt_v5-rev0" > c:\installers\mingw32.install.log

      if not exist c:\installers\x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z curl -fSL -o c:\installers\x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z "https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/6.4.0/threads-posix/seh/x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z"

      md "c:\Program Files\mingw-w64\x86_64-6.4.0-posix-seh-rt_v5-rev0"

      7z x c:\installers\x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z -o"c:\Program Files\mingw-w64\x86_64-6.4.0-posix-seh-rt_v5-rev0" > c:\installers\mingw64.install.log

      set PATH=c:\nasm-2.10.01;c:\Program Files (x86)\NSIS;c:\msys64\usr\bin;%PATH%

      "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"

      set INCLUDE

      set LIB

      set PATH

      set MSYSTEM=MINGW32

      bash -c "pacman --noconfirm -S zip"

      mklink /d "%ProgramData%\Oracle\Java32" "c:\Program Files (x86)\Java\jdk1.8.0"

      git clone --depth=1 https://github.com/libjpeg-turbo/buildscripts.git -b %APPVEYOR_REPO_BRANCH% c:/buildscripts

cache:
  - c:\installers\nasm-2.10.01-win32.zip -> appveyor.yml
  - c:\installers\i686-6.4.0-release-posix-dwarf-rt_v5-rev0.7z -> appveyor.yml
  - c:\installers\x86_64-6.4.0-release-posix-seh-rt_v5-rev0.7z -> appveyor.yml

build_script:
  - cmd: >-
      for /f %%i in ('"cygpath %CD%"') do set MINGWPATH=%%i

      bash c:/buildscripts/buildljt -d %MINGWPATH% -b /c/ljt.nightly -v

      cmake --build . --target clean

      md win64

      cd win64

      bash c:/buildscripts/setupscripts/win64 -DCMAKE_C_FLAGS='-DWIN32 -D_WINDOWS -W4 -wd4100 -wd4127 -wd4245 -wd4324 -wd4701 -wd4702 -wd4706 -WX'

      cd ..

      ninja

      move c:\ljt.nightly\files\*.tar.gz .

      move c:\ljt.nightly\files\*.exe .

      move c:\ljt.nightly\files\*.html .

      move c:\ljt.nightly\log-windows.txt .

      zip libjpeg-turbo-installers.zip libjpeg-turbo-*.exe

artifacts:
  - path: '*.tar.gz'
    name: Source tarball

  - path: '*-gcc*.exe'
    name: SDK for MinGW

  - path: '*-vc*.exe'
    name: SDK for Visual C++

  - path: '*.zip'
    name: All libjpeg-turbo installers

  - path: 'log-windows.txt'
    name: Build log

  - path: 'index.html'
    name: MD5 checksums

test: off

deploy:
  - provider: Webhook
    url: https://app.signpath.io/API/v1/3bc964ce-257b-4362-829f-1df1f087f5a0/Integrations/AppVeyor?ProjectSlug=libjpeg-turbo&SigningPolicySlug=release-signing
    authorization:
      secure: rrx5wnu5VWQqrFZJv75WdPc1H5gyYqp7cV/xVhsx1TnVR7VyUaVEiCYm/64Fcx1zmEPHGyEBrlrbjuRHgDjURA==
    on:
      appveyor_repo_tag: true
  - provider: S3
    access_key_id:
      secure: Z74OYogQ6bNV/I+6b5ZEXig74+6MW2WLER0v/bPM/uk=
    secret_access_key:
      secure: cyGZhHVCFwZ9jgf5lXoW69mVtECmqwx3eLo61ha8ueWbMYlHho7lwDXwVvxOFiCa
    bucket: libjpeg-turbo-pr
    region:
      secure: qSElYBgBRcEUf88M6Osthw==
    folder: $(APPVEYOR_REPO_BRANCH)/windows
    set_public: true
    remove_files: true
