Skip to content

Commit

Permalink
Merge pull request #905 from jingjingxyk/build_native_php
Browse files Browse the repository at this point in the history
Build native php
  • Loading branch information
jingjingxyk authored Jan 5, 2025
2 parents 9ed9550 + 8ebc0aa commit 9f9ac1d
Show file tree
Hide file tree
Showing 30 changed files with 194 additions and 260 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/artifact-hash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ jobs:
- name: upload artifacts to cloud object storage
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (inputs.enable_upload_cloud_object_storage == true) }}
env:
SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-all --swoole-cli-version ${{ inputs.version }}
6 changes: 4 additions & 2 deletions .github/workflows/linux-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ jobs:
- name: upload artifacts to cloud object storage
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
env:
SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-v${{ env.APP_VERSION }}-linux-arm64.tar.xz
6 changes: 4 additions & 2 deletions .github/workflows/linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ jobs:
- name: upload artifacts to cloud object storage
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
env:
SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-v${{ env.APP_VERSION }}-linux-x64.tar.xz
6 changes: 4 additions & 2 deletions .github/workflows/macos-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ jobs:
- name: upload artifacts to cloud object storage
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
env:
SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-v${{ env.APP_VERSION }}-macos-arm64.tar.xz
6 changes: 4 additions & 2 deletions .github/workflows/macos-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ jobs:
- name: upload artifacts to cloud object storage
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
env:
SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-v${{ env.APP_VERSION }}-macos-x64.tar.xz
8 changes: 6 additions & 2 deletions .github/workflows/windows-cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
git config --global core.ignorecase false
git config --global --add safe.directory ${{ github.workspace }}
ipconfig
- uses: actions/checkout@v4
- name: set php version
Expand Down Expand Up @@ -180,8 +182,10 @@ jobs:
- name: upload artifacts to cloud object storage
if: ${{ 0 && (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }}
env:
SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_SECRET_ID: ${{ secrets.QCLOUD_OSS_SECRET_ID }}
OSS_SECRET_KEY: ${{ secrets.QCLOUD_OSS_SECRET_KEY }}
OSS_BUCKET: ${{ vars.QCLOUD_OSS_BUCKET }}
OSS_REGION: ${{ vars.QCLOUD_OSS_REGION }}
run: |
FILE_NAME=$(ls -d swoole-cli-v*-cygwin-x64)
FILE="${{ github.workspace }}/${FILE_NAME}/${FILE_NAME}.zip"
Expand Down
91 changes: 0 additions & 91 deletions sapi/musl-cross-make/config.mak

This file was deleted.

23 changes: 6 additions & 17 deletions sapi/quickstart/build-native-php-example.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#!/bin/env bash
set -uex


OS=$(uname -s)
ARCH=$(uname -m)


export CC=clang
export CXX=clang++
export LD=ld.lld

if [ "$OS" = 'Linux' ] ;then
if [ "$OS" = 'Linux' ]; then

: <<'EOF'
: <<'EOF'
# setup container environment
docker run --rm -ti --init -v .:/work -w /work debian:11
Expand All @@ -24,15 +22,12 @@ EOF

fi

if [ "$OS" = 'Darwin' ]; then

if [ "$OS" = 'Darwin' ] ;then

export PATH=/usr/local/opt/bison/bin/:/usr/local/opt/llvm/bin/:$PATH
export PATH=/usr/local/opt/bison/bin/:/usr/local/opt/llvm/bin/:$PATH

fi



mkdir -p /tmp/t
cd /tmp/t

Expand All @@ -53,10 +48,6 @@ tar --strip-components=1 -C mongodb -xf mongodb-${MONGODB_VERSION}.tgz
test -d php-src/ext/mongodb && rm -rf php-src/ext/mongodb
mv mongodb php-src/ext/





cd php-src

./buildconf --force
Expand All @@ -83,13 +74,11 @@ cd php-src

make -j $(nproc)


if [ "$OS" = 'Linux' ] ;then
if [ "$OS" = 'Linux' ]; then

file sapi/cli/php
readelf -h sapi/cli/php

else
otool -L sapi/cli/php
otool -L sapi/cli/php
fi

21 changes: 8 additions & 13 deletions sapi/quickstart/linux/arm64/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# x86_64 运行 arm64
> 使用 qemu-user-static 实现
# `x86_64` 平台模拟 `arm64`

## 参考文档
qemu
https://www.qemu.org/
https://github.com/qemu/qemu.git

qemu-user-static
https://github.com/multiarch/qemu-user-static.git
使用 `qemu-user-static` 实现

x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建
https://www.cnblogs.com/chen2ha/p/17180287.html
## 参考文档

Docker在x86架构的物理机上跑Qemu-arm 容器
https://blog.csdn.net/sunSHINEEzy/article/details/80015638
- [qemu 官网](https://www.qemu.org/)
- [qemu GitHub](https://github.com/qemu/qemu.git)
- [qemu-user-static](https://github.com/multiarch/qemu-user-static.git)
- [x86 平台利用 qemu-user-static 实现 arm64 平台 docker 镜像的运行和构建](https://www.cnblogs.com/chen2ha/p/17180287.html)
- [Docker在x86架构的物理机上跑Qemu-arm 容器](https://blog.csdn.net/sunSHINEEzy/article/details/80015638)


25 changes: 13 additions & 12 deletions sapi/quickstart/linux/extra/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
#
# 常见问题

## 当环境中没有 PHP 解释器时 可以快速安装 PHP 解释器
## 快速安装 `PHP` 解释器

```bash

# alpine
### Alpine

sh sapi/quickstart/linux/extra/alpine-php-init.sh
```bash
sh sapi/quickstart/linux/extra/alpine-php-init.sh
```

## debian
### Debian/Ubuntu

```bash
bash sapi/quickstart/linux/extra/debian-php-init.sh

```

## download composer
## 安装 `Composer`

```bash

curl -Lo /usr/local/bin/composer.phar https://getcomposer.org/download/latest-stable/composer.phar

ln -sf /usr/local/bin/composer.phar /usr/local/bin/composer
chmod a+x /usr/local/bin/composer

```

## c c++编译器 组合
## `C/C++` 编译器组合

- 组合一 clang clang++
- 组合二 gcc g++
- `clang` + `clang++`
- `gcc` + `g++`

2 changes: 1 addition & 1 deletion sapi/quickstart/linux/install-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ ! -f /usr/libexec/docker/cli-plugins/docker-compose ]; then

# show more version info
# https://github.com/docker/compose/releases
VERSION="v2.29.1"
VERSION="v2.32.1"

curl -fsSL "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Expand Down
12 changes: 6 additions & 6 deletions sapi/quickstart/linux/install-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ while [ $# -gt 0 ]; do
shift $(($# > 0 ? 1 : 0))
done


# https://github.com/docker/docker-install.git
# test -f get-docker.sh || curl -fsSL https://get.docker.com -o get-docker.sh

Expand All @@ -41,14 +40,15 @@ china | ustc | tuna)
;;
esac


if [ -n "$http_proxy" ] || [ -n "$https_proxy" ] || [ -n "$HTTP_PROXY" ] || [ -n "$HTTPS_PROXY" ]; then
echo 'Please delete proxy settings !'
echo 'Execute this script again !'
exit 0
set +u
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
set -u
fi


case "$MIRROR" in
china | ustc)
sed -i "s@https://mirrors.aliyun.com/docker-ce@https://mirrors.ustc.edu.cn/docker-ce@g" get-docker.sh
Expand Down
5 changes: 2 additions & 3 deletions sapi/quickstart/linux/run-alpine-container-full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cd ${__DIR__}

{
docker stop swoole-cli-alpine-dev
docker stop swoole-cli-builder
sleep 5
} || {
echo $?
Expand Down Expand Up @@ -75,7 +74,7 @@ cd ${__DIR__}
if [ $DEV_SHM -eq 1 ]; then
mkdir -p /dev/shm/swoole-cli/thirdparty/
mkdir -p /dev/shm/swoole-cli/ext/
docker run --rm --name swoole-cli-builder -d -v ${__PROJECT__}:/work -v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ -v /dev/shm/swoole-cli/ext/:/work/ext/ -w /work --init $IMAGE tail -f /dev/null
docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -v /dev/shm/swoole-cli/thirdparty/:/work/thirdparty/ -v /dev/shm/swoole-cli/ext/:/work/ext/ -w /work --init $IMAGE tail -f /dev/null
else
docker run --rm --name swoole-cli-builder -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null
docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null
fi
Loading

0 comments on commit 9f9ac1d

Please sign in to comment.