Skip to content

Commit b66f21f

Browse files
committed
Update windows build scripts
1 parent f76b706 commit b66f21f

File tree

5 files changed

+96
-54
lines changed

5 files changed

+96
-54
lines changed

build_scripts/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ Make sure ``git`` is in you PATH
1616
2. Set up Firebird 32-bit and 64-bit installations or libraries.
1717
3. Set up PHP-SDK according to https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
1818
4. Clone php-firebird extension source somewhere.
19-
4. Copy these build scripts to C:\php-sdk\
2019
5. Adjust php-fb-config.bat.
21-
2220
``Note: PFB_SOURCE_DIR should point one level up. For example
2321
PFB_SOURCE_DIR=D:\php-firebird\ then your source should reside in D:\php-firebird\php-firebird\
2422
``
25-
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.
23+
6. cd into php-sdk and from there run ``<path_to>\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.

build_scripts/php-fb-build-all.bat

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@echo off
22

3-
call php-fb-build.bat 7.3 vc15 || exit /B %ERRORLEVEL%
4-
call php-fb-build.bat 7.4 vc15 || exit /B %ERRORLEVEL%
5-
call php-fb-build.bat 8.0 vs16 || exit /B %ERRORLEVEL%
6-
call php-fb-build.bat 8.1 vs16 || exit /B %ERRORLEVEL%
7-
call php-fb-build.bat 8.2 vs16 || exit /B %ERRORLEVEL%
8-
call php-fb-build.bat 8.3 vs16 || exit /B %ERRORLEVEL%
9-
call php-fb-build.bat 8.4 vs17 || exit /B %ERRORLEVEL%
10-
call php-fb-build.bat 8.5 vs17 || exit /B %ERRORLEVEL%
3+
call %~dp0php-fb-build.bat php-7.3.33 vc15 || exit %ERRORLEVEL%
4+
call %~dp0php-fb-build.bat php-7.4.13 vc15 || exit %ERRORLEVEL%
5+
call %~dp0php-fb-build.bat php-8.0.30 vs16 || exit %ERRORLEVEL%
6+
call %~dp0php-fb-build.bat php-8.1.33 vs16 || exit %ERRORLEVEL%
7+
call %~dp0php-fb-build.bat php-8.2.29 vs16 || exit %ERRORLEVEL%
8+
call %~dp0php-fb-build.bat php-8.3.26 vs16 || exit %ERRORLEVEL%
9+
call %~dp0php-fb-build.bat php-8.4.13 vs17 || exit %ERRORLEVEL%
10+
call %~dp0php-fb-build.bat php-8.5.0RC2 vs17 || exit %ERRORLEVEL%

build_scripts/php-fb-build.bat

Lines changed: 75 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22

33
@REM config ======================================================================================
4-
call php-fb-config.bat
4+
call %~dp0php-fb-config.bat
55

66
goto :MAIN
77

@@ -15,17 +15,49 @@ goto :MAIN
1515
echo ---------------------------------------------------------------------
1616
exit /B
1717

