# DO NOT CHANGE the "init" and "install" sections below

# Download script file from GitHub
init:
  ps: |
        $ErrorActionPreference = "Stop"
        Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1"
        Import-Module '..\appveyor-tool.ps1'
   
install:
    - ps: Bootstrap
    ## install GDAL2
    - ps: (new-object net.webclient).DownloadFile('http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe', 'osgeo4w-setup-x86_64.exe')
    - osgeo4w-setup-x86_64.exe --quiet-mode --upgrade-also --delete-orphans --no-desktop --advanced  --root %systemdrive%\OSGeo4w --packages msvcrt setup shell avce00 zlib iconv libxml2 cairo openssl curl expat fcgi ffmpeg fftw freexl fribidi libpng libjpeg libjpeg12 libtiff libgeotiff proj-hpgn proj-datumgrid proj geos libmysql sqlite3 hdf5 netcdf libpq xerces-c-vc10 hdf4 ogdi openjpeg spatialite gdal python-core python-numpy gdal-python gdal-autotest gdal-filegdb pdcurses msys python-win32 wxpython python-pil pyopengl gs grass gsl-libs libspatialindex mapserver mapscript-python msinttypes opencv psycopg2 qt4-libs pyqt4 pyspatialite six python-dateutil python-devel python-help sip qscintilla python-qscintilla python-shapely python-simplejson python-tcltk python-test python-tools python-xlrd python-xlwt qwt5-libs-qt4 qgis-common qgis qgis-grass-plugin qgis-server setuptools --site http://download.osgeo.org/osgeo4w

    #- ps: mkdir C:\gdal | out-null
    #- curl http://download.gisinternals.com/sdk/downloads/release-1800-x64-gdal-2-1-3-mapserver-7-0-4.zip --output gdalbin.zip
    #- 7z x gdalbin.zip -oC:\gdal
    #- curl http://download.gisinternals.com/sdk/downloads/release-1800-x64-gdal-2-1-3-mapserver-7-0-4-libs.zip --output gdallibs.zip
    #- 7z x gdallibs.zip -oC:\gdal
    - "SET PATH=%systemdrive%\\OSGeo4w;%systemdrive%\\OSGeo4w\\bin;%systemdrive%\\OSGeo4w\\share\\gdal;%systemdrive%\\OSGeo4w\\apps\\gdal;%PATH%"
    - "SET GDAL_DATA=%systemdrive%\\OSGeo4w\\share\\gdal"
    #- "SET PATH=C:\\gdal;C:\\gdal\\bin;C:\\gdal\\data;C:\\gdal\\bin\\gdal\\apps;%PATH%"
    #- "SET GDAL_DATA=C:\\gdal\\bin\\gdal-data"
    #- ECHO "Filesystem C:/GDAL:"
    #- ps: "ls \"C:/GDAL\""

cache:
  - C:\RLibrary

# Adapt as necessary starting from here

build_script:
  - travis-tool.sh install_deps

test_script:
  - travis-tool.sh run_tests

on_failure:
  - 7z a failure.zip *.Rcheck\*
  - appveyor PushArtifact failure.zip

artifacts:
  - path: '*.Rcheck\**\*.log'
    name: Logs

  - path: '*.Rcheck\**\*.out'
    name: Logs

  - path: '*.Rcheck\**\*.fail'
    name: Logs

  - path: '*.Rcheck\**\*.Rout'
    name: Logs

  - path: '\*_*.tar.gz'
    name: Bits

  - path: '\*_*.zip'
    name: Bits
