swoole / swoole-cli

SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions.
192 stars 35 forks source link

支持event和protobuf扩展以及如何构建指定版本swoole #159

Open hjw0968 opened 1 year ago

hjw0968 commented 1 year ago

1,支持event和protobuf 2,如何构建指定版本swoole (比如我想构建swoole版本4.8.13的cli, 官方提供的包没有我需要的扩展)

protobuf扩展按如下添加成功

php prepare.php \ --with-build-type=release \ +protobuf \ --with-download-mirror-url=https://swoole-cli.jingjingxyk.com/

但是无法成功构建

image
jingjingxyk commented 1 year ago

需要 event ,可以切换到 experiment 分支,实验分支里包含了 event 扩展 和所需的库


git checkout experiment

切换swoole 版本,进入 ext/swoole 目录, 使用git 切换分支。 swoole 分支查看


cd ext/swoole
git checkout  v4.8.13
jingjingxyk commented 1 year ago

@hjw0968 可以用这个(v4.8.x )分支,我稍微改了下,把curl 依赖的nghttp2 nghttp3 库的支持去掉了(因为nghttp2 功能与swoole内置nghttp2 冲突)这里可以看到那些地方被修改了https://github.com/swoole/swoole-cli/pull/160/files


git clone -b experiment_v4.8.x  --recursive  https://github.com/jingjingxyk/swoole-cli
cd ext/swoole
git checkout  v4.8.13
cd ../..

php prepare.php +protobuf +event +inotify 
jingjingxyk commented 1 year ago

@hjw0968 通过验证:启用event 和 protobuf ,与你遇到了同样的问题

hjw0968 commented 1 year ago

@hjw0968 通过验证:启用event 和 protobuf 你遇到同样的问题

尝试按你上面的进行验证,又出现如下错误

image
jingjingxyk commented 1 year ago

@hjw0968 已经复现问题

单独编译 protobuf 扩展是可以编译成功的。多个扩展同时编译就不行。

编译 扩展event 始终不行。

同时我还验证了,直接使用 php-src 源码, 静态构建也是不行。还需要研究研究。

本项目: build_native_php 分支可以直接用 php-src 源码event 静态构建

按需构建例子: https://github.com/swoole/swoole-cli/blob/build_native_php/sapi/quickstart/enable-single-extension-example.sh

hjw0968 commented 1 year ago

本项目: build_native_php 分支可以直接用 php-src 源码event 静态构建

按需构建例子: https://github.com/swoole/swoole-cli/blob/build_native_php/sapi/quickstart/enable-single-extension-example.sh

@jingjingxyk build_native_php分支构建成功,但是redis和swoole扩展都没被打包进去

还是等你们官方更新修复主仓库吧, 只需要能成功把protobuf编译进去, 我们的项目就可以马上全部切换到swoole-cli了, 省下了每次一台一台的按需编译的时间

event扩展在纯swoole环境下也许并不那么重要, 但是 protobuf 就很重要了

jingjingxyk commented 1 year ago

@hjw0968 通过实验,只要不编译 event 扩展 , protobuf 扩展是可以启用成功 (编译过 event 扩展 记得执行 make clean)

php prepare.php  +protobuf

web ui 助手 https://swoole-cli-ui.jingjingxyk.com/

jingjingxyk commented 1 year ago

@hjw0968 编译好的,不包括 event

swoole-cli-v5.0.3-linux-x64.zip

hjw0968 commented 1 year ago

@hjw0968 通过实验,只要不编译 event 扩展 , protobuf 扩展是可以启用成功 (编译过 event 扩展 记得执行 make clean)

php prepare.php  +protobuf

web ui 助手 https://swoole-cli-ui.jingjingxyk.com/

@jingjingxyk 编译4.8.13分支依然卡在, 5.0.3我自己还未尝试

image

想问下你编译成功的仓库分支是main还是 experiment_v4.8.xexperiment

编译参数

php prepare.php  +protobuf
make clean
make.sh clean
make.sh config
make.sh build
image image
hjw0968 commented 1 year ago

清空docker, 删除后重新构建主分支, v5.0.3也是卡在一样的错误 构建参数和上面一样,报一样的错, 这我就纳了大闷了

hjw0968 commented 1 year ago

更新一下我的测试结果

# cd ext/protobuf
# 手动替换为protobuf3.23.2
# cd ../..
php prepare.php +protobuf -bz2 -imagick -mongodb -pdo_sqlite -sqlite3 -yaml
make clean
./make.sh clean
./make.sh config
./make.sh build
./make.sh archive

编译通过✅

没有更多的时间尝试, 不太确定是否是protobuf扩展版本的原因

image
jingjingxyk commented 1 year ago

@hjw0968 我用的是主分支 main 全部执行命令如下:

bash sapi/quickstart/setup-php-runtime.sh --mirror china

bash sapi/quickstart/linux/run-alpine-3.16-container-full.sh

# 进入容器
bash sapi/quickstart/linux/connection-swoole-cli-alpine.sh

sh sapi/quickstart/linux/alpine-3.16-init.sh --mirror china

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

composer update --no-dev  --optimize-autoloader

php prepare.php --with-global-prefix=/usr --with-download-mirror-url=https://swoole-cli.jingjingxyk.com/ +protobuf

# bash make.sh all-library  (这步省略,因为已经提前构建好,并打包到容器中,运行容器已经包含)
bash make.sh config
bash make.sh build

bash make.sh archive

image

hjw0968 commented 1 year ago

@jingjingxyk macos m2 编译通过✅ 给你提个不确定是不是bug的bug, mac下php prepare.php -mongodb 时, make.sh 中的 export PATH 没有bison的PATH, 在config阶段会报错, 这里需要手动修改make.sh 中的 export PATH

# make.sh line 8 export PATH=‘xxx:$PATH’
# 无此path时手动在末尾正确位置添加
:/usr/local/swoole-cli/bison/bin

带protobuf的2种版本, 有需要的其他朋友可以直接下载使用

image

全部扩展

php prepare.php --without-docker=1 +protobuf

swoole-cli-v5.0.3-macos-arm64_full.tar.xz.zip

个人配置

php prepare.php --without-docker=1 -mongodb -xsl -yaml -opcache -gmp -imagick +protobuf

swoole-cli-v5.0.3-macos-arm64.tar.xz.zip

jingjingxyk commented 1 year ago

@hjw0968 bison 这个问题实际有两个解决思路: 一个是这个: https://github.com/swoole/swoole-cli/pull/157/files#diff-f5c5aecdd2031458d94ebb42fbce28e3dbe9fc21926badc42559c857dacd3266

另外一个是这个: export PATH=/usr/local/opt/bison/bin:$PATH