18+
@REM usage =======================================================================================
1819
:usage
19-
call :log "Usage: %~nx0 php_vers cpp_vers"
20+
call :log "Usage: %~nx0 php_tag cpp_vers"
21+
exit /B
22+
23+
@REM validate_build ===============================================================================
24+
@REM validate_build <path_to_php_exe>:string <arch>:string <ts>:int
25+
:validate_build
26+
setlocal disabledelayedexpansion
27+
set vb_php=%~1
28+
set vb_arch=%~2
29+
set vb_ts=%~3
30+
31+
set vb_check_code=^
32+
if(!extension_loaded('interbase')){ print \"Extension not loaded\n\"; exit(1); }^
33+
if('php-'.PHP_VERSION != '%pfb_php_tag%'){ printf(\"Version mismatch: expected '%pfb_php_tag%', but got '%%s' \n\", 'php-'.PHP_VERSION); exit(1); }^
34+
if((int)ZEND_THREAD_SAFE != %vb_ts%){ printf(\"Thread Safety mismatch: expected %vb_ts%, but got %%d \n\", ZEND_THREAD_SAFE); exit(1); }^
35+
if((PHP_INT_SIZE == 8 ? 'x64' : 'x86') != '%vb_arch%'){ printf(\"Architecture mismatch: expected '%vb_arch%', but got '%%s' \n\", (PHP_INT_SIZE == 8 ? 'x64' : 'x86')); exit(1); }
36+
37+
if %vb_arch% EQU x86 (
38+
set vb_libs=%PFB_FB32_DIR%
39+
) else (
40+
set vb_libs=%PFB_FB64_DIR%
41+
)
42+
43+
call :log "Validating %pfb_php_tag% %vb_arch% Thread Safety %vb_ts%"
44+
45+
set vb_cmd=cmd /c set "PATH=%vb_libs%;%PATH%" %php_exe% -dextension=.\php_interbase.dll -r "%vb_check_code%"
46+
%vb_cmd% || exit /B 1
47+
48+
echo Validated OK
49+
echo ---------------------------------------------------------------------
50+
2051
exit /B
2152

2253
:MAIN
23-
set pfb_php_vers=%1
54+
55+
set pfb_php_tag=%1
2456
set pfb_cpp_vers=%2
2557

26-
if [%pfb_php_vers%] == [] (
58+
if [%pfb_php_tag%] == [] (
2759
call :usage
28-
echo pfb_php_vers varible not set
60+
echo pfb_php_tag varible not set
2961
exit 1
3062
)
3163

@@ -35,39 +67,52 @@ if [%pfb_cpp_vers%] == [] (
3567
exit 1
3668
)
3769

70+
@REM Convert php-8.4.13 -> 8.4
71+
for /f "tokens=2,3 delims=-." %%a in ("%pfb_php_tag%") do set pfb_php_vers=%%a.%%b
72+
73+
if [%pfb_php_vers%] == [] (
74+
echo BUG: pfb_php_vers should be set at this point
75+
exit 1
76+
)
77+
3878
set pfb_build_root=php%pfb_php_vers%\%pfb_cpp_vers%\
3979

40-
(for %%a in (x86 x64) do (
41-
@REM check out or pull PHP version of interest
42-
if exist %pfb_build_root%\%%a\php-src\.git\ (
43-
call :log "Checking out PHP-%pfb_php_vers% %%a"
44-
git -C %pfb_build_root%\%%a\php-src pull || goto :error
80+
(for %%a in (x64 x86) do (
81+
set pfb_arch=%%a
82+
83+
if not exist %pfb_build_root%\%%a\php-src\.git\ (
84+
call :log "Cloning %pfb_php_tag% %%a"
85+
call phpsdk-%pfb_cpp_vers%-%%a.bat -t %~dp0php-fb-sdk-init.bat || goto :error
86+
)
87+
88+
if %%a EQU x86 (
89+
set php_exe_arch=%pfb_build_root%%%a\php-src\
4590
) else (
46-
call :log "Cloning PHP-%pfb_php_vers% %%a"
47-
call phpsdk-%pfb_cpp_vers%-%%a.bat -t php-fb-sdk-init.bat || goto :error
91+
set php_exe_arch=%pfb_build_root%%%a\php-src\x64\
4892
)
4993

50-
if %%a EQU x86 ( set pfb_x86=1 ) else ( set pfb_x86=0 )
94+
setlocal enabledelayedexpansion
95+
(for %%t in (0 1) do (
96+
set pfb_ts=%%t
97+
if %%t EQU 1 (
98+
set php_exe="!php_exe_arch!Release_TS\php.exe"
99+
) else (
100+
set php_exe="!php_exe_arch!Release\php.exe"
101+
)
51102

52-
(for %%n in (0 1) do (
53-
set pfb_nts=%%n
54-
call phpsdk-%pfb_cpp_vers%-%%a.bat -t php-fb-sdk-build.bat || goto :error
55-
))
56-
))
103+
if [!php_exe!] == [] (
104+
echo BUG: php_exe should be set at this point
105+
exit 1
106+
)
57107

58-
@REM check if ibase_connect() function exists in newly compiled extension
59-
set check_code="if(!function_exists('ibase_connect'))exit(1);"
108+
call phpsdk-%pfb_cpp_vers%-%%a.bat -t %~dp0php-fb-sdk-build.bat || goto :error
60109

61-
set TPATH=%PATH%
62-
set PATH=%PFB_FB64_DIR%;%TPATH%
63-
"%pfb_build_root%x64\php-src\x64\Release_TS\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
64-
"%pfb_build_root%x64\php-src\x64\Release\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
65-
set PATH=%PFB_FB32_DIR%;%TPATH%
66-
"%pfb_build_root%x86\php-src\Release_TS\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
67-
"%pfb_build_root%x86\php-src\Release\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
68-
set PATH=%TPATH%
110+
call :validate_build !php_exe! !pfb_arch! !pfb_ts! || goto :error
111+
))
112+
))
69113

70-
call :log "PHP %pfb_php_vers% build OK"
114+
echo.
115+
call :log "%pfb_php_tag% build OK"
71116

72117
@REM copy compiled extension to target directory
73118
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
@@ -78,6 +123,6 @@ copy %pfb_build_root%x86\php-src\Release\php_interbase.dll %PFB_OUTPUT_DIR%php_i
78123
exit /B 0
79124

80125
:error
81-
call :log "PHP %pfb_php_vers% build FAILED"
126+
call :log "%pfb_php_tag% build FAILED"
82127

83128
exit /B 1

build_scripts/php-fb-sdk-build.bat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
@REM Must be called under phpsdk-<php_vers>-<arch>.bat
44
@REM
55
@REM Calling script should set variables:
6-
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> <pfb_php_vers> [pfb_nts] [pfb_x86]
6+
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> <pfb_php_vers> [pfb_ts] [pfb_arch]
77
@REM
88
@REM set pfb_php_vers=7.4
9-
@REM set pfb_nts=1 if nts expected, 0 if ts
10-
@REM set pfb_x86=1 if linking to x86 fbclient, o if x64
9+
@REM set pfb_ts=1 if thread safety enabled, 0 if not
10+
@REM set pfb_arch=x86 to build agains 32-bit, otherwise 64-bit
1111
@REM
1212
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> all set in php-fb-config.bat
1313
@REM
@@ -32,15 +32,15 @@ exit /B
3232

3333
set build_msg=Building PHP-%pfb_php_vers%
3434

35-
if "%pfb_nts%" gtr "0" (
35+
if "%pfb_nts%" gtr "0" (
3636
set build_msg=%build_msg% non-TS
3737
set extra_args=--disable-zts
3838
) else (
3939
set build_msg=%build_msg% TS
4040
set extra_args=
4141
)
4242

43-
if "%pfb_x86%" gtr "0" (
43+
if %pfb_arch% EQU x86 (
4444
set with_interbase="shared,%PFB_FB32_DIR%"
4545
set build_msg=%build_msg% x86
4646
) else (

build_scripts/php-fb-sdk-init.bat

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
@REM
33
@REM Must be called under phpsdk-<php_vers>-<arch>.bat
44
@REM
5-
@REM Calling script should set variables: <pfb_php_vers>
5+
@REM Calling script should set variables: <pfb_php_vers> <pfb_php_tag>
66
@REM
7-
@REM set pfb_php_vers=7.4
7+
@REM Example: pfb_php_tag=7.4.13
8+
@REM Example: pfb_php_vers=7.4
89

910
if [%pfb_php_vers%] == [] (
1011
echo pfb_php_vers varible not set
1112
exit 1
1213
)
1314

14-
@REM Handle current master branch
15-
if "%pfb_php_vers%" == "master" (
16-
set pfb_git_args=
17-
) else (
18-
set pfb_git_args=--branch PHP-%pfb_php_vers%
15+
if [%pfb_php_tag%] == [] (
16+
echo pfb_php_tag varible not set
17+
exit 1
1918
)
2019

2120
call phpsdk_buildtree php%pfb_php_vers%
22-
git clone --depth 1 %pfb_git_args% https://github.com/php/php-src.git
21+
git clone --depth 1 --branch %pfb_php_tag% https://github.com/php/php-src.git
2322
cd php-src
2423

2524
@REM Remove built-in extension

0 commit comments

Comments
 (0)