Skip to content

Commit 8ff3b03

Browse files
authored
Merge pull request #970 from jingjingxyk/build_native_php
Build native php
2 parents b746c96 + 2287e9c commit 8ff3b03

18 files changed

+460
-90
lines changed

.github/workflows/windows-cygwin.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99

1010
jobs:
1111
windows-cygwin:
12-
if: 0
12+
if: 1
1313
runs-on: windows-2022
1414
strategy:
1515
matrix:
@@ -48,11 +48,6 @@ jobs:
4848
run: |
4949
echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $GITHUB_ENV
5050
51-
- name: Prepare submodule
52-
run: |
53-
ipconfig /all
54-
# git submodule update --init
55-
5651
- name: Cache cygwin packages
5752
id: cache-cygwin
5853
uses: actions/cache@v4
@@ -98,12 +93,17 @@ jobs:
9893
run: |
9994
bash ./sapi/scripts/cygwin/install-re2c.sh
10095
96+
- name: install deps lib with source code
97+
if: 0
98+
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
99+
run: |
100+
bash ./sapi/scripts/msys2/install-libzip.sh
101+
101102
- name: Prepare
102103
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
103104
run: |
104105
# git config --global --add safe.directory /cygdrive/d/a/swoole-cli/swoole-cli
105-
# git submodule update --init
106-
bash ./sapi/scripts/cygwin/cygwin-config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }}
106+
bash ./sapi/scripts/cygwin/cygwin-config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }} --swoole-version master
107107
108108
- name: Configure
109109
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0}
@@ -115,6 +115,10 @@ jobs:
115115
run: |
116116
bash ./sapi/scripts/cygwin/cygwin-build.sh
117117
118+
- name: Archive
119+
run: |
120+
bash ./sapi/scripts/cygwin/cygwin-archive.sh
121+
118122
- name: Show Build Result
119123
run: |
120124
./bin/php.exe -v
@@ -123,6 +127,7 @@ jobs:
123127
./bin/php.exe --ri gd
124128
./bin/php.exe --ri swoole
125129
./bin/php.exe -r "echo PHP_VERSION;"
130+
ldd ./bin/php.exe
126131
127132
- name: get app version with bash
128133
# 参考 https://github.com/marketplace/actions/install-cygwin
@@ -151,9 +156,6 @@ jobs:
151156
# Add-Content -Path $env:GITHUB_ENV -Value "name=$value"
152157
# Add-Content -Path $env:GITHUB_ENV -Value "APP_VERSION=$APP_VERSION"
153158
154-
- name: Archive
155-
run: |
156-
bash ./sapi/scripts/cygwin/cygwin-archive.sh
157159
158160
- name: production artifacts
159161
uses: actions/upload-artifact@v4
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: build-swoole-cli-windows-msys2
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
windows-msys2:
9+
if: 1
10+
runs-on: windows-2022
11+
strategy:
12+
matrix:
13+
php-version:
14+
- "8.2.28"
15+
- "8.1.32"
16+
- "8.3.19"
17+
- "8.4.5"
18+
steps:
19+
- name: Show Environment Info
20+
shell: cmd
21+
run: |
22+
ver
23+
wmic cpu get name, caption, maxclockspeed, status
24+
systeminfo
25+
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
26+
systeminfo | findstr /B /C:"Manufacturer" /C:"Product" /C:"Version"
27+
set
28+
ipconfig
29+
uname -a
30+
pwd
31+
ipconfig /all
32+
33+
- name: Prepare git
34+
run: |
35+
git config --global core.autocrlf false
36+
git config --global core.eol lf
37+
git config --global core.ignorecase false
38+
git config --global --add safe.directory ${{ github.workspace }}
39+
40+
- uses: actions/checkout@v4
41+
- name: Cache msys2 packages
42+
id: cache-msys2
43+
uses: actions/cache@v4
44+
env:
45+
cache-name: cache-msys2-packages
46+
with:
47+
path: C:\msys2-packages
48+
key: "${{ runner.os }}-build-${{ env.cache-name }}"
49+
50+
- name: Cache pool
51+
id: cache-msys2-pool
52+
uses: actions/cache@v4
53+
with:
54+
path: "${{ github.workspace }}\\pool\\"
55+
key: "${{ runner.os }}-build-pool-cache"
56+
57+
- uses: msys2/setup-msys2@v2
58+
# https://github.com/msys2/setup-msys2
59+
with:
60+
msystem: MSYS
61+
location: C:\msys2-packages
62+
63+
- name: prepare build environment
64+
shell: msys2 {0}
65+
run: |
66+
bash ./sapi/quickstart/windows/msys2-build/install-msys2.sh
67+
68+
- name: install deps lib with source code
69+
shell: msys2 {0}
70+
run: |
71+
bash ./sapi/scripts/msys2/install-deps-lib.sh
72+
73+
- name: Prepare
74+
shell: msys2 {0}
75+
run: |
76+
bash ./sapi/scripts/msys2/config-ext.sh --php-version ${{ env.BUILD_PHP_VERSION }} --swoole-version master
77+
78+
- name: Configure
79+
shell: msys2 {0}
80+
run: |
81+
bash ./sapi/scripts/msys2/config.sh --php-version ${{ env.BUILD_PHP_VERSION }}
82+
83+
- name: Build
84+
shell: msys2 {0}
85+
run: |
86+
bash ./sapi/scripts/msys2/build.sh
87+
88+
- name: Archive
89+
shell: msys2 {0}
90+
run: |
91+
bash ./sapi/scripts/msys2/archive.sh
92+
93+
- name: Show Build Result
94+
shell: msys2 {0}
95+
run: |
96+
./bin/swoole-cli.exe -v
97+
./bin/swoole-cli.exe -m
98+
./bin/swoole-cli.exe --ri swoole
99+
./bin/swoole-cli.exe -r "echo PHP_VERSION;"
100+
ldd ./bin/swoole-cli.exe
101+
102+
- name: get app version with bash
103+
shell: msys2 {0}
104+
run: |
105+
APP_VERSION=$(cat ./APP_VERSION)
106+
APP_NAME=$(cat ./APP_NAME)
107+
echo $APP_VERSION
108+
echo $APP_NAME
109+
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV
110+
echo "APP_NAME=${APP_NAME}" >> $GITHUB_ENV
111+
112+
- name: production artifacts
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-msys2-x64
116+
retention-days: 90
117+
path: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-msys2-x64.zip
118+
119+
- name: gh release
120+
uses: softprops/action-gh-release@v2
121+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
files: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-msys2-x64.zip

