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
34rem Some undefined behavior is reported on 32-bit, this should be fixed
35if "%PLATFORM%" == "x86" (
36	set CFLAGS=/W1
37) else (
38	set CFLAGS=/W1 /WX
39)
40
41cmd /c configure.bat ^
42	--enable-snapshot-build ^
43	--disable-debug-pack ^
44	--enable-com-dotnet=shared ^
45	--without-analyzer ^
46	--enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^
47	--with-php-build=%DEPS_DIR% ^
48	%ADD_CONF% ^
49	--disable-test-ini
50if %errorlevel% neq 0 exit /b 3
51
52nmake /NOLOGO
53if %errorlevel% neq 0 exit /b 3
54
55exit /b 0
56