Skip to content

Commit 05442e5

Browse files
committed
* fix Windows build2
1 parent 1ebff7a commit 05442e5

File tree

9 files changed

+380
-128
lines changed

9 files changed

+380
-128
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Setup
2+
runs:
3+
using: composite
4+
steps:
5+
- name: Setup MySQL
6+
shell: cmd
7+
run: |
8+
mysqld --initialize-insecure
9+
mysqld --install
10+
net start MySQL
11+
mysql --port=3306 --user=root --password="" -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Password12!'; FLUSH PRIVILEGES;"
12+
- name: Setup MSSQL
13+
shell: pwsh
14+
run: |
15+
choco install sql-server-express -y --no-progress --install-arguments="/SECURITYMODE=SQL /SAPWD=Password12!"
16+
- name: Setup PostgreSQL
17+
shell: pwsh
18+
run: |
19+
Set-Service -Name "postgresql-x64-14" -StartupType manual -Status Running
20+
pwsh -Command { $env:PGPASSWORD="root"; & "$env:PGBIN\psql" -U postgres -c "ALTER USER postgres WITH PASSWORD 'Password12!';" }

.github/scripts/windows/build.bat

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
if /i "%GITHUB_ACTIONS%" neq "True" (
2+
echo for CI only
3+
exit /b 3
4+
)
5+
6+
set SDK_REMOTE=https://github.com/php/php-sdk-binary-tools.git
7+
set SDK_BRANCH=%PHP_BUILD_SDK_BRANCH%
8+
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
9+
10+
if not exist "%PHP_BUILD_CACHE_BASE_DIR%" (
11+
echo Creating %PHP_BUILD_CACHE_BASE_DIR%
12+
mkdir "%PHP_BUILD_CACHE_BASE_DIR%"
13+
)
14+
15+
if not exist "%PHP_BUILD_OBJ_DIR%" (
16+
echo Creating %PHP_BUILD_OBJ_DIR%
17+
mkdir "%PHP_BUILD_OBJ_DIR%"
18+
)
19+
20+
if not exist "%SDK_RUNNER%" (
21+
if exist "%PHP_BUILD_CACHE_SDK_DIR%" rmdir /s /q "%PHP_BUILD_CACHE_SDK_DIR%"
22+
)
23+
24+
if 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+
29+
for /f "tokens=*" %%a in ('type %PHP_BUILD_CACHE_SDK_DIR%\VERSION') do set GOT_SDK_VER=%%a
30+
echo Got SDK version %GOT_SDK_VER%
31+
if 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+
39+
if not exist "%SDK_RUNNER%" (
40+
echo "%SDK_RUNNER%" doesn't exist
41+
exit /b 3
42+
)
43+
44+
for /f "delims=" %%T in ('call .github\scripts\windows\find-vs-toolset.bat %PHP_BUILD_CRT%') do set "VS_TOOLSET=%%T"
45+
echo Got VS Toolset %VS_TOOLSET%
46+
cmd /c %SDK_RUNNER% -s %VS_TOOLSET% -t .github\scripts\windows\build_task.bat
47+
if %errorlevel% neq 0 exit /b 3
48+
49+
exit /b 0
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@echo off
2+
3+
if /i "%GITHUB_ACTIONS%" neq "True" (
4+
echo for CI only
5+
exit /b 3
6+
)
7+
8+
call %~dp0find-target-branch.bat
9+
set STABILITY=staging
10+
set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
11+
rem SDK is cached, deps info is cached as well
12+
echo Updating dependencies in %DEPS_DIR%
13+
cmd /c phpsdk_deps --update --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR% --crt %PHP_BUILD_CRT%
14+
if %errorlevel% neq 0 exit /b 3
15+
16+
rem Something went wrong, most likely when concurrent builds were to fetch deps
17+
rem updates. It might be, that some locking mechanism is needed.
18+
if not exist "%DEPS_DIR%" (
19+
cmd /c phpsdk_deps --update --force --no-backup --branch %BRANCH% --stability %STABILITY% --deps %DEPS_DIR%
20+
)
21+
if %errorlevel% neq 0 exit /b 3
22+
23+
cmd /c buildconf.bat --force
24+
if %errorlevel% neq 0 exit /b 3
25+
26+
if "%THREAD_SAFE%" equ "0" set ADD_CONF=%ADD_CONF% --disable-zts
27+
if "%INTRINSICS%" neq "" set ADD_CONF=%ADD_CONF% --enable-native-intrinsics=%INTRINSICS%
28+
if "%ASAN%" equ "1" set ADD_CONF=%ADD_CONF% --enable-sanitizer --enable-debug-pack
29+
30+
rem C4018: comparison: signed/unsigned mismatch
31+
rem C4146: unary minus operator applied to unsigned type
32+
rem C4244: type conversion, possible loss of data
33+
rem C4267: 'size_t' type conversion, possible loss of data
34+
set CFLAGS=/W3 /WX /wd4018 /wd4146 /wd4244 /wd4267
35+
36+
rem Set LibUV paths for async extension
37+
set LIBUV_INCLUDE=C:\vcpkg\installed\x64-windows\include
38+
set LIBUV_LIB=C:\vcpkg\installed\x64-windows\lib
39+
40+
cmd /c configure.bat ^
41+
--enable-snapshot-build ^
42+
--disable-debug-pack ^
43+
--without-analyzer ^
44+
--enable-object-out-dir=%PHP_BUILD_OBJ_DIR% ^
45+
--with-php-build=%DEPS_DIR% ^
46+
--enable-async ^
47+
--with-libuv=%LIBUV_INCLUDE% ^
48+
%ADD_CONF% ^
49+
--disable-test-ini
50+
if %errorlevel% neq 0 exit /b 3
51+
52+
nmake /NOLOGO
53+
if %errorlevel% neq 0 exit /b 3
54+
nmake /NOLOGO comtest.dll
55+
if %errorlevel% neq 0 exit /b 3
56+
57+
exit /b 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
3+
for /f "usebackq tokens=3" %%i in (`findstr PHP_MAJOR_VERSION main\php_version.h`) do set BRANCH=%%i
4+
for /f "usebackq tokens=3" %%i in (`findstr PHP_MINOR_VERSION main\php_version.h`) do set BRANCH=%BRANCH%.%%i
5+
6+
if /i "%BRANCH%" equ "8.5" (
7+
set BRANCH=master
8+
)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@echo off
2+
3+
setlocal enabledelayedexpansion
4+
5+
if "%~1"=="" (
6+
echo ERROR: Usage: %~nx0 [vc14^|vc15^|vs16^|vs17]
7+
exit /b 1
8+
)
9+
10+
set "toolsets_vc14=14.0"
11+
set "toolsets_vc15="
12+
set "toolsets_vs16="
13+
set "toolsets_vs17="
14+
15+
16+
for /f "usebackq tokens=*" %%I in (`vswhere.exe -latest -find "VC\Tools\MSVC"`) do set "MSVCDIR=%%I"
17+
18+
if not defined MSVCDIR (
19+
echo ERROR: could not locate VC\Tools\MSVC
20+
exit /b 1
21+
)
22+
23+
for /f "delims=" %%D in ('dir /b /ad "%MSVCDIR%"') do (
24+
for /f "tokens=1,2 delims=." %%A in ("%%D") do (
25+
set "maj=%%A" & set "min=%%B"
26+
if "!maj!"=="14" (
27+
if !min! LEQ 9 (
28+
set "toolsets_vc14=%%D"
29+
) else if !min! LEQ 19 (
30+
set "toolsets_vc15=%%D"
31+
) else if !min! LEQ 29 (
32+
set "toolsets_vs16=%%D"
33+
) else (
34+
set "toolsets_vs17=%%D"
35+
)
36+
)
37+
)
38+
)
39+
40+
set "KEY=%~1"
41+
set "VAR=toolsets_%KEY%"
42+
call set "RESULT=%%%VAR%%%"
43+
if defined RESULT (
44+
echo %RESULT%
45+
exit /b 0
46+
) else (
47+
echo ERROR: no toolset found for %KEY%
48+
exit /b 1
49+
)

