Skip to content
Merged
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
25 changes: 25 additions & 0 deletions win_build_scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Scripts building php-firebird extension on Windows

## How it works

These scripts will clone or pull corresponding PHP version(s) from the PHP source repo and build 4 .dll files per PHP version: x86, x64 and ts and non-ts for each architecture.

Do not run scripts with ``-sdk-`` in their files names directly. These are called from php-sdk environment.

Make sure you got ~20GB free disk space to build for all PHP versions.

## Set up

Make sure ``git`` is in you PATH

1. Set up Microsoft Visual Studio vc15 and vs16.
2. Set up Firebird 32-bit and 64-bit installations or libraries.
3. Set up PHP-SDK according to https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
4. Clone php-firebird extension source somewhere.
4. Copy these build scripts to C:\php-sdk\
5. Adjust php-fb-config.bat.

``Note: PFB_SOURCE_DIR should point one level up. For example
PFB_SOURCE_DIR=D:\php-firebird\ then your source should reside in D:\php-firebird\php-firebird\
``
6. Run ``php-fb-build-all.bat`` to build for all PHP versions or run ``php-fb-build.bat 7.4 vc15`` to build for particular version.
8 changes: 8 additions & 0 deletions win_build_scripts/php-fb-build-all.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off

call php-fb-build.bat 7.3 vc15 || exit /B %ERRORLEVEL%
call php-fb-build.bat 7.4 vc15 || exit /B %ERRORLEVEL%
call php-fb-build.bat 8.0 vs16 || exit /B %ERRORLEVEL%
call php-fb-build.bat 8.1 vs16 || exit /B %ERRORLEVEL%
call php-fb-build.bat 8.2 vs16 || exit /B %ERRORLEVEL%
call php-fb-build.bat master vs16 || exit /B %ERRORLEVEL%
78 changes: 78 additions & 0 deletions win_build_scripts/php-fb-build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@echo off

@REM config ======================================================================================
call php-fb-config.bat

goto :MAIN

@REM log =========================================================================================
@REM log <msg>
@REM example> call :log "<msg>"
:log
set msg=%~1
echo ---------------------------------------------------------------------
echo %msg%
echo ---------------------------------------------------------------------
exit /B

:usage
call :log "Usage: %~nx0 php_vers cpp_vers"
exit /B

:MAIN
set pfb_php_vers=%1
set pfb_cpp_vers=%2

if [%pfb_php_vers%] == [] (
call :usage
echo pfb_php_vers varible not set
exit 1
)

if [%pfb_cpp_vers%] == [] (
call :usage
echo pfb_cpp_vers varible not set
exit 1
)

set pfb_build_root=php%pfb_php_vers%\%pfb_cpp_vers%\

(for %%a in (x86 x64) do (
@REM check out or pull PHP version of interest
if exist %pfb_build_root%\%%a\php-src\.git\ (
call :log "Checking out PHP-%pfb_php_vers% %%a"
git -C %pfb_build_root%\%%a\php-src pull || goto :error
) else (
call :log "Cloning PHP-%pfb_php_vers% %%a"
call phpsdk-%pfb_cpp_vers%-%%a.bat -t php-fb-sdk-init.bat || goto :error
)

if %%a EQU x86 ( set pfb_x86=1 ) else ( set pfb_x86=0 )

(for %%n in (0 1) do (
set pfb_nts=%%n
call phpsdk-%pfb_cpp_vers%-%%a.bat -t php-fb-sdk-build.bat || goto :error
))
))

@REM check if ibase_connect() function exists in newly compiled extension
set check_code="if(!function_exists('ibase_connect'))exit(1);"
"%pfb_build_root%x64\php-src\x64\Release_TS\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
"%pfb_build_root%x64\php-src\x64\Release\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
"%pfb_build_root%x86\php-src\Release_TS\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
"%pfb_build_root%x86\php-src\Release\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error

call :log "PHP %pfb_php_vers% build OK"

