version: '{branch}.{build}'

branches:
  only:
  - master

image: Visual Studio 2017

clone_folder: c:\projects\php-ds

environment:
  PHP_SDK_BINARY_TOOLS_VER: php-sdk-2.1.1

  matrix:
    - ARCH: x86
      INT_SIZE: 32
      PHP_VER: 8.3
      VC_VER: vc15
      ZTS: --enable-zts
    - ARCH: x64
      INT_SIZE: 64
      PHP_VER: 8.3
      VC_VER: vc15
      ZTS: --enable-zts
    - ARCH: x86
      INT_SIZE: 32
      PHP_VER: 8.3
      VC_VER: vc15
      ZTS: --disable-zts
    - ARCH: x64
      INT_SIZE: 64
      PHP_VER: 8.3
      VC_VER: vc15
      ZTS: --disable-zts

install:
- cmd: choco feature enable -n=allowGlobalConfirmation
- cmd: cinst wget
- cmd: mkdir C:\projects\php-ds\bin
- cmd: cd C:\projects\php-ds\bin && appveyor DownloadFile https://getcomposer.org/composer.phar

build_script:
- cmd: >-
    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %ARCH%

    wget https://github.com/OSTC/php-sdk-binary-tools/archive/%PHP_SDK_BINARY_TOOLS_VER%.zip --no-check-certificate -q -O php-sdk-binary-tools-%PHP_SDK_BINARY_TOOLS_VER%.zip

    7z x -y php-sdk-binary-tools-%PHP_SDK_BINARY_TOOLS_VER%.zip -oC:\projects

    move C:\projects\php-sdk-binary-tools-%PHP_SDK_BINARY_TOOLS_VER% C:\projects\php-sdk

    C:\projects\php-sdk\bin\phpsdk_setvars.bat

    git clone https://github.com/php/php-src C:\projects\php-src -b PHP-%PHP_VER% --depth=1

    mkdir C:\projects\php-src\ext\ds

    xcopy C:\projects\php-ds C:\projects\php-src\ext\ds /s /e /y /q

    phpsdk_deps -u -t %VC_VER% -b %PHP_VER% -a %ARCH% -f -d C:\projects\php-src\deps

    cd C:\projects\php-src

    buildconf.bat

    cscript /nologo configure.js --disable-all --enable-cli --enable-cgi %ZTS% --with-openssl --enable-ds=shared --enable-phar --with-prefix=C:\projects\php-ds\bin --with-php-build=deps --with-config-file-scan-dir=C:\projects\php-ds\bin\modules.d --enable-bcmath --enable-calendar --enable-ctype --enable-filter --enable-hash --with-mhash --with-iconv --enable-json --enable-mbstring --with-readline --enable-session --enable-soap=shared --enable-tokenizer --enable-zip --enable-zlib --with-libxml --with-dom --with-simplexml --with-xml --with-wddx --enable-xmlreader --enable-xmlwriter

    nmake

    nmake install

    copy php.ini-development C:\projects\php-ds\bin\php.ini

    mkdir C:\projects\php-ds\bin\modules.d

    echo extension=php_ds.dll >> C:\projects\php-ds\bin\modules.d\php.ini

    echo extension=php_openssl.dll >> C:\projects\php-ds\bin\modules.d\php.ini

    echo extension=php_soap.dll >> C:\projects\php-ds\bin\modules.d\php.ini

    cd C:\projects\php-ds\bin

    set TEST_PHP_EXECUTABLE=%cd%\php.exe

    php -v

    php -m

test_script:
- cmd: cd C:\projects\php-ds
- cmd: C:\projects\php-ds\bin\php.exe C:\projects\php-ds\bin\composer.phar update --prefer-source
- cmd: C:\projects\php-ds\bin\php.exe test.php > test.txt
- cmd: type test.txt
- cmd: cd C:\projects\php-ds\bin
- cmd: php.exe /projects/php-src/run-tests.php /projects/php-src/ext/ds -q --show-diff

artifacts:
  - path: bin
    name: master
    type: zip