.github/scripts/windows/test.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
if /i "%GITHUB_ACTIONS%" neq "True" (
2+
echo for CI only
3+
exit /b 3
4+
)
5+
6+
set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
7+
if not exist "%SDK_RUNNER%" (
8+
echo "%SDK_RUNNER%" doesn't exist
9+
exit /b 3
10+
)
11+
12+
for /f "delims=" %%T in ('call .github\scripts\windows\find-vs-toolset.bat %PHP_BUILD_CRT%') do set "VS_TOOLSET=%%T"
13+
cmd /c %SDK_RUNNER% -s %VS_TOOLSET% -t .github\scripts\windows\test_task.bat
14+
if %errorlevel% neq 0 exit /b 3
15+
16+
exit /b 0
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
if /i "%GITHUB_ACTIONS%" neq "True" (
2+
echo for CI only
3+
exit /b 3
4+
)
5+
6+
set NO_INTERACTION=1
7+
set REPORT_EXIT_STATUS=1
8+
set SKIP_IO_CAPTURE_TESTS=1
9+
10+
call %~dp0find-target-branch.bat
11+
if "%BRANCH%" neq "master" (
12+
set STABILITY=stable
13+
) else (
14+
set STABILITY=staging
15+
)
16+
set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
17+
if not exist "%DEPS_DIR%" (
18+
echo "%DEPS_DIR%" doesn't exist
19+
exit /b 3
20+
)
21+
22+
rem setup MySQL related exts
23+
set MYSQL_PWD=Password12!
24+
set MYSQL_TEST_PASSWD=%MYSQL_PWD%
25+
set MYSQL_TEST_USER=root
26+
set MYSQL_TEST_HOST=127.0.0.1
27+
set MYSQL_TEST_PORT=3306
28+
set PDO_MYSQL_TEST_USER=%MYSQL_TEST_USER%
29+
set PDO_MYSQL_TEST_PASS=%MYSQL_PWD%
30+
set PDO_MYSQL_TEST_HOST=%MYSQL_TEST_HOST%
31+
set PDO_MYSQL_TEST_PORT=%MYSQL_TEST_PORT%
32+
set PDO_MYSQL_TEST_DSN=mysql:host=%PDO_MYSQL_TEST_HOST%;port=%PDO_MYSQL_TEST_PORT%;dbname=test
33+
mysql --host=%PDO_MYSQL_TEST_HOST% --port=%MYSQL_TEST_PORT% --user=%MYSQL_TEST_USER% --password=%MYSQL_TEST_PASSWD% -e "CREATE DATABASE IF NOT EXISTS test"
34+
if %errorlevel% neq 0 exit /b 3
35+
36+
rem setup PostgreSQL related exts
37+
set PGUSER=postgres
38+
set PGPASSWORD=Password12!
39+
rem set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=postgres password=Password12!
40+
echo ^<?php $conn_str = "host=127.0.0.1 dbname=test port=5432 user=%PGUSER% password=%PGPASSWORD%"; ?^> >> "./ext/pgsql/tests/config.inc"
41+
set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=%PGUSER% password=%PGPASSWORD%
42+
set TMP_POSTGRESQL_BIN=%PGBIN%
43+
"%TMP_POSTGRESQL_BIN%\createdb.exe" test
44+
if %errorlevel% neq 0 exit /b 3
45+
46+
rem setup ODBC related exts
47+
set ODBC_TEST_USER=sa
48+
set ODBC_TEST_PASS=Password12!
49+
set ODBC_TEST_DSN=Driver={ODBC Driver 17 for SQL Server};Server=^(local^)\SQLEXPRESS;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
50+
set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%
51+
52+
rem setup Firebird related exts
53+
if "%PLATFORM%" == "x64" (
54+
set PHP_FIREBIRD_DOWNLOAD_URL=https://github.com/FirebirdSQL/firebird/releases/download/v4.0.4/Firebird-4.0.4.3010-0-x64.zip
55+
) else (
56+
set PHP_FIREBIRD_DOWNLOAD_URL=https://github.com/FirebirdSQL/firebird/releases/download/v4.0.4/Firebird-4.0.4.3010-0-Win32.zip
57+
)
58+
curl -sLo Firebird.zip %PHP_FIREBIRD_DOWNLOAD_URL%
59+
7z x -oC:\Firebird Firebird.zip
60+
set PDO_FIREBIRD_TEST_DATABASE=C:\test.fdb
61+
set PDO_FIREBIRD_TEST_DSN=firebird:dbname=127.0.0.1:%PDO_FIREBIRD_TEST_DATABASE%
62+
set PDO_FIREBIRD_TEST_USER=SYSDBA
63+
set PDO_FIREBIRD_TEST_PASS=phpfi
64+
echo create user %PDO_FIREBIRD_TEST_USER% password '%PDO_FIREBIRD_TEST_PASS%';> C:\Firebird\create_user.sql
65+
echo commit;>> C:\Firebird\create_user.sql
66+
echo create database '%PDO_FIREBIRD_TEST_DATABASE%' user '%PDO_FIREBIRD_TEST_USER%' password '%PDO_FIREBIRD_TEST_PASS%';> C:\Firebird\setup.sql
67+
C:\Firebird\instsvc.exe install -n TestInstance
68+
C:\Firebird\isql -q -i C:\Firebird\setup.sql
69+
C:\Firebird\isql -q -i C:\Firebird\create_user.sql -user sysdba %PDO_FIREBIRD_TEST_DATABASE%
70+
C:\Firebird\instsvc.exe start -n TestInstance
71+
if %errorlevel% neq 0 exit /b 3
72+
path C:\Firebird;%PATH%
73+
74+
rem prepare for ext/openssl
75+
rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL
76+
rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL
77+
if "%PLATFORM%" == "x64" (
78+
set OPENSSLDIR="C:\Program Files\Common Files\SSL"
79+
) else (
80+
set OPENSSLDIR="C:\Program Files (x86)\Common Files\SSL"
81+
)
82+
if /i "%GITHUB_ACTIONS%" equ "True" (
83+
rmdir /s /q %OPENSSLDIR% >nul 2>&1
84+
)
85+
mkdir %OPENSSLDIR%
86+
if %errorlevel% neq 0 exit /b 3
87+
copy %DEPS_DIR%\template\ssl\openssl.cnf %OPENSSLDIR%
88+
if %errorlevel% neq 0 exit /b 3
89+
rem set OPENSSL_CONF=%OPENSSLDIR%\openssl.cnf
90+
set OPENSSL_CONF=
91+
rem set SSLEAY_CONF=
92+
93+
rem prepare for OPcache
94+
if "%OPCACHE%" equ "1" set OPCACHE_OPTS=-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.protect_memory=1 -d opcache.jit_buffer_size=64M -d opcache.jit=tracing
95+
96+
rem prepare for enchant
97+
mkdir %~d0\usr\local\lib\enchant-2
98+
if %errorlevel% neq 0 exit /b 3
99+
copy %DEPS_DIR%\bin\libenchant2_hunspell.dll %~d0\usr\local\lib\enchant-2
100+
if %errorlevel% neq 0 exit /b 3
101+
mkdir %~d0\usr\local\share\enchant\hunspell
102+
if %errorlevel% neq 0 exit /b 3
103+
echo Fetching enchant dicts
104+
pushd %~d0\usr\local\share\enchant\hunspell
105+
powershell -Command wget https://downloads.php.net/~windows/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip
106+
unzip dict.zip
107+
del /q dict.zip
108+
popd
109+
110+
rem prepare for snmp
111+
set MIBDIRS=%DEPS_DIR%\share\mibs
112+
sed -i "s/exec HexTest .*/exec HexTest cscript\.exe \/nologo %GITHUB_WORKSPACE:\=\/%\/ext\/snmp\/tests\/bigtest\.js/g" %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf
113+
start %DEPS_DIR%\bin\snmpd.exe -C -c %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -Ln
114+
115+
set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release
116+
if "%THREAD_SAFE%" equ "1" set PHP_BUILD_DIR=%PHP_BUILD_DIR%_TS
117+
118+
rem prepare for mail
119+
curl -sLo hMailServer.exe https://www.hmailserver.com/download_file/?downloadid=271
120+
hMailServer.exe /verysilent
121+
cd %APPVEYOR_BUILD_FOLDER%
122+
%PHP_BUILD_DIR%\php.exe -dextension_dir=%PHP_BUILD_DIR% -dextension=com_dotnet .github\setup_hmailserver.php
123+
124+
rem prepare for com_dotnet
125+
nmake register_comtest
126+
127+
mkdir %PHP_BUILD_DIR%\test_file_cache
128+
rem generate php.ini
129+
echo extension_dir=%PHP_BUILD_DIR% > %PHP_BUILD_DIR%\php.ini
130+
echo opcache.file_cache=%PHP_BUILD_DIR%\test_file_cache >> %PHP_BUILD_DIR%\php.ini
131+
if "%OPCACHE%" equ "1" echo zend_extension=php_opcache.dll >> %PHP_BUILD_DIR%\php.ini
132+
rem work-around for some spawned PHP processes requiring OpenSSL and sockets
133+
echo extension=php_openssl.dll >> %PHP_BUILD_DIR%\php.ini
134+
echo extension=php_sockets.dll >> %PHP_BUILD_DIR%\php.ini
135+
136+
rem remove ext dlls for which tests are not supported
137+
for %%i in (ldap) do (
138+
del %PHP_BUILD_DIR%\php_%%i.dll
139+
)
140+
141+
rem reduce excessive stack reserve for testing
142+
editbin /stack:8388608 %PHP_BUILD_DIR%\php.exe
143+
editbin /stack:8388608 %PHP_BUILD_DIR%\php-cgi.exe
144+
145+
set TEST_PHPDBG_EXECUTABLE=%PHP_BUILD_DIR%\phpdbg.exe
146+
147+
copy /-y %DEPS_DIR%\bin\*.dll %PHP_BUILD_DIR%\*
148+
149+
if "%ASAN%" equ "1" set ASAN_OPTS=--asan
150+
151+
mkdir c:\tests_tmp
152+
153+
nmake test TESTS="%OPCACHE_OPTS% -g FAIL,BORK,LEAK,XLEAK %ASAN_OPTS% --no-progress -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp %PARALLEL%"
154+
155+
set EXIT_CODE=%errorlevel%
156+
157+
nmake unregister_comtest
158+
taskkill /f /im snmpd.exe
159+
160+
exit /b %EXIT_CODE%

0 commit comments

Comments
 (0)