Skip to content

Commit 13c7c52

Browse files
committed
Init
1 parent 5f0edb8 commit 13c7c52

File tree

6 files changed

+160
-0
lines changed

6 files changed

+160
-0
lines changed

_config.bat

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@echo off
2+
3+
4+
:: VC2019 complier path
5+
:: e.g., C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.29.30133
6+
set VC_TOOLS_PATH=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.29.30133
7+
8+
9+
:: Windows SDK path
10+
:: e.g., D:\Windows Kits OR C:\Program Files (x86)\Microsoft SDKs\Windows Kits
11+
set WIN_SDK_PATH=D:\Windows Kits
12+
13+
14+
:: Windows SDK version
15+
:: e.g., 10.0.22621.0
16+
set WIN_SDK_VERSION=10.0.22621.0
17+
18+
19+
:: Enable NTS
20+
:: Default is 1, for FastCGI, set blank for SAPI
21+
set PHP_NTS=1

_ready.bat

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@echo off
2+
3+
4+
if %1 == begin (
5+
goto BEGIN
6+
) else (
7+
goto END
8+
)
9+
10+
11+
:BEGIN
12+
13+
14+
set BUILD_PATH=%~dp0
15+
set BUILD_PATH=%BUILD_PATH:~0,-1%
16+
set PHP_SDK_PATH=%BUILD_PATH%\php-sdk
17+
set PHP_EXT_SDK_PATH=%BUILD_PATH%\php-sdk-ext
18+
set PHP_SRC_PATH=%BUILD_PATH%\php-src
19+
set INCLUDE=%VC_TOOLS_PATH%\include;%WIN_SDK_PATH%\10\Include\%WIN_SDK_VERSION%\shared;%WIN_SDK_PATH%\10\Include\%WIN_SDK_VERSION%\ucrt;%WIN_SDK_PATH%\10\Include\%WIN_SDK_VERSION%\um
20+
set LIB=%VC_TOOLS_PATH%\lib\x64;%WIN_SDK_PATH%\10\Lib\%WIN_SDK_VERSION%\um\x64;%WIN_SDK_PATH%\10\Lib\%WIN_SDK_VERSION%\ucrt\x64
21+
set ORIGN_PATH=%path%
22+
23+
set path=%PATH%;%VC_TOOLS_PATH%\bin\HostX64\x64
24+
set path=%PATH%;%WIN_SDK_PATH%\10\bin\%WIN_SDK_VERSION%\x64
25+
set path=%PATH%;%PHP_SDK_PATH%;%PHP_SDK_PATH%\bin;%PHP_SDK_PATH%\msys2\usr\bin
26+
set path=%PATH%;%PHP_EXT_SDK_PATH%
27+
set path=%PATH%;%PHP_SRC_PATH%
28+
29+
goto EXIT
30+
31+
32+
:END
33+
34+
35+
set path=%ORIGN_PATH%
36+
goto EXIT
37+
38+
39+
:EXIT

build.bat

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@echo off
2+
@echo Phpredis Windows Build Tools - Build
3+
@echo ====================================
4+
call _config.bat
5+
call _ready.bat begin
6+
::------------------------------------------------------------------------------
7+
8+
9+
cd /d %PHP_SRC_PATH%
10+
nmake clean 1>nul 2>nul
11+
nmake
12+
cd /d %BUILD_PATH%\
13+
del /q %BUILD_PATH%\release\*.* 1>nul 2>nul
14+
if defined PHP_NTS (
15+
copy /y %PHP_SRC_PATH%\x64\Release\php_redis.dll %BUILD_PATH%\release\php_redis_nts.dll 1>nul 2>nul
16+
rmdir /s /q %PHP_SRC_PATH%\x64\Release 1>nul 2>nul
17+
) else (
18+
copy /y %PHP_SRC_PATH%\x64\Release_TS\php_redis.dll %BUILD_PATH%\release\php_redis_ts.dll 1>nul 2>nul
19+
rmdir /s /q %PHP_SRC_PATH%\x64\Release_TS 1>nul 2>nul
20+
)
21+
echo --------------------------
22+
echo Done!
23+
24+
25+
::------------------------------------------------------------------------------
26+
call _ready.bat end

env.bat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@echo off
2+
@echo Phpredis Windows Build Tools - Env
3+
@echo ==================================
4+
call _config.bat
5+
call _ready.bat begin
6+
::------------------------------------------------------------------------------
7+

init.bat

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@echo off
2+
@echo Phpredis Windows Build Tools - Init
3+
@echo ===================================
4+
call _config.bat
5+
call _ready.bat begin
6+
::------------------------------------------------------------------------------
7+
8+
9+
cd /d %PHP_SRC_PATH%
10+
call buildconf.bat
11+
set PARAMS=--enable-cli --enable-cgi --disable-all --enable-redis=shared
12+
if defined PHP_NTS (
13+
set PARAMS=%PARAMS% --disable-zts
14+
)
15+
set PARAMS=%PARAMS% --with-extra-includes="%INCLUDE%"
16+
call configure.bat %PARAMS%
17+
cd /d %BUILD_PATH%\
18+
19+
20+
::------------------------------------------------------------------------------
21+
call _ready.bat end

readme.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# PhpRedis Windows Build Tools
2+
3+
Easy build PhpRedis binary DLL for windows.
4+
5+
Links:
6+
- [PHP for Windows](https://windows.php.net)
7+
- [PhpRedis](https://github.com/phpredis/phpredis)
8+
- [PHP SDK Binary Tools](https://github.com/php/php-sdk-binary-tools)
9+
- [PhpRedis on PECL](https://pecl.php.net/package/redis)
10+
11+
12+
# Download
13+
14+
- Visual Studio ( https://visualstudio.microsoft.com/downloads ) Download Community Edition
15+
- PHP SDK ( https://github.com/php/php-sdk-binary-tools ) Download source code ZIP
16+
- PHP Source ( https://windows.php.net/download ) Download source code ZIP
17+
- PhpRedis Source ( https://github.com/phpredis/phpredis ) Download source code ZIP
18+
19+
# Prepare
20+
21+
- Run [Visual Studio Setup], select `MSVC v142 VS2019 C++ x64/x86 build tools` and `Windows 11 SDK (10.0.22621.0)`, complete the installation according to the wizard.
22+
- Extract this tools to a empty folder, e.g., `c:\build` alias `{build}`
23+
- Extract SDKs and sources to specified folder, excluding the first level directory if exist:
24+
- PHP SDK -> `{build}\php-sdk`
25+
- PHP Source -> `{build}\php-src`
26+
- PhpRedis Source -> `{build}\php-src\ext\redis`
27+
- **Edit `{build}\_config.bat`** !!!
28+
29+
# Run
30+
31+
Open CMD console, cd `{build}`, run
32+
33+
`init.bat`
34+
35+
if no error accured, next
36+
37+
`build.bat`
38+
39+
# Output
40+
41+
`php_redis_nts.dll` or `php_redis_ts.dll` you will find in `{build}\release`
42+
43+
# Remark
44+
45+
- Open CMD console,run `{build}\env.bat` to initialize runtime environment,if you want to run tools related.
46+
- This script is support x64 only.

0 commit comments

Comments
 (0)