@REM copy compiled extension to target directory
copy %pfb_build_root%x64\php-src\x64\Release_TS\php_interbase.dll %PFB_OUTPUT_DIR%php_interbase-%PFB_VERS%-%pfb_php_vers%-%pfb_cpp_vers%-x86_64.dll>nul
copy %pfb_build_root%x64\php-src\x64\Release\php_interbase.dll %PFB_OUTPUT_DIR%php_interbase-%PFB_VERS%-%pfb_php_vers%-%pfb_cpp_vers%-nts-x86_64.dll>nul
copy %pfb_build_root%x86\php-src\Release_TS\php_interbase.dll %PFB_OUTPUT_DIR%php_interbase-%PFB_VERS%-%pfb_php_vers%-%pfb_cpp_vers%.dll>nul
copy %pfb_build_root%x86\php-src\Release\php_interbase.dll %PFB_OUTPUT_DIR%php_interbase-%PFB_VERS%-%pfb_php_vers%-%pfb_cpp_vers%-nts.dll>nul

exit /B 0

:error
call :log "PHP %pfb_php_vers% build FAILED"

exit /B 1
16 changes: 16 additions & 0 deletions win_build_scripts/php-fb-config.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@REM
@REM git command must be in PATH
@REM

@REM sets php-firebird version part in extension file, for example, php_interbase-<<3.0.1-ba8e63b>>-7.3-vc15.dll
set PFB_VERS=3.0.1-ba8e63b

@REM Directory where all compiled files will be copied
set PFB_OUTPUT_DIR=D:\php-firebird\releases\

@REM FB 32-bit and 64-bit libraries
set PFB_FB32_DIR=C:\Program Files\Firebird\Firebird_3_0-x86\
set PFB_FB64_DIR=C:\Program Files\Firebird\Firebird_3_0\

@REM php-firebird source directory
set PFB_SOURCE_DIR=D:\php-firebird\ba8e63b\
57 changes: 57 additions & 0 deletions win_build_scripts/php-fb-sdk-build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@echo off
@REM
@REM Must be called under phpsdk-<php_vers>-<arch>.bat
@REM
@REM Calling script should set variables:
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> <pfb_php_vers> [pfb_nts] [pfb_x86]
@REM
@REM set pfb_php_vers=7.4
@REM set pfb_nts=1 if nts expected, 0 if ts
@REM set pfb_x86=1 if linking to x86 fbclient, o if x64
@REM
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> all set in php-fb-config.bat
@REM

goto :MAIN

@REM log =========================================================================================
@REM log <msg>
@REM example> call :log "<msg>"
:log
set msg=%~1
echo ---------------------------------------------------------------------
echo %msg%
echo ---------------------------------------------------------------------
exit /B

:MAIN
if [%pfb_php_vers%] == [] (
echo pfb_php_vers varible not set
exit 1
)

set build_msg=Building PHP-%pfb_php_vers%

if "%pfb_nts%" gtr "0" (
set build_msg=%build_msg% non-TS
set extra_args=--disable-zts
) else (
set build_msg=%build_msg% TS
set extra_args=
)

if "%pfb_x86%" gtr "0" (
set with_interbase="shared,%PFB_FB32_DIR%lib;%PFB_FB32_DIR%include"
set build_msg=%build_msg% x86
) else (
set with_interbase="shared,%PFB_FB64_DIR%lib;%PFB_FB64_DIR%include"
set build_msg=%build_msg% x86_64
)

call :log "%build_msg%"

call phpsdk_buildtree php%pfb_php_vers%
cd /D php-src
call buildconf.bat --force --add-modules-dir=%PFB_SOURCE_DIR%
call configure.bat --disable-all --enable-cli %extra_args% --with-interbase=%with_interbase%
nmake
30 changes: 30 additions & 0 deletions win_build_scripts/php-fb-sdk-init.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@echo off
@REM
@REM Must be called under phpsdk-<php_vers>-<arch>.bat
@REM
@REM Calling script should set variables: <pfb_php_vers>
@REM
@REM set pfb_php_vers=7.4

if [%pfb_php_vers%] == [] (
echo pfb_php_vers varible not set
exit 1
)

@REM Handle current master branch
if "%pfb_php_vers%" == "master" (
set pfb_git_args=
) else (
set pfb_git_args=--branch PHP-%pfb_php_vers%
)

call phpsdk_buildtree php%pfb_php_vers%
git clone --depth 1 %pfb_git_args% https://github.com/php/php-src.git
cd php-src

@REM Remove built-in extension
if "%pfb_php_vers%" == "7.3" (
rd /Q /S ext\interbase
)

call phpsdk_deps --update