Skip to content

Commit 3df43ba

Browse files
author
Martin Köditz
authored
Merge pull request #51 from mlazdans/win_build_scripts
Add windows build scripts
2 parents 2a6bf54 + debb432 commit 3df43ba

File tree

6 files changed

+214
-0
lines changed

6 files changed

+214
-0
lines changed

win_build_scripts/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Scripts building php-firebird extension on Windows
2+
3+
## How it works
4+
5+
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.
6+
7+
Do not run scripts with ``-sdk-`` in their files names directly. These are called from php-sdk environment.
8+
9+
Make sure you got ~20GB free disk space to build for all PHP versions.
10+
11+
## Set up
12+
13+
Make sure ``git`` is in you PATH
14+
15+
1. Set up Microsoft Visual Studio vc15 and vs16.
16+
2. Set up Firebird 32-bit and 64-bit installations or libraries.
17+
3. Set up PHP-SDK according to https://wiki.php.net/internals/windows/stepbystepbuild_sdk_2
18+
4. Clone php-firebird extension source somewhere.
19+
4. Copy these build scripts to C:\php-sdk\
20+
5. Adjust php-fb-config.bat.
21+
22+
``Note: PFB_SOURCE_DIR should point one level up. For example
23+
PFB_SOURCE_DIR=D:\php-firebird\ then your source should reside in D:\php-firebird\php-firebird\
24+
``
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.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
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 master vs16 || exit /B %ERRORLEVEL%

win_build_scripts/php-fb-build.bat

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
@echo off
2+
3+
@REM config ======================================================================================
4+
call php-fb-config.bat
5+
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+
:usage
19+
call :log "Usage: %~nx0 php_vers cpp_vers"
20+
exit /B
21+
22+
:MAIN
23+
set pfb_php_vers=%1
24+
set pfb_cpp_vers=%2
25+
26+
if [%pfb_php_vers%] == [] (
27+
call :usage
28+
echo pfb_php_vers varible not set
29+
exit 1
30+
)
31+
32+
if [%pfb_cpp_vers%] == [] (
33+
call :usage
34+
echo pfb_cpp_vers varible not set
35+
exit 1
36+
)
37+
38+
set pfb_build_root=php%pfb_php_vers%\%pfb_cpp_vers%\
39+
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
45+
) 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
48+
)
49+
50+
if %%a EQU x86 ( set pfb_x86=1 ) else ( set pfb_x86=0 )
51+
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+
))
57+
58+
@REM check if ibase_connect() function exists in newly compiled extension
59+
set check_code="if(!function_exists('ibase_connect'))exit(1);"
60+
"%pfb_build_root%x64\php-src\x64\Release_TS\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
61+
"%pfb_build_root%x64\php-src\x64\Release\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
62+
"%pfb_build_root%x86\php-src\Release_TS\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
63+
"%pfb_build_root%x86\php-src\Release\php.exe" -dextension=.\php_interbase.dll -r %check_code% || goto :error
64+
65+
call :log "PHP %pfb_php_vers% build OK"
66+
67+
@REM copy compiled extension to target directory
68+
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
69+
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
70+
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
71+
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
72+
73+
exit /B 0
74+
75+
:error
76+
call :log "PHP %pfb_php_vers% build FAILED"
77+
78+
exit /B 1
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@REM
2+
@REM git command must be in PATH
3+
@REM
4+
5+
@REM sets php-firebird version part in extension file, for example, php_interbase-<<3.0.1-ba8e63b>>-7.3-vc15.dll
6+
set PFB_VERS=3.0.1-ba8e63b
7+
8+
@REM Directory where all compiled files will be copied
9+
set PFB_OUTPUT_DIR=D:\php-firebird\releases\
10+
11+
@REM FB 32-bit and 64-bit libraries
12+
set PFB_FB32_DIR=C:\Program Files\Firebird\Firebird_3_0-x86\
13+
set PFB_FB64_DIR=C:\Program Files\Firebird\Firebird_3_0\
14+
15+
@REM php-firebird source directory
16+
set PFB_SOURCE_DIR=D:\php-firebird\ba8e63b\
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@echo off
2+
@REM
3+
@REM Must be called under phpsdk-<php_vers>-<arch>.bat
4+
@REM
5+
@REM Calling script should set variables:
6+
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> <pfb_php_vers> [pfb_nts] [pfb_x86]
7+
@REM
8+
@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
11+
@REM
12+
@REM <PFB_FB32_DIR> <PFB_FB64_DIR> <PFB_SOURCE_DIR> all set in php-fb-config.bat
13+
@REM
14+
15+
goto :MAIN
16+
17+
@REM log =========================================================================================
18+
@REM log <msg>
19+
@REM example> call :log "<msg>"
20+
:log
21+
set msg=%~1
22+
echo ---------------------------------------------------------------------
23+
echo %msg%
24+
echo ---------------------------------------------------------------------
25+
exit /B
26+
27+
:MAIN
28+
if [%pfb_php_vers%] == [] (
29+
echo pfb_php_vers varible not set
30+
exit 1
31+
)
32+
33+
set build_msg=Building PHP-%pfb_php_vers%
34+
35+
if "%pfb_nts%" gtr "0" (
36+
set build_msg=%build_msg% non-TS
37+
set extra_args=--disable-zts
38+
) else (
39+
set build_msg=%build_msg% TS
40+
set extra_args=
41+
)
42+
43+
if "%pfb_x86%" gtr "0" (
44+
set with_interbase="shared,%PFB_FB32_DIR%lib;%PFB_FB32_DIR%include"
45+
set build_msg=%build_msg% x86
46+
) else (
47+
set with_interbase="shared,%PFB_FB64_DIR%lib;%PFB_FB64_DIR%include"
48+
set build_msg=%build_msg% x86_64
49+
)
50+
51+
call :log "%build_msg%"
52+
53+
call phpsdk_buildtree php%pfb_php_vers%
54+
cd /D php-src
55+
call buildconf.bat --force --add-modules-dir=%PFB_SOURCE_DIR%
56+
call configure.bat --disable-all --enable-cli %extra_args% --with-interbase=%with_interbase%
57+
nmake
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@echo off
2+
@REM
3+
@REM Must be called under phpsdk-<php_vers>-<arch>.bat
4+
@REM
5+
@REM Calling script should set variables: <pfb_php_vers>
6+
@REM
7+
@REM set pfb_php_vers=7.4
8+
9+
if [%pfb_php_vers%] == [] (
10+
echo pfb_php_vers varible not set
11+
exit 1
12+
)
13+
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%
19+
)
20+
21+
call phpsdk_buildtree php%pfb_php_vers%
22+
git clone --depth 1 %pfb_git_args% https://github.com/php/php-src.git
23+
cd php-src
24+
25+
@REM Remove built-in extension
26+
if "%pfb_php_vers%" == "7.3" (
27+
rd /Q /S ext\interbase
28+
)
29+
30+
call phpsdk_deps --update

0 commit comments

Comments
 (0)