sapi/quickstart/windows/msys2-build/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ c:\msys64\ucrt64.exe
4343
https://www.msys2.org/dev/mirrors/
4444
https://www.msys2.org/docs/environments/
4545
# MSYS2 包搜索
46-
https://packages.msys2.org/queue
46+
https://packages.msys2.org/search?t=binpkg
47+
4748

sapi/quickstart/windows/msys2-build/download-msys2.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ if not (%1)==() goto getopt
3333

3434
:: curl.exe -fSLo msys2-x86_64-20241208.exe https://repo.msys2.org/distrib/x86_64/msys2-x86_64-20241208.exe
3535
:: curl.exe -fSLo msys2-x86_64-20241208.exe https://mirror.msys2.org/distrib/x86_64/msys2-x86_64-20241208.exe
36-
curl.exe -fSLo msys2-x86_64-20241208.exe %SITE%/distrib/x86_64/msys2-x86_64-20241208.exe
36+
curl.exe -fSLo msys2-x86_64-20250221.exe %SITE%/distrib/x86_64/msys2-x86_64-20250221.exe
3737

38-
copy .\msys2-x86_64-20241208.exe %__PROJECT__%\msys2-x86_64.exe
38+
copy .\msys2-x86_64-20250221.exe %__PROJECT__%\msys2-x86_64.exe
3939

4040

4141
endlocal

