Skip to content

Commit

Permalink
调整快捷构建脚本和使用文档 (#527)
Browse files Browse the repository at this point in the history
* 调整快捷构建脚本和使用文档

* update build-release-example.sh

* update build-release-example.sh
  • Loading branch information
jingjingxyk authored Jan 3, 2024
1 parent 5a3956e commit d4b04b8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ indent_style = space

[*.md]
indent_style = space
max_line_length = 80
max_line_length = 120

[COMMIT_EDITMSG]
indent_size = 4
Expand Down
2 changes: 1 addition & 1 deletion build-release-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fi
# 定制构建选项
OPTIONS='+apcu +ds +xlswriter +ssh2'
OPTIONS="${OPTIONS} --with-swoole-pgsql=1"

# OPTIONS="${OPTIONS} @macos"


if [ ${IN_DOCKER} -eq 1 ] ; then
Expand Down
25 changes: 23 additions & 2 deletions docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
`Linux` 下需要在容器中构建,因此需要先构建 `swoole-cli-builder:base` 基础镜像。
基础镜像 `Dockerfile` 参考 [sapi/Dockerfile](/sapi/docker/Dockerfile)

1. 构建基础镜像:`./make.sh docker-build`,也可以直接使用官方构建好的镜像 `docker pull phpswoole/swoole-cli-builder:base`
1. 构建基础镜像:`./make.sh docker-build [china|ustc|tuna] `
,也可以直接使用官方构建好的镜像 `docker pull phpswoole/swoole-cli-builder:base`
1. 构建完成之后,使用 `./make.sh docker-bash` 进入容器
2. 构建所有 `C/C++`库: `./make.sh all-library`
3. 提交镜像:`./make.sh docker-commit` 提交 `swoole-cli-builder` 镜像
Expand All @@ -12,6 +13,26 @@
> `C库` 变更时,应该修改 `swoole-cli-builder` 镜像的版本
> `make.sh all-library` 是可重入的,它会自动跳过已构建成功的库
快速初始化构建环境
====
不执行 `./make.sh docker-build [china|ustc|tuna] ` 生成基础镜像
使用如下命令快速进入容器环境
便捷调整构建环境

```bash
# 安装容器运行环境
# bash sapi/quickstart/linux/install-docker.sh

bash sapi/quickstart/linux/run-alpine-container.sh
bash sapi/quickstart/linux/alpine-init.sh

# 使用镜像源 例子
# bash sapi/quickstart/linux/install-docker.sh --mirror [ china | ustc | tuna ]
# bash sapi/quickstart/linux/alpine-init.sh --mirror [ china | ustc | tuna | tencentyun | huaweicloud ]
# bash sapi/quickstart/linux/alpine-init.sh --mirror china

```

构建 swoole-cli
====
需要依赖 `phpswoole/swoole-cli-builder` 镜像,可按照第一步的提示构建镜像,也可以直接拉取官方构建好的镜像。
Expand All @@ -26,6 +47,7 @@

其他指令
====

* `./make.sh list-library`:列出所有 `C/C++`
* `./make.sh list-extension`:列出所有扩展
* `./make.sh clean-all-library`:清理所有 `C/C++`
Expand All @@ -38,7 +60,6 @@
* `./make.sh clean-[library-name]`:单独清理某个 `C/C++`
* `./make.sh clean-[library-name]-cached`:单独清理某个 `C/C++` 库,保留缓存文件


常见错误
=====

Expand Down
31 changes: 30 additions & 1 deletion docs/macOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@
3. 配置 `./make.sh config`
4. 构建 `./make.sh build`

## 快速 初始化macos 构建环境

运行此命令解决构建过程中遇到的绝大部分问题
`homebrew`已安装,跳过执行此命令`bash sapi/quickstart/macos/install-homebrew.sh`

```bash


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` 的编译,必须要在构建之前将关联的软件进行卸载。在构建完成后再重新安装。
Expand Down Expand Up @@ -121,7 +143,14 @@ export LIBSODIUM_LIBS=$(pkg-config --libs libsodium)
> 解压以后执行如下命令:
```bash
sudo xattr -d com.apple.quarantine ./swoole-cli

sudo xattr -d com.apple.quarantine ./swoole-cli

file ./bin/swoole-cli
otool -L ./bin/swoole-cli

```

## [macOS doesn't officially support fully static linking ](https://developer.apple.com/library/archive/qa/qa1118/_index.html)

macos 支持构建静态库,不支持构建静态链接的二进制文件

0 comments on commit d4b04b8

Please sign in to comment.