git clone --recursive https://github.com/swoole/swoole-cli.git
cd swoole-cli
bash setup-php-runtime.sh
composer install --no-interaction --no-autoloader --no-scripts --profile
composer dump-autoload --optimize --profile
php prepare.php --without-docker=1 +apcu +ds +xlswriter +ssh2 +uuid
bash sapi/quickstart/macos/macos-init.sh
bash ./make.sh all-library
bash ./make.sh config
bash ./make.sh build
bash ./make.sh archive
./bin/swoole-cli -m
./bin/swoole-cli --ri swoole
xattr -cr ./bin/swoole-cli
otool -L ./bin/swoole-cli
- 清理
brew
安装的软件 - 执行
php prepare.php --without-docker=1
生成构建shell 脚本 - 编译所有依赖的库
./make.sh all-library
- 配置
./make.sh config
- 构建
./make.sh build
运行此命令解决构建过程中遇到的绝大部分问题
如homebrew
已安装,跳过执行此命令bash sapi/quickstart/macos/install-homebrew.sh
bash sapi/quickstart/macos/install-homebrew.sh
bash sapi/quickstart/macos/macos-init.sh
# 使用homebrew镜像源
# bash sapi/quickstart/macos/install-homebrew.sh --mirror ustc
# bash sapi/quickstart/macos/macos-init.sh --mirror ustc
# 设置默认安装库目录的权限
CURRENT_USER=$(whoami)
sudo mkdir -p /usr/local/swoole-cli
CURRENT_USER=$(whoami) && sudo chown -R ${CURRENT_USER}:staff /usr/local/swoole-cli
使用 brew
安装的库可能会干扰 swoole-cli
的编译,必须要在构建之前将关联的软件进行卸载。在构建完成后再重新安装。
# 多数情况下,只需要卸载 snappy 和 capstone
# brew uninstall --ignore-dependencies oniguruma
# brew uninstall --ignore-dependencies brotli
# brew uninstall --ignore-dependencies freetype
# brew uninstall --ignore-dependencies zstd
brew uninstall --ignore-dependencies snappy
brew uninstall --ignore-dependencies capstone
brew install wget curl libtool automake re2c llvm flex bison
brew install gettext coreutils binutils libunistring
export PATH=/usr/local/opt/bison/bin:/usr/local/opt/llvm/bin:$PATH
下载源代码,自行编译安装 (此问题已解决,安装依赖库时 已经包含bison源码编译,或者如下操作)
brew intall bison
export PATH=/usr/local/opt/bison/bin:$PATH
# 若目录不存在,可以先安装 llvm
brew intall llvm
export PATH=/usr/local/opt/llvm/bin:$PATH
可使用 which glibtool
找到所在路径,使用 ln -s
创建软连接
ln -s /usr/local/bin/glibtool /usr/local/bin/libtool
ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
若使用 brew
安装,可能是在 /opt/homebrew/bin/glibtool
位置
ln -s /opt/homebrew/bin/glibtool /opt/homebrew/bin/libtool
ln -s /opt/homebrew/bin/glibtoolize /opt/homebrew/bin/libtoolize
brew install gettext coreutils re2c libunistring flex bison
修改 ext/curl/config.m4
,去掉 HAVE_CURL
检测
错误信息:
checking for icu-uc >= 50.1 icu-io icu-i18n... no
configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:
No package 'icu-uc' found
No package 'icu-io' found
No package 'icu-i18n' found
export ICU_CFLAGS=$(pkg-config --cflags icu-uc)
export ICU_LIBS=$(pkg-config --libs icu-uc)
export ONIG_CFLAGS=$(pkg-config --cflags oniguruma)
export ONIG_LIBS=$(pkg-config --libs oniguruma)
export LIBZIP_CFLAGS=$(pkg-config --cflags libzip)
export LIBZIP_LIBS=$(pkg-config --libs libzip)
export LIBSODIUM_CFLAGS=$(pkg-config --cflags libsodium)
export LIBSODIUM_LIBS=$(pkg-config --libs libsodium)
note: macos clearing the com.apple.quarantine extended attribute macos环境下 首次运行提示无权限 ,通过清除扩展属性 解决
# 查看扩展属性
xattr ./bin/swoole-cli
# 移除扩展属性
sudo xattr -d com.apple.quarantine ./bin/swoole-cli
file ./bin/swoole-cli
otool -L ./bin/swoole-cli
macos 支持构建静态库,不支持构建静态链接的二进制文件