sapi/quickstart/windows/msys2-build/install-msys2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
1111
> https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20230526.exe (支持 win7 的最后一版本)
1212
13-
> https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20240507.exe
13+
> https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20250221.exe
1414
1515
> 安装 msys2
1616
1717
> 开始菜单,打开 MSYS2 MSYS 控制台,并安装必要的包,命令如下
1818
19-
> MSYS2 包搜索 https://packages.msys2.org/queue
19+
> MSYS2 包搜索 https://packages.msys2.org/search?t=binpkg
2020
2121
> [ msys2 各版本环境 区别 ](https://www.msys2.org/docs/environments/)
2222

sapi/quickstart/windows/msys2-build/install-msys2.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ __PROJECT__=$(
1212
cd ${__PROJECT__}
1313
pwd
1414

15-
1615
MIRROR=''
1716
IS_UPGRADE=0
1817
while [ $# -gt 0 ]; do
@@ -36,12 +35,11 @@ china)
3635
;;
3736
esac
3837

39-
if [ $IS_UPGRADE == 1 ] ; then
38+
if [ $IS_UPGRADE == 1 ]; then
4039
# 升级
4140
pacman -Su --noconfirm
4241
fi
4342

44-
4543
# 搜索包
4644
# pacman -Ss curl
4745

@@ -51,7 +49,8 @@ pacman -Sy
5149
# 无须确认安装包
5250
pacman -S --noconfirm git curl wget openssl
5351

54-
pacman -S --noconfirm zip unzip xz gcc cmake make
52+
pacman -S --noconfirm zip unzip xz gcc gcc-libs cmake make
53+
5554
pacman -S --noconfirm re2c
5655

5756
pacman -S --noconfirm openssl-devel libreadline
@@ -61,30 +60,31 @@ pacman -S --noconfirm zip unzip
6160
pacman -S --noconfirm bison automake autoconf libtool coreutils
6261
pacman -S --noconfirm libcurl-devel libxml2-devel libxslt-devel
6362
pacman -S --noconfirm zlib-devel
64-
pacman -S --noconfirm libbz2-devel liblz4-devel liblzma-devel libcares-devel
65-
pacman -S --noconfirm libyaml-devel libzstd-devel libreadline-devel
63+
pacman -S --noconfirm libbz2-devel liblz4-devel liblzma-devel libcares-devel
64+
pacman -S --noconfirm libyaml-devel libzstd-devel libreadline-devel
6665
pacman -S --noconfirm libssh2-devel libidn2-devel gettext-devel
6766
pacman -S --noconfirm libzstd-devel
68-
pacman -S --noconfirm icu-devel
6967
pacman -S --noconfirm libsqlite-devel libsqlite
7068
pacman -S --noconfirm gmp-devel
71-
pacman -S --noconfirm libintl
72-
pacman -S --noconfirm pcre2
7369
pacman -S --noconfirm brotli-devel
70+
pacman -S --noconfirm pcre pcre2
71+
pacman -S --noconfirm icu
72+
pacman -S --noconfirm icu-devel
73+
pacman -S --noconfirm gettext-devel
74+
pacman -S --noconfirm libintl
75+
pacman -S --noconfirm flex
7476

75-
:<<EOF
77+
: <<EOF
7678
# 不存在的包
77-
pacman -S --noconfirm libpcre2-devel libssl-devel libgmp-devel
7879
pacman -S --noconfirm ImageMagick libpng-devel libjpeg-devel libfreetype-devel libwebp-devel libsqlite3-devel
79-
pacman -S --noconfirm libzip-devel libicu-devel libonig-devel libsodium-devel
80+
pacman -S --noconfirm libzip-devel libonig-devel libsodium-devel
8081
pacman -S --noconfirm libMagick-devel libbrotli-devel libintl-devel libpq-devel
8182
pacman -S --noconfirm libpq5 libpq-devel
82-
pacman -S --noconfirm gcc-g++
83+
8384
8485
# msys 环境下 可以安装 re2c
8586
# 不需要执行 bash ./sapi/scripts/cygwin/install-re2c.sh
8687
87-
8888
EOF
8989

9090
# 清理缓存

sapi/scripts/cygwin/cygwin-build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@ cp -f ${WORK_TEMP_DIR}/php-src/sapi/cli/php.exe ${__PROJECT__}/bin/
3737
${__PROJECT__}/bin/php.exe -v
3838
${__PROJECT__}/bin/php.exe -m
3939
${__PROJECT__}/bin/php.exe --ri swoole
40+
41+
cd ${__PROJECT__}
42+
APP_VERSION=$(${__PROJECT__}/bin/php.exe -v | awk '{print $2}')
43+
APP_NAME='php-cli'
44+
echo "v${APP_VERSION}" >${__PROJECT__}/APP_VERSION
45+
echo ${APP_NAME} >${__PROJECT__}/APP_NAME

sapi/scripts/cygwin/cygwin-config-ext.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ __PROJECT__=$(
1111
)
1212
cd ${__PROJECT__}
1313

14-
1514
PHP_VERSION='8.2.28'
1615
SWOOLE_VERSION='v6.0.2'
17-
SWOOLE_VERSION='master'
1816
X_PHP_VERSION='8.2'
1917

2018
while [ $# -gt 0 ]; do
@@ -75,6 +73,7 @@ download_and_extract "yaml" ${YAML_VERSION}
7573
download_and_extract "imagick" ${IMAGICK_VERSION}
7674

7775
cd ${__PROJECT__}/pool/ext
76+
# with git clone swoole source code
7877
if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then
7978
test -d ${WORK_TEMP_DIR}/swoole && rm -rf ${WORK_TEMP_DIR}/swoole
8079
git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git ${WORK_TEMP_DIR}/swoole
@@ -84,7 +83,7 @@ if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then
8483
cd ${__PROJECT__}/pool/ext
8584
fi
8685
mkdir -p ${WORK_TEMP_DIR}/ext/swoole/
87-
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/swoole/ -xf swoole-${SWOOLE_VERSION}.tgz
86+
tar --strip-components=1 -C ${WORK_TEMP_DIR}/ext/swoole/ -xf ${__PROJECT__}/pool/ext/swoole-${SWOOLE_VERSION}.tgz
8887

8988
cd ${__PROJECT__}
9089
# clean extension folder
@@ -105,8 +104,10 @@ tar --strip-components=1 -C ${WORK_TEMP_DIR}/php-src -xf php-${PHP_VERSION}.tar.
105104

106105
cd ${__PROJECT__}
107106
# copy extension
108-
# cp -rf var/cygwin-build/ext/* var/cygwin-build/php-src/ext/
109-
cp -rf ${WORK_TEMP_DIR}/ext/* ${WORK_TEMP_DIR}/php-src/ext/
107+
# cp -rf ${WORK_TEMP_DIR}/ext/. ${__PROJECT__}/ext/
108+
# cp -rf ${__PROJECT__}/ext/. ${WORK_TEMP_DIR}/php-src/ext/
109+
# cp -rf ${__PROJECT__}/ext/. ${WORK_TEMP_DIR}/php-src/ext/
110+
cp -rf ${WORK_TEMP_DIR}/ext/. ${WORK_TEMP_DIR}/php-src/ext/
110111

111112
# extension hook
112113
if [ "$X_PHP_VERSION" = "8.4" ]; then

sapi/scripts/cygwin/cygwin-config.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ while [ $# -gt 0 ]; do
2424
--php-version)
2525
PHP_VERSION="$2"
2626
X_PHP_VERSION=$(echo ${PHP_VERSION:0:3})
27-
if [ "$X_PHP_VERSION" = "8.4" ]; then
28-
OPTIONS+=''
29-
fi
3027
;;
3128
--*)
3229
echo "Illegal option $1"
@@ -44,6 +41,7 @@ cd ${WORK_TEMP_DIR}/php-src/
4441
# export CFLAGS=""
4542
# export LDFLAGS="-L/usr/lib"
4643

44+
export ICU_CXXFLAGS=" -std=gnu++17 "
4745
./buildconf --force
4846
test -f Makefile && make clean
4947
./configure --prefix=/usr --disable-all \
@@ -88,6 +86,8 @@ test -f Makefile && make clean
8886
--with-imagick \
8987
--with-yaml \
9088
--with-readline \
89+
--with-zip \
90+
--with-pgsql \
9191
${OPTIONS}
9292

9393
# --with-pdo-pgsql \

0 commit comments

Comments
 (0)