xref: /php-src/.github/scripts/windows/build.bat (revision b94ef611)
1if /i "%GITHUB_ACTIONS%" neq "True" (
2    echo for CI only
3    exit /b 3
4)
5
6set SDK_REMOTE=https://github.com/php/php-sdk-binary-tools.git
7set SDK_BRANCH=%PHP_BUILD_SDK_BRANCH%
8set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
9
10if not exist "%PHP_BUILD_CACHE_BASE_DIR%" (
11	echo Creating %PHP_BUILD_CACHE_BASE_DIR%
12	mkdir "%PHP_BUILD_CACHE_BASE_DIR%"
13)
14
15if not exist "%PHP_BUILD_OBJ_DIR%" (
16	echo Creating %PHP_BUILD_OBJ_DIR%
17	mkdir "%PHP_BUILD_OBJ_DIR%"
18)
19
20if not exist "%SDK_RUNNER%" (
21	if exist "%PHP_BUILD_CACHE_SDK_DIR%" rmdir /s /q "%PHP_BUILD_CACHE_SDK_DIR%"
22)
23
24if not exist "%PHP_BUILD_CACHE_SDK_DIR%" (
25	echo Cloning remote SDK repository
26	git clone --branch %SDK_BRANCH% %SDK_REMOTE% --depth 1 "%PHP_BUILD_CACHE_SDK_DIR%" 2>&1
27)
28
29for /f "tokens=*" %%a in ('type %PHP_BUILD_CACHE_SDK_DIR%\VERSION') do set GOT_SDK_VER=%%a
30echo Got SDK version %GOT_SDK_VER%
31if NOT "%GOT_SDK_VER%" == "%PHP_BUILD_SDK_BRANCH:~8%" (
32	echo Switching to the configured SDK version %SDK_BRANCH:~8%
33	echo Fetching remote SDK repository
34	git --git-dir="%PHP_BUILD_CACHE_SDK_DIR%\.git" --work-tree="%PHP_BUILD_CACHE_SDK_DIR%" fetch --prune origin 2>&1
35	echo Checkout SDK repository branch
36	git --git-dir="%PHP_BUILD_CACHE_SDK_DIR%\.git" --work-tree="%PHP_BUILD_CACHE_SDK_DIR%" checkout --force %SDK_BRANCH%
37)
38
39if not exist "%SDK_RUNNER%" (
40	echo "%SDK_RUNNER%" doesn't exist
41	exit /b 3
42)
43
44cmd /c %SDK_RUNNER% -t .github\scripts\windows\build_task.bat
45if %errorlevel% neq 0 exit /b 3
46
47exit /b 0
48