# The SourceForge servers are really unreliable to download from.
# Half the time, the downloads time-out, causing the build to fail.
# As such, I have made a bintray mirror, which should be more reliable.
platform:
  - x64
branches:
  only:
  - master
clone_depth: 10
environment:
  global:
    MBASH: C:\msys64\usr\bin\sh -lc
    MSYS2_FC_CACHE_SKIP: true
  matrix:
    - MSYSTEM: MINGW32
      MBITS: 32
      VCXSRV: VcXsrv-1.14.2-minimal.tar.xz
      BACKEND: x11
# For speed, we disable 64-bit builds.
#    - MSYSTEM: MINGW64
#      MBITS: 64
#      VCXSRV: VcXsrv-1.17.0.0-x86_64-minimal.tar.xz
#      BACKEND: x11
# No GDK builds yet
#    - MSYSTEM: MINGW32
#      MBITS: 32
#      VCXSRV: VcXsrv-1.14.2-minimal.tar.xz
#      BACKEND: gdk
#      GDKOPT: --enable-gdk
#    - MSYSTEM: MINGW64
#      MBITS: 64
#      VCXSRV: VcXsrv-1.17.0.0-x86_64-minimal.tar.xz
#      BACKEND: gdk
#      GDKOPT: --enable-gdk

#The cache is slightly slower than just downloading the files
#cache:
#  - 'C:\msys64\var\cache\pacman\pkg'
install:
  - git clone --depth=1 --branch=master https://github.com/fontforge/fontforgebuilds.git
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds/original-archives/binaries; exec 0</dev/null; wget --tries 4 https://dl.bintray.com/jtanx/fontforgelibs/build-system-extras/potrace-1.14.win$MBITS.tar.gz"
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds/original-archives/binaries; exec 0</dev/null; wget --tries 4 https://dl.bintray.com/jtanx/fontforgelibs/build-system-extras/$VCXSRV"
  - >-
    call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds/original-archives/sources; exec 0</dev/null;
    wget --tries 1 http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.bz2 || 
    wget --tries 4 https://sourceforge.net/projects/freetype/files/freetype2/2.8/freetype-2.8.tar.bz2"
# These steps will update msys2 to the latest version
# Uncomment these if builds fail because of pacman not installing dependencies due to version conflicts
#  - call %MBASH% "pacman -Syuu --noconfirm"
#  - call %MBASH% "pacman -Suu --noconfirm"
#  - call %MBASH% "pacman -Suu --noconfirm"
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds; exec 0</dev/null; ./ffbuild.sh $GDKOPT --appveyor --depsonly"
build_script:
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds; exec 0</dev/null; ./ffbuild.sh $GDKOPT --appveyor"
  - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER/fontforgebuilds; exec 0</dev/null; FFPATH=`cygpath -m $APPVEYOR_BUILD_FOLDER` ./make-portable-package.sh appveyor"
test: off
artifacts:
  - path: fontforgebuilds\*-appveyor.7z
    name: FontForge $(MBITS)-bit $(BACKEND) build
  - path: fontforgebuilds\*-debugging-symbols.7z
    name: FontForge $(MBITS)-bit $(BACKEND) debugging symbols
