diff --git a/.github/workflows/auto-cache-pool-tarball.yml b/.github/workflows/auto-cache-pool-tarball.yml index ff3b0405d9..3394e276c4 100644 --- a/.github/workflows/auto-cache-pool-tarball.yml +++ b/.github/workflows/auto-cache-pool-tarball.yml @@ -93,7 +93,7 @@ jobs: php prepare.php --show-tarball-hash=1 --with-php-version=8.3.23 php prepare.php --show-tarball-hash=1 --with-php-version=8.4.10 - echo 'cygwin: https://www.cygwin.com/COPYING' > bin/LICENSE + echo 'cygwin: https://www.cygwin.com/COPYING' >> bin/LICENSE cd ${{ github.workspace }}/pool/ zip -9 -r ${WORK_DIR}/all-deps.zip ext lib php-tar HASH=$(sha256sum ${WORK_DIR}/all-deps.zip | awk '{print $1}') diff --git a/.github/workflows/linux-mips64le.yaml b/.github/workflows/linux-mips64le.yaml deleted file mode 100644 index c6bc53fee7..0000000000 --- a/.github/workflows/linux-mips64le.yaml +++ /dev/null @@ -1,196 +0,0 @@ -name: build-php-cli-linux-mips64le - -on: [ push, pull_request ] - -env: - BUILD_PHP_VERSION: 8.2.13 - -jobs: - linux-mips64le: - if: 0 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Prepare Source Code - run: | - echo $PATH - env - docker info - id -u - id -g - who - cat /etc/os-release - hostnamectl - uname -s - uname -m - uname -r - export IPV6=$(ip -6 address show | grep inet6 | awk '{print $2}' | cut -d'/' -f1 | sed -n '2p') - export IPV4=$(ip -4 address show | grep inet | grep -v 127.0.0 | awk '{print $2}' | cut -d'/' -f1 | sed -n '1p') - echo $IPV4 - echo $IPV6 - echo "X_IPV6=${IPV6}" >> $GITHUB_ENV - echo "X_IPV4=${IPV4}" >> $GITHUB_ENV - - echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $GITHUB_ENV - - # git submodule update --init - - sudo mkdir -p /usr/local/swoole-cli - uid=$(id -u) && gid=$(id -g) && sudo chown -R ${uid}:${gid} /usr/local/swoole-cli - - mkdir -p ${{ github.workspace }}/var/build-github-action-container/ - - - name: Cache PHP Vendor - uses: actions/cache@v3 - id: php-vendor-cache - with: - path: ${{ github.workspace }}/vendor - key: ${{ runner.os }}-mips64le-php-vendor - - - name: Cache Dependency Source Code Tarball - uses: actions/cache@v4 - id: pool-cache - with: - path: ${{ github.workspace }}/pool/ - key: source-code-tarball-pool - - - name: Cache all-library - uses: actions/cache@v4 - id: all-library-cache - with: - path: /usr/local/swoole-cli - key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-mips64le-all-library - - - name: Cache swoole-cli-builder-image - uses: actions/cache@v4 - id: swoole-cli-builder-image-mips64le-cache - with: - path: ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar - key: ${{ runner.os }}-mips64le-swoole-cli-builder-image - - - name: Prepare Libraries and Extensions - run: | - set -x - mkdir -p pool/lib - mkdir -p pool/ext - - CACHE_NUM=$(ls -A pool/lib/ | wc -l) - LIB_NUM=$(ls -A sapi/src/builder/library/ | wc -l) - echo `expr $LIB_NUM - $CACHE_NUM` - - if test $CACHE_NUM -eq 0 ; then - bash sapi/download-box/download-box-get-archive-from-container.sh - fi - - ls -A pool/lib/ - ls -A /usr/local/swoole-cli/ - - - name: Prepare QEMU - run: | - set -x - sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - - name: Prepare swoole-cli-builder-image - run: | - if [ -f ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar ] ; then - docker load -i ${{ github.workspace }}/var/build-github-action-container/swoole-cli-builder-image.tar - else - bash .github/workflows/build-debian-builder-container.sh --platform "linux/mips64le" - fi - - - name: prepare pre-built library - if: 1 - uses: addnab/docker-run-action@v3 - with: - image: swoole-cli-builder:latest - options: -v ${{ github.workspace }}:/work -w /work -v /usr/local/swoole-cli/:/usr/local/swoole-cli/ - run: | - for i in `ls /usr/local/swoole-cli/` - do - echo $i - done - uname -a - uname -s - uname -m - apt install -y php-dev php-cli - - - - name: Build - if: 1 - uses: addnab/docker-run-action@v3 - with: - image: swoole-cli-builder:latest - options: -v ${{ github.workspace }}:/work -w /work -e BUILD_PHP_VERSION=${{ env.BUILD_PHP_VERSION }} -v /usr/local/swoole-cli:/usr/local/swoole-cli - run: | - set -eux - uname -m - if [ ! -f bin/runtime/php ] ; then - bash setup-php-runtime.sh - fi - - # export PATH=/work/bin/runtime:$PATH # 容器已经内置 php 和 composer - # alias php="php -d curl.cainfo=/work/bin/runtime/cacert.pem -d openssl.cafile=/work/bin/runtime/cacert.pem" - - sh sapi/quickstart/linux/alpine-init.sh - composer install --no-interaction --no-autoloader --no-scripts --profile --no-dev - composer dump-autoload --optimize --profile --no-dev - - php prepare.php --with-override-default-enabled-ext=1 --with-php-version=8.3.4 - - bash make-install-deps.sh - - bash make.sh all-library - - bash make.sh config - bash make.sh build - bash make.sh archive - - - name: Show Build Result - if: 1 - uses: addnab/docker-run-action@v3 - with: - image: swoole-cli-builder:latest - options: -v ${{ github.workspace }}:/work -w /work - run: | - ./thirdparty/php-src/sapi/cli/php -v - ./thirdparty/php-src/sapi/cli/php -m - BUILD_PHP_VERSION=$(./thirdparty/php-src/sapi/cli/php -v | head -n 1 | awk '{print $2}') - file ./bin/php-${BUILD_PHP_VERSION}/bin/php - readelf -h ./bin/php-${BUILD_PHP_VERSION}/bin/php - APP_VERSION=$(./bin/php-${BUILD_PHP_VERSION}/bin/php -v | head -n 1 | awk '{print $2}') - echo ${APP_VERSION} - echo ${APP_VERSION} > APP_VERSION - ./bin/php-${BUILD_PHP_VERSION}/bin/php -r "echo PHP_VERSION;" - - - name: get app version - if: 1 - run: | - APP_VERSION=$(cat ./APP_VERSION) - echo $APP_VERSION - echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV - echo "BUILD_PHP_VERSION=${APP_VERSION}" >> $GITHUB_ENV - - - name: production artifacts debug - if: 0 - uses: actions/upload-artifact@v4 - with: - name: php-cli-v${{ env.APP_VERSION }}-linux-mips64le-debug - retention-days: 90 - path: ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/php - - - name: production artifacts - if: 0 - uses: actions/upload-artifact@v4 - with: - name: php-cli-v${{ env.APP_VERSION }}-linux-mips64le - retention-days: 90 - path: ./bin/php-${{ env.BUILD_PHP_VERSION }}/bin/dist/php - - - name: gh release - uses: softprops/action-gh-release@v2 - if: 0 && startsWith(github.ref, 'refs/tags/') - with: - files: | - php-cli-v${{ env.APP_VERSION }}-linux-mips64le.tar.xz - php-cli-v${{ env.APP_VERSION }}-linux-mips64le-debug.tar.xz - diff --git a/README.md b/README.md index 799b0b2640..d757978f98 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,8 @@ `php-cli` 是一个 `PHP`的 运行时 ,默认包含 swoole 扩展 - > 本项目 派生于 [swoole-cli](https://github.com/swoole/swoole-cli/) - > 代码与 swoole-cli 项目的 build_native_php 分支的代码 保持一致 > 构建流程 与 swoole-cli 构建流程一致 diff --git a/sapi/quickstart/README.md b/sapi/quickstart/README.md index e9704cdaf9..bfa0fcacb6 100644 --- a/sapi/quickstart/README.md +++ b/sapi/quickstart/README.md @@ -2,13 +2,13 @@ ## 一个脚本执行整个构建流程 -> 定制 build-release-php.sh 脚本 即可开始构建 +> 定制 build-release-php.sh 即可开始构建 ```bash -cp build-release-example.sh build-release-php.sh + cp build-release-example.sh build-release-php.sh -bash build-release-php.sh + bash build-release-php.sh ``` @@ -22,6 +22,50 @@ bash build-release-php.sh ## [wsl](../../docs/wsl.md) +## 准备 PHP 运行时 + +```bash +# 准备 PHP 运行时 +bash sapi/setup-php-runtime.sh + +# 准备PHP 运行时 使用代理 +bash sapi/setup-php-runtime.sh --proxy http://192.168.3.26:8015 + +# 准备PHP 运行时 使用镜像 (镜像源 https://www.swoole.com/download) +bash sapi/setup-php-runtime.sh --mirror china + + +# 验证 +shopt -s expand_aliases +__DIR__=$(pwd) +export PATH="${__DIR__}/runtime/php/:$PATH" +alias php="php -d curl.cainfo=${__DIR__}/runtime/php/cacert.pem -d openssl.cafile=${__DIR__}/runtime/php/cacert.pem" + +php -v +composer -v + +``` + +## 准备依赖库源码 + +```bash + +# 源码来源 https://github.com/swoole/swoole-cli/releases/download/${TAG}/all-deps.zip + +bash sapi/download-box/download-box-get-archive-from-server.sh + +``` + +## 准备 swoole 源码 + +> 拉取 swoole-cli 源码时没有拉取子模块,就需要执行这一步 + +```bash + +git submodule update --init -f + +``` + ## 准备运行环境 (linux/macos/windows) 1. [ linux 快速启动 容器 构建环环境 ](linux/README.md) diff --git a/sapi/quickstart/windows/msys2-build/install-msys2.sh b/sapi/quickstart/windows/msys2-build/install-msys2.sh index f2c1fb90ff..05715d057b 100644 --- a/sapi/quickstart/windows/msys2-build/install-msys2.sh +++ b/sapi/quickstart/windows/msys2-build/install-msys2.sh @@ -51,18 +51,17 @@ fi pacman -S --needed --noconfirm git curl wget openssl pacman -S --needed --noconfirm zip unzip xz gcc gcc-libs cmake make pacman -S --needed --noconfirm re2c -pacman -S --needed --noconfirm openssl-devel libreadline pacman -S --needed --noconfirm lzip pacman -S --needed --noconfirm zip unzip pacman -S --needed --noconfirm zlib-devel pacman -S --needed --noconfirm bison automake autoconf libtool coreutils +pacman -S --needed --noconfirm openssl-devel libreadline-devel libiconv-devel pacman -S --needed --noconfirm libcurl-devel libxml2-devel libxslt-devel pacman -S --needed --noconfirm libbz2-devel liblz4-devel liblzma-devel libcares-devel -pacman -S --needed --noconfirm libyaml-devel libzstd-devel libreadline-devel -pacman -S --needed --noconfirm libssh2-devel libidn2-devel gettext-devel pacman -S --needed --noconfirm libzstd-devel -pacman -S --needed --noconfirm icu-devel -pacman -S --needed --noconfirm libsqlite-devel libsqlite +pacman -S --needed --noconfirm libyaml-devel +pacman -S --needed --noconfirm libssh2-devel libidn2-devel gettext-devel +pacman -S --needed --noconfirm libsqlite-devel pacman -S --needed --noconfirm libedit-devel pacman -S --needed --noconfirm gmp-devel pacman -S --needed --noconfirm brotli-devel diff --git a/sapi/src/builder/extension/swoole_latest.php b/sapi/src/builder/extension/swoole_latest.php index afa6968f2d..77a98ebaa9 100644 --- a/sapi/src/builder/extension/swoole_latest.php +++ b/sapi/src/builder/extension/swoole_latest.php @@ -4,7 +4,8 @@ use SwooleCli\Extension; return function (Preprocessor $p) { - $file = "swoole-latest.tar.gz"; + $swoole_tag = 'master'; + $file = "swoole-v{$swoole_tag}.tar.gz"; $options = []; if ($p->getBuildType() === 'debug') { @@ -42,7 +43,8 @@ $p->withExportVariable('URING_LIBS', '$(pkg-config --libs --static liburing)'); } - $p->addExtension((new Extension('swoole')) + $p->addExtension((new Extension('swoole_latest')) + ->withAliasName('swoole') ->withHomePage('https://github.com/swoole/swoole-src') ->withLicense('https://github.com/swoole/swoole-src/blob/master/LICENSE', Extension::LICENSE_APACHE2) ->withManual('https://wiki.swoole.com/#/') @@ -50,7 +52,7 @@ ->withDownloadScript( 'swoole-src', <<withAutoUpdateFile() diff --git a/sapi/src/builder/extension/swoole_v5.1.x.php b/sapi/src/builder/extension/swoole_v5.1.x.php index f1b3644365..30f71b1360 100644 --- a/sapi/src/builder/extension/swoole_v5.1.x.php +++ b/sapi/src/builder/extension/swoole_v5.1.x.php @@ -5,9 +5,8 @@ use SwooleCli\Extension; return function (Preprocessor $p) { - - $file = "swoole-v5.1.x.tar.gz"; $swoole_tag = '5.1.x'; + $file = "swoole-v${$swoole_tag}.tar.gz"; $options = []; if ($p->getBuildType() === 'debug') { diff --git a/sapi/src/builder/extension/swow.php b/sapi/src/builder/extension/swow.php index 5f8ba1895d..d930f03833 100644 --- a/sapi/src/builder/extension/swow.php +++ b/sapi/src/builder/extension/swow.php @@ -5,6 +5,7 @@ use SwooleCli\Library; return function (Preprocessor $p) { + $swow_tag = 'v1.6.1'; $options = ' --enable-swow '; $options .= ' --enable-swow-ssl '; $options .= ' --enable-swow-curl '; @@ -20,14 +21,12 @@ ->withHomePage('https://github.com/swow/swow') ->withLicense('https://github.com/swow/swow/blob/develop/LICENSE', Extension::LICENSE_APACHE2) ->withManual('https://docs.toast.run/swow/en/install.html') - ->withFile('swow-v1.5.3.tar.gz') + ->withFile("swow-{$swow_tag}.tar.gz") ->withDownloadScript( "swow", <<withBuildCached(false) diff --git a/sapi/src/builder/extension/swow_latest.php b/sapi/src/builder/extension/swow_latest.php index 287bccd49b..4976d8627d 100644 --- a/sapi/src/builder/extension/swow_latest.php +++ b/sapi/src/builder/extension/swow_latest.php @@ -26,10 +26,8 @@ ->withDownloadScript( "swow", <<withDependentLibraries(...$dependentLibraries) diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index ad32e5d8a9..d6f0486285 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -97,10 +97,10 @@ done case "$MIRROR" in china) - APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + APP_DOWNLOAD_URL="https://storage.swoole.com/dist/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" if [ $OS = 'windows' ]; then - APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + APP_DOWNLOAD_URL="https://storage.swoole.com/dist/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" fi ;; diff --git a/setup-swoole-cli-runtime.ps1 b/setup-swoole-cli-runtime.ps1 index 97f2f0c021..d7c4d45a3c 100644 --- a/setup-swoole-cli-runtime.ps1 +++ b/setup-swoole-cli-runtime.ps1 @@ -36,7 +36,7 @@ try if ($mirror -eq 'china') { - $APP_DOWNLOAD_URL = "https://wenda-1252906962.file.myqcloud.com/dist/$APP_NAME-$APP_VERSION-cygwin-x64.zip" + $APP_DOWNLOAD_URL = "https://storage.swoole.com/dist/$APP_NAME-$APP_VERSION-cygwin-x64.zip" } if ($proxy -ne '') { @@ -47,13 +47,17 @@ try { if (Get-Command "curl.exe" -ErrorAction SilentlyContinue) { - curl.exe -fSLo "$TMP_APP_RUNTIME\$FILE" $APP_DOWNLOAD_URL + curl.exe -H 'Referer: https://www.swoole.com/download' -H 'User-Agent: download swoole-cli runtime with setup-swoole-cli-runtime.ps1' -fSLo "$TMP_APP_RUNTIME\$FILE" $APP_DOWNLOAD_URL } else { + $headers = @{ + 'User-Agent' = 'download swoole-cli runtime with setup-swoole-cli-runtime.ps1' + 'Referer' = 'https://www.swoole.com/download' + } # Invoke-WebRequest $APP_DOWNLOAD_URL -UseBasicParsing -OutFile $FILE # Invoke-WebRequest -Uri $APP_DOWNLOAD_URL -OutFile $FILE - irm $APP_DOWNLOAD_URL -outfile "$TMP_APP_RUNTIME\$FILE" + irm $APP_DOWNLOAD_URL -Headers $headers -outfile "$TMP_APP_RUNTIME\$FILE" } } diff --git a/setup-swoole-cli-runtime.sh b/setup-swoole-cli-runtime.sh index 1d7c543ff1..1ac4d04661 100644 --- a/setup-swoole-cli-runtime.sh +++ b/setup-swoole-cli-runtime.sh @@ -121,10 +121,10 @@ fi case "$MIRROR" in china) - APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" + APP_DOWNLOAD_URL="https://storage.swoole.com/dist/${APP_NAME}-${APP_VERSION}-${OS}-${ARCH}.tar.xz" COMPOSER_DOWNLOAD_URL="https://mirrors.tencent.com/composer/composer.phar" if [ $OS = 'windows' ]; then - APP_DOWNLOAD_URL="https://wenda-1252906962.file.myqcloud.com/dist/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" + APP_DOWNLOAD_URL="https://storage.swoole.com/dist/${APP_NAME}-${APP_VERSION}-cygwin-${ARCH}.zip" fi ;;