Skip to content

Commit 6179d16

Browse files
authored
Merge pull request #93 from FirebirdSQL/ibase_result
2 parents ce45760 + 33e02b0 commit 6179d16

37 files changed

+1684
-795
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,4 @@ tests/*.sh
7373
/reports
7474
win_build_scripts
7575
.vscode-win
76+
build_scripts/php-fb-config.bat

build_scripts/php-fb-build-all.bat

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

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%
3+
set "phps="php-7.4.13 vc15" "php-8.0.30 vs16" "php-8.1.33 vs16" "php-8.2.29 vs16" "php-8.3.26 vs16" "php-8.4.13 vs17" "php-8.5.0RC2 vs17""
4+
5+
setlocal enabledelayedexpansion
6+
for %%p in (%phps%) do (
7+
for /f "tokens=1,2" %%a in (%%p) do (
8+
set php_vers=%%a
9+
set cpp_vers=%%b
10+
call %~dp0php-fb-build.bat !php_vers! !cpp_vers! 1 x64 || exit %ERRORLEVEL%
11+
call %~dp0php-fb-build.bat !php_vers! !cpp_vers! 0 x64 || exit %ERRORLEVEL%
12+
call %~dp0php-fb-build.bat !php_vers! !cpp_vers! 1 x86 || exit %ERRORLEVEL%
13+
call %~dp0php-fb-build.bat !php_vers! !cpp_vers! 0 x86 || exit %ERRORLEVEL%
14+
)
15+
)
16+
endlocal

build_scripts/php-fb-build.bat

Lines changed: 86 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,124 @@
11
@echo off
2+
@REM php-fb-build.bat <pfb_php_tag> <pfb_cpp_vers> <pfb_ts> <pfb_arch>
3+
@REM php-fb-build.bat php-7.4.13 vc15 [0|1] [x64|x86]
4+
@REM
25

36
@REM config ======================================================================================
7+
call %~dp0php-fb-config.dist.bat
48
call %~dp0php-fb-config.bat
59

6-
goto :MAIN
7-
8-
@REM log =========================================================================================
9-
@REM log <msg>
10-
@REM example> call :log "<msg>"
11-
:log
12-
set msg=%~1
13-
echo ---------------------------------------------------------------------
14-
echo %msg%
15-
echo ---------------------------------------------------------------------
16-
exit /B
17-
18-
@REM usage =======================================================================================
19-
:usage
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%" == "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-
51-
exit /B
52-
53-
:MAIN
54-
5510
set pfb_php_tag=%1
5611
set pfb_cpp_vers=%2
12+
set pfb_ts=%3
13+
set pfb_arch=%4
5714

5815
if "%pfb_php_tag%" == "" (
16+
call :log "pfb_php_tag varible not set"
5917
call :usage
60-
echo pfb_php_tag varible not set
6118
exit 1
6219
)
6320

6421
if "%pfb_cpp_vers%" == "" (
22+
call :log "pfb_cpp_vers varible not set"
6523
call :usage
66-
echo pfb_cpp_vers varible not set
6724
exit 1
6825
)
6926

27+
if "%pfb_ts%" == "1" (
28+
set pfb_ts=1
29+
) else (
30+
set pfb_ts=0
31+
)
32+
33+
if not "%pfb_arch%" == "x86" (
34+
set pfb_arch=x64
35+
)
36+
7037
@REM Convert php-8.4.13 -> 8.4
7138
for /f "tokens=2,3 delims=-." %%a in ("%pfb_php_tag%") do set pfb_php_vers=%%a.%%b
7239

7340
if "%pfb_php_vers%" == "" (
74-
echo BUG: pfb_php_vers should be set at this point
41+
call :log "BUG: pfb_php_vers should be set at this point"
7542
exit 1
7643
)
7744

78-
set pfb_build_root=php%pfb_php_vers%\%pfb_cpp_vers%\
45+
@REM Grab version
46+
for /f "tokens=3" %%i in ('findstr /b /c:"#define PHP_INTERBASE_VER_MAJOR" %~dp0..\php_interbase.h') do set VER_MAJOR=%%i
47+
for /f "tokens=3" %%i in ('findstr /b /c:"#define PHP_INTERBASE_VER_MINOR" %~dp0..\php_interbase.h') do set VER_MINOR=%%i
48+
for /f "tokens=3" %%i in ('findstr /b /c:"#define PHP_INTERBASE_VER_REV" %~dp0..\php_interbase.h') do set VER_REV=%%i
49+
for /f "tokens=3" %%i in ('findstr /b /c:"#define PHP_INTERBASE_VER_PRE" %~dp0..\php_interbase.h') do set VER_PRE=%%~i
50+
set PFB_VERS=%VER_MAJOR%.%VER_MINOR%.%VER_REV%%VER_PRE%
51+
52+
if %PFB_ATTACH_GIT_HASH_TO_VERS% equ 1 (
53+
for /f %%i in ('git -C %~dp0..\ rev-parse --short HEAD') do set PFB_VERS=%PFB_VERS%-%%i
54+
)
55+
56+
@REM Initialize
57+
set php_root=php%pfb_php_vers%\%pfb_cpp_vers%\%pfb_arch%\php-src\
58+
set php_interbase=php_interbase-%PFB_VERS%-%pfb_php_vers%-%pfb_cpp_vers%
7959

80-
(for %%a in (x64 x86) do (
81-
set pfb_arch=%%a
60+
if not exist "%php_root%.git\" (
61+
call :log "Cloning %pfb_php_tag% %pfb_arch%"
62+
call phpsdk-%pfb_cpp_vers%-%pfb_arch%.bat -t %~dp0php-fb-sdk-init.bat || goto :error
63+
)
8264

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-
)
65+
if "%pfb_arch%" == "x86" (
66+
set build_root=%php_root%
67+
set php_interbase=%php_interbase%-x86
68+
) else (
69+
set build_root=%php_root%x64\
70+
)
8771

88-
if "%%a" == "x86" (
89-
set php_exe_arch=%pfb_build_root%%%a\php-src\
90-
) else (
91-
set php_exe_arch=%pfb_build_root%%%a\php-src\x64\
92-
)
72+
if %pfb_ts% equ 1 (
73+
set build_root=%build_root%Release_TS\
74+
) else (
75+
set build_root=%build_root%Release\
76+
set php_interbase=%php_interbase%-nts
77+
)
78+
79+
@REM Build
80+
call :log "Building %php_interbase%.dll..."
81+
call phpsdk-%pfb_cpp_vers%-%pfb_arch%.bat -t %~dp0php-fb-sdk-build.bat || goto :error
82+
83+
@REM Validate
84+
set vb_check_code=^
85+
if(!extension_loaded('interbase')){ print \"Extension not loaded\n\"; exit(1); }^
86+
if('php-'.PHP_VERSION != '%pfb_php_tag%'){ printf(\"Version mismatch: expected '%pfb_php_tag%', but got '%%s' \n\", 'php-'.PHP_VERSION); exit(1); }^
87+
if((int)ZEND_THREAD_SAFE != %pfb_ts%){ printf(\"Thread Safety mismatch: expected %pfb_ts%, but got %%d \n\", ZEND_THREAD_SAFE); exit(1); }^
88+
if((PHP_INT_SIZE == 8 ? 'x64' : 'x86') != '%pfb_arch%'){ printf(\"Architecture mismatch: expected '%pfb_arch%', but got '%%s' \n\", (PHP_INT_SIZE == 8 ? 'x64' : 'x86')); exit(1); }
9389

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-
)
90+
if "%pfb_arch%" == "x86" (
91+
set vb_libs=%PFB_FB32_DIR%
92+
) else (
93+
set vb_libs=%PFB_FB64_DIR%
94+
)
10295

103-
if "!php_exe!" == "" (
104-
echo BUG: php_exe should be set at this point
105-
exit 1
106-
)
96+
call :log "Validating %php_interbase%.dll..."
97+
set vb_cmd=cmd /c set "PATH=%vb_libs%;%PATH%" %build_root%php_exe -dextension=.\php_interbase.dll -r "%vb_check_code%"
98+
%vb_cmd% || goto :error
10799

108-
call phpsdk-%pfb_cpp_vers%-%%a.bat -t %~dp0php-fb-sdk-build.bat || goto :error
100+
call :log "Copying %php_interbase%.dll..."
101+
copy "%build_root%php_interbase.dll" "%PFB_OUTPUT_DIR%%php_interbase%.dll" || goto :error
109102

110-
call :validate_build !php_exe! !pfb_arch! !pfb_ts! || goto :error
111-
))
112-
))
103+
call :log "Build OK" "%pfb_php_tag% %pfb_cpp_vers% %pfb_arch% Thread Safety %pfb_ts%" "%php_interbase%.dll"
113104

114-
echo.
115-
call :log "%pfb_php_tag% build OK"
105+
exit /B
116106

117-
@REM copy compiled extension to target directory
118-
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%-x64.dll
119-
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-x64.dll
120-
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
121-
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
107+
@REM log =========================================================================================
108+
@REM log <msg>
109+
@REM example> call :log "<msg1>"
110+
:log
111+
echo ---------------------------------------------------------------------
112+
for %%a in (%*) do ( echo %%~a )
113+
echo ---------------------------------------------------------------------
114+
exit /B
122115

123-
exit /B 0
116+
@REM usage =======================================================================================
117+
:usage
118+
call :log "Usage: %~nx0 php_tag cpp_vers [ts=0|1] [arch=x86|x64]" " Example: %~nx0 php-8.4.13 vs17 1 x86"
119+
exit /B
124120

121+
@REM error =======================================================================================
125122
:error
126-
call :log "%pfb_php_tag% build FAILED"
127-
123+
call :log "Build FAILED" "%pfb_php_tag% %pfb_cpp_vers% %pfb_arch% Thread Safety %pfb_ts%" "%php_interbase%.dll"
128124
exit /B 1

build_scripts/php-fb-config.bat

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@echo off
2+
@REM Do not modify this file directly.
3+
@REM Create build_scripts/php-fb-config.bat if you need to change any variable
4+
@REM and put overrides there
5+
6+
@REM php-firebird source directory
7+
@REM Should point one level up. For example
8+
@REM PFB_SOURCE_DIR=D:\php-firebird\ then your source should reside in D:\php-firebird\php-firebird\
9+
set PFB_SOURCE_DIR=%~dp0..\..\
10+
11+
@REM Directory where all compiled files will be copied
12+
set PFB_OUTPUT_DIR=%PFB_SOURCE_DIR%releases\
13+
14+
@REM FB 32-bit and 64-bit libraries
15+
set PFB_FB32_DIR=C:\Program Files\Firebird\Firebird_5_0-x86
16+
set PFB_FB64_DIR=C:\Program Files\Firebird\Firebird_5_0
17+
18+
@REM Attach current git commit hash to version. git command must be in PATH
19+
set PFB_ATTACH_GIT_HASH_TO_VERS=0
20+
21+
@REM Additional flags for ./configure
22+
@REM set PFB_CONFIGURE_FLAGS=--enable-debug

build_scripts/php-fb-sdk-build.bat

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ exit /B
3232

3333
set build_msg=Building PHP-%pfb_php_vers%
3434

35-
if "%pfb_ts%" gtr "0" (
36-
set build_msg=%build_msg% non-TS
37-
set extra_args=--disable-zts
38-
) else (
35+
if %pfb_ts% equ 1 (
3936
set build_msg=%build_msg% TS
4037
set extra_args=
38+
) else (
39+
set build_msg=%build_msg% non-TS
40+
set extra_args=--disable-zts
4141
)
4242

4343
if "%pfb_arch%" == "x86" (
@@ -53,5 +53,5 @@ exit /B
5353
call phpsdk_buildtree php%pfb_php_vers%
5454
cd /D php-src
5555
call buildconf.bat --force --add-modules-dir=%PFB_SOURCE_DIR%
56-
call configure.bat --disable-all --enable-cli %extra_args% --with-interbase=%with_interbase%
56+
call configure.bat --disable-all --enable-cli %PFB_CONFIGURE_FLAGS% %extra_args% --with-interbase=%with_interbase%
5757
nmake

0 commit comments

Comments
 (0)