1@echo off
2
3if /i "%GITHUB_ACTIONS%" neq "True" (
4    echo for CI only
5    exit /b 3
6)
7
8del /f /q C:\Windows\System32\libcrypto-1_1-x64.dll >NUL 2>NUL
9if %errorlevel% neq 0 exit /b 3
10del /f /q C:\Windows\System32\libssl-1_1-x64.dll >NUL 2>NUL
11if %errorlevel% neq 0 exit /b 3
12
13call %~dp0find-target-branch.bat
14set STABILITY=staging
15set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
16rem SDK is cached, deps info is cached as well
17echo Updating dependencies in %DEPS_DIR%
18cmd /c phpsdk_deps --update --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR% --crt %PHP_BUILD_CRT%
19if %errorlevel% neq 0 exit /b 3
20
21rem Something went wrong, most likely when concurrent builds were to fetch deps
22rem updates. It might be, that some locking mechanism is needed.
23if not exist "%DEPS_DIR%" (
24	cmd /c phpsdk_deps --update --force --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR%
25)
26if %errorlevel% neq 0 exit /b 3
27
28cmd /c buildconf.bat --force
29if %errorlevel% neq 0 exit /b 3
30
31if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts
32if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS%
33
34set CFLAGS=/W1 /WX
35
36cmd /c configure.bat ^
37	--enable-snapshot-build ^
38	--disable-debug-pack ^
39	--without-analyzer ^
40	--enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^
41	--with-php-build=%DEPS_DIR% ^
42	%ADD_CONF% ^
43	--disable-test-ini
44if %errorlevel% neq 0 exit /b 3
45
46nmake /NOLOGO
47if %errorlevel% neq 0 exit /b 3
48
49exit /b 0
50