From 292539f8ac10bafe3d82d3bd63de57ea3ec99d15 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 26 Nov 2025 12:29:40 +0800 Subject: [PATCH 01/25] Upgrade swoole to v6.1.3 --- sapi/SWOOLE-VERSION.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index 035fbdc6e7..b2c63a1c1b 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.1 +v6.1.3 From fd7471d575e820272fe50a4ef75fbcb10c91edf4 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 26 Nov 2025 20:01:57 +0800 Subject: [PATCH 02/25] Add support for deb package --- .gitignore | 2 ++ sapi/src/Preprocessor.php | 22 ++++++++++++++ sapi/src/builder/nfpm/deb-depends.php | 43 +++++++++++++++++++++++++++ sapi/src/template/deb-pkg.php | 19 ++++++++++++ sapi/src/template/make.php | 30 +++++++++++++++++++ 5 files changed, 116 insertions(+) create mode 100644 sapi/src/builder/nfpm/deb-depends.php create mode 100644 sapi/src/template/deb-pkg.php diff --git a/.gitignore b/.gitignore index 301ea23b8e..2d99e9eaa0 100644 --- a/.gitignore +++ b/.gitignore @@ -327,3 +327,5 @@ cppflags.log libs.log /runtime !/runtime/.gitkeep +*.deb +nfpm-deb.yaml diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index c7218c1f1f..81df1058e9 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -37,6 +37,7 @@ class Preprocessor protected string $libraryDir; protected string $extensionDir; protected array $pkgConfigPaths = []; + protected array $nfpmDepends = []; protected string $phpSrcDir; protected string $dockerVersion = 'latest'; /** @@ -137,6 +138,19 @@ public function getSystemArch(): string } } + public function getDebArch(): string + { + $uname = posix_uname(); + switch ($uname['machine']) { + case 'x86_64': + return 'amd64'; + case 'aarch64': + return 'arm64'; + default: + return $uname['machine']; + } + } + public function getImageTag(): string { $arch = $this->getSystemArch(); @@ -218,6 +232,11 @@ public function getBuildDir(): string return $this->buildDir; } + public function getSwooleVersion(): string + { + return trim(file_get_contents($this->rootDir . '/sapi/SWOOLE-VERSION.conf')); + } + public function getWorkDir(): string { return $this->workDir; @@ -801,11 +820,14 @@ public function execute(): void $this->generateDownloadLinks(); } + $this->nfpmDepends['deb'] = require __DIR__ . '/builder/nfpm/deb-depends.php'; + $this->generateFile(__DIR__ . '/template/make.php', $this->rootDir . '/make.sh'); shell_exec('chmod a+x ' . $this->rootDir . '/make.sh'); $this->mkdirIfNotExists($this->rootDir . '/bin'); $this->generateFile(__DIR__ . '/template/license.php', $this->rootDir . '/bin/LICENSE'); $this->generateFile(__DIR__ . '/template/credits.php', $this->rootDir . '/bin/credits.html'); + $this->generateFile(__DIR__ . '/template/deb-pkg.php', $this->rootDir . '/nfpm-deb.yaml'); copy($this->rootDir . '/sapi/scripts/pack-sfx.php', $this->rootDir . '/bin/pack-sfx.php'); diff --git a/sapi/src/builder/nfpm/deb-depends.php b/sapi/src/builder/nfpm/deb-depends.php new file mode 100644 index 0000000000..f73f961a86 --- /dev/null +++ b/sapi/src/builder/nfpm/deb-depends.php @@ -0,0 +1,43 @@ + '>=2.35', + "libgcc-s1" => '>= 3.0', + "libstdc++6" => '>= 11', + "libyaml-0-2" => '', + "libssl3" => '', + "libxml2" => '', + "libmagickcore-6.q16-6" => '', + "libmagickcore-6.q16-6-extra" => '', + "libmagickcore-6.q16hdri-6" => '', + "libmagickcore-6.q16hdri-6-extra" => '', + "libmagickwand-6.q16-6" => '', + "libmagickwand-6.q16hdri-6" => '', + "libpng16-16" => '', + "libjpeg8" => '', + "libjpeg-turbo8" => '', + "libfreetype6" => '', + "libc-ares2" => '', + "libpcre2-8-0" => '', + "libsodium23" => '', + "libcurl4" => '', + "libmariadb3" => '', + "libaio1" => '', + "zlib1g" => '', + "mime-support" => '', + "tzdata" => '', + "ucf" => '', + "libargon2-1" => '', + "libsqlite3-0" => '', + "libbrotli1" => '', + "libpq5" => '', + "unixodbc" => '', + "firebird3.0-common" => '', + "libzstd1" => '', + "libssh2-1" => '', + "liburing2" => '', + "libedit2" => '', + "libmagic1" => '', + 'libonig5' => '', + 'libxslt1.1' => '', + 'libzip4' => '', +]; diff --git a/sapi/src/template/deb-pkg.php b/sapi/src/template/deb-pkg.php new file mode 100644 index 0000000000..96cbbb2d86 --- /dev/null +++ b/sapi/src/template/deb-pkg.php @@ -0,0 +1,19 @@ +name: "swoole-cli" +arch: "getDebArch()?>" +platform: "getOsType()?>" +version: "getSwooleVersion()?>" +section: "default" +priority: "extra" +maintainer: "service " +description: | + SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions +homepage: "https://github.com/swoole/swoole-cli" + +depends: +nfpmDepends['deb'] as $pkg => $version) : ?> + - () + + +contents: + - src: "bin/swoole-cli" + dst: "/usr/local/bin/swoole-cli" diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index 91ab9d56f6..f2c296658d 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -310,6 +310,25 @@ rm -f ext/opcache/minilua } +make_swoole_cli_with_linux_gcc() { + if [ ! -f bin/swoole-cli ] ;then + ./buildconf --force + ./sapi/scripts/build-swoole-cli-with-linux-gcc.sh + fi +} + +make_deb_pkg() { + make_swoole_cli_with_linux_gcc + nfpm pkg --config nfpm-deb.yaml --target swoole-cli-getSwooleVersion()?>.deb + return 0 +} + +make_yum_pkg() { + make_swoole_cli_with_linux_gcc + nfpm pkg --config nfpm-yum.yaml --target swoole-cli-getSwooleVersion()?>.rpm + return 0 +} + help() { echo "./make.sh docker-build [ china | ustc | tuna ]" echo "./make.sh docker-bash" @@ -327,10 +346,13 @@ echo "./make.sh clean-all-library-cached" echo "./make.sh sync" echo "./make.sh pkg-check" + echo "./make.sh deb-depends-check" echo "./make.sh variables" echo "./make.sh list-swoole-branch" echo "./make.sh switch-swoole-branch" echo "./make.sh [library-name]" + echo "./make.sh deb-pkg" + echo "./make.sh yum-pkg" echo "./make.sh clean-[library-name]" echo "./make.sh clean-[library-name]-cached" echo "./make.sh clean" @@ -459,6 +481,14 @@ echo "name ?>" exit 0 +elif [ "$1" = "deb-pkg" ] ;then + make_deb_pkg +elif [ "$1" = "deb-depends-check" ] ;then +nfpmDepends['deb'] as $pkg => $version) : ?> + apt info + +elif [ "$1" = "yum-pkg" ] ;then + make_yum_pkg elif [ "$1" = "clean" ] ;then make_clean elif [ "$1" = "variables" ] ;then From ddec7c6ec61c804b73c3d6b1da365c59bb48bded Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 28 Nov 2025 14:35:04 +0800 Subject: [PATCH 03/25] Add support for the dynamically linked glibc build --- .github/workflows/linux-glibc.yml | 150 ++++++++++++++++++ .gitignore | 3 + prepare.php | 7 +- sapi/SWOOLE-VERSION.conf | 2 +- .../build-swoole-cli-with-linux-gcc.sh | 16 +- sapi/scripts/copy-depend-libs.php | 99 ++++++++++++ sapi/scripts/download-swoole-src-archive.sh | 48 ++++++ sapi/scripts/install-deps-on-ubuntu.sh | 36 +++++ sapi/src/Preprocessor.php | 20 +++ sapi/src/builder/extension/swoole.php | 41 ----- sapi/src/template/make.php | 20 +++ sapi/src/template/nfpm-yaml.php | 24 +++ 12 files changed, 418 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/linux-glibc.yml create mode 100644 sapi/scripts/copy-depend-libs.php create mode 100755 sapi/scripts/download-swoole-src-archive.sh create mode 100755 sapi/scripts/install-deps-on-ubuntu.sh create mode 100644 sapi/src/template/nfpm-yaml.php diff --git a/.github/workflows/linux-glibc.yml b/.github/workflows/linux-glibc.yml new file mode 100644 index 0000000000..28e9b59f78 --- /dev/null +++ b/.github/workflows/linux-glibc.yml @@ -0,0 +1,150 @@ +name: build-swoole-cli-linux-glibc-x86_64 + +on: [ push, pull_request ] + +jobs: + linux-glibc: + if: ${{ !contains(github.event.head_commit.message, '--filter=') || contains(github.event.head_commit.message, '[linux-glibc]') }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-22.04, ubuntu-22.04-arm ] + name: linux-glibc-${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Show Environment Info + run: | + echo $PATH + env + docker info + id -u + id -g + who + cat /etc/os-release + hostnamectl + uname -s + uname -m + uname -r + + cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c + cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l + cat /proc/cpuinfo | grep "cpu cores" | uniq + cat /proc/cpuinfo| grep "processor"| wc -l + lscpu + + 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 + + - name: Prepare Build Environment + run: | + 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 Runtime + uses: actions/cache@v4 + id: php-runtime-cache-x86_64 + with: + path: ${{ github.workspace }}/runtime + key: ${{ runner.os }}-x86_64-php-runtime + + - name: Cache PHP Vendor + uses: actions/cache@v4 + id: php-vendor-cache-x86_64 + with: + path: ${{ github.workspace }}/vendor + key: ${{ runner.os }}-x86_64-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-x86_64 + with: + path: /usr/local/swoole-cli + key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-x86_64-all-library + + - name: Prepare Runtime and Libraries and Extensions + run: | + set -x + mkdir -p pool/lib + mkdir -p pool/ext + mkdir -p bin/ + mkdir -p runtime/ + test -f runtime/php && rm -f runtime/php + if [ ! -f runtime/php/php ] ; then + bash setup-php-runtime.sh + fi + bash sapi/download-box/download-box-get-archive-from-server.sh + ls -A pool/lib/ + ls -A /usr/local/swoole-cli/ + + - name: Build + run: | + set -eux + uname -m + composer install --no-interaction --no-autoloader --no-scripts --profile + composer dump-autoload --optimize --profile + + php prepare.php --with-libavif + + sudo apt update + bash ./sapi/scripts/install-deps-on-ubuntu.sh + bash ./ext/swoole/scripts/install-deps-on-ubuntu.sh + bash ./sapi/scripts/build-swoole-cli-with-linux-gcc.sh + + ./bin/swoole-cli -v + ./bin/swoole-cli -m + ./bin/swoole-cli --ri curl + ./bin/swoole-cli --ri gd + ./bin/swoole-cli --ri imagick + ./bin/swoole-cli --ri swoole + { ldd ./bin/swoole-cli ; } || { echo $? ; } ; + file ./bin/swoole-cli + + - name: Make nfpm package + run: | + ARCH=$(uname -m) + if [ "$ARCH" = "aarch64" ]; then + NFPM_ARCH="arm64" + else + NFPM_ARCH="amd64" + fi + wget https://github.com/goreleaser/nfpm/releases/download/v2.43.4/nfpm_2.43.4_${NFPM_ARCH}.deb + sudo dpkg -i nfpm_2.43.4_${NFPM_ARCH}.deb + strip ./bin/swoole-cli + ./make.sh nfpm-pkg + ls -ls ./*.deb + ls -ls ./*.rpm + + - name: upload artifacts to cloud object storage + if: ${{ (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} + env: + 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: | + ARCH=$(uname -m) + if [ "$ARCH" = "aarch64" ]; then + FILE_ARCH="arm64" + else + FILE_ARCH="x64" + fi + SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf") + OS="linux" + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.deb + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.rpm diff --git a/.gitignore b/.gitignore index 301ea23b8e..092cd9d96e 100644 --- a/.gitignore +++ b/.gitignore @@ -327,3 +327,6 @@ cppflags.log libs.log /runtime !/runtime/.gitkeep +*.deb +*.rpm +nfpm-pkg.yaml diff --git a/prepare.php b/prepare.php index 08c9f4bc6a..1e65a07d55 100755 --- a/prepare.php +++ b/prepare.php @@ -7,7 +7,6 @@ $php_version_tag = trim(file_get_contents(__DIR__ . '/sapi/PHP-VERSION.conf')); define('BUILD_PHP_VERSION', $php_version_tag); - $homeDir = getenv('HOME'); $p = Preprocessor::getInstance(); $p->parseArguments($argc, $argv); @@ -26,13 +25,17 @@ // Sync code from php-src $p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION); +// Download swoole-src +if (!is_dir(__DIR__ . '/ext/swoole')) { + shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh'); +} + // Compile directly on the host machine, not in the docker container if ($p->getInputOption('without-docker') || ($p->isMacos())) { $p->setWorkDir(__DIR__); $p->setBuildDir(__DIR__ . '/thirdparty'); } - if ($p->getInputOption('with-global-prefix')) { $p->setGlobalPrefix($p->getInputOption('with-global-prefix')); } diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index 035fbdc6e7..b2c63a1c1b 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.1 +v6.1.3 diff --git a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh index a5155870f6..ed76758c6c 100755 --- a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh +++ b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh @@ -1,4 +1,9 @@ -./configure --prefix=/usr --disable-all \ +if [ ! -f ./configure ]; then + ./buildconf --force +fi + +./configure --prefix=/usr/local/swoole-cli \ + --disable-all \ --enable-zts \ --without-pcre-jit \ --with-openssl --enable-openssl \ @@ -31,17 +36,20 @@ --with-sodium \ --enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \ --enable-gd --with-jpeg --with-freetype \ - --enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \ + --enable-swoole \ + --enable-swoole-curl \ + --enable-cares \ --enable-swoole-pgsql \ --enable-swoole-sqlite \ + --with-swoole-odbc=unixODBC,/usr \ --enable-swoole-thread \ + --enable-swoole-stdext \ --enable-brotli \ --enable-zstd \ - --enable-swoole-stdext \ --enable-redis \ --with-imagick \ --with-yaml \ --with-readline \ --enable-opcache -make -j "$(nproc)" \ No newline at end of file +make -j "$(nproc)" diff --git a/sapi/scripts/copy-depend-libs.php b/sapi/scripts/copy-depend-libs.php new file mode 100644 index 0000000000..a1d7a8703f --- /dev/null +++ b/sapi/scripts/copy-depend-libs.php @@ -0,0 +1,99 @@ + (typical ldd output) + if (preg_match('/^\s*.*\s+=>\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) { + $libPath = trim($matches[1]); + if (file_exists($libPath)) { + $dependencies[] = $libPath; + } + } + // Match lines without => (statically linked or direct paths) + elseif (preg_match('/^\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) { + $libPath = trim($matches[1]); + if (file_exists($libPath)) { + $dependencies[] = $libPath; + } + } +} + +// Remove duplicates +$dependencies = array_unique($dependencies); + +// Filter out ignored libraries +$filteredDependencies = []; +foreach ($dependencies as $libPath) { + $fileName = basename($libPath); + foreach ($ignoredLibraries as $ignoredLib) { + if (strpos($fileName, $ignoredLib) !== false) { + echo "Skipping system library: $fileName\n"; + continue 2; + } + } + $filteredDependencies[] = $libPath; +} + +echo "Found " . count($filteredDependencies) . " dependencies (excluding system libraries)\n"; + +// Copy each dependency to target directory +$successCount = 0; +foreach ($filteredDependencies as $libPath) { + $fileName = basename($libPath); + $targetPath = "$targetDir/$fileName"; + + echo "Copying $libPath to $targetPath... "; + + if (copy($libPath, $targetPath)) { + echo "SUCCESS\n"; + $successCount++; + } else { + echo "FAILED\n"; + } +} + +echo "Successfully copied $successCount out of " . count($filteredDependencies) . " dependencies\n"; diff --git a/sapi/scripts/download-swoole-src-archive.sh b/sapi/scripts/download-swoole-src-archive.sh new file mode 100755 index 0000000000..9818ba63e7 --- /dev/null +++ b/sapi/scripts/download-swoole-src-archive.sh @@ -0,0 +1,48 @@ +__DIR__=$( + cd "$(dirname "$0")" || exit + pwd +) + +WORKDIR=$( + cd "${__DIR__}"/../../ || exit + pwd +) + +ORIGIN_SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf") +SWOOLE_VERSION=$(echo "${ORIGIN_SWOOLE_VERSION}" | sed 's/[^a-zA-Z0-9]/_/g') +CURRENT_SWOOLE_VERSION='' + +cd "${WORKDIR}" || exit + +TGZ_FILE="${WORKDIR}/pool/ext/swoole-${ORIGIN_SWOOLE_VERSION}.tgz" +SWOOLE_DIR="${WORKDIR}/ext/swoole/" + +if [ -f "ext/swoole/CMakeLists.txt" ] ;then + CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//') + if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then + echo 'swoole version master' + if [ -n "${GITHUB_ACTION}" ]; then + test -f "$TGZ_FILE" && rm -f "$TGZ_FILE" + CURRENT_SWOOLE_VERSION='' + fi + fi +fi + +if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then + if [ ! -f "$TGZ_FILE" ] ;then + echo "downloading swoole-${ORIGIN_SWOOLE_VERSION}.tgz" + test -d /tmp/swoole && rm -rf /tmp/swoole + git clone -b "${ORIGIN_SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole + status=$? + if [[ $status -ne 0 ]]; then { echo $status ; exit 1 ; } fi + cd /tmp/swoole || exit + rm -rf /tmp/swoole/.git/ + tar -czvf "$TGZ_FILE" . + fi + + if [ ! -d "$SWOOLE_DIR" ] ;then + echo "unpacking swoole-${ORIGIN_SWOOLE_VERSION}.tgz" + mkdir -p "${SWOOLE_DIR}" + tar --strip-components=1 -C "${SWOOLE_DIR}" -xf "$TGZ_FILE" + fi +fi diff --git a/sapi/scripts/install-deps-on-ubuntu.sh b/sapi/scripts/install-deps-on-ubuntu.sh new file mode 100755 index 0000000000..6f4a7e73d7 --- /dev/null +++ b/sapi/scripts/install-deps-on-ubuntu.sh @@ -0,0 +1,36 @@ +# build tools +sudo apt install gcc g++ make autoconf libtool pkg-config re2c + +# libraries +sudo apt install libyaml-dev \ + libssl-dev \ + libxml2-dev \ + libmagic-dev \ + libpng-dev \ + libjpeg-dev \ + libfreetype-dev \ + libc-ares-dev \ + libpcre2-dev \ + libsodium-dev \ + libcurl4-openssl-dev \ + libmariadb-dev \ + libaio-dev \ + zlib1g \ + mime-support \ + tzdata \ + ucf \ + libargon2-dev \ + libsqlite3-dev \ + libbrotli-dev \ + libpq-dev \ + unixodbc-dev \ + firebird-dev \ + libzstd-dev \ + libssh-dev \ + liburing-dev \ + libedit-dev \ + libreadline-dev \ + libmagic-dev \ + libonig-dev \ + libxslt-dev \ + libzip-dev diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index c7218c1f1f..3da0fd4d0a 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -37,6 +37,7 @@ class Preprocessor protected string $libraryDir; protected string $extensionDir; protected array $pkgConfigPaths = []; + protected array $nfpmDepends = []; protected string $phpSrcDir; protected string $dockerVersion = 'latest'; /** @@ -137,6 +138,19 @@ public function getSystemArch(): string } } + public function getDebArch(): string + { + $uname = posix_uname(); + switch ($uname['machine']) { + case 'x86_64': + return 'amd64'; + case 'aarch64': + return 'arm64'; + default: + return $uname['machine']; + } + } + public function getImageTag(): string { $arch = $this->getSystemArch(); @@ -218,6 +232,11 @@ public function getBuildDir(): string return $this->buildDir; } + public function getSwooleVersion(): string + { + return trim(file_get_contents($this->rootDir . '/sapi/SWOOLE-VERSION.conf')); + } + public function getWorkDir(): string { return $this->workDir; @@ -806,6 +825,7 @@ public function execute(): void $this->mkdirIfNotExists($this->rootDir . '/bin'); $this->generateFile(__DIR__ . '/template/license.php', $this->rootDir . '/bin/LICENSE'); $this->generateFile(__DIR__ . '/template/credits.php', $this->rootDir . '/bin/credits.html'); + $this->generateFile(__DIR__ . '/template/nfpm-yaml.php', $this->rootDir . '/nfpm-pkg.yaml'); copy($this->rootDir . '/sapi/scripts/pack-sfx.php', $this->rootDir . '/bin/pack-sfx.php'); diff --git a/sapi/src/builder/extension/swoole.php b/sapi/src/builder/extension/swoole.php index 4abadd4139..6213b213f4 100644 --- a/sapi/src/builder/extension/swoole.php +++ b/sapi/src/builder/extension/swoole.php @@ -47,45 +47,4 @@ $p->withExportVariable('ZSTD_LIBS', '$(pkg-config --libs --static libzstd)'); $p->withExportVariable('SWOOLE_ODBC_LIBS', '$(pkg-config --libs-only-L --libs-only-l --static odbc odbccr odbcinst readline ncursesw ) ' . " -L{$libiconv_prefix}/lib -liconv "); - - $p->withBeforeConfigureScript('swoole', function () use ($p) { - $workDir = $p->getWorkDir(); - $shell = "set -x ;cd {$workDir} ; WORKDIR={$workDir} ;" . PHP_EOL; - $shell .= <<<'EOF' - - SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf") - ORIGIN_SWOOLE_VERSION=${SWOOLE_VERSION} - SWOOLE_VERSION=$(echo "${SWOOLE_VERSION}" | sed 's/[^a-zA-Z0-9]/_/g') - CURRENT_SWOOLE_VERSION='' - - if [ -f "ext/swoole/CMakeLists.txt" ] ;then - CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//') - if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then - echo 'swoole version master' - if [ -n "${GITHUB_ACTION}" ]; then - test -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz && rm -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz - CURRENT_SWOOLE_VERSION='' - fi - fi - fi - - if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then - test -d ext/swoole && rm -rf ext/swoole - if [ ! -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz ] ;then - test -d /tmp/swoole && rm -rf /tmp/swoole - git clone -b "${ORIGIN_SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole - status=$? - if [[ $status -ne 0 ]]; then { echo $status ; exit 1 ; } fi - cd /tmp/swoole - rm -rf /tmp/swoole/.git/ - tar -czvf ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz . - fi - mkdir -p ${WORKDIR}/ext/swoole/ - tar --strip-components=1 -C ${WORKDIR}/ext/swoole/ -xf ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz - fi - # swoole extension hook -EOF; - - return $shell; - }); }; diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index 91ab9d56f6..d9acd45968 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -310,6 +310,23 @@ rm -f ext/opcache/minilua } +make_swoole_cli_with_linux_gcc() { + if [ ! -f bin/swoole-cli ] ;then + ./buildconf --force + ./sapi/scripts/build-swoole-cli-with-linux-gcc.sh + fi +} + +make_nfpm_pkg() { + make_swoole_cli_with_linux_gcc + ./bin/swoole-cli sapi/scripts/copy-depend-libs.php + patchelf --force-rpath --set-rpath '/usr/local/swoole-cli/lib' bin/swoole-cli + NFPM_PKG_FILENAME=swoole-cli-getSwooleVersion()?>-linux-getSystemArch()?>-glibc + nfpm pkg --config nfpm-pkg.yaml --target "${NFPM_PKG_FILENAME}.rpm" + nfpm pkg --config nfpm-pkg.yaml --target "${NFPM_PKG_FILENAME}.deb" + return 0 +} + help() { echo "./make.sh docker-build [ china | ustc | tuna ]" echo "./make.sh docker-bash" @@ -331,6 +348,7 @@ echo "./make.sh list-swoole-branch" echo "./make.sh switch-swoole-branch" echo "./make.sh [library-name]" + echo "./make.sh nfpm-pkg" echo "./make.sh clean-[library-name]" echo "./make.sh clean-[library-name]-cached" echo "./make.sh clean" @@ -459,6 +477,8 @@ echo "name ?>" exit 0 +elif [ "$1" = "nfpm-pkg" ] ;then + make_nfpm_pkg elif [ "$1" = "clean" ] ;then make_clean elif [ "$1" = "variables" ] ;then diff --git a/sapi/src/template/nfpm-yaml.php b/sapi/src/template/nfpm-yaml.php new file mode 100644 index 0000000000..430f68e3a1 --- /dev/null +++ b/sapi/src/template/nfpm-yaml.php @@ -0,0 +1,24 @@ +name: "swoole-cli" +arch: "getDebArch()?>" +platform: "getOsType()?>" +version: "getSwooleVersion()?>" +section: "default" +priority: "extra" +maintainer: "service " +description: | + SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions +homepage: "https://github.com/swoole/swoole-cli" + +overrides: + deb: + depends: + - libc6 (>=2.35) + rpm: + depends: + - glibc >= 2.35 + +contents: + - src: "bin/swoole-cli" + dst: "/usr/local/bin/swoole-cli" + - src: "runtime/libs/" + dst: "/usr/local/swoole-cli/lib/" From 2c1115ab5cb545559d5ccf08e3012e032a0198ae Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 28 Nov 2025 14:35:04 +0800 Subject: [PATCH 04/25] Add support for the dynamically linked glibc build # Conflicts: # .gitignore # sapi/src/Preprocessor.php # sapi/src/template/make.php --- .github/workflows/linux-glibc.yml | 150 ++++++++++++++++++ .gitignore | 3 +- prepare.php | 7 +- .../build-swoole-cli-with-linux-gcc.sh | 16 +- sapi/scripts/copy-depend-libs.php | 99 ++++++++++++ sapi/scripts/download-swoole-src-archive.sh | 48 ++++++ sapi/scripts/install-deps-on-ubuntu.sh | 36 +++++ sapi/src/Preprocessor.php | 4 +- sapi/src/builder/extension/swoole.php | 41 ----- sapi/src/template/make.php | 28 ++-- sapi/src/template/nfpm-yaml.php | 24 +++ 11 files changed, 386 insertions(+), 70 deletions(-) create mode 100644 .github/workflows/linux-glibc.yml create mode 100644 sapi/scripts/copy-depend-libs.php create mode 100755 sapi/scripts/download-swoole-src-archive.sh create mode 100755 sapi/scripts/install-deps-on-ubuntu.sh create mode 100644 sapi/src/template/nfpm-yaml.php diff --git a/.github/workflows/linux-glibc.yml b/.github/workflows/linux-glibc.yml new file mode 100644 index 0000000000..28e9b59f78 --- /dev/null +++ b/.github/workflows/linux-glibc.yml @@ -0,0 +1,150 @@ +name: build-swoole-cli-linux-glibc-x86_64 + +on: [ push, pull_request ] + +jobs: + linux-glibc: + if: ${{ !contains(github.event.head_commit.message, '--filter=') || contains(github.event.head_commit.message, '[linux-glibc]') }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-22.04, ubuntu-22.04-arm ] + name: linux-glibc-${{ matrix.os }} + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Show Environment Info + run: | + echo $PATH + env + docker info + id -u + id -g + who + cat /etc/os-release + hostnamectl + uname -s + uname -m + uname -r + + cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c + cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l + cat /proc/cpuinfo | grep "cpu cores" | uniq + cat /proc/cpuinfo| grep "processor"| wc -l + lscpu + + 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 + + - name: Prepare Build Environment + run: | + 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 Runtime + uses: actions/cache@v4 + id: php-runtime-cache-x86_64 + with: + path: ${{ github.workspace }}/runtime + key: ${{ runner.os }}-x86_64-php-runtime + + - name: Cache PHP Vendor + uses: actions/cache@v4 + id: php-vendor-cache-x86_64 + with: + path: ${{ github.workspace }}/vendor + key: ${{ runner.os }}-x86_64-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-x86_64 + with: + path: /usr/local/swoole-cli + key: ${{ github.head_ref || github.ref_name }}-${{ runner.os }}-x86_64-all-library + + - name: Prepare Runtime and Libraries and Extensions + run: | + set -x + mkdir -p pool/lib + mkdir -p pool/ext + mkdir -p bin/ + mkdir -p runtime/ + test -f runtime/php && rm -f runtime/php + if [ ! -f runtime/php/php ] ; then + bash setup-php-runtime.sh + fi + bash sapi/download-box/download-box-get-archive-from-server.sh + ls -A pool/lib/ + ls -A /usr/local/swoole-cli/ + + - name: Build + run: | + set -eux + uname -m + composer install --no-interaction --no-autoloader --no-scripts --profile + composer dump-autoload --optimize --profile + + php prepare.php --with-libavif + + sudo apt update + bash ./sapi/scripts/install-deps-on-ubuntu.sh + bash ./ext/swoole/scripts/install-deps-on-ubuntu.sh + bash ./sapi/scripts/build-swoole-cli-with-linux-gcc.sh + + ./bin/swoole-cli -v + ./bin/swoole-cli -m + ./bin/swoole-cli --ri curl + ./bin/swoole-cli --ri gd + ./bin/swoole-cli --ri imagick + ./bin/swoole-cli --ri swoole + { ldd ./bin/swoole-cli ; } || { echo $? ; } ; + file ./bin/swoole-cli + + - name: Make nfpm package + run: | + ARCH=$(uname -m) + if [ "$ARCH" = "aarch64" ]; then + NFPM_ARCH="arm64" + else + NFPM_ARCH="amd64" + fi + wget https://github.com/goreleaser/nfpm/releases/download/v2.43.4/nfpm_2.43.4_${NFPM_ARCH}.deb + sudo dpkg -i nfpm_2.43.4_${NFPM_ARCH}.deb + strip ./bin/swoole-cli + ./make.sh nfpm-pkg + ls -ls ./*.deb + ls -ls ./*.rpm + + - name: upload artifacts to cloud object storage + if: ${{ (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} + env: + 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: | + ARCH=$(uname -m) + if [ "$ARCH" = "aarch64" ]; then + FILE_ARCH="arm64" + else + FILE_ARCH="x64" + fi + SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf") + OS="linux" + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.deb + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${{ github.workspace }}/swoole-cli-"${SWOOLE_VERSION}-${OS}-${FILE_ARCH}"-glibc.rpm diff --git a/.gitignore b/.gitignore index 2d99e9eaa0..092cd9d96e 100644 --- a/.gitignore +++ b/.gitignore @@ -328,4 +328,5 @@ libs.log /runtime !/runtime/.gitkeep *.deb -nfpm-deb.yaml +*.rpm +nfpm-pkg.yaml diff --git a/prepare.php b/prepare.php index 08c9f4bc6a..1e65a07d55 100755 --- a/prepare.php +++ b/prepare.php @@ -7,7 +7,6 @@ $php_version_tag = trim(file_get_contents(__DIR__ . '/sapi/PHP-VERSION.conf')); define('BUILD_PHP_VERSION', $php_version_tag); - $homeDir = getenv('HOME'); $p = Preprocessor::getInstance(); $p->parseArguments($argc, $argv); @@ -26,13 +25,17 @@ // Sync code from php-src $p->setPhpSrcDir($p->getWorkDir() . '/var/php-' . BUILD_PHP_VERSION); +// Download swoole-src +if (!is_dir(__DIR__ . '/ext/swoole')) { + shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh'); +} + // Compile directly on the host machine, not in the docker container if ($p->getInputOption('without-docker') || ($p->isMacos())) { $p->setWorkDir(__DIR__); $p->setBuildDir(__DIR__ . '/thirdparty'); } - if ($p->getInputOption('with-global-prefix')) { $p->setGlobalPrefix($p->getInputOption('with-global-prefix')); } diff --git a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh index a5155870f6..ed76758c6c 100755 --- a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh +++ b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh @@ -1,4 +1,9 @@ -./configure --prefix=/usr --disable-all \ +if [ ! -f ./configure ]; then + ./buildconf --force +fi + +./configure --prefix=/usr/local/swoole-cli \ + --disable-all \ --enable-zts \ --without-pcre-jit \ --with-openssl --enable-openssl \ @@ -31,17 +36,20 @@ --with-sodium \ --enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \ --enable-gd --with-jpeg --with-freetype \ - --enable-swoole --enable-sockets --enable-mysqlnd --enable-swoole-curl --enable-cares \ + --enable-swoole \ + --enable-swoole-curl \ + --enable-cares \ --enable-swoole-pgsql \ --enable-swoole-sqlite \ + --with-swoole-odbc=unixODBC,/usr \ --enable-swoole-thread \ + --enable-swoole-stdext \ --enable-brotli \ --enable-zstd \ - --enable-swoole-stdext \ --enable-redis \ --with-imagick \ --with-yaml \ --with-readline \ --enable-opcache -make -j "$(nproc)" \ No newline at end of file +make -j "$(nproc)" diff --git a/sapi/scripts/copy-depend-libs.php b/sapi/scripts/copy-depend-libs.php new file mode 100644 index 0000000000..a1d7a8703f --- /dev/null +++ b/sapi/scripts/copy-depend-libs.php @@ -0,0 +1,99 @@ + (typical ldd output) + if (preg_match('/^\s*.*\s+=>\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) { + $libPath = trim($matches[1]); + if (file_exists($libPath)) { + $dependencies[] = $libPath; + } + } + // Match lines without => (statically linked or direct paths) + elseif (preg_match('/^\s+(\/.*)\s+\(0x[0-9a-f]+\)$/', $line, $matches)) { + $libPath = trim($matches[1]); + if (file_exists($libPath)) { + $dependencies[] = $libPath; + } + } +} + +// Remove duplicates +$dependencies = array_unique($dependencies); + +// Filter out ignored libraries +$filteredDependencies = []; +foreach ($dependencies as $libPath) { + $fileName = basename($libPath); + foreach ($ignoredLibraries as $ignoredLib) { + if (strpos($fileName, $ignoredLib) !== false) { + echo "Skipping system library: $fileName\n"; + continue 2; + } + } + $filteredDependencies[] = $libPath; +} + +echo "Found " . count($filteredDependencies) . " dependencies (excluding system libraries)\n"; + +// Copy each dependency to target directory +$successCount = 0; +foreach ($filteredDependencies as $libPath) { + $fileName = basename($libPath); + $targetPath = "$targetDir/$fileName"; + + echo "Copying $libPath to $targetPath... "; + + if (copy($libPath, $targetPath)) { + echo "SUCCESS\n"; + $successCount++; + } else { + echo "FAILED\n"; + } +} + +echo "Successfully copied $successCount out of " . count($filteredDependencies) . " dependencies\n"; diff --git a/sapi/scripts/download-swoole-src-archive.sh b/sapi/scripts/download-swoole-src-archive.sh new file mode 100755 index 0000000000..9818ba63e7 --- /dev/null +++ b/sapi/scripts/download-swoole-src-archive.sh @@ -0,0 +1,48 @@ +__DIR__=$( + cd "$(dirname "$0")" || exit + pwd +) + +WORKDIR=$( + cd "${__DIR__}"/../../ || exit + pwd +) + +ORIGIN_SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf") +SWOOLE_VERSION=$(echo "${ORIGIN_SWOOLE_VERSION}" | sed 's/[^a-zA-Z0-9]/_/g') +CURRENT_SWOOLE_VERSION='' + +cd "${WORKDIR}" || exit + +TGZ_FILE="${WORKDIR}/pool/ext/swoole-${ORIGIN_SWOOLE_VERSION}.tgz" +SWOOLE_DIR="${WORKDIR}/ext/swoole/" + +if [ -f "ext/swoole/CMakeLists.txt" ] ;then + CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//') + if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then + echo 'swoole version master' + if [ -n "${GITHUB_ACTION}" ]; then + test -f "$TGZ_FILE" && rm -f "$TGZ_FILE" + CURRENT_SWOOLE_VERSION='' + fi + fi +fi + +if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then + if [ ! -f "$TGZ_FILE" ] ;then + echo "downloading swoole-${ORIGIN_SWOOLE_VERSION}.tgz" + test -d /tmp/swoole && rm -rf /tmp/swoole + git clone -b "${ORIGIN_SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole + status=$? + if [[ $status -ne 0 ]]; then { echo $status ; exit 1 ; } fi + cd /tmp/swoole || exit + rm -rf /tmp/swoole/.git/ + tar -czvf "$TGZ_FILE" . + fi + + if [ ! -d "$SWOOLE_DIR" ] ;then + echo "unpacking swoole-${ORIGIN_SWOOLE_VERSION}.tgz" + mkdir -p "${SWOOLE_DIR}" + tar --strip-components=1 -C "${SWOOLE_DIR}" -xf "$TGZ_FILE" + fi +fi diff --git a/sapi/scripts/install-deps-on-ubuntu.sh b/sapi/scripts/install-deps-on-ubuntu.sh new file mode 100755 index 0000000000..6f4a7e73d7 --- /dev/null +++ b/sapi/scripts/install-deps-on-ubuntu.sh @@ -0,0 +1,36 @@ +# build tools +sudo apt install gcc g++ make autoconf libtool pkg-config re2c + +# libraries +sudo apt install libyaml-dev \ + libssl-dev \ + libxml2-dev \ + libmagic-dev \ + libpng-dev \ + libjpeg-dev \ + libfreetype-dev \ + libc-ares-dev \ + libpcre2-dev \ + libsodium-dev \ + libcurl4-openssl-dev \ + libmariadb-dev \ + libaio-dev \ + zlib1g \ + mime-support \ + tzdata \ + ucf \ + libargon2-dev \ + libsqlite3-dev \ + libbrotli-dev \ + libpq-dev \ + unixodbc-dev \ + firebird-dev \ + libzstd-dev \ + libssh-dev \ + liburing-dev \ + libedit-dev \ + libreadline-dev \ + libmagic-dev \ + libonig-dev \ + libxslt-dev \ + libzip-dev diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 81df1058e9..3da0fd4d0a 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -820,14 +820,12 @@ public function execute(): void $this->generateDownloadLinks(); } - $this->nfpmDepends['deb'] = require __DIR__ . '/builder/nfpm/deb-depends.php'; - $this->generateFile(__DIR__ . '/template/make.php', $this->rootDir . '/make.sh'); shell_exec('chmod a+x ' . $this->rootDir . '/make.sh'); $this->mkdirIfNotExists($this->rootDir . '/bin'); $this->generateFile(__DIR__ . '/template/license.php', $this->rootDir . '/bin/LICENSE'); $this->generateFile(__DIR__ . '/template/credits.php', $this->rootDir . '/bin/credits.html'); - $this->generateFile(__DIR__ . '/template/deb-pkg.php', $this->rootDir . '/nfpm-deb.yaml'); + $this->generateFile(__DIR__ . '/template/nfpm-yaml.php', $this->rootDir . '/nfpm-pkg.yaml'); copy($this->rootDir . '/sapi/scripts/pack-sfx.php', $this->rootDir . '/bin/pack-sfx.php'); diff --git a/sapi/src/builder/extension/swoole.php b/sapi/src/builder/extension/swoole.php index 4abadd4139..6213b213f4 100644 --- a/sapi/src/builder/extension/swoole.php +++ b/sapi/src/builder/extension/swoole.php @@ -47,45 +47,4 @@ $p->withExportVariable('ZSTD_LIBS', '$(pkg-config --libs --static libzstd)'); $p->withExportVariable('SWOOLE_ODBC_LIBS', '$(pkg-config --libs-only-L --libs-only-l --static odbc odbccr odbcinst readline ncursesw ) ' . " -L{$libiconv_prefix}/lib -liconv "); - - $p->withBeforeConfigureScript('swoole', function () use ($p) { - $workDir = $p->getWorkDir(); - $shell = "set -x ;cd {$workDir} ; WORKDIR={$workDir} ;" . PHP_EOL; - $shell .= <<<'EOF' - - SWOOLE_VERSION=$(awk 'NR==1{ print $1 }' "sapi/SWOOLE-VERSION.conf") - ORIGIN_SWOOLE_VERSION=${SWOOLE_VERSION} - SWOOLE_VERSION=$(echo "${SWOOLE_VERSION}" | sed 's/[^a-zA-Z0-9]/_/g') - CURRENT_SWOOLE_VERSION='' - - if [ -f "ext/swoole/CMakeLists.txt" ] ;then - CURRENT_SWOOLE_VERSION=$(grep 'set(SWOOLE_VERSION' ext/swoole/CMakeLists.txt | awk '{ print $2 }' | sed 's/)//') - if [[ "${CURRENT_SWOOLE_VERSION}" =~ "-dev" ]]; then - echo 'swoole version master' - if [ -n "${GITHUB_ACTION}" ]; then - test -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz && rm -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz - CURRENT_SWOOLE_VERSION='' - fi - fi - fi - - if [ "${SWOOLE_VERSION}" != "${CURRENT_SWOOLE_VERSION}" ] ;then - test -d ext/swoole && rm -rf ext/swoole - if [ ! -f ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz ] ;then - test -d /tmp/swoole && rm -rf /tmp/swoole - git clone -b "${ORIGIN_SWOOLE_VERSION}" https://github.com/swoole/swoole-src.git /tmp/swoole - status=$? - if [[ $status -ne 0 ]]; then { echo $status ; exit 1 ; } fi - cd /tmp/swoole - rm -rf /tmp/swoole/.git/ - tar -czvf ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz . - fi - mkdir -p ${WORKDIR}/ext/swoole/ - tar --strip-components=1 -C ${WORKDIR}/ext/swoole/ -xf ${WORKDIR}/pool/ext/swoole-${SWOOLE_VERSION}.tgz - fi - # swoole extension hook -EOF; - - return $shell; - }); }; diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index f2c296658d..d9acd45968 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -317,15 +317,13 @@ fi } -make_deb_pkg() { +make_nfpm_pkg() { make_swoole_cli_with_linux_gcc - nfpm pkg --config nfpm-deb.yaml --target swoole-cli-getSwooleVersion()?>.deb - return 0 -} - -make_yum_pkg() { - make_swoole_cli_with_linux_gcc - nfpm pkg --config nfpm-yum.yaml --target swoole-cli-getSwooleVersion()?>.rpm + ./bin/swoole-cli sapi/scripts/copy-depend-libs.php + patchelf --force-rpath --set-rpath '/usr/local/swoole-cli/lib' bin/swoole-cli + NFPM_PKG_FILENAME=swoole-cli-getSwooleVersion()?>-linux-getSystemArch()?>-glibc + nfpm pkg --config nfpm-pkg.yaml --target "${NFPM_PKG_FILENAME}.rpm" + nfpm pkg --config nfpm-pkg.yaml --target "${NFPM_PKG_FILENAME}.deb" return 0 } @@ -346,13 +344,11 @@ echo "./make.sh clean-all-library-cached" echo "./make.sh sync" echo "./make.sh pkg-check" - echo "./make.sh deb-depends-check" echo "./make.sh variables" echo "./make.sh list-swoole-branch" echo "./make.sh switch-swoole-branch" echo "./make.sh [library-name]" - echo "./make.sh deb-pkg" - echo "./make.sh yum-pkg" + echo "./make.sh nfpm-pkg" echo "./make.sh clean-[library-name]" echo "./make.sh clean-[library-name]-cached" echo "./make.sh clean" @@ -481,14 +477,8 @@ echo "name ?>" exit 0 -elif [ "$1" = "deb-pkg" ] ;then - make_deb_pkg -elif [ "$1" = "deb-depends-check" ] ;then -nfpmDepends['deb'] as $pkg => $version) : ?> - apt info - -elif [ "$1" = "yum-pkg" ] ;then - make_yum_pkg +elif [ "$1" = "nfpm-pkg" ] ;then + make_nfpm_pkg elif [ "$1" = "clean" ] ;then make_clean elif [ "$1" = "variables" ] ;then diff --git a/sapi/src/template/nfpm-yaml.php b/sapi/src/template/nfpm-yaml.php new file mode 100644 index 0000000000..430f68e3a1 --- /dev/null +++ b/sapi/src/template/nfpm-yaml.php @@ -0,0 +1,24 @@ +name: "swoole-cli" +arch: "getDebArch()?>" +platform: "getOsType()?>" +version: "getSwooleVersion()?>" +section: "default" +priority: "extra" +maintainer: "service " +description: | + SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions +homepage: "https://github.com/swoole/swoole-cli" + +overrides: + deb: + depends: + - libc6 (>=2.35) + rpm: + depends: + - glibc >= 2.35 + +contents: + - src: "bin/swoole-cli" + dst: "/usr/local/bin/swoole-cli" + - src: "runtime/libs/" + dst: "/usr/local/swoole-cli/lib/" From 2b811db6c759f6d348b59f23795eb1bfb52160db Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 08:18:22 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E8=A7=A3=E5=86=B3linux=20=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=86=85=20git=20=E6=B7=BB=E5=8A=A0=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/linux-aarch64.yml | 3 ++- .github/workflows/linux-x86_64.yml | 1 + sapi/scripts/tencent-cloud-object-storage.sh | 15 ++++++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index 73b6bd4a62..d25111e95b 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -114,9 +114,10 @@ jobs: alias php="php -d curl.cainfo=/work/runtime/php/cacert.pem -d openssl.cafile=/work/runtime/php/cacert.pem" sh sapi/quickstart/linux/alpine-init.sh + git config --global --add safe.directory /work composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - + php prepare.php --with-static-pie --with-libavif bash make.sh all-library diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index b6ab4be37a..b0034b33f0 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -114,6 +114,7 @@ jobs: alias php="php -d curl.cainfo=/work/runtime/php/cacert.pem -d openssl.cafile=/work/runtime/php/cacert.pem" sh sapi/quickstart/linux/alpine-init.sh + git config --global --add safe.directory /work composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile diff --git a/sapi/scripts/tencent-cloud-object-storage.sh b/sapi/scripts/tencent-cloud-object-storage.sh index 723d930860..e4e00eba52 100644 --- a/sapi/scripts/tencent-cloud-object-storage.sh +++ b/sapi/scripts/tencent-cloud-object-storage.sh @@ -136,18 +136,17 @@ if [ "${UPLOAD_TYPE}" == 'all' ]; then SWOOLE_VERSION=$(echo ${SWOOLE_CLI_VERSION} | awk -F '.' '{ printf "%s.%s.%s" ,$1,$2,$3 }') cd ${__PROJECT__}/var/artifact-hash/${SWOOLE_CLI_VERSION} { - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-cygwin-x64.zip ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-linux-arm64.tar.xz ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-linux-x64.tar.xz ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-macos-arm64.tar.xz ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-macos-x64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-cygwin-x64.zip ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-linux-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-linux-x64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-macos-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-macos-x64.tar.xz ${COS_BUCKET_FOLDER} status=$? } || { status=$? } if [[ $status -ne 0 ]]; then echo $status - cat ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log exit 1 fi cd ${__PROJECT__} @@ -155,11 +154,10 @@ if [ "${UPLOAD_TYPE}" == 'all' ]; then fi if [ "${UPLOAD_TYPE}" == 'single' ]; then - ${COSCLI} cp --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log ${UPLOAD_FILE} ${COS_BUCKET_FOLDER} + ${COSCLI} cp ${UPLOAD_FILE} ${COS_BUCKET_FOLDER} status=$? if [[ $status -ne 0 ]]; then echo $status - cat ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log exit 1 fi exit 0 @@ -172,7 +170,6 @@ if [ "${UPLOAD_TYPE}" == 'show' ]; then status=$? if [[ $status -ne 0 ]]; then echo $status - cat ${__PROJECT__}/var/tencent-cloud-object-storage/coscli.log exit 1 fi exit 0 From 6680893b29adcc45de3dede5e7f774eda1551a3a Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 08:21:43 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E4=BF=9D=E6=8C=81=20bin=20=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=20var=20=E7=9B=AE=E5=BD=95=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++-- bin/.gitkeep | 0 var/.gitkeep | 0 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 bin/.gitkeep create mode 100644 var/.gitkeep diff --git a/.gitignore b/.gitignore index 092cd9d96e..46e18f9c0e 100644 --- a/.gitignore +++ b/.gitignore @@ -322,11 +322,11 @@ cppflags.log /packages /conf.d.loader Makefile.backup -ldflags.log -cppflags.log libs.log /runtime !/runtime/.gitkeep *.deb *.rpm nfpm-pkg.yaml +!/var/.gitkeep + diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/var/.gitkeep b/var/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 7d5c6267c1b7b62af01832d0feb3a779de912f42 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 20:24:56 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E5=90=AF=E7=94=A8=20gd=20imagemagick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapi/scripts/msys2/config-ext.sh | 2 + sapi/scripts/msys2/config.sh | 4 +- sapi/scripts/msys2/install-deps-lib.sh | 11 +++ sapi/scripts/msys2/install-freetype.sh | 52 ++++++++++++++ sapi/scripts/msys2/install-imagemagick.sh | 88 +++++++++++++++++++++++ sapi/scripts/msys2/install-libaom.sh | 51 +++++++++++++ sapi/scripts/msys2/install-libavif.sh | 3 +- sapi/scripts/msys2/install-libgav1.sh | 49 +++++++++++++ sapi/scripts/msys2/install-libgif.sh | 38 ++++++++++ sapi/scripts/msys2/install-libjpeg.sh | 51 +++++++++++++ sapi/scripts/msys2/install-libpng.sh | 45 ++++++++++++ sapi/scripts/msys2/install-libwebp.sh | 45 ++++++++++++ sapi/scripts/msys2/install-libyuv.sh | 1 - 13 files changed, 436 insertions(+), 4 deletions(-) create mode 100644 sapi/scripts/msys2/install-freetype.sh create mode 100644 sapi/scripts/msys2/install-imagemagick.sh create mode 100644 sapi/scripts/msys2/install-libaom.sh create mode 100644 sapi/scripts/msys2/install-libgav1.sh create mode 100644 sapi/scripts/msys2/install-libgif.sh create mode 100644 sapi/scripts/msys2/install-libjpeg.sh create mode 100644 sapi/scripts/msys2/install-libpng.sh create mode 100644 sapi/scripts/msys2/install-libwebp.sh diff --git a/sapi/scripts/msys2/config-ext.sh b/sapi/scripts/msys2/config-ext.sh index ab28e2628a..ec7d94380a 100644 --- a/sapi/scripts/msys2/config-ext.sh +++ b/sapi/scripts/msys2/config-ext.sh @@ -75,9 +75,11 @@ download_and_extract "yaml" ${YAML_VERSION} download_and_extract "imagick" ${IMAGICK_VERSION} cd ${__PROJECT__}/pool/ext +set +u if [ -n "${GITHUB_ACTION}" ]; then test -f ${__PROJECT__}/pool/ext/swoole-${SWOOLE_VERSION}.tgz && rm -f ${__PROJECT__}/pool/ext/swoole-${SWOOLE_VERSION}.tgz fi +set -u if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then test -d ${WORK_TEMP_DIR}/swoole && rm -rf ${WORK_TEMP_DIR}/swoole git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git ${WORK_TEMP_DIR}/swoole diff --git a/sapi/scripts/msys2/config.sh b/sapi/scripts/msys2/config.sh index 33acb69fb2..39bdeda756 100644 --- a/sapi/scripts/msys2/config.sh +++ b/sapi/scripts/msys2/config.sh @@ -94,7 +94,9 @@ test -f Makefile && make clean --enable-mbstring \ --with-pgsql \ --enable-intl \ - ${OPTIONS} + ${OPTIONS} \ + --enable-gd --with-jpeg --with-freetype --with-webp --with-avif \ + --with-imagick # --enable-intl \ # --with-sodium \ diff --git a/sapi/scripts/msys2/install-deps-lib.sh b/sapi/scripts/msys2/install-deps-lib.sh index ac12e3ac7e..918a3c395d 100644 --- a/sapi/scripts/msys2/install-deps-lib.sh +++ b/sapi/scripts/msys2/install-deps-lib.sh @@ -14,3 +14,14 @@ bash install-libzip.sh bash install-libsodium.sh bash install-liboniguruma.sh bash install-libpq.sh +bash install-libgif.sh +bash install-libpng.sh +bash install-freetype.sh +bash install-libjpeg.sh +bash install-libwebp.sh +bash install-libyuv.sh +bash install-libaom.sh +bash install-libgav1.sh +bash install-libavif.sh +bash install-imagemagick.sh + diff --git a/sapi/scripts/msys2/install-freetype.sh b/sapi/scripts/msys2/install-freetype.sh new file mode 100644 index 0000000000..e744bd4ab1 --- /dev/null +++ b/sapi/scripts/msys2/install-freetype.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=2.13.2 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/freetype-${VERSION}.tar.gz https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p freetype-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/freetype-${VERSION}.tar.gz -C freetype-${VERSION} + cd freetype-${VERSION} + + mkdir -p build + cd build + + cmake -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DFT_REQUIRE_ZLIB=TRUE \ + -DFT_REQUIRE_BZIP2=TRUE \ + -DFT_REQUIRE_BROTLI=TRUE \ + -DFT_REQUIRE_PNG=TRUE \ + -DFT_DISABLE_HARFBUZZ=TRUE \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/freetype-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-imagemagick.sh b/sapi/scripts/msys2/install-imagemagick.sh new file mode 100644 index 0000000000..cf23d78f04 --- /dev/null +++ b/sapi/scripts/msys2/install-imagemagick.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=7.1.2-8 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/ImageMagick-v${VERSION}.tar.gz https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.2-8.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p ImageMagick-v${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/ImageMagick-v${VERSION}.tar.gz -C ImageMagick-v${VERSION} + cd ImageMagick-v${VERSION} + + ./configure \ + --prefix=/usr/ \ + --enable-shared=yes \ + --enable-static=no \ + --with-pic \ + --with-zip \ + --with-zlib \ + --with-lzma \ + --with-zstd \ + --with-jpeg \ + --with-png \ + --with-webp \ + --with-xml \ + --with-freetype \ + --with-heic \ + --with-raw \ + --with-tiff \ + --with-lcms \ + --enable-zero-configuration \ + --enable-bounds-checking \ + --enable-hdri \ + --disable-dependency-tracking \ + --without-perl \ + --disable-docs \ + --disable-opencl \ + --disable-openmp \ + --without-djvu \ + --without-rsvg \ + --without-fontconfig \ + --without-jbig \ + --without-jxl \ + --without-openjp2 \ + --without-lqr \ + --without-openexr \ + --without-pango \ + --without-x \ + --without-modules \ + --with-magick-plus-plus \ + --without-utilities \ + --without-gvc \ + --without-autotrace \ + --without-dps \ + --without-fftw \ + --without-flif \ + --without-fpx \ + --without-gslib \ + --without-perl \ + --without-raqm \ + --without-wmf + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/ImageMagick-v${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libaom.sh b/sapi/scripts/msys2/install-libaom.sh new file mode 100644 index 0000000000..549adfe0ad --- /dev/null +++ b/sapi/scripts/msys2/install-libaom.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=v3.10.0 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libaom-${VERSION}.tar.gz https://aomedia.googlesource.com/aom/+archive/c2fe6bf370f7c14fbaf12884b76244a3cfd7c5fc.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libaom-${VERSION} + tar -xvf ${__PROJECT__}/pool/lib/libaom-${VERSION}.tar.gz -C libaom-${VERSION} + cd libaom-${VERSION} + + mkdir -p build_dir + cd build_dir + cmake -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_STANDARD=11 \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_STATIC_LIBS=ON \ + -DENABLE_DOCS=OFF \ + -DENABLE_EXAMPLES=OFF \ + -DENABLE_TESTS=OFF \ + -DENABLE_TOOLS=ON + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libaom-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libavif.sh b/sapi/scripts/msys2/install-libavif.sh index eac0fa1fb9..e4244e7b9c 100644 --- a/sapi/scripts/msys2/install-libavif.sh +++ b/sapi/scripts/msys2/install-libavif.sh @@ -45,8 +45,7 @@ build() { -DENABLE_ZSTD=ON \ -DBUILD_REGRESS=OFF \ -DBUILD_OSSFUZZ=OFF \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_PREFIX_PATH="/usr/local/;/usr/" + -DCMAKE_VERBOSE_MAKEFILE=ON make -j $(nproc) diff --git a/sapi/scripts/msys2/install-libgav1.sh b/sapi/scripts/msys2/install-libgav1.sh new file mode 100644 index 0000000000..3ccce2ed9e --- /dev/null +++ b/sapi/scripts/msys2/install-libgav1.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=v0.19.0 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libgav1-${VERSION}.tar.gz https://chromium.googlesource.com/codecs/libgav1/+archive/e386d8f1fb983200972d159b9be47fd5d0776708.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libgav1-${VERSION} + tar -xvf ${__PROJECT__}/pool/lib/libgav1-${VERSION}.tar.gz -C libgav1-${VERSION} + cd libgav1-${VERSION} + + mkdir -p build + cd build + cmake -G "Unix Makefiles" -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF \ + -DLIBGAV1_ENABLE_TESTS=OFF \ + -DLIBGAV1_ENABLE_EXAMPLES=OFF \ + -DLIBGAV1_THREADPOOL_USE_STD_MUTEX=1 + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libgav1-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libgif.sh b/sapi/scripts/msys2/install-libgif.sh new file mode 100644 index 0000000000..97d5b81aa9 --- /dev/null +++ b/sapi/scripts/msys2/install-libgif.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=5.2.1 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/giflib-${VERSION}.tar.gz https://sourceforge.net/projects/giflib/files/giflib-${VERSION}.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p giflib-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/giflib-${VERSION}.tar.gz -C giflib-${VERSION} + cd giflib-${VERSION} + make -j $(nproc) libgif.so + # make install + cp -f libgif.so /usr/lib/libgif.so + cp -f gif_lib.h /usr/include/gif_lib.h +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/giflib-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libjpeg.sh b/sapi/scripts/msys2/install-libjpeg.sh new file mode 100644 index 0000000000..8292e35766 --- /dev/null +++ b/sapi/scripts/msys2/install-libjpeg.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=3.1.2 + +download() { + # document https://github.com/libjpeg-turbo/libjpeg-turbo/ + curl -fSLo ${__PROJECT__}/pool/lib/libjpeg-${VERSION}.tar.gz https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/${VERSION}.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libjpeg-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/libjpeg-${VERSION}.tar.gz -C libjpeg-${VERSION} + cd libjpeg-${VERSION} + + mkdir -p build + cd build + + cmake -G"Unix Makefiles" -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_INSTALL_LIBDIR=/usr/lib \ + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF + + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libjpeg-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libpng.sh b/sapi/scripts/msys2/install-libpng.sh new file mode 100644 index 0000000000..e2010f4957 --- /dev/null +++ b/sapi/scripts/msys2/install-libpng.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=1.6.43 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libpng-${VERSION}.tar.gz https://sourceforge.net/projects/libpng/files/libpng16/1.6.43/libpng-1.6.43.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libpng-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/libpng-${VERSION}.tar.gz -C libpng-${VERSION} + cd libpng-${VERSION} + + mkdir -p build + cd build + cmake -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DPNG_SHARED=ON \ + -DPNG_TESTS=OFF + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libpng-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libwebp.sh b/sapi/scripts/msys2/install-libwebp.sh new file mode 100644 index 0000000000..55bfd36b43 --- /dev/null +++ b/sapi/scripts/msys2/install-libwebp.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=1.3.2 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libwebp-${VERSION}.tar.gz https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libwebp-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/libwebp-${VERSION}.tar.gz -C libwebp-${VERSION} + cd libwebp-${VERSION} + + ./autogen.sh + ./configure \ + --prefix=/usr/ \ + --enable-shared=yes \ + --enable-everything \ + --disable-tiff + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libwebp-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libyuv.sh b/sapi/scripts/msys2/install-libyuv.sh index dedca02791..a672af1b82 100644 --- a/sapi/scripts/msys2/install-libyuv.sh +++ b/sapi/scripts/msys2/install-libyuv.sh @@ -17,7 +17,6 @@ mkdir -p ${WORK_TEMP_DIR} VERSION=068c9f2f643ce59eeb3001d61374bf44a2abd825 download() { - # document https://github.com/AOMediaCodec/libavif/ curl -fSLo ${__PROJECT__}/pool/lib/libyuv-${VERSION}.tar.gz https://chromium.googlesource.com/libyuv/libyuv/+archive/${VERSION}.tar.gz } From 157b5fdfec0110f0ddce2a46aee98525934436e9 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 20:27:30 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E5=90=AF=E7=94=A8=20msys2=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/windows-msys2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 40305b65d5..0e8d86bf28 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -6,7 +6,7 @@ on: jobs: windows-msys2: - if: 0 + if: 1 runs-on: windows-2022 steps: - name: Show Environment Info From a693af14fef9b2f4a9f8a421336482f8fa2b0862 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 20:31:11 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 092cd9d96e..a784b1d8a7 100644 --- a/.gitignore +++ b/.gitignore @@ -330,3 +330,5 @@ libs.log *.deb *.rpm nfpm-pkg.yaml +/APP_VERSION +/APP_NAME From 1914a071a5abced699e159b31a0ebbef35883f88 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 20:34:30 +0800 Subject: [PATCH 10/25] =?UTF-8?q?msys2=20=E6=9E=84=E5=BB=BA=E5=8C=85?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=88=B0=20OSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/windows-msys2.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 0e8d86bf28..524867a3d7 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -117,3 +117,26 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-msys2-x64.zip + + + upload-to-cloud-object-storage: + if: 1 + runs-on: ubuntu-latest + needs: windows-msys2 + steps: + - name: Prepare Run Environment + run: + sudo apt install -y curl + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: upload artifacts to cloud object storage + if: ${{ (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} + env: + 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*-msys2-x64) + FILE="${{ github.workspace }}/${FILE_NAME}/${FILE_NAME}.zip" + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${FILE} From 7dafafa9ea1636d90411863259924a1715647fca Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 3 Dec 2025 20:36:55 +0800 Subject: [PATCH 11/25] msys2 install nasm yasm --- sapi/quickstart/windows/msys2-build/install-msys2.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/sapi/quickstart/windows/msys2-build/install-msys2.sh b/sapi/quickstart/windows/msys2-build/install-msys2.sh index 5072be9457..e6c7e324d9 100644 --- a/sapi/quickstart/windows/msys2-build/install-msys2.sh +++ b/sapi/quickstart/windows/msys2-build/install-msys2.sh @@ -70,6 +70,7 @@ pacman -S --needed --noconfirm icu-devel pacman -S --needed --noconfirm gettext-devel pacman -S --needed --noconfirm libintl pacman -S --needed --noconfirm flex +pacman -S --needed --noconfirm nasm yasm : <<'COMMENT' # 不存在的包 From b339860de283b5f56d21efbd745a0837b58cb6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=90=A7=EF=BC=8C=E4=BD=A0=E6=83=B3=E8=AF=B4?= =?UTF-8?q?=E5=95=A5?= Date: Thu, 4 Dec 2025 15:21:25 +0800 Subject: [PATCH 12/25] Fix linux container exception (#1054) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 解决linux 容器内 git 添加目录安全配置 * 保持 bin 目录 var 目录存在 --- .github/workflows/linux-aarch64.yml | 3 ++- .github/workflows/linux-x86_64.yml | 1 + .gitignore | 4 ++-- bin/.gitkeep | 0 sapi/scripts/tencent-cloud-object-storage.sh | 15 ++++++--------- var/.gitkeep | 0 6 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 bin/.gitkeep create mode 100644 var/.gitkeep diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index 73b6bd4a62..d25111e95b 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -114,9 +114,10 @@ jobs: alias php="php -d curl.cainfo=/work/runtime/php/cacert.pem -d openssl.cafile=/work/runtime/php/cacert.pem" sh sapi/quickstart/linux/alpine-init.sh + git config --global --add safe.directory /work composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - + php prepare.php --with-static-pie --with-libavif bash make.sh all-library diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index b6ab4be37a..b0034b33f0 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -114,6 +114,7 @@ jobs: alias php="php -d curl.cainfo=/work/runtime/php/cacert.pem -d openssl.cafile=/work/runtime/php/cacert.pem" sh sapi/quickstart/linux/alpine-init.sh + git config --global --add safe.directory /work composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile diff --git a/.gitignore b/.gitignore index 092cd9d96e..46e18f9c0e 100644 --- a/.gitignore +++ b/.gitignore @@ -322,11 +322,11 @@ cppflags.log /packages /conf.d.loader Makefile.backup -ldflags.log -cppflags.log libs.log /runtime !/runtime/.gitkeep *.deb *.rpm nfpm-pkg.yaml +!/var/.gitkeep + diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sapi/scripts/tencent-cloud-object-storage.sh b/sapi/scripts/tencent-cloud-object-storage.sh index 723d930860..e4e00eba52 100644 --- a/sapi/scripts/tencent-cloud-object-storage.sh +++ b/sapi/scripts/tencent-cloud-object-storage.sh @@ -136,18 +136,17 @@ if [ "${UPLOAD_TYPE}" == 'all' ]; then SWOOLE_VERSION=$(echo ${SWOOLE_CLI_VERSION} | awk -F '.' '{ printf "%s.%s.%s" ,$1,$2,$3 }') cd ${__PROJECT__}/var/artifact-hash/${SWOOLE_CLI_VERSION} { - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-cygwin-x64.zip ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-linux-arm64.tar.xz ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-linux-x64.tar.xz ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-macos-arm64.tar.xz ${COS_BUCKET_FOLDER} - ${COSCLI} cp --forbid-overwrite --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log swoole-cli-${SWOOLE_VERSION}-macos-x64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-cygwin-x64.zip ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-linux-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-linux-x64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-macos-arm64.tar.xz ${COS_BUCKET_FOLDER} + ${COSCLI} cp --forbid-overwrite swoole-cli-${SWOOLE_VERSION}-macos-x64.tar.xz ${COS_BUCKET_FOLDER} status=$? } || { status=$? } if [[ $status -ne 0 ]]; then echo $status - cat ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log exit 1 fi cd ${__PROJECT__} @@ -155,11 +154,10 @@ if [ "${UPLOAD_TYPE}" == 'all' ]; then fi if [ "${UPLOAD_TYPE}" == 'single' ]; then - ${COSCLI} cp --fail-output-path ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log ${UPLOAD_FILE} ${COS_BUCKET_FOLDER} + ${COSCLI} cp ${UPLOAD_FILE} ${COS_BUCKET_FOLDER} status=$? if [[ $status -ne 0 ]]; then echo $status - cat ${__PROJECT__}/var/tencent-cloud-object-storage/upload.log exit 1 fi exit 0 @@ -172,7 +170,6 @@ if [ "${UPLOAD_TYPE}" == 'show' ]; then status=$? if [[ $status -ne 0 ]]; then echo $status - cat ${__PROJECT__}/var/tencent-cloud-object-storage/coscli.log exit 1 fi exit 0 diff --git a/var/.gitkeep b/var/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 0c6cabcde573cf761fd0264a4b6edd1c52c50a83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=90=A7=EF=BC=8C=E4=BD=A0=E6=83=B3=E8=AF=B4?= =?UTF-8?q?=E5=95=A5?= Date: Thu, 4 Dec 2025 15:22:47 +0800 Subject: [PATCH 13/25] =?UTF-8?q?msys2=20=20=E6=9E=84=E5=BB=BA=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=20=E5=90=AF=E7=94=A8=20gd=20imagemagick=20(#1055)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 启用 gd imagemagick * 启用 msys2 构建环境 * 添加忽略文件 * msys2 构建包上传到 OSS * msys2 install nasm yasm --------- Co-authored-by: Tianfeng.Han --- .github/workflows/windows-msys2.yml | 25 +++++- .gitignore | 2 + .../windows/msys2-build/install-msys2.sh | 1 + sapi/scripts/msys2/config-ext.sh | 2 + sapi/scripts/msys2/config.sh | 4 +- sapi/scripts/msys2/install-deps-lib.sh | 11 +++ sapi/scripts/msys2/install-freetype.sh | 52 +++++++++++ sapi/scripts/msys2/install-imagemagick.sh | 88 +++++++++++++++++++ sapi/scripts/msys2/install-libaom.sh | 51 +++++++++++ sapi/scripts/msys2/install-libavif.sh | 3 +- sapi/scripts/msys2/install-libgav1.sh | 49 +++++++++++ sapi/scripts/msys2/install-libgif.sh | 38 ++++++++ sapi/scripts/msys2/install-libjpeg.sh | 51 +++++++++++ sapi/scripts/msys2/install-libpng.sh | 45 ++++++++++ sapi/scripts/msys2/install-libwebp.sh | 45 ++++++++++ sapi/scripts/msys2/install-libyuv.sh | 1 - 16 files changed, 463 insertions(+), 5 deletions(-) create mode 100644 sapi/scripts/msys2/install-freetype.sh create mode 100644 sapi/scripts/msys2/install-imagemagick.sh create mode 100644 sapi/scripts/msys2/install-libaom.sh create mode 100644 sapi/scripts/msys2/install-libgav1.sh create mode 100644 sapi/scripts/msys2/install-libgif.sh create mode 100644 sapi/scripts/msys2/install-libjpeg.sh create mode 100644 sapi/scripts/msys2/install-libpng.sh create mode 100644 sapi/scripts/msys2/install-libwebp.sh diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 40305b65d5..524867a3d7 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -6,7 +6,7 @@ on: jobs: windows-msys2: - if: 0 + if: 1 runs-on: windows-2022 steps: - name: Show Environment Info @@ -117,3 +117,26 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: files: ${{ env.APP_NAME }}-${{ env.APP_VERSION }}-msys2-x64.zip + + + upload-to-cloud-object-storage: + if: 1 + runs-on: ubuntu-latest + needs: windows-msys2 + steps: + - name: Prepare Run Environment + run: + sudo apt install -y curl + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + - name: upload artifacts to cloud object storage + if: ${{ (github.repository == 'swoole/swoole-cli') && (startsWith(github.ref, 'refs/tags/')) }} + env: + 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*-msys2-x64) + FILE="${{ github.workspace }}/${FILE_NAME}/${FILE_NAME}.zip" + bash sapi/scripts/tencent-cloud-object-storage.sh --upload-file ${FILE} diff --git a/.gitignore b/.gitignore index 46e18f9c0e..f0f45a4d04 100644 --- a/.gitignore +++ b/.gitignore @@ -328,5 +328,7 @@ libs.log *.deb *.rpm nfpm-pkg.yaml +/APP_VERSION +/APP_NAME !/var/.gitkeep diff --git a/sapi/quickstart/windows/msys2-build/install-msys2.sh b/sapi/quickstart/windows/msys2-build/install-msys2.sh index 5072be9457..e6c7e324d9 100644 --- a/sapi/quickstart/windows/msys2-build/install-msys2.sh +++ b/sapi/quickstart/windows/msys2-build/install-msys2.sh @@ -70,6 +70,7 @@ pacman -S --needed --noconfirm icu-devel pacman -S --needed --noconfirm gettext-devel pacman -S --needed --noconfirm libintl pacman -S --needed --noconfirm flex +pacman -S --needed --noconfirm nasm yasm : <<'COMMENT' # 不存在的包 diff --git a/sapi/scripts/msys2/config-ext.sh b/sapi/scripts/msys2/config-ext.sh index ab28e2628a..ec7d94380a 100644 --- a/sapi/scripts/msys2/config-ext.sh +++ b/sapi/scripts/msys2/config-ext.sh @@ -75,9 +75,11 @@ download_and_extract "yaml" ${YAML_VERSION} download_and_extract "imagick" ${IMAGICK_VERSION} cd ${__PROJECT__}/pool/ext +set +u if [ -n "${GITHUB_ACTION}" ]; then test -f ${__PROJECT__}/pool/ext/swoole-${SWOOLE_VERSION}.tgz && rm -f ${__PROJECT__}/pool/ext/swoole-${SWOOLE_VERSION}.tgz fi +set -u if [ ! -f swoole-${SWOOLE_VERSION}.tgz ]; then test -d ${WORK_TEMP_DIR}/swoole && rm -rf ${WORK_TEMP_DIR}/swoole git clone -b ${SWOOLE_VERSION} https://github.com/swoole/swoole-src.git ${WORK_TEMP_DIR}/swoole diff --git a/sapi/scripts/msys2/config.sh b/sapi/scripts/msys2/config.sh index 33acb69fb2..39bdeda756 100644 --- a/sapi/scripts/msys2/config.sh +++ b/sapi/scripts/msys2/config.sh @@ -94,7 +94,9 @@ test -f Makefile && make clean --enable-mbstring \ --with-pgsql \ --enable-intl \ - ${OPTIONS} + ${OPTIONS} \ + --enable-gd --with-jpeg --with-freetype --with-webp --with-avif \ + --with-imagick # --enable-intl \ # --with-sodium \ diff --git a/sapi/scripts/msys2/install-deps-lib.sh b/sapi/scripts/msys2/install-deps-lib.sh index ac12e3ac7e..918a3c395d 100644 --- a/sapi/scripts/msys2/install-deps-lib.sh +++ b/sapi/scripts/msys2/install-deps-lib.sh @@ -14,3 +14,14 @@ bash install-libzip.sh bash install-libsodium.sh bash install-liboniguruma.sh bash install-libpq.sh +bash install-libgif.sh +bash install-libpng.sh +bash install-freetype.sh +bash install-libjpeg.sh +bash install-libwebp.sh +bash install-libyuv.sh +bash install-libaom.sh +bash install-libgav1.sh +bash install-libavif.sh +bash install-imagemagick.sh + diff --git a/sapi/scripts/msys2/install-freetype.sh b/sapi/scripts/msys2/install-freetype.sh new file mode 100644 index 0000000000..e744bd4ab1 --- /dev/null +++ b/sapi/scripts/msys2/install-freetype.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=2.13.2 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/freetype-${VERSION}.tar.gz https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p freetype-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/freetype-${VERSION}.tar.gz -C freetype-${VERSION} + cd freetype-${VERSION} + + mkdir -p build + cd build + + cmake -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DFT_REQUIRE_ZLIB=TRUE \ + -DFT_REQUIRE_BZIP2=TRUE \ + -DFT_REQUIRE_BROTLI=TRUE \ + -DFT_REQUIRE_PNG=TRUE \ + -DFT_DISABLE_HARFBUZZ=TRUE \ + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/freetype-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-imagemagick.sh b/sapi/scripts/msys2/install-imagemagick.sh new file mode 100644 index 0000000000..cf23d78f04 --- /dev/null +++ b/sapi/scripts/msys2/install-imagemagick.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=7.1.2-8 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/ImageMagick-v${VERSION}.tar.gz https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.2-8.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p ImageMagick-v${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/ImageMagick-v${VERSION}.tar.gz -C ImageMagick-v${VERSION} + cd ImageMagick-v${VERSION} + + ./configure \ + --prefix=/usr/ \ + --enable-shared=yes \ + --enable-static=no \ + --with-pic \ + --with-zip \ + --with-zlib \ + --with-lzma \ + --with-zstd \ + --with-jpeg \ + --with-png \ + --with-webp \ + --with-xml \ + --with-freetype \ + --with-heic \ + --with-raw \ + --with-tiff \ + --with-lcms \ + --enable-zero-configuration \ + --enable-bounds-checking \ + --enable-hdri \ + --disable-dependency-tracking \ + --without-perl \ + --disable-docs \ + --disable-opencl \ + --disable-openmp \ + --without-djvu \ + --without-rsvg \ + --without-fontconfig \ + --without-jbig \ + --without-jxl \ + --without-openjp2 \ + --without-lqr \ + --without-openexr \ + --without-pango \ + --without-x \ + --without-modules \ + --with-magick-plus-plus \ + --without-utilities \ + --without-gvc \ + --without-autotrace \ + --without-dps \ + --without-fftw \ + --without-flif \ + --without-fpx \ + --without-gslib \ + --without-perl \ + --without-raqm \ + --without-wmf + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/ImageMagick-v${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libaom.sh b/sapi/scripts/msys2/install-libaom.sh new file mode 100644 index 0000000000..549adfe0ad --- /dev/null +++ b/sapi/scripts/msys2/install-libaom.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=v3.10.0 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libaom-${VERSION}.tar.gz https://aomedia.googlesource.com/aom/+archive/c2fe6bf370f7c14fbaf12884b76244a3cfd7c5fc.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libaom-${VERSION} + tar -xvf ${__PROJECT__}/pool/lib/libaom-${VERSION}.tar.gz -C libaom-${VERSION} + cd libaom-${VERSION} + + mkdir -p build_dir + cd build_dir + cmake -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_STANDARD=11 \ + -DBUILD_SHARED_LIBS=OFF \ + -DBUILD_STATIC_LIBS=ON \ + -DENABLE_DOCS=OFF \ + -DENABLE_EXAMPLES=OFF \ + -DENABLE_TESTS=OFF \ + -DENABLE_TOOLS=ON + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libaom-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libavif.sh b/sapi/scripts/msys2/install-libavif.sh index eac0fa1fb9..e4244e7b9c 100644 --- a/sapi/scripts/msys2/install-libavif.sh +++ b/sapi/scripts/msys2/install-libavif.sh @@ -45,8 +45,7 @@ build() { -DENABLE_ZSTD=ON \ -DBUILD_REGRESS=OFF \ -DBUILD_OSSFUZZ=OFF \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_PREFIX_PATH="/usr/local/;/usr/" + -DCMAKE_VERBOSE_MAKEFILE=ON make -j $(nproc) diff --git a/sapi/scripts/msys2/install-libgav1.sh b/sapi/scripts/msys2/install-libgav1.sh new file mode 100644 index 0000000000..3ccce2ed9e --- /dev/null +++ b/sapi/scripts/msys2/install-libgav1.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=v0.19.0 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libgav1-${VERSION}.tar.gz https://chromium.googlesource.com/codecs/libgav1/+archive/e386d8f1fb983200972d159b9be47fd5d0776708.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libgav1-${VERSION} + tar -xvf ${__PROJECT__}/pool/lib/libgav1-${VERSION}.tar.gz -C libgav1-${VERSION} + cd libgav1-${VERSION} + + mkdir -p build + cd build + cmake -G "Unix Makefiles" -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF \ + -DLIBGAV1_ENABLE_TESTS=OFF \ + -DLIBGAV1_ENABLE_EXAMPLES=OFF \ + -DLIBGAV1_THREADPOOL_USE_STD_MUTEX=1 + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libgav1-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libgif.sh b/sapi/scripts/msys2/install-libgif.sh new file mode 100644 index 0000000000..97d5b81aa9 --- /dev/null +++ b/sapi/scripts/msys2/install-libgif.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=5.2.1 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/giflib-${VERSION}.tar.gz https://sourceforge.net/projects/giflib/files/giflib-${VERSION}.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p giflib-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/giflib-${VERSION}.tar.gz -C giflib-${VERSION} + cd giflib-${VERSION} + make -j $(nproc) libgif.so + # make install + cp -f libgif.so /usr/lib/libgif.so + cp -f gif_lib.h /usr/include/gif_lib.h +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/giflib-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libjpeg.sh b/sapi/scripts/msys2/install-libjpeg.sh new file mode 100644 index 0000000000..8292e35766 --- /dev/null +++ b/sapi/scripts/msys2/install-libjpeg.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=3.1.2 + +download() { + # document https://github.com/libjpeg-turbo/libjpeg-turbo/ + curl -fSLo ${__PROJECT__}/pool/lib/libjpeg-${VERSION}.tar.gz https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/${VERSION}.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libjpeg-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/libjpeg-${VERSION}.tar.gz -C libjpeg-${VERSION} + cd libjpeg-${VERSION} + + mkdir -p build + cd build + + cmake -G"Unix Makefiles" -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr/ \ + -DCMAKE_INSTALL_LIBDIR=/usr/lib \ + -DCMAKE_INSTALL_INCLUDEDIR=/usr/include \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DBUILD_STATIC_LIBS=OFF + + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libjpeg-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libpng.sh b/sapi/scripts/msys2/install-libpng.sh new file mode 100644 index 0000000000..e2010f4957 --- /dev/null +++ b/sapi/scripts/msys2/install-libpng.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=1.6.43 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libpng-${VERSION}.tar.gz https://sourceforge.net/projects/libpng/files/libpng16/1.6.43/libpng-1.6.43.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libpng-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/libpng-${VERSION}.tar.gz -C libpng-${VERSION} + cd libpng-${VERSION} + + mkdir -p build + cd build + cmake -S .. -B . \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DPNG_SHARED=ON \ + -DPNG_TESTS=OFF + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libpng-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libwebp.sh b/sapi/scripts/msys2/install-libwebp.sh new file mode 100644 index 0000000000..55bfd36b43 --- /dev/null +++ b/sapi/scripts/msys2/install-libwebp.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +set -exu +__DIR__=$( + cd "$(dirname "$0")" + pwd +) +__PROJECT__=$( + cd ${__DIR__}/../../../ + pwd +) +cd ${__PROJECT__} +mkdir -p pool/lib/ +WORK_TEMP_DIR=${__PROJECT__}/var/msys2-build/ +mkdir -p ${WORK_TEMP_DIR} + +VERSION=1.3.2 + +download() { + curl -fSLo ${__PROJECT__}/pool/lib/libwebp-${VERSION}.tar.gz https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz +} + +build() { + + cd ${WORK_TEMP_DIR} + mkdir -p libwebp-${VERSION} + tar --strip-components=1 -xvf ${__PROJECT__}/pool/lib/libwebp-${VERSION}.tar.gz -C libwebp-${VERSION} + cd libwebp-${VERSION} + + ./autogen.sh + ./configure \ + --prefix=/usr/ \ + --enable-shared=yes \ + --enable-everything \ + --disable-tiff + + make -j $(nproc) + make install + +} + +cd ${__PROJECT__} +test -f ${__PROJECT__}/pool/lib/libwebp-${VERSION}.tar.gz || download + +build diff --git a/sapi/scripts/msys2/install-libyuv.sh b/sapi/scripts/msys2/install-libyuv.sh index dedca02791..a672af1b82 100644 --- a/sapi/scripts/msys2/install-libyuv.sh +++ b/sapi/scripts/msys2/install-libyuv.sh @@ -17,7 +17,6 @@ mkdir -p ${WORK_TEMP_DIR} VERSION=068c9f2f643ce59eeb3001d61374bf44a2abd825 download() { - # document https://github.com/AOMediaCodec/libavif/ curl -fSLo ${__PROJECT__}/pool/lib/libyuv-${VERSION}.tar.gz https://chromium.googlesource.com/libyuv/libyuv/+archive/${VERSION}.tar.gz } From f0efec207d8a3a6ab5aa716775e09e4b4b87764c Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 4 Dec 2025 15:27:06 +0800 Subject: [PATCH 14/25] Added avif supports --- sapi/scripts/build-swoole-cli-with-linux-gcc.sh | 2 +- sapi/scripts/install-deps-on-ubuntu.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh index ed76758c6c..a175c3379f 100755 --- a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh +++ b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh @@ -35,7 +35,7 @@ fi --enable-exif \ --with-sodium \ --enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \ - --enable-gd --with-jpeg --with-freetype \ + --enable-gd --with-jpeg --with-freetype --with-avif \ --enable-swoole \ --enable-swoole-curl \ --enable-cares \ diff --git a/sapi/scripts/install-deps-on-ubuntu.sh b/sapi/scripts/install-deps-on-ubuntu.sh index 6f4a7e73d7..e1994cdc33 100755 --- a/sapi/scripts/install-deps-on-ubuntu.sh +++ b/sapi/scripts/install-deps-on-ubuntu.sh @@ -33,4 +33,5 @@ sudo apt install libyaml-dev \ libmagic-dev \ libonig-dev \ libxslt-dev \ - libzip-dev + libzip-dev \ + libavif-dev From 954441716cc969ecf758b2e1f9e3643041c7109b Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 4 Dec 2025 15:27:06 +0800 Subject: [PATCH 15/25] Added avif supports --- sapi/scripts/build-swoole-cli-with-linux-gcc.sh | 2 +- sapi/scripts/install-deps-on-ubuntu.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh index ed76758c6c..a175c3379f 100755 --- a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh +++ b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh @@ -35,7 +35,7 @@ fi --enable-exif \ --with-sodium \ --enable-xml --enable-simplexml --enable-xmlreader --enable-xmlwriter --enable-dom --with-libxml \ - --enable-gd --with-jpeg --with-freetype \ + --enable-gd --with-jpeg --with-freetype --with-avif \ --enable-swoole \ --enable-swoole-curl \ --enable-cares \ diff --git a/sapi/scripts/install-deps-on-ubuntu.sh b/sapi/scripts/install-deps-on-ubuntu.sh index 6f4a7e73d7..e1994cdc33 100755 --- a/sapi/scripts/install-deps-on-ubuntu.sh +++ b/sapi/scripts/install-deps-on-ubuntu.sh @@ -33,4 +33,5 @@ sudo apt install libyaml-dev \ libmagic-dev \ libonig-dev \ libxslt-dev \ - libzip-dev + libzip-dev \ + libavif-dev From e2d961992e9d43cdca18b23efb9a26f8933311b5 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 4 Dec 2025 15:47:36 +0800 Subject: [PATCH 16/25] Add ext-phpy --- .gitignore | 1 + sapi/scripts/build-swoole-cli-with-linux-gcc.sh | 1 + sapi/scripts/install-deps-on-ubuntu.sh | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f0f45a4d04..bfc6462f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -314,6 +314,7 @@ tmp-php.ini /ext/ds /ext/xlswriter /ext/uuid +/ext/phpy /.phpunit.result.cache /samples/sfx/*.phar .php-cs-fixer.cache diff --git a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh index a175c3379f..e26ac414a1 100755 --- a/sapi/scripts/build-swoole-cli-with-linux-gcc.sh +++ b/sapi/scripts/build-swoole-cli-with-linux-gcc.sh @@ -50,6 +50,7 @@ fi --with-imagick \ --with-yaml \ --with-readline \ + --enable-phpy --with-python-config=python3-config \ --enable-opcache make -j "$(nproc)" diff --git a/sapi/scripts/install-deps-on-ubuntu.sh b/sapi/scripts/install-deps-on-ubuntu.sh index e1994cdc33..75af25e7b2 100755 --- a/sapi/scripts/install-deps-on-ubuntu.sh +++ b/sapi/scripts/install-deps-on-ubuntu.sh @@ -34,4 +34,5 @@ sudo apt install libyaml-dev \ libonig-dev \ libxslt-dev \ libzip-dev \ - libavif-dev + libavif-dev \ + libpython3-dev From e05b6683a8fa86e1b16975eea2650e6dcbd583f3 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 9 Dec 2025 17:28:02 +0800 Subject: [PATCH 17/25] Update swoole version --- sapi/SWOOLE-VERSION.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index b2c63a1c1b..dc2fce17b2 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.3 +v6.1.4 From 85cdab87f1319333005b6972732b9068351ef352 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Mon, 15 Dec 2025 20:39:24 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E8=A7=A3=E5=86=B3msys2=20=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=8C=85=E5=B7=B2=E5=AD=98=E5=9C=A8=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/windows-msys2.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 524867a3d7..82bbdb0118 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -31,15 +31,6 @@ jobs: git config --global --add safe.directory ${{ github.workspace }} - uses: actions/checkout@v4 - - name: Cache msys2 packages - id: cache-msys2 - uses: actions/cache@v4 - env: - cache-name: cache-msys2-packages - with: - path: C:\msys2-packages - key: "${{ runner.os }}-build-${{ env.cache-name }}" - - name: Cache pool id: cache-msys2-pool uses: actions/cache@v4 From b21c622764ace5d390fa4a257ff810135f8f4972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=90=A7=EF=BC=8C=E4=BD=A0=E6=83=B3=E8=AF=B4?= =?UTF-8?q?=E5=95=A5?= Date: Mon, 22 Dec 2025 13:54:37 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E8=A7=A3=E5=86=B3msys2=20=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=8C=85=E5=B7=B2=E5=AD=98=E5=9C=A8=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20(#1056)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/windows-msys2.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 524867a3d7..82bbdb0118 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -31,15 +31,6 @@ jobs: git config --global --add safe.directory ${{ github.workspace }} - uses: actions/checkout@v4 - - name: Cache msys2 packages - id: cache-msys2 - uses: actions/cache@v4 - env: - cache-name: cache-msys2-packages - with: - path: C:\msys2-packages - key: "${{ runner.os }}-build-${{ env.cache-name }}" - - name: Cache pool id: cache-msys2-pool uses: actions/cache@v4 From b7f696ee714bf0359e26e3021adff442d0996021 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Mon, 22 Dec 2025 21:39:38 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E5=8D=87=E7=BA=A7=20swoole=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=BAv6.1.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapi/SWOOLE-VERSION.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index dc2fce17b2..f01dcaef90 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.4 +v6.1.5 From f67ba721c676d7e3f60d9886bee7107221e3e862 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 26 Dec 2025 22:17:46 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E5=85=BC=E5=AE=B9macos-12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapi/src/template/make.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index d9acd45968..77cc45f8d8 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -16,7 +16,10 @@ PREPARE_ARGS="getPrepareArgs())?>" export LOGICAL_PROCESSORS=logicalProcessors). PHP_EOL ?> export CMAKE_BUILD_PARALLEL_LEVEL=maxJob. PHP_EOL ?> - +isMacos()) :?> +# 兼容 最低 macOS 版本 +export MACOSX_DEPLOYMENT_TARGET=12.0 + export CC=cCompiler . PHP_EOL ?> export CXX=cppCompiler . PHP_EOL ?> export LD=lld . PHP_EOL ?> From afa5540915e8090ac20e1172781c6b45dd6c03ce Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Mon, 29 Dec 2025 20:56:08 +0800 Subject: [PATCH 22/25] update swoole version to v6.1.6 --- sapi/SWOOLE-VERSION.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index f01dcaef90..4871c222ec 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.5 +v6.1.6 From 84dcfe97280355e83af3027652d48767ce50664e Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Fri, 9 Jan 2026 21:06:43 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E4=BD=BF=E7=94=A8PIE=20=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=89=A9=E5=B1=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/linux-aarch64.yml | 2 +- .github/workflows/linux-glibc.yml | 4 +- .github/workflows/linux-x86_64.yml | 2 +- .github/workflows/macos-aarch64.yml | 2 +- .github/workflows/macos-x86_64.yml | 2 +- .github/workflows/windows-msys2.yml | 3 +- prepare.php | 11 ++++-- sapi/SWOOLE-VERSION.conf | 2 +- sapi/src/Extension.php | 16 ++++++++ sapi/src/Preprocessor.php | 56 +++++++++++++++++++++++++-- sapi/src/builder/extension/swoole.php | 22 ++++++----- setup-php-runtime.sh | 2 +- 12 files changed, 99 insertions(+), 25 deletions(-) diff --git a/.github/workflows/linux-aarch64.yml b/.github/workflows/linux-aarch64.yml index d25111e95b..03b2e2327b 100644 --- a/.github/workflows/linux-aarch64.yml +++ b/.github/workflows/linux-aarch64.yml @@ -95,7 +95,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/linux-glibc.yml b/.github/workflows/linux-glibc.yml index 28e9b59f78..3580cfe5a6 100644 --- a/.github/workflows/linux-glibc.yml +++ b/.github/workflows/linux-glibc.yml @@ -85,7 +85,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh @@ -99,7 +99,7 @@ jobs: composer install --no-interaction --no-autoloader --no-scripts --profile composer dump-autoload --optimize --profile - php prepare.php --with-libavif + php prepare.php --with-libavif --without-docker sudo apt update bash ./sapi/scripts/install-deps-on-ubuntu.sh diff --git a/.github/workflows/linux-x86_64.yml b/.github/workflows/linux-x86_64.yml index b0034b33f0..0e4ab704f7 100644 --- a/.github/workflows/linux-x86_64.yml +++ b/.github/workflows/linux-x86_64.yml @@ -95,7 +95,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/macos-aarch64.yml b/.github/workflows/macos-aarch64.yml index 61226e828b..31b3cefb40 100644 --- a/.github/workflows/macos-aarch64.yml +++ b/.github/workflows/macos-aarch64.yml @@ -90,7 +90,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 625dc09231..75d442a37d 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -90,7 +90,7 @@ jobs: mkdir -p bin/ mkdir -p runtime/ test -f runtime/php && rm -f runtime/php - if [ ! -f runtime/php/php ] ; then + if [ ! -f runtime/php/pie ] ; then bash setup-php-runtime.sh fi bash sapi/download-box/download-box-get-archive-from-server.sh diff --git a/.github/workflows/windows-msys2.yml b/.github/workflows/windows-msys2.yml index 82bbdb0118..5b8116bdae 100644 --- a/.github/workflows/windows-msys2.yml +++ b/.github/workflows/windows-msys2.yml @@ -47,7 +47,8 @@ jobs: - name: prepare build environment shell: msys2 {0} run: | - bash ./sapi/quickstart/windows/msys2-build/install-msys2.sh + bash sapi/quickstart/windows/msys2-build/install-msys2.sh + bash sapi/download-box/download-box-get-archive-from-server.sh - name: install deps lib with source code shell: msys2 {0} diff --git a/prepare.php b/prepare.php index 1e65a07d55..1d1707bbc6 100755 --- a/prepare.php +++ b/prepare.php @@ -27,11 +27,11 @@ // Download swoole-src if (!is_dir(__DIR__ . '/ext/swoole')) { - shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh'); + //shell_exec(__DIR__ . '/sapi/scripts/download-swoole-src-archive.sh'); } // Compile directly on the host machine, not in the docker container -if ($p->getInputOption('without-docker') || ($p->isMacos())) { +if ($p->getInputOption('without-docker') || ($p->isMacos()) || ($p->isLinux() && (!is_file('/.dockerenv')))) { $p->setWorkDir(__DIR__); $p->setBuildDir(__DIR__ . '/thirdparty'); } @@ -46,7 +46,12 @@ if ($p->isMacos()) { $p->setExtraLdflags(''); - $homebrew_prefix = trim(shell_exec('brew --prefix')); + exec("brew --prefix 2>&1", $output, $result_code); + if ($result_code == 0) { + $homebrew_prefix = trim(implode(' ', $output)); + } else { + $homebrew_prefix = ""; + } $p->withBinPath($homebrew_prefix . '/opt/flex/bin') ->withBinPath($homebrew_prefix . '/opt/bison/bin') ->withBinPath($homebrew_prefix . '/opt/libtool/bin') diff --git a/sapi/SWOOLE-VERSION.conf b/sapi/SWOOLE-VERSION.conf index b2c63a1c1b..4871c222ec 100644 --- a/sapi/SWOOLE-VERSION.conf +++ b/sapi/SWOOLE-VERSION.conf @@ -1 +1 @@ -v6.1.3 +v6.1.6 diff --git a/sapi/src/Extension.php b/sapi/src/Extension.php index fc9d681898..c056cc3f8b 100644 --- a/sapi/src/Extension.php +++ b/sapi/src/Extension.php @@ -7,6 +7,9 @@ class Extension extends Project public string $options = ''; public string $peclVersion = ''; + public string $pieVersion = ''; + public string $pieName = ''; + public array $dependentExtensions = []; public function withOptions(string $options): static @@ -26,4 +29,17 @@ public function withDependentExtensions(string ...$extensions): static $this->dependentExtensions += $extensions; return $this; } + + public function withPieVersion(string $pieVersion): static + { + $this->pieVersion = $pieVersion; + return $this; + } + + public function withPieName(string $pieName): static + { + $this->pieName = $pieName; + return $this; + } + } diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 3da0fd4d0a..63a51cc2ca 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -339,6 +339,46 @@ protected function downloadFile(string $url, string $file, ?object $project = nu } } + public function downloadFileWithPie(string $pieName, string $pieVersion, string $file, string $path, object $project): void + { + $workdir = $this->getWorkDir(); + $cmd = << \${TEMP_FILE} 2>&1 +cat \${TEMP_FILE} +SOURCE_CODE_DIR=\$(cat \${TEMP_FILE} | grep 'source to: ' | awk -F 'source to: ' '{ print $2 }') +rm -f \${TEMP_FILE} +echo "{$pieName}:{$pieVersion} source code: \${SOURCE_CODE_DIR}" +pie info {$pieName}:{$pieVersion}; +cd \${SOURCE_CODE_DIR} +tar -czf "{$workdir}/var/ext/{$file}" . +cp -f {$workdir}/var/ext/{$file} {$path} +cd {$workdir} +EOF; + echo $cmd; + echo PHP_EOL; + echo '------------RUNNING START-------------'; + echo PHP_EOL; + echo `$cmd`; + echo '------------RUNNING END-------------'; + echo PHP_EOL; + $file = $path; + // 下载失败 + if (!is_file($file) or filesize($file) == 0) { + throw new Exception("with pie Downloading file[" . basename($file) . "] from failed"); + } + // 下载文件的 hash 不一致 + if (!$this->skipHashVerify and $project->enableHashVerify) { + if (!$project->hashVerify($file)) { + throw new Exception("The {$project->hashAlgo} of downloaded file[$file] is inconsistent with the configuration"); + } + } + } + /** * @param Library $lib * @throws Exception @@ -396,8 +436,10 @@ public function addLibrary(Library $lib): void public function addExtension(Extension $ext): void { - if ($ext->peclVersion) { - $ext->file = $ext->name . '-' . $ext->peclVersion . '.tgz'; + if ($ext->peclVersion || $ext->pieVersion) { + $extensionVersion = !empty($ext->peclVersion) ? $ext->peclVersion : $ext->pieVersion; + $downloadType = $ext->peclVersion ? 'pecl' : 'pie'; + $ext->file = $ext->name . '-' . $extensionVersion . '.tgz'; $ext->path = $this->extensionDir . '/' . $ext->file; $ext->url = "https://pecl.php.net/get/{$ext->file}"; @@ -411,8 +453,14 @@ public function addExtension(Extension $ext): void } if (!$this->getInputOption('skip-download')) { if (!is_file($ext->path) or filesize($ext->path) === 0) { - echo "[Extension] {$ext->file} not found, downloading: " . $ext->url . PHP_EOL; - $this->downloadFile($ext->url, $ext->path, $ext); + if ($downloadType === 'pecl') { + echo "[Extension] {$ext->file} not found, downloading: " . $ext->url . PHP_EOL; + $this->downloadFile($ext->url, $ext->path, $ext); + } else { + echo "[Extension] {$ext->file} not found, download with pie.phar " . $ext->homePage . PHP_EOL; + $this->downloadFileWithPie($ext->pieName, $ext->pieVersion, $ext->file, $ext->path, $ext); + } + } else { echo "[Extension] file cached: " . $ext->file . PHP_EOL; } diff --git a/sapi/src/builder/extension/swoole.php b/sapi/src/builder/extension/swoole.php index 6213b213f4..100c049e01 100644 --- a/sapi/src/builder/extension/swoole.php +++ b/sapi/src/builder/extension/swoole.php @@ -30,15 +30,19 @@ $p->withExportVariable('URING_CFLAGS', '$(pkg-config --cflags --static liburing)'); $p->withExportVariable('URING_LIBS', '$(pkg-config --libs --static liburing)'); } - - $p->addExtension((new Extension('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/#/') - ->withOptions(implode(' ', $options)) - ->withBuildCached(false) - ->withDependentLibraries(...$dependentLibraries) - ->withDependentExtensions(...$dependentExtensions)); + $swoole_version = trim(file_get_contents(__DIR__ . '/../../../SWOOLE-VERSION.conf')); + $p->addExtension( + (new Extension('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/#/') + ->withOptions(implode(' ', $options)) + ->withBuildCached(false) + ->withDependentLibraries(...$dependentLibraries) + ->withDependentExtensions(...$dependentExtensions) + ->withPieName('swoole/swoole') + ->withPieVersion($swoole_version) + ); $p->withVariable('LIBS', '$LIBS ' . ($p->isMacos() ? '-lc++' : '-lstdc++')); $p->withExportVariable('CARES_CFLAGS', '$(pkg-config --cflags --static libcares)'); diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 17931779a1..0621068ff8 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -51,7 +51,7 @@ esac APP_VERSION='v5.1.3' APP_NAME='swoole-cli' VERSION='v5.1.3.0' -PIE_VERSION="1.2.1" +PIE_VERSION="1.3.5" # 查看pie最新版本 https://github.com/php/pie/releases/latest cd ${__PROJECT__} From 2600d6c4809f66770d5c952c35b8556f8de7ad76 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Sun, 11 Jan 2026 22:26:20 +0800 Subject: [PATCH 24/25] fix code bug --- sapi/src/Preprocessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 9a13b379d3..6902ce3b1b 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -600,7 +600,7 @@ public function addLibrary(Library $lib): void $this->downloadFile($lib, $httpProxyConfig); } - $file = $lib->file; + $file = $lib->path; if (is_file($file) && (filesize($file) == 0)) { unlink($file); } From c76cf4fb9161eef332dd1d7757c639717cf1b893 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Mon, 12 Jan 2026 21:00:03 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E4=BC=98=E5=8C=96=20preprocessor.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapi/src/Preprocessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/src/Preprocessor.php b/sapi/src/Preprocessor.php index 6902ce3b1b..164fdb2ecc 100644 --- a/sapi/src/Preprocessor.php +++ b/sapi/src/Preprocessor.php @@ -463,7 +463,7 @@ protected function downloadFile(?object $project = null, string $httpProxyConfig * @param string $httpProxyConfig * @return void */ - public function downloadFileWithPie(object $project, string $httpProxyConfig): void + public function downloadFileWithPie(?object $project = null, string $httpProxyConfig): void { $pieName = $project->pieName; $pieVersion = $project->pieVersion; @@ -503,7 +503,7 @@ public function downloadFileWithPie(object $project, string $httpProxyConfig): v * @param string $httpProxyConfig * @return void */ - protected function downloadFileWithScript(object $project = null, string $httpProxyConfig): void + protected function downloadFileWithScript(?object $project = null, string $httpProxyConfig): void { if (!empty($project->downloadScript) && !empty($project->downloadDirName)) {