Skip to content

Docs/php win build local and remote #12179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/scripts/windows/build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@echo off

if /i "%GITHUB_ACTIONS%" neq "True" (
echo for CI only
exit /b 3
Expand Down
24 changes: 24 additions & 0 deletions .github/scripts/windows/cleanup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@echo off
echo "Stopping Firebird Server..."
sc query FirebirdServerTestInstance >nul 2>&1
if errorlevel 1 (
echo "FirebirdServerTestInstance Service does not exist. Nothing to do."
) else (
sc stop FirebirdServerTestInstance
sc delete FirebirdServerTestInstance
echo "Stopped FirebirdServerTestInstance"
)

echo "Stopping SNMPTrap..."
sc query SNMPTrap >nul 2>&1
if errorlevel 1 (
echo "SNMPTrap Service does not exist. Nothing to do."
) else (
sc stop SNMPTrap
sc delete SNMPTrap
echo "Stopped SNMPTrap"
)

if EXIST C:\tests_tmp rmdir /s /q C:\tests_tmp
if EXIST %PHP_BUILD_DIR%\test_file_cache rmdir /s /q %PHP_BUILD_DIR%\test_file_cache

16 changes: 16 additions & 0 deletions .github/scripts/windows/env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@echo off

set PHP_BUILD_CACHE_BASE_DIR=C:\build-cache
set PHP_BUILD_OBJ_DIR=C:\obj
set PHP_BUILD_CACHE_SDK_DIR=C:\build-cache\sdk
set PHP_BUILD_SDK_BRANCH=php_src-2.2.1-dev
set PHP_BUILD_CRT=vs16
set PLATFORM=x64
set THREAD_SAFE=1
set INTRINSICS=AVX2
set PARALLEL= -j2
set OPCACHE=1

set GITHUB_ACTIONS=True
set BRANCH=master
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust to whatever command you like; I forgot the one-liner to get the currently checked out git branch is all


6 changes: 4 additions & 2 deletions .github/scripts/windows/test.bat
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@echo off

if /i "%GITHUB_ACTIONS%" neq "True" (
echo for CI only
exit /b 3
)

set WIN_SCRIPTS_DIR=%~dp0
set SCRIPT_DRIVE=%~d0

set SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
rem SDK_RUNNER=%PHP_BUILD_CACHE_SDK_DIR%\phpsdk-%PHP_BUILD_CRT%-%PLATFORM%.bat
if not exist "%SDK_RUNNER%" (
echo "%SDK_RUNNER%" doesn't exist
exit /b 3
Expand Down
31 changes: 17 additions & 14 deletions .github/scripts/windows/test_task.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@echo off

if /i "%GITHUB_ACTIONS%" neq "True" (
echo for CI only
exit /b 3
Expand All @@ -9,7 +7,7 @@ set NO_INTERACTION=1
set REPORT_EXIT_STATUS=1
set SKIP_IO_CAPTURE_TESTS=1

call %~dp0find-target-branch.bat
call %WIN_SCRIPTS_DIR%\find-target-branch.bat
if "%BRANCH%" neq "master" (
set STABILITY=stable
) else (
Expand All @@ -32,18 +30,21 @@ set PDO_MYSQL_TEST_PASS=%MYSQL_PWD%
set PDO_MYSQL_TEST_HOST=%MYSQL_TEST_HOST%
set PDO_MYSQL_TEST_PORT=%MYSQL_TEST_PORT%
set PDO_MYSQL_TEST_DSN=mysql:host=%PDO_MYSQL_TEST_HOST%;port=%PDO_MYSQL_TEST_PORT%;dbname=test
set TMP_MYSQL_BIN=C:\mysql\bin
"%TMP_MYSQL_BIN%\mysql.exe" --host=%PDO_MYSQL_TEST_HOST% --port=%MYSQL_TEST_PORT% --user=%MYSQL_TEST_USER% --password=%MYSQL_TEST_PASSWD% -e "CREATE DATABASE IF NOT EXISTS test"
set PATH=%PATH%;C:\mysql\bin
mysql.exe --host=%PDO_MYSQL_TEST_HOST% --port=%MYSQL_TEST_PORT% --user=%MYSQL_TEST_USER% --password=%MYSQL_TEST_PASSWD% -e "CREATE DATABASE IF NOT EXISTS test"
Comment on lines +33 to +34
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea why C:\mysql is expected, but chocolatey doesn't set it up, so here is a workaround to allow GH actions to work at the same time as allowing any mysql cli binary to be executed

if %errorlevel% neq 0 exit /b 3

rem setup PostgreSQL related exts
set PGUSER=postgres
set PGPASSWORD=Password12!
rem set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=postgres password=Password12!
git checkout "./ext/pgsql/tests/config.inc"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this the config.inc gets constantly appended to. This ensures there is one line 😄

echo ^<?php $conn_str = "host=127.0.0.1 dbname=test port=5432 user=%PGUSER% password=%PGPASSWORD%"; ?^> >> "./ext/pgsql/tests/config.inc"
set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=%PGUSER% password=%PGPASSWORD%
set TMP_POSTGRESQL_BIN=%PGBIN%
"%TMP_POSTGRESQL_BIN%\createdb.exe" test
set PATH=%PATH%;%PGBIN%
psql -U postgres -c "DROP SCHEMA IF EXISTS test"
psql -U postgres -c "CREATE SCHEMA IF NOT EXISTS test"
Comment on lines +44 to +46
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll see this pattern copied with mysql. Basically the createdb command does not exist on my local install of postgres. This makes sure there is a schema and that it's fresh. It also uses path so if the path explicitly supplied did exist, then we can use that set of binaries. But respects user paths if not.

rem psql -U postgres -W -c "\dn"
if %errorlevel% neq 0 exit /b 3

rem setup ODBC related exts
Expand All @@ -54,7 +55,7 @@ set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%

rem setup Firebird related exts
curl -sLo Firebird.zip https://github.com/FirebirdSQL/firebird/releases/download/v3.0.9/Firebird-3.0.9.33560-0_x64.zip
7z x -oC:\Firebird Firebird.zip
7z x -y -oC:\Firebird Firebird.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this flag answers yes to overwriting files if run more than once. As a result the cleanup.bat and other such scripts provide improvement (can't remove or overwrite if firebird exists, which it never will in GitHub actions)

set PDO_FIREBIRD_TEST_DATABASE=C:\test.fdb
set PDO_FIREBIRD_TEST_DSN=firebird:dbname=%PDO_FIREBIRD_TEST_DATABASE%
set PDO_FIREBIRD_TEST_USER=SYSDBA
Expand All @@ -77,7 +78,7 @@ if "%PLATFORM%" == "x64" (
if /i "%GITHUB_ACTIONS%" equ "True" (
rmdir /s /q %OPENSSLDIR% >nul 2>&1
)
mkdir %OPENSSLDIR%
if NOT exist %OPENSSLDIR% mkdir %OPENSSLDIR%
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what passes for mkdir -p in windows 🤮

if %errorlevel% neq 0 exit /b 3
copy %DEPS_DIR%\template\ssl\openssl.cnf %OPENSSLDIR%
if %errorlevel% neq 0 exit /b 3
Expand All @@ -91,16 +92,16 @@ rem work-around for failing to dl(mysqli) with OPcache (https://github.com/php/p
if "%OPCACHE%" equ "1" set OPCACHE_OPTS=%OPCACHE_OPTS% -d extension=mysqli

rem prepare for enchant
mkdir %~d0\usr\local\lib\enchant-2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%~d0 apparently means current drive. I believe using C:\ will make this more readable

if NOT EXIST %SCRIPT_DRIVE%\usr\local\lib\enchant-2 mkdir %SCRIPT_DRIVE%\usr\local\lib\enchant-2
if %errorlevel% neq 0 exit /b 3
copy %DEPS_DIR%\bin\libenchant2_hunspell.dll %~d0\usr\local\lib\enchant-2
copy %DEPS_DIR%\bin\libenchant2_hunspell.dll %SCRIPT_DRIVE%\usr\local\lib\enchant-2
if %errorlevel% neq 0 exit /b 3
mkdir %~d0\usr\local\share\enchant\hunspell
if NOT EXIST %SCRIPT_DRIVE%\usr\local\share\enchant\hunspell mkdir %SCRIPT_DRIVE%\usr\local\share\enchant\hunspell
if %errorlevel% neq 0 exit /b 3
echo Fetching enchant dicts
pushd %~d0\usr\local\share\enchant\hunspell
pushd %SCRIPT_DRIVE%\usr\local\share\enchant\hunspell
powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip
unzip dict.zip
unzip -o dict.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overwrite files when unzipping

del /q dict.zip
popd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to use this locally we should separate installation (i.e. downloading of libs, unzipping, etc.) into a separate script that doesn't have to be run every time PHP is built.


Expand All @@ -117,6 +118,7 @@ hMailServer.exe /verysilent
cd %APPVEYOR_BUILD_FOLDER%
%PHP_BUILD_DIR%\php.exe -dextension_dir=%PHP_BUILD_DIR% -dextension=com_dotnet appveyor\setup_hmailserver.php

if EXIST %PHP_BUILD_DIR%\test_file_cache rmdir /s /q %PHP_BUILD_DIR%\test_file_cache
mkdir %PHP_BUILD_DIR%\test_file_cache
rem generate php.ini
echo extension_dir=%PHP_BUILD_DIR% > %PHP_BUILD_DIR%\php.ini
Expand All @@ -132,6 +134,7 @@ for %%i in (ldap oci8_12c pdo_oci) do (

set TEST_PHPDBG_EXECUTABLE=%PHP_BUILD_DIR%\phpdbg.exe

if EXIST C:\tests_tmp rmdir /s /q C:\tests_tmp
mkdir c:\tests_tmp

set TEST_PHP_JUNIT=c:\junit.out.xml
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,5 @@ tmp-php.ini
!/ext/fileinfo/magicdata.patch
!/ext/pcre/pcre2lib/config.h
!/win32/build/Makefile
Firebird.zip
hMailServer.exe
Comment on lines +300 to +301
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two uglies showed up on my local