branches:
  # As AppVeyor test is slow, we only run AppVeyor against development and
  # stable branches.
  # To disable AppVeyor against Pull-Requests, disable Pull-Request event
  # in web-hook configuration of GitHub settings.
  only:
    - master
    - v2

image:
  - Visual Studio 2015

environment:
  global:
    # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
    # /E:ON and /V:ON options are not enabled in the batch script intepreter
    # See: https://stackoverflow.com/a/13751649/163740
    CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"

  matrix:

    # Pre-installed Python versions, which Appveyor may upgrade to
    # a later point release.
    # See: https://www.appveyor.com/docs/installed-software#python

    - PYTHON: "C:\\Python36-x64"
      PYTHON_VERSION: "3.6.x"
      PYTHON_ARCH: "64"

  CUPY_CI: appveyor

install:
  - ECHO "Filesystem root:"
  - ps: "ls \"C:/\""

  - ECHO "Installed SDKs:"
  - ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""

  # Install CUDA & cuDNN.
  - ps: appveyor\install-cuda.ps1
  - "SET CUDA_PATH=%ProgramFiles%\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.1"
  - "SET NVTOOLSEXT_PATH=%ProgramFiles%\\NVIDIA Corporation\\NvToolsExt"
  - "SET PATH=%CUDA_PATH%\\bin;%NVTOOLSEXT_PATH%\\bin\\x64;%PATH%"

  # Install Python (from the official .msi of https://www.python.org) and pip when
  # not already installed.
  - ps: if (-not(Test-Path($env:PYTHON))) { & appveyor\install.ps1 }

  # Prepend newly installed Python to the PATH of this build (this cannot be
  # done from inside the powershell script as it would require to restart
  # the parent CMD process).
  - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"

  # Check that we have the expected version and architecture for Python
  - "python --version"
  - "python -c \"import struct; print(struct.calcsize('P') * 8)\""

  - "python -m pip install -U pip"
  - "pip install -U setuptools"
  - "pip install -U Cython"


build_script:
  # for CUB submodule
  - "git submodule update --init --recursive"
  # Build the compiled extension
  - "%CMD_IN_ENV% python setup.py build install -vvvv"

test_script:
  # Installation test
  - "%CMD_IN_ENV% pip install -U -e .[appveyor]"
  # Import test
  #- python -c "import cupy"
  #- python -c "import cupy.cuda.nvtx"
  #- python -c "import cupy.cuda.cudnn"
  #- python -c "import cupy.cuda.cusolver"
  #- python -c "import cupy.cuda.thrust"
