From 2c13eb257be68efc9c22812da3729816d7995968 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 30 Apr 2025 21:46:27 +0700 Subject: [PATCH 001/319] static compilation is not quite working yet --- config/env.ini | 4 ++-- config/source.json | 2 +- src/SPC/builder/extension/spx.php | 13 +------------ src/SPC/command/BuildPHPCommand.php | 6 +++--- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/config/env.ini b/config/env.ini index f70ad0a2..4fd1a28a 100644 --- a/config/env.ini +++ b/config/env.ini @@ -68,7 +68,7 @@ CXX=${SPC_LINUX_DEFAULT_CXX} AR=${SPC_LINUX_DEFAULT_AR} LD=ld.gold ; default compiler flags, used in CMake toolchain file, openssl and pkg-config build -SPC_DEFAULT_C_FLAGS="-fPIC" +SPC_DEFAULT_C_FLAGS="-fPIC -std=c11" SPC_DEFAULT_CXX_FLAGS= ; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) SPC_EXTRA_LIBS= @@ -97,7 +97,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; LIBS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -fPIE -fPIC -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm" ; EXTRA_LDFLAGS_PROGRAM for `make` php diff --git a/config/source.json b/config/source.json index a4b25cb8..2beea67c 100644 --- a/config/source.json +++ b/config/source.json @@ -859,7 +859,7 @@ "spx": { "type": "git", "rev": "master", - "url": "https://github.com/static-php/php-spx.git", + "url": "https://github.com/NoiseByNorthwest/php-spx.git", "path": "php-src/ext/spx", "license": { "type": "file", diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index dc341e39..ef9e95bf 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -5,25 +5,14 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\WrongUsageException; use SPC\util\CustomExt; #[CustomExt('spx')] class spx extends Extension { - /** - * @throws WrongUsageException - */ - public function validate(): void - { - if ($this->builder->getOption('enable-zts')) { - throw new WrongUsageException('ext-spx is not thread safe, do not build it with ZTS builds'); - } - } - public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-spx'; + $arg = '--enable-SPX'; if ($this->builder->getExt('zlib') === null) { $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 49067b0b..0cf64f67 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -73,7 +73,7 @@ class BuildPHPCommand extends BuildCommand } $static_and_shared = array_intersect($static_extensions, $shared_extensions); if (!empty($static_and_shared)) { - $this->output->writeln('Building extensions [' . implode(',', $static_and_shared) . '] as both static and shared\, tests may not be accurate or fail.'); + $this->output->writeln('Building extensions [' . implode(',', $static_and_shared) . '] as both static and shared, tests may not be accurate or fail.'); } if ($rule === BUILD_TARGET_NONE) { @@ -128,7 +128,6 @@ class BuildPHPCommand extends BuildCommand $include_suggest_lib = $this->getOption('with-suggested-libs'); [$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs(array_merge($static_extensions, $shared_extensions), $libraries, $include_suggest_ext, $include_suggest_lib); $display_libs = array_filter($libraries, fn ($lib) => in_array(Config::getLib($lib, 'type', 'lib'), ['lib', 'package'])); - $display_extensions = array_map(fn ($ext) => in_array($ext, $shared_extensions) ? "*{$ext}" : $ext, $extensions); // separate static and shared extensions from $extensions // filter rule: including shared extensions if they are in $static_extensions or $shared_extensions @@ -138,7 +137,8 @@ class BuildPHPCommand extends BuildCommand $indent_texts = [ 'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')', 'Build SAPI' => $builder->getBuildTypeName($rule), - 'Extensions (' . count($extensions) . ')' => implode(',', $display_extensions), + 'Extensions (' . count($extensions) . ')' => implode(',', $extensions), + 'Shared Extensions (' . count($shared_extensions) . ')' => implode(',', $shared_extensions), 'Libraries (' . count($libraries) . ')' => implode(',', $display_libs), 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', 'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no', From b3dacf9c5ad9eeb4783cf0c51ea3e72df02211f1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 6 May 2025 16:22:37 +0700 Subject: [PATCH 002/319] lowercase --- src/SPC/builder/extension/spx.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index ef9e95bf..a797a126 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -12,7 +12,7 @@ class spx extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-SPX'; + $arg = '--enable-spx'; if ($this->builder->getExt('zlib') === null) { $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; } From f5fffafd43028e73964d5d5df08c028771fc80af Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 14:45:51 +0700 Subject: [PATCH 003/319] =?UTF-8?q?format=20setEnv=C2=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SPC/builder/linux/library/libffi.php | 6 +++++- src/SPC/builder/linux/library/openssl.php | 6 +++++- src/SPC/builder/macos/library/openssl.php | 6 +++++- src/SPC/builder/unix/library/brotli.php | 6 +++++- src/SPC/builder/unix/library/bzip2.php | 6 +++++- src/SPC/builder/unix/library/freetype.php | 6 +++++- src/SPC/builder/unix/library/gmp.php | 6 +++++- src/SPC/builder/unix/library/gmssl.php | 6 +++++- src/SPC/builder/unix/library/libargon2.php | 6 +++++- src/SPC/builder/unix/library/libavif.php | 6 +++++- src/SPC/builder/unix/library/libcares.php | 6 +++++- src/SPC/builder/unix/library/libevent.php | 6 +++++- src/SPC/builder/unix/library/libiconv.php | 6 +++++- src/SPC/builder/unix/library/liblz4.php | 6 +++++- src/SPC/builder/unix/library/libtiff.php | 6 +++++- src/SPC/builder/unix/library/ncurses.php | 6 +++++- src/SPC/builder/unix/library/nghttp2.php | 6 +++++- src/SPC/builder/unix/library/onig.php | 6 +++++- src/SPC/builder/unix/library/pkgconfig.php | 6 +++++- src/SPC/builder/unix/library/readline.php | 6 +++++- src/SPC/builder/unix/library/sqlite.php | 6 +++++- src/SPC/builder/unix/library/zlib.php | 6 +++++- 22 files changed, 110 insertions(+), 22 deletions(-) diff --git a/src/SPC/builder/linux/library/libffi.php b/src/SPC/builder/linux/library/libffi.php index 9d1c2d79..d7421425 100644 --- a/src/SPC/builder/linux/library/libffi.php +++ b/src/SPC/builder/linux/library/libffi.php @@ -21,7 +21,11 @@ class libffi extends LinuxLibraryBase $arch = getenv('SPC_ARCH'); shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static ' . diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 5c07ec7e..55a238f9 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -65,7 +65,11 @@ class openssl extends LinuxLibraryBase $clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : ''; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( "{$env} ./Configure no-shared {$extra} " . '--prefix=/ ' . diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index e0e3919f..28796d7c 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -50,7 +50,11 @@ class openssl extends MacOSLibraryBase $arch = getenv('SPC_ARCH'); shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->exec( "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 9e764fcb..44be934d 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -18,7 +18,11 @@ trait brotli { FileSystem::resetDir($this->source_dir . '/build-dir'); shell()->cd($this->source_dir . '/build-dir') - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( 'cmake ' . '-DCMAKE_BUILD_TYPE=Release ' . diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index 0241fb1b..284783c9 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -17,7 +17,11 @@ trait bzip2 protected function build(): void { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv("make PREFIX='" . BUILD_ROOT_PATH . "' clean") ->execWithEnv("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") ->exec('cp libbz2.a ' . BUILD_LIB_PATH) diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 42e8f91c..6fb24212 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -23,7 +23,11 @@ trait freetype $extra_libs .= $this->builder->getLib('brotli') ? '-DFT_DISABLE_BROTLI=OFF ' : '-DFT_DISABLE_BROTLI=ON '; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( "cmake {$this->builder->makeCmakeArgs()} -DFT_DISABLE_HARFBUZZ=ON " . '-DBUILD_SHARED_LIBS=OFF ' . diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index 49b207fb..c74251d6 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -16,7 +16,11 @@ trait gmp protected function build(): void { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static --disable-shared ' . diff --git a/src/SPC/builder/unix/library/gmssl.php b/src/SPC/builder/unix/library/gmssl.php index 1d946621..792a1c93 100644 --- a/src/SPC/builder/unix/library/gmssl.php +++ b/src/SPC/builder/unix/library/gmssl.php @@ -20,7 +20,11 @@ trait gmssl FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); diff --git a/src/SPC/builder/unix/library/libargon2.php b/src/SPC/builder/unix/library/libargon2.php index e91b71f0..e2dba687 100644 --- a/src/SPC/builder/unix/library/libargon2.php +++ b/src/SPC/builder/unix/library/libargon2.php @@ -11,7 +11,11 @@ trait libargon2 protected function build() { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->exec("make PREFIX='' clean") ->execWithEnv("make -j{$this->builder->concurrency} PREFIX=''") ->execWithEnv("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index c2aaafcd..ddcf1d57 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -22,7 +22,11 @@ trait libavif FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DAVIF_LIBYUV=OFF ..") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php index d99cc685..94871927 100644 --- a/src/SPC/builder/unix/library/libcares.php +++ b/src/SPC/builder/unix/library/libcares.php @@ -25,7 +25,11 @@ trait libcares protected function build(): void { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --with-pic') ->execWithEnv("make -j {$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index 2e80f32e..bd070fd5 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -44,7 +44,11 @@ trait libevent FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index a587c472..710e7425 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -11,7 +11,11 @@ trait libiconv [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static ' . diff --git a/src/SPC/builder/unix/library/liblz4.php b/src/SPC/builder/unix/library/liblz4.php index 45e803bf..39c24512 100644 --- a/src/SPC/builder/unix/library/liblz4.php +++ b/src/SPC/builder/unix/library/liblz4.php @@ -18,7 +18,11 @@ trait liblz4 protected function build(): void { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv("make PREFIX='' clean") ->execWithEnv("make -j{$this->builder->concurrency} PREFIX=''") ->execWithEnv("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index 5d2cb4c1..b4ed21ad 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -23,7 +23,11 @@ trait libtiff $extra_libs .= ' --disable-lzma --disable-zstd --disable-webp --disable-libdeflate'; $shell = shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static --disable-shared ' . diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index a44ac175..0297afe2 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -12,7 +12,11 @@ trait ncurses { $filelist = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true); shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static ' . diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index 8f764c2a..cd0c488f 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -36,7 +36,11 @@ trait nghttp2 [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static ' . diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index 60ea84fa..56f72413 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -18,7 +18,11 @@ trait onig [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv('./configure --enable-static --disable-shared --prefix=') ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index b489bbba..9478d9ea 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -14,7 +14,11 @@ trait pkgconfig $ldflags = !($this instanceof LinuxLibraryBase) || getenv('SPC_LIBC') === 'glibc' ? '' : '--static'; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", 'LDFLAGS' => "{$this->getLibExtraLdFlags()} {$ldflags}", 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", + 'LDFLAGS' => "{$this->getLibExtraLdFlags()} {$ldflags}", + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--disable-shared ' . diff --git a/src/SPC/builder/unix/library/readline.php b/src/SPC/builder/unix/library/readline.php index d0369c1a..0e881e7c 100644 --- a/src/SPC/builder/unix/library/readline.php +++ b/src/SPC/builder/unix/library/readline.php @@ -16,7 +16,11 @@ trait readline protected function build(): void { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv( './configure ' . '--enable-static=yes ' . diff --git a/src/SPC/builder/unix/library/sqlite.php b/src/SPC/builder/unix/library/sqlite.php index ee814702..7f9f31bd 100644 --- a/src/SPC/builder/unix/library/sqlite.php +++ b/src/SPC/builder/unix/library/sqlite.php @@ -9,7 +9,11 @@ trait sqlite protected function build(): void { shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv('./configure --enable-static --disable-shared --prefix=') ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index f764de91..42c46259 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -18,7 +18,11 @@ trait zlib [,,$destdir] = SEPARATED_PATH; shell()->cd($this->source_dir) - ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->execWithEnv('./configure --static --prefix=') ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") From 2897fdda04b0729aaef343a180a50aabdf507eff Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 14:47:54 +0700 Subject: [PATCH 004/319] fix icu for relocatable objects (required by libphp.so building) --- src/SPC/builder/linux/library/icu.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 519c0734..0543c0d8 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -14,13 +14,19 @@ class icu extends LinuxLibraryBase protected function build(): void { - $cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -fPIC -fPIE -fno-ident"'; - $cxxflags = 'CXXFLAGS="-std=c++17"'; + $cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"'; + $cxxflags = 'CXXFLAGS="-std=c++17 -fPIC -fno-ident"'; $ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : ''; shell()->cd($this->source_dir . '/source') - ->exec( + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv( "{$cppflags} {$cxxflags} {$ldflags} " . './runConfigureICU Linux ' . + '--enable-pic ' . '--enable-static ' . '--disable-shared ' . '--with-data-packaging=static ' . @@ -33,9 +39,9 @@ class icu extends LinuxLibraryBase '--enable-samples=no ' . '--prefix=' . BUILD_ROOT_PATH ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + ->execWithEnv('make clean') + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install'); $this->patchPkgconfPrefix(['icu-i18n.pc', 'icu-io.pc', 'icu-uc.pc'], PKGCONF_PATCH_PREFIX); FileSystem::removeDir(BUILD_LIB_PATH . '/icu'); From 03b634b9614efa00bad51708e7ed6086f80c7f6d Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 15:29:12 +0700 Subject: [PATCH 005/319] fix libsodium with -fPIC too --- src/SPC/builder/unix/library/libsodium.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index b24d52b7..c6bc6168 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -9,10 +9,15 @@ trait libsodium protected function build(): void { shell()->cd($this->source_dir) - ->exec('./configure --enable-static --disable-shared --prefix=') - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv('./configure --with-pic --enable-static --disable-shared --prefix=') + ->execWithEnv('make clean') + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX); } From 23ae3f60f3ccf8418308b45de6997077a4d3d1d8 Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 15:35:13 +0700 Subject: [PATCH 006/319] remove unused option --- src/SPC/builder/linux/library/icu.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 0543c0d8..ddcfe1b2 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -26,7 +26,6 @@ class icu extends LinuxLibraryBase ->execWithEnv( "{$cppflags} {$cxxflags} {$ldflags} " . './runConfigureICU Linux ' . - '--enable-pic ' . '--enable-static ' . '--disable-shared ' . '--with-data-packaging=static ' . From 6fe8b591ceeba17a78cbc009b12a79cf87593fcf Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 19:52:30 +0700 Subject: [PATCH 007/319] ld library path for shared extension building --- .gitignore | 3 +++ src/SPC/builder/Extension.php | 1 + 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 0560542f..9d9289f6 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ docker/source/ # default source extract directory /source/ +# built by shared embed tests +/locale/ + # default source download directory /downloads/ diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index a3d08f09..92894054 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -297,6 +297,7 @@ class Extension 'CFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; // prepare configure args shell()->cd($this->source_dir) From 9557c9ef21789e5a0eee13698958a37d1c61650e Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 21:50:35 +0700 Subject: [PATCH 008/319] remove static target for zip --- config/ext.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/ext.json b/config/ext.json index 1df91d3b..a3018b2f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1055,9 +1055,6 @@ "support": { "BSD": "wip" }, - "target": [ - "static" - ], "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "enable", From 22001792cd7a5c6a306aa2c8bd9eaf375c3db8de Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 21:51:18 +0700 Subject: [PATCH 009/319] remove static target for swoole --- config/ext.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/config/ext.json b/config/ext.json index a3018b2f..47acef96 100644 --- a/config/ext.json +++ b/config/ext.json @@ -124,10 +124,6 @@ "Linux": "partial", "BSD": "wip" }, - "target": [ - "static", - "shared" - ], "notes": true, "arg-type": "custom", "type": "builtin", @@ -781,9 +777,6 @@ "Windows": "no", "BSD": "wip" }, - "target": [ - "static" - ], "notes": true, "type": "external", "source": "swoole", From b402b735d63a4de8bfa43c94314e2997ed10a5de Mon Sep 17 00:00:00 2001 From: henderkes Date: Thu, 15 May 2025 23:30:07 +0700 Subject: [PATCH 010/319] fix copy command with BUILD_MODULES_CONSTANT --- src/SPC/builder/Extension.php | 13 +++++++++++-- src/SPC/builder/extension/opcache.php | 11 +++++++++++ src/SPC/builder/extension/xdebug.php | 5 ++++- src/SPC/builder/unix/UnixBuilderBase.php | 4 ++-- src/globals/internal-env.php | 7 +++++++ 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 92894054..2ab50f98 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -194,7 +194,7 @@ class Extension */ public function runSharedExtensionCheckUnix(): void { - [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "extension=' . BUILD_LIB_PATH . '/' . $this->getName() . '.so" --ri ' . $this->getName()); + [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "extension=' . BUILD_MODULES_PATH . '/' . $this->getName() . '.so" --ri ' . $this->getName()); if ($ret !== 0) { throw new RuntimeException($this->getName() . '.so failed to load'); } @@ -308,7 +308,16 @@ class Extension ->execWithEnv('make -j' . $this->builder->concurrency); // copy shared library - copy($this->source_dir . '/modules/' . $this->getDistName() . '.so', BUILD_LIB_PATH . '/' . $this->getDistName() . '.so'); + FileSystem::createDir(BUILD_MODULES_PATH); + $extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so'; + $sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so'; + if (file_exists($extensionDirFile)) { + copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); + } elseif (file_exists($sourceDirFile)) { + copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); + } else { + throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.'); + } // check shared extension with php-cli if (file_exists(BUILD_BIN_PATH . '/php')) { $this->runSharedExtensionCheckUnix(); diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 5d9dda0a..5f406e16 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -24,6 +24,17 @@ class opcache extends Extension } } + public function runSharedExtensionCheckUnix(): void + { + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -v'); + if ($ret !== 0) { + throw new RuntimeException('opcache.so failed to load.'); + } + if (!str_contains(join($out), 'with Zend OPcache')) { + throw new RuntimeException('opcache.so failed to load.'); + } + } + public function patchBeforeBuildconf(): bool { if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) { diff --git a/src/SPC/builder/extension/xdebug.php b/src/SPC/builder/extension/xdebug.php index ed592056..6b945f49 100644 --- a/src/SPC/builder/extension/xdebug.php +++ b/src/SPC/builder/extension/xdebug.php @@ -13,9 +13,12 @@ class xdebug extends Extension { public function runSharedExtensionCheckUnix(): void { - [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_LIB_PATH . '/xdebug.so" --ri xdebug'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -v'); if ($ret !== 0) { throw new RuntimeException('xdebug.so failed to load.'); } + if (!str_contains(join($out), 'with Xdebug')) { + throw new RuntimeException('xdebug.so failed to load.'); + } } } diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 4c8df333..9ffca22a 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -223,8 +223,8 @@ abstract class UnixBuilderBase extends BuilderBase default => throw new RuntimeException('Deployment does not accept type ' . $type), }; logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file'); - FileSystem::createDir(BUILD_ROOT_PATH . '/bin'); - shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '/bin/')); + FileSystem::createDir(BUILD_BIN_PATH); + shell()->exec('cp ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_BIN_PATH)); return true; } diff --git a/src/globals/internal-env.php b/src/globals/internal-env.php index 34b1ed99..1046848e 100644 --- a/src/globals/internal-env.php +++ b/src/globals/internal-env.php @@ -9,10 +9,17 @@ use SPC\builder\windows\SystemUtil as WindowsSystemUtil; use SPC\store\FileSystem; use SPC\util\GlobalEnvManager; +// output path for everything, other paths are defined relative to this by default define('BUILD_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot'))); +// output path for header files for development define('BUILD_INCLUDE_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include'))); +// output path for libraries and for libphp.so, if building shared embed define('BUILD_LIB_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib'))); +// output path for binaries define('BUILD_BIN_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin'))); +// output path for shared extensions +define('BUILD_MODULES_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_MODULES_PATH')) ? $a : (BUILD_ROOT_PATH . '/modules'))); + define('PKG_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('PKG_ROOT_PATH')) ? $a : (WORKING_DIR . '/pkgroot'))); define('SOURCE_PATH', FileSystem::convertPath(is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source'))); define('DOWNLOAD_PATH', FileSystem::convertPath(is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads'))); From 1ae27c7b5a7292d8b5f5246812c41db2be6bdd7d Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 16 May 2025 00:24:18 +0700 Subject: [PATCH 011/319] oopsie --- src/SPC/builder/extension/xdebug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/xdebug.php b/src/SPC/builder/extension/xdebug.php index 6b945f49..367eb420 100644 --- a/src/SPC/builder/extension/xdebug.php +++ b/src/SPC/builder/extension/xdebug.php @@ -13,7 +13,7 @@ class xdebug extends Extension { public function runSharedExtensionCheckUnix(): void { - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -v'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_MODULES_PATH . '/xdebug.so" -v'); if ($ret !== 0) { throw new RuntimeException('xdebug.so failed to load.'); } From 872673655ee531d66b737583a2d9e97fed6dc1c2 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 16 May 2025 00:26:23 +0700 Subject: [PATCH 012/319] oopsie in opcache --- src/SPC/builder/extension/opcache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 5f406e16..ec468cb8 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -26,7 +26,7 @@ class opcache extends Extension public function runSharedExtensionCheckUnix(): void { - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -v'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_MODULES_PATH . '/opcache.so" -v'); if ($ret !== 0) { throw new RuntimeException('opcache.so failed to load.'); } From 76a9be2167c22357a06994c60a3f9a0396b2c9a2 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 17 May 2025 19:00:57 +0700 Subject: [PATCH 013/319] fix shared bz2 build --- src/SPC/builder/Extension.php | 4 ++++ src/SPC/builder/extension/bz2.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 2ab50f98..43e0a5e8 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -275,6 +275,10 @@ class Extension */ public function buildShared(): void { + if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { + logger()->info('extension ' . $this->getName() . ' already built, skipping'); + return; + } match (PHP_OS_FAMILY) { 'Darwin', 'Linux' => $this->buildUnixShared(), default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'), diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php index 88f22e56..ee3f2996 100644 --- a/src/SPC/builder/extension/bz2.php +++ b/src/SPC/builder/extension/bz2.php @@ -24,4 +24,9 @@ class bz2 extends Extension FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks); return true; } + + public function getUnixConfigureArg(bool $shared = false): string + { + return $shared ? '--with-bz2=' . BUILD_ROOT_PATH : ''; + } } From 05e9129a66f7f4208e73e7bffda3c2b17ebf879a Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 17 May 2025 19:01:32 +0700 Subject: [PATCH 014/319] refactor dom out to its own extension, fails shared build --- src/SPC/builder/extension/dom.php | 72 +++++++++++++++++++++++++++++++ src/SPC/builder/extension/xml.php | 1 - 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/SPC/builder/extension/dom.php diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php new file mode 100644 index 00000000..bb2f659f --- /dev/null +++ b/src/SPC/builder/extension/dom.php @@ -0,0 +1,72 @@ +builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'] . ' -I' . SOURCE_PATH . '/php-src', + 'LDFLAGS' => $config['ldflags'], + 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, + ]; + // prepare configure args + shell()->cd($this->source_dir) + ->setEnv($env) + ->execWithEnv(BUILD_BIN_PATH . '/phpize') + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency); + + // copy shared library + FileSystem::createDir(BUILD_MODULES_PATH); + $extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so'; + $sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so'; + if (file_exists($extensionDirFile)) { + copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); + } elseif (file_exists($sourceDirFile)) { + copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); + } else { + throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.'); + } + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } + } +} diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index fc8bfc4d..544585ad 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -13,7 +13,6 @@ use SPC\util\CustomExt; #[CustomExt('soap')] #[CustomExt('xmlreader')] #[CustomExt('xmlwriter')] -#[CustomExt('dom')] #[CustomExt('simplexml')] class xml extends Extension { From c1e91e1ccb56c552d632bc76351fea1338861e1e Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 17 May 2025 22:40:30 +0700 Subject: [PATCH 015/319] sockets doesn't install header?! --- src/SPC/builder/Extension.php | 10 ++++++++++ src/SPC/builder/extension/sockets.php | 21 +++++++++++++++++++++ src/SPC/builder/unix/library/gmp.php | 2 +- src/SPC/command/BuildPHPCommand.php | 4 +++- src/SPC/store/SourcePatcher.php | 9 +++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/extension/sockets.php diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 43e0a5e8..81f8cac9 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -423,4 +423,14 @@ class Extension return $deps; } + + /** + * Patch code before shared extension ./configure + * If you need to patch some code, overwrite this + * return true if you patched something, false if not + */ + public function patchBeforeSharedBuild(): bool + { + return false; + } } diff --git a/src/SPC/builder/extension/sockets.php b/src/SPC/builder/extension/sockets.php new file mode 100644 index 00000000..a0901415 --- /dev/null +++ b/src/SPC/builder/extension/sockets.php @@ -0,0 +1,21 @@ +execWithEnv( './configure ' . - '--enable-static --disable-shared ' . + '--enable-static --disable-shared --with-pic ' . '--prefix=' ) ->execWithEnv('make clean') diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 49067b0b..8226b045 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -208,7 +208,9 @@ class BuildPHPCommand extends BuildCommand SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); // start to build - $builder->buildPHP($rule); + // $builder->buildPHP($rule); + + SourcePatcher::patchBeforeSharedBuild($builder); // build dynamic extensions if needed if (!empty($shared_extensions)) { diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index b5de166f..24ba666c 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -78,6 +78,15 @@ class SourcePatcher } } + public static function patchBeforeSharedBuild(BuilderBase $builder): void + { + foreach ($builder->getExts() as $ext) { + if ($ext->patchBeforeSharedBuild() === true) { + logger()->info('Extension [' . $ext->getName() . '] patched before shared build'); + } + } + } + /** * Source patcher runner before configure * From eab8c27e4ab54888d5adc2fd3e4de5832c5fbad5 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 17 May 2025 22:43:34 +0700 Subject: [PATCH 016/319] shared dom ext requires xml --- config/ext.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index 47acef96..9c36a35e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -75,7 +75,7 @@ "libxml2", "zlib" ], - "ext-depends-windows": [ + "ext-depends": [ "xml" ] }, From f88c10d4aa24dd9f237bdd773cb9f1c9c8454307 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 08:57:07 +0700 Subject: [PATCH 017/319] restore buildphp command --- config/ext.json | 11 ++++++++++- src/SPC/builder/Extension.php | 20 ++++++++++---------- src/SPC/command/BuildPHPCommand.php | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/config/ext.json b/config/ext.json index 9c36a35e..d051526a 100644 --- a/config/ext.json +++ b/config/ext.json @@ -75,7 +75,7 @@ "libxml2", "zlib" ], - "ext-depends": [ + "ext-depends-windows": [ "xml" ] }, @@ -410,6 +410,9 @@ }, "mysqli": { "type": "builtin", + "target": [ + "static" + ], "arg-type": "with", "ext-depends": [ "mysqlnd" @@ -417,6 +420,9 @@ }, "mysqlnd": { "type": "builtin", + "target": [ + "static" + ], "arg-type-windows": "with", "lib-depends": [ "zlib" @@ -450,6 +456,9 @@ "openssl": { "notes": true, "type": "builtin", + "target": [ + "static" + ], "arg-type": "custom", "arg-type-windows": "with", "lib-depends": [ diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 81f8cac9..808d8c54 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -188,6 +188,16 @@ class Extension return false; } + /** + * Patch code before shared extension ./configure + * If you need to patch some code, overwrite this + * return true if you patched something, false if not + */ + public function patchBeforeSharedBuild(): bool + { + return false; + } + /** * Run shared extension check when cli is enabled * @throws RuntimeException @@ -423,14 +433,4 @@ class Extension return $deps; } - - /** - * Patch code before shared extension ./configure - * If you need to patch some code, overwrite this - * return true if you patched something, false if not - */ - public function patchBeforeSharedBuild(): bool - { - return false; - } } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 8226b045..1da60f63 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -208,7 +208,7 @@ class BuildPHPCommand extends BuildCommand SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); // start to build - // $builder->buildPHP($rule); + $builder->buildPHP($rule); SourcePatcher::patchBeforeSharedBuild($builder); From 2ff300970a8ce1a3791fa006b7aa31d2ea7507d7 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 12:19:26 +0700 Subject: [PATCH 018/319] -fPIC for unixodbc --- src/SPC/builder/unix/library/unixodbc.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index f89eb0a4..be7e9297 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -16,19 +16,25 @@ trait unixodbc protected function build(): void { shell()->cd($this->source_dir) - ->exec( + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv( './configure ' . '--enable-static --disable-shared ' . '--disable-debug ' . + '--with-pic ' . '--disable-dependency-tracking ' . '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . '--with-included-ltdl ' . '--enable-gui=no ' . '--prefix=' ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->execWithEnv('make clean') + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); $this->cleanLaFiles(); } From 1fbd2c1adcffbd8a834d87b4a79c296e5ca4974b Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 12:46:55 +0700 Subject: [PATCH 019/319] -fPIC for postgresql CFLAGS, but it's still erroring out --- src/SPC/builder/unix/library/postgresql.php | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 7885eca3..43efca38 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -42,7 +42,7 @@ trait postgresql if (!empty($output[1][0])) { $cppflags = $output[1][0]; $macos_15_bug_cflags = PHP_OS_FAMILY === 'Darwin' ? ' -Wno-unguarded-availability-new' : ''; - $envs .= " CPPFLAGS=\"{$cppflags} -fPIC -fPIE -fno-ident{$macos_15_bug_cflags}\""; + $envs .= " CPPFLAGS=\"{$cppflags} -DPIC -fpic -fPIC -fPIE -fno-ident{$macos_15_bug_cflags}\""; } $output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}"); $error_exec_cnt += $output[0] === 0 ? 0 : 1; @@ -78,9 +78,15 @@ trait postgresql throw new RuntimeException('Unsupported version for postgresql: ' . $version . ' !'); } + $env = [ + 'CFLAGS' => $this->getLibExtraCFlags() . ' -DPIC -fpic', + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]; // configure shell()->cd($this->source_dir . '/build') - ->exec( + ->setEnv($env) + ->execWithEnv( "{$envs} ../configure " . "--prefix={$builddir} " . '--disable-thread-safety ' . @@ -89,6 +95,7 @@ trait postgresql '--with-readline ' . '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . + // ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . '--without-ldap ' . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . @@ -98,16 +105,12 @@ trait postgresql '--without-pam ' . '--without-bonjour ' . '--without-tcl ' - ); - // ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . - - // build - shell()->cd($this->source_dir . '/build') - ->exec($envs . ' make -C src/bin/pg_config install') - ->exec($envs . ' make -C src/include install') - ->exec($envs . ' make -C src/common install') - ->exec($envs . ' make -C src/port install') - ->exec($envs . ' make -C src/interfaces/libpq install'); + ) + ->execWithEnv($envs . ' make -C src/bin/pg_config install') + ->execWithEnv($envs . ' make -C src/include install') + ->execWithEnv($envs . ' make -C src/common install') + ->execWithEnv($envs . ' make -C src/port install') + ->execWithEnv($envs . ' make -C src/interfaces/libpq install'); // remove dynamic libs shell()->cd($this->source_dir . '/build') From bdd764218b4be21c81b36af96faa41ad288edfa1 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 12:53:49 +0700 Subject: [PATCH 020/319] install headers and modules from shared extensions --- src/SPC/builder/BuilderBase.php | 10 ++++++++++ src/SPC/builder/Extension.php | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 59f371ef..3d5648ef 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -233,8 +233,15 @@ abstract class BuilderBase */ abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE); + /** + * @throws WrongUsageException + * @throws RuntimeException + * @throws FileSystemException + */ public function buildSharedExts(): void { + FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir="', 'extension_dir="' . BUILD_MODULES_PATH . '"'); + FileSystem::createDir(BUILD_MODULES_PATH); foreach ($this->getExts() as $ext) { if (!$ext->isBuildShared()) { continue; @@ -242,6 +249,9 @@ abstract class BuilderBase logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); $ext->buildShared(); } + if (getenv('EXTENSION_DIR')) { + FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir="', 'extension_dir="' . getenv('EXTENSION_DIR') . '"'); + } } /** diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 808d8c54..1402bc58 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -319,10 +319,10 @@ class Extension ->execWithEnv(BUILD_BIN_PATH . '/phpize') ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') ->execWithEnv('make clean') - ->execWithEnv('make -j' . $this->builder->concurrency); + ->execWithEnv('make -j' . $this->builder->concurrency) + ->execWithEnv('make install'); // copy shared library - FileSystem::createDir(BUILD_MODULES_PATH); $extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so'; $sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so'; if (file_exists($extensionDirFile)) { From ea7c145c62a98e536c53359db065d318cd9687fb Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 15:52:15 +0700 Subject: [PATCH 021/319] libxml2 pic... --- src/SPC/builder/linux/library/libxml2.php | 12 +++++++++--- src/SPC/builder/unix/library/postgresql.php | 10 ++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 6f42d672..6d9470ae 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -24,13 +24,19 @@ class libxml2 extends LinuxLibraryBase FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->exec( + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv( 'cmake ' . '-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . '-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DIconv_IS_BUILT_IN=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . @@ -41,8 +47,8 @@ class libxml2 extends LinuxLibraryBase '-DLIBXML2_WITH_TESTS=OFF ' . '..' ) - ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install'); + ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") + ->execWithEnv('make install'); FileSystem::replaceFileStr( BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc', diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 43efca38..5a0da5de 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -39,10 +39,12 @@ trait postgresql $output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}"); $error_exec_cnt += $output[0] === 0 ? 0 : 1; + $macos_15_bug_cflags = PHP_OS_FAMILY === 'Darwin' ? ' -Wno-unguarded-availability-new' : ''; + $cflags = ''; if (!empty($output[1][0])) { - $cppflags = $output[1][0]; - $macos_15_bug_cflags = PHP_OS_FAMILY === 'Darwin' ? ' -Wno-unguarded-availability-new' : ''; - $envs .= " CPPFLAGS=\"{$cppflags} -DPIC -fpic -fPIC -fPIE -fno-ident{$macos_15_bug_cflags}\""; + $cflags = $output[1][0]; + $envs .= ' CPPFLAGS="-DPIC"'; + $cflags = "{$cflags} -fno-ident{$macos_15_bug_cflags}"; } $output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}"); $error_exec_cnt += $output[0] === 0 ? 0 : 1; @@ -79,7 +81,7 @@ trait postgresql } $env = [ - 'CFLAGS' => $this->getLibExtraCFlags() . ' -DPIC -fpic', + 'CFLAGS' => $this->getLibExtraCFlags() . ' ' . $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]; From 117923791ae1f6439ef56f6441e4ce649b9764e3 Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 18 May 2025 17:46:55 +0700 Subject: [PATCH 022/319] Update test-extensions.php --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 2739d3ac..e2f0ca12 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -51,7 +51,7 @@ $extensions = match (PHP_OS_FAMILY) { // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'xdebug', + 'Linux' => 'xdebug,intl,pgsql', 'Windows', 'Darwin' => '', }; From f708907d99b682ed98bec7037c6f916070c24777 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 17:59:02 +0700 Subject: [PATCH 023/319] zstd pic --- src/SPC/builder/linux/library/libpng.php | 5 ++--- src/SPC/builder/unix/library/zstd.php | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 56daee55..16fdca60 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -45,12 +45,11 @@ class libpng extends LinuxLibraryBase ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') ->setEnv([ - 'CFLAGS' => trim($this->getLibExtraCFlags() . ' ' . $this->builder->arch_c_flags), - 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags() . ' -L' . BUILD_LIB_PATH, 'LIBS' => $this->getLibExtraLibs(), ]) ->execWithEnv( - 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' . './configure ' . '--disable-shared ' . '--enable-static ' . diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index 1990f658..939567f2 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -18,11 +18,17 @@ trait zstd { FileSystem::resetDir($this->source_dir . '/build/cmake/build'); shell()->cd($this->source_dir . '/build/cmake/build') + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) ->exec( 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DZSTD_BUILD_STATIC=ON ' . '-DZSTD_BUILD_SHARED=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") From 6b50700d8c4fae4b138e40e4f3439e2f87420378 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 18 May 2025 18:24:09 +0700 Subject: [PATCH 024/319] remove dom extra cake --- src/SPC/builder/extension/dom.php | 34 ------------------------------- 1 file changed, 34 deletions(-) diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index bb2f659f..819a7787 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -35,38 +35,4 @@ class dom extends Extension { return '--with-dom --with-libxml'; } - - public function buildUnixShared(): void - { - $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); - $env = [ - 'CFLAGS' => $config['cflags'] . ' -I' . SOURCE_PATH . '/php-src', - 'LDFLAGS' => $config['ldflags'], - 'LIBS' => $config['libs'], - 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, - ]; - // prepare configure args - shell()->cd($this->source_dir) - ->setEnv($env) - ->execWithEnv(BUILD_BIN_PATH . '/phpize') - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') - ->execWithEnv('make clean') - ->execWithEnv('make -j' . $this->builder->concurrency); - - // copy shared library - FileSystem::createDir(BUILD_MODULES_PATH); - $extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so'; - $sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so'; - if (file_exists($extensionDirFile)) { - copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); - } elseif (file_exists($sourceDirFile)) { - copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); - } else { - throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.'); - } - // check shared extension with php-cli - if (file_exists(BUILD_BIN_PATH . '/php')) { - $this->runSharedExtensionCheckUnix(); - } - } } From 81474336c10a54ddc3f9c07339fe5ca5c2cc728e Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 18 May 2025 18:29:43 +0700 Subject: [PATCH 025/319] Update dom.php --- src/SPC/builder/extension/dom.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index 819a7787..a08fcd81 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -8,7 +8,6 @@ use SPC\builder\Extension; use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\CustomExt; -use SPC\util\SPCConfigUtil; #[CustomExt('dom')] class dom extends Extension From 54ff71798c9a8624019bdce6f62d6c532c9b2dab Mon Sep 17 00:00:00 2001 From: Marc Date: Sun, 18 May 2025 21:48:43 +0700 Subject: [PATCH 026/319] patch intl standard to c++17 --- src/SPC/builder/extension/intl.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SPC/builder/extension/intl.php b/src/SPC/builder/extension/intl.php index 8130b5d3..819aee69 100644 --- a/src/SPC/builder/extension/intl.php +++ b/src/SPC/builder/extension/intl.php @@ -23,4 +23,9 @@ class intl extends Extension } return true; } + + public function patchBeforeSharedBuild(): bool + { + return $this->patchBeforeBuildconf(); + } } From bff99fa53712134a9eacc437eec3c611a74ed081 Mon Sep 17 00:00:00 2001 From: henderkes Date: Mon, 19 May 2025 13:15:03 +0700 Subject: [PATCH 027/319] fix imagick shared build --- src/SPC/builder/unix/library/imagemagick.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 56da92e5..345cf6f0 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -80,5 +80,17 @@ trait imagemagick 'includearchdir=${prefix}/include/ImageMagick-7' ); } + $filelist = [ + 'libMagick++-7.Q16HDRI.la', + 'libMagickCore-7.Q16HDRI.la', + 'libMagickWand-7.Q16HDRI.la', + ]; + foreach ($filelist as $file) { + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/' . $file, + ' /lib/', + ' ' . BUILD_LIB_PATH . '/', + ); + } } } From 5bd53ed7142bfc770629e630802a81d257d3a61e Mon Sep 17 00:00:00 2001 From: henderkes Date: Mon, 19 May 2025 13:23:19 +0700 Subject: [PATCH 028/319] skip php rebuild if we're only building shared libphp.so --- src/SPC/builder/linux/LinuxBuilder.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index e38714f1..c06267d7 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -106,6 +106,18 @@ class LinuxBuilder extends UnixBuilderBase */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { + if ($build_target === BUILD_TARGET_EMBED && + file_exists(BUILD_BIN_PATH . '/php-config') && + file_exists(BUILD_BIN_PATH . '/phpize') + ) { + $embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static'; + if ($embed_type === 'shared' && file_exists(BUILD_LIB_PATH . '/libphp.so')) { + return; + } + if (file_exists(BUILD_LIB_PATH . '/libphp.a')) { + return; + } + } // ---------- Update extra-libs ---------- $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; // bloat means force-load all static libraries, even if they are not used From 7ba194810147bd476a438be205b2a2b36a741b60 Mon Sep 17 00:00:00 2001 From: henderkes Date: Mon, 19 May 2025 16:30:34 +0700 Subject: [PATCH 029/319] fix pdo_sqlsrv --- src/SPC/builder/Extension.php | 10 ------ src/SPC/builder/extension/pdo_sqlsrv.php | 40 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 src/SPC/builder/extension/pdo_sqlsrv.php diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 1402bc58..d25f1f12 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -322,16 +322,6 @@ class Extension ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); - // copy shared library - $extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so'; - $sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so'; - if (file_exists($extensionDirFile)) { - copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); - } elseif (file_exists($sourceDirFile)) { - copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); - } else { - throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.'); - } // check shared extension with php-cli if (file_exists(BUILD_BIN_PATH . '/php')) { $this->runSharedExtensionCheckUnix(); diff --git a/src/SPC/builder/extension/pdo_sqlsrv.php b/src/SPC/builder/extension/pdo_sqlsrv.php new file mode 100644 index 00000000..bc1aacf5 --- /dev/null +++ b/src/SPC/builder/extension/pdo_sqlsrv.php @@ -0,0 +1,40 @@ +builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'], + 'CXXFLAGS' => $config['cflags'], + 'LDFLAGS' => $config['ldflags'], + 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, + ]; + // prepare configure args + shell()->cd($this->source_dir) + ->setEnv($env) + ->execWithEnv(BUILD_BIN_PATH . '/phpize') + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency) + ->execWithEnv('make install'); + + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } + } +} From 683371adaa54500f5b0b1a516dbf396c0cba658a Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 20 May 2025 07:46:07 +0700 Subject: [PATCH 030/319] fix phar --- src/SPC/builder/extension/pdo_sqlsrv.php | 2 -- src/SPC/builder/extension/phar.php | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/extension/phar.php diff --git a/src/SPC/builder/extension/pdo_sqlsrv.php b/src/SPC/builder/extension/pdo_sqlsrv.php index bc1aacf5..195eaffe 100644 --- a/src/SPC/builder/extension/pdo_sqlsrv.php +++ b/src/SPC/builder/extension/pdo_sqlsrv.php @@ -5,8 +5,6 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\FileSystemException; -use SPC\store\FileSystem; use SPC\util\CustomExt; use SPC\util\SPCConfigUtil; diff --git a/src/SPC/builder/extension/phar.php b/src/SPC/builder/extension/phar.php new file mode 100644 index 00000000..a3563e07 --- /dev/null +++ b/src/SPC/builder/extension/phar.php @@ -0,0 +1,23 @@ +source_dir . '/config.m4', + ['$ext_dir/phar.1', '$ext_dir/phar.phar.1'], + ['${ext_dir}phar.1', '${ext_dir}phar.phar.1'] + ); + return true; + } +} From 38dfcdabd08fa1195ddf0f553a54a022273b749c Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 20 May 2025 08:06:49 +0700 Subject: [PATCH 031/319] fix rdkafka --- src/SPC/builder/extension/rdkafka.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/SPC/builder/extension/rdkafka.php b/src/SPC/builder/extension/rdkafka.php index 50610325..7af34d72 100644 --- a/src/SPC/builder/extension/rdkafka.php +++ b/src/SPC/builder/extension/rdkafka.php @@ -33,4 +33,12 @@ class rdkafka extends Extension $pkgconf_libs = trim(implode('', $pkgconf_libs)); return '--with-rdkafka=' . BUILD_ROOT_PATH . ' LIBS="' . $pkgconf_libs . '"'; } + + public function getUnixConfigureArg(bool $shared = false): string + { + if ($shared) { + return '--with-rdkafka=' . BUILD_ROOT_PATH; + } + return parent::getUnixConfigureArg($shared); + } } From 14a0e1a6ccd147eadd41866b4976c0cf42432e71 Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 20 May 2025 08:24:28 +0700 Subject: [PATCH 032/319] fix macos --- src/SPC/builder/extension/phar.php | 4 ++++ src/SPC/builder/extension/readline.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/SPC/builder/extension/phar.php b/src/SPC/builder/extension/phar.php index a3563e07..2bffea45 100644 --- a/src/SPC/builder/extension/phar.php +++ b/src/SPC/builder/extension/phar.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\linux\LinuxBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -13,6 +14,9 @@ class phar extends Extension { public function patchBeforeSharedBuild(): bool { + if (!$this->builder instanceof LinuxBuilder) { + return false; + } FileSystem::replaceFileStr( $this->source_dir . '/config.m4', ['$ext_dir/phar.1', '$ext_dir/phar.phar.1'], diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index c66e7afa..120fa42f 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -24,4 +24,9 @@ class readline extends Extension ); return true; } + + public function getUnixConfigureArg(bool $shared = false): string + { + return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; + } } From 20b6870f903ce97bd6a08dbb099905f4e962095d Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 20 May 2025 09:14:13 +0700 Subject: [PATCH 033/319] rewrite extension_dir --- src/SPC/builder/BuilderBase.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 3d5648ef..3b38019e 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder; +use PharIo\FileSystem\File; use SPC\exception\ExceptionHandler; use SPC\exception\FileSystemException; use SPC\exception\InterruptException; @@ -240,7 +241,16 @@ abstract class BuilderBase */ public function buildSharedExts(): void { - FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir="', 'extension_dir="' . BUILD_MODULES_PATH . '"'); + $lines = file(BUILD_BIN_PATH . '/php-config'); + $extension_dir_line = null; + foreach ($lines as $key => $value) { + if (str_starts_with($value, 'extension_dir=')) { + $lines[$key] = 'extension_dir="' . BUILD_MODULES_PATH . '"' . PHP_EOL; + $extension_dir_line = $value; + break; + } + } + file_put_contents(BUILD_BIN_PATH . '/php-config', implode('', $lines)); FileSystem::createDir(BUILD_MODULES_PATH); foreach ($this->getExts() as $ext) { if (!$ext->isBuildShared()) { @@ -249,9 +259,7 @@ abstract class BuilderBase logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); $ext->buildShared(); } - if (getenv('EXTENSION_DIR')) { - FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir="', 'extension_dir="' . getenv('EXTENSION_DIR') . '"'); - } + FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); } /** From 545a653c0d1e0a2b8fdfd3df4b1dbcd1ec8e81ff Mon Sep 17 00:00:00 2001 From: henderkes Date: Tue, 20 May 2025 09:20:20 +0700 Subject: [PATCH 034/319] better phar handling --- src/SPC/builder/extension/phar.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/extension/phar.php b/src/SPC/builder/extension/phar.php index 2bffea45..7396ba83 100644 --- a/src/SPC/builder/extension/phar.php +++ b/src/SPC/builder/extension/phar.php @@ -12,16 +12,26 @@ use SPC\util\CustomExt; #[CustomExt('phar')] class phar extends Extension { - public function patchBeforeSharedBuild(): bool + public function buildUnixShared(): void { if (!$this->builder instanceof LinuxBuilder) { - return false; + parent::buildUnixShared(); + return; } + FileSystem::replaceFileStr( $this->source_dir . '/config.m4', ['$ext_dir/phar.1', '$ext_dir/phar.phar.1'], ['${ext_dir}phar.1', '${ext_dir}phar.phar.1'] ); - return true; + try { + parent::buildUnixShared(); + } finally { + FileSystem::replaceFileStr( + $this->source_dir . '/config.m4', + ['${ext_dir}phar.1', '${ext_dir}phar.phar.1'], + ['$ext_dir/phar.1', '$ext_dir/phar.phar.1'] + ); + } } } From 1e50dac5a693a92b816bf33f5aeda9b9d8e6a9e3 Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 20 May 2025 10:50:41 +0700 Subject: [PATCH 035/319] Update BuildPHPCommand.php fix printed path --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 1da60f63..edeb7c47 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -248,7 +248,7 @@ class BuildPHPCommand extends BuildCommand } if (!empty($shared_extensions)) { foreach ($shared_extensions as $ext) { - $path = FileSystem::convertPath("{$build_root_path}/lib/{$ext}.so"); + $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); } } From 93c692862490c705b04e83a71245f37ea1cf84ad Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 20 May 2025 20:00:37 +0700 Subject: [PATCH 036/319] fix readline --- src/SPC/builder/Extension.php | 22 ++++++++++++++++++++-- src/SPC/builder/extension/mbregex.php | 5 +++++ src/SPC/builder/extension/mbstring.php | 11 +++++++++++ src/SPC/builder/extension/readline.php | 18 ++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index d25f1f12..aea8ba8c 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -9,6 +9,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; +use SPC\store\SourcePatcher; use SPC\util\SPCConfigUtil; class Extension @@ -189,7 +190,7 @@ class Extension } /** - * Patch code before shared extension ./configure + * Patch code before shared extension phpize * If you need to patch some code, overwrite this * return true if you patched something, false if not */ @@ -198,6 +199,16 @@ class Extension return false; } + /** + * Patch code before shared extension ./configure + * If you need to patch some code, overwrite this + * return true if you patched something, false if not + */ + public function patchBeforeSharedConfigure(): bool + { + return false; + } + /** * Run shared extension check when cli is enabled * @throws RuntimeException @@ -316,7 +327,14 @@ class Extension // prepare configure args shell()->cd($this->source_dir) ->setEnv($env) - ->execWithEnv(BUILD_BIN_PATH . '/phpize') + ->execWithEnv(BUILD_BIN_PATH . '/phpize'); + + if ($this->patchBeforeSharedConfigure()) { + logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); + } + + shell()->cd($this->source_dir) + ->setEnv($env) ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 4bf28544..492c4fbb 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -21,6 +21,11 @@ class mbregex extends Extension return ''; } + public function buildUnixShared(): void + { + print('mbregex is already built as part of mbstring, skipping build' . PHP_EOL); + } + /** * mbregex is not an extension, we need to overwrite the default check. */ diff --git a/src/SPC/builder/extension/mbstring.php b/src/SPC/builder/extension/mbstring.php index 5fcb88bd..aa86ee53 100644 --- a/src/SPC/builder/extension/mbstring.php +++ b/src/SPC/builder/extension/mbstring.php @@ -20,4 +20,15 @@ class mbstring extends Extension } return $arg; } + + public function getUnixConfigureArg(bool $shared = false): string + { + $arg = '--enable-mbstring'; + if ($this->builder->getExt('mbregex') === null) { + $arg .= ' --disable-mbregex'; + } else { + $arg .= ' --enable-mbregex'; + } + return $arg; + } } diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index 120fa42f..71c82a8b 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -29,4 +29,22 @@ class readline extends Extension { return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; } + + public function patchBeforeSharedConfigure(): bool + { + FileSystem::replaceFileStr($this->source_dir . '/configure', + 'test "$PHP_LIBEDIT" = "no" && PHP_LIBEDIT=yes', + '' + ); + return true; + } + + public function buildUnixShared(): void + { + if (!file_exists(BUILD_BIN_PATH . '/php') || !file_exists(BUILD_INCLUDE_PATH . '/php/sapi/cli/cli.h')) { + logger()->warning('CLI mode is not enabled, skipping readline build'); + return; + } + parent::buildUnixShared(); + } } From a9f81dd38ed3c69958ba59181922972bd730e45b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 20 May 2025 20:03:02 +0700 Subject: [PATCH 037/319] remove -fpic and -fpie (-fPIC and -fPIE are still there) --- config/env.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/env.ini b/config/env.ini index f70ad0a2..1a1fbaa7 100644 --- a/config/env.ini +++ b/config/env.ini @@ -97,7 +97,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; LIBS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm" ; EXTRA_LDFLAGS_PROGRAM for `make` php From 03ca3f4f59951a2f438edfccfb04989b371513b5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 20 May 2025 22:19:09 +0700 Subject: [PATCH 038/319] why do we have prefix= calls instead of prefix=BUILD_ROOT_DIR? --- config/ext.json | 3 - src/SPC/builder/extension/curl.php | 73 ++++++++++++++++++++ src/SPC/builder/macos/library/libpng.php | 1 + src/SPC/builder/traits/UnixLibraryTrait.php | 17 +++++ src/SPC/builder/unix/library/imagemagick.php | 11 +-- src/SPC/builder/unix/library/ldap.php | 1 + 6 files changed, 94 insertions(+), 12 deletions(-) diff --git a/config/ext.json b/config/ext.json index d051526a..ee1c68db 100644 --- a/config/ext.json +++ b/config/ext.json @@ -456,9 +456,6 @@ "openssl": { "notes": true, "type": "builtin", - "target": [ - "static" - ], "arg-type": "custom", "arg-type-windows": "with", "lib-depends": [ diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index d4f8b078..5ed224f6 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\linux\LinuxBuilder; use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; use SPC\exception\WrongUsageException; @@ -54,4 +55,76 @@ class curl extends Extension FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lcurl/', $this->getLibFilesString() . $frameworks); return true; } + + public function patchBeforeSharedConfigure(): bool + { + $file = SOURCE_PATH . '/php-src/ext/curl/config.m4'; + $content = FileSystem::readFile($file); + + // Inject patch before it + $patch = ' save_LIBS="$LIBS" + LIBS="$LIBS $CURL_LIBS" +'; + // Check if already patched + if (str_contains($content, $patch)) { + return false; // Already patched + } + + // Match the line containing PHP_CHECK_LIBRARY for curl + $pattern = '/(PHP_CHECK_LIBRARY\(\[curl],\s*\[curl_easy_perform],)/'; + + + // Restore LIBS after the check — append this just after the macro block + $restore = ' + LIBS="$save_LIBS"'; + + // Apply patch + $patched = preg_replace_callback($pattern, function ($matches) use ($patch) { + return $patch . $matches[1]; + }, $content, 1); + + // Inject restore after the matching PHP_CHECK_LIBRARY block + $patched = preg_replace( + '/(PHP_CHECK_LIBRARY\(\[curl],\s*\[curl_easy_perform],.*?\)\n)/s', + "$1$restore\n", + $patched, + 1 + ); + + if ($patched === null) { + throw new \RuntimeException("Failed to patch config.m4 due to a regex error"); + } + + FileSystem::writeFile($file, $patched); + return true; + } + + + public function getUnixConfigureArg(bool $shared = false): string + { + return '--with-curl'; + } + + public function buildUnixShared(): void + { + if (!$this->builder instanceof LinuxBuilder) { + parent::buildUnixShared(); + return; + } + + FileSystem::replaceFileStr( + $this->source_dir . '/config.m4', + ['$ext_dir/phar.1', '$ext_dir/phar.phar.1'], + ['${ext_dir}phar.1', '${ext_dir}phar.phar.1'] + ); + try { + parent::buildUnixShared(); + } finally { + FileSystem::replaceFileStr( + $this->source_dir . '/config.m4', + ['${ext_dir}phar.1', '${ext_dir}phar.phar.1'], + ['$ext_dir/phar.1', '$ext_dir/phar.phar.1'] + ); + } + } } diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index b61cc898..f273bff6 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -59,6 +59,7 @@ class libpng extends MacOSLibraryBase ->cd(BUILD_LIB_PATH) ->exec('ln -sf libpng16.a libpng.a'); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); + $this->patchLaDependencyPrefix(['libpng16.la']); $this->cleanLaFiles(); } } diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 8e69f6d3..45de0cf4 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -84,6 +84,23 @@ trait UnixLibraryTrait } } + public function patchLaDependencyPrefix(array $files): void + { + logger()->info('Patching library [' . static::NAME . '] la files'); + foreach ($files as $name) { + $realpath = realpath(BUILD_LIB_PATH . '/' . $name); + if ($realpath === false) { + throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); + } + logger()->debug('Patching ' . $realpath); + // replace prefix + $file = FileSystem::readFile($realpath); + $file = str_replace(' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); + $file = preg_replace("/^libdir=.*$/m", "libdir='" . BUILD_LIB_PATH . "'", $file); + FileSystem::writeFile($realpath, $file); + } + } + /** * remove libtool archive files * diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 345cf6f0..deb1e402 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -80,17 +80,10 @@ trait imagemagick 'includearchdir=${prefix}/include/ImageMagick-7' ); } - $filelist = [ + $this->patchLaDependencyPrefix([ 'libMagick++-7.Q16HDRI.la', 'libMagickCore-7.Q16HDRI.la', 'libMagickWand-7.Q16HDRI.la', - ]; - foreach ($filelist as $file) { - FileSystem::replaceFileStr( - BUILD_LIB_PATH . '/' . $file, - ' /lib/', - ' ' . BUILD_LIB_PATH . '/', - ); - } + ]); } } diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 2831f094..93f889f0 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -50,5 +50,6 @@ trait ldap ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']); + $this->patchLaDependencyPrefix(['libldap.la', 'liblber.la']); } } From f47daac3cc205e51bbf4ceb371bd26ea25e3ab83 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 20 May 2025 23:04:34 +0700 Subject: [PATCH 039/319] cs fix, xml building fails now, unsure why, doesn't seem to import expat_compat.h for some reason --- config/ext.json | 3 +++ src/SPC/builder/Extension.php | 12 +++++++++++- src/SPC/builder/extension/xml.php | 6 +++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index ee1c68db..1c74db74 100644 --- a/config/ext.json +++ b/config/ext.json @@ -77,6 +77,9 @@ ], "ext-depends-windows": [ "xml" + ], + "shared-ext-depends": [ + "xml" ] }, "ds": { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index aea8ba8c..9322e49b 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -127,6 +127,9 @@ class Extension foreach (Config::getExt($this->name, 'ext-suggests', []) as $name) { $this->addExtensionDependency($name, true); } + foreach (Config::getExt($this->name, 'shared-ext-depends', []) as $name) { + $this->addExtensionDependency($name); + } return $this; } @@ -300,6 +303,13 @@ class Extension logger()->info('extension ' . $this->getName() . ' already built, skipping'); return; } + foreach (Config::getExt($this->name, 'shared-ext-depends', []) as $name) { + $dependencyExt = $this->builder->getExt($name); + if ($dependencyExt === null) { + throw new RuntimeException("extension {$this->name} requires shared extension {$name}"); + } + $dependencyExt->buildShared(); + } match (PHP_OS_FAMILY) { 'Darwin', 'Linux' => $this->buildUnixShared(), default => throw new WrongUsageException(PHP_OS_FAMILY . ' build shared extensions is not supported yet'), @@ -335,7 +345,7 @@ class Extension shell()->cd($this->source_dir) ->setEnv($env) - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static --with-pic') ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index 544585ad..b1a8c5f3 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -26,11 +26,12 @@ class xml extends Extension 'soap' => '--enable-soap', 'xmlreader' => '--enable-xmlreader', 'xmlwriter' => '--enable-xmlwriter', - 'dom' => '--enable-dom', 'simplexml' => '--enable-simplexml', default => throw new RuntimeException('Not accept non-xml extension'), }; - $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; + if (!$shared) { + $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; + } return $arg; } @@ -47,7 +48,6 @@ class xml extends Extension 'soap' => '--enable-soap', 'xmlreader' => '--enable-xmlreader', 'xmlwriter' => '--enable-xmlwriter', - 'dom' => '--with-dom', 'simplexml' => '--with-simplexml', default => throw new RuntimeException('Not accept non-xml extension'), }; From fa285ecc82060159ec1b045ad7b77dfb46014b32 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 20 May 2025 23:16:36 +0700 Subject: [PATCH 040/319] more patching, xml still not working though --- src/SPC/builder/unix/library/gettext.php | 1 + src/SPC/builder/unix/library/libiconv.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 69736c36..16622560 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -37,5 +37,6 @@ trait gettext ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install'); + $this->patchLaDependencyPrefix(['libintl.la']); } } diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index 710e7425..72297646 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -30,5 +30,6 @@ trait libiconv if (file_exists(BUILD_BIN_PATH . '/iconv')) { unlink(BUILD_BIN_PATH . '/iconv'); } + $this->patchLaDependencyPrefix(['libiconv.la']); } } From c43423a7d0868e658ab1ca5e804b9a40b22c6a23 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 11:19:28 +0700 Subject: [PATCH 041/319] replace root cause of the automatic enable --- src/SPC/builder/extension/readline.php | 9 --------- src/SPC/builder/linux/LinuxBuilder.php | 1 + src/SPC/builder/unix/UnixBuilderBase.php | 1 + 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index 71c82a8b..dc4d15f7 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -30,15 +30,6 @@ class readline extends Extension return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; } - public function patchBeforeSharedConfigure(): bool - { - FileSystem::replaceFileStr($this->source_dir . '/configure', - 'test "$PHP_LIBEDIT" = "no" && PHP_LIBEDIT=yes', - '' - ); - return true; - } - public function buildUnixShared(): void { if (!file_exists(BUILD_BIN_PATH . '/php') || !file_exists(BUILD_INCLUDE_PATH . '/php/sapi/cli/cli.h')) { diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index c06267d7..2db05b5e 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -184,6 +184,7 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . + '--prefix=' . BUILD_ROOT_PATH . ' ' . ($enable_cli ? '--enable-cli ' : '--disable-cli ') . ($enable_fpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') . ($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') . diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 9ffca22a..48c82601 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -250,6 +250,7 @@ abstract class UnixBuilderBase extends BuilderBase logger()->debug('Patching phpize prefix'); FileSystem::replaceFileStr(BUILD_BIN_PATH . '/phpize', "prefix=''", "prefix='" . BUILD_ROOT_PATH . "'"); FileSystem::replaceFileStr(BUILD_BIN_PATH . '/phpize', 's##', 's#/usr/local#'); + FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', 'test "[$]$1" = "no" && $1=yes', '# test "[$]$1" = "no" && $1=yes'); } // patch php-config if (file_exists(BUILD_BIN_PATH . '/php-config')) { From 95a2f4600bb0b2f183829d5723566e2eff7c939a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 12:01:00 +0700 Subject: [PATCH 042/319] rework building of shared extensions so that builtin extensions are built at php-src/configure -> make time --- config/env.ini | 2 +- src/SPC/builder/BuilderBase.php | 18 ++++++++++--- src/SPC/builder/Extension.php | 36 +++++++++++-------------- src/SPC/builder/extension/amqp.php | 2 +- src/SPC/builder/extension/dba.php | 2 +- src/SPC/builder/extension/dom.php | 2 +- src/SPC/builder/extension/ffi.php | 2 +- src/SPC/builder/extension/glfw.php | 2 +- src/SPC/builder/extension/ldap.php | 5 ++++ src/SPC/builder/extension/mbregex.php | 2 +- src/SPC/builder/extension/mbstring.php | 2 +- src/SPC/builder/extension/openssl.php | 2 +- src/SPC/builder/extension/pdo_odbc.php | 2 +- src/SPC/builder/extension/pdo_pgsql.php | 2 +- src/SPC/builder/extension/pgsql.php | 2 +- src/SPC/builder/extension/rdkafka.php | 2 +- src/SPC/builder/extension/redis.php | 2 +- src/SPC/builder/extension/swow.php | 2 +- src/SPC/builder/extension/xlswriter.php | 2 +- src/SPC/builder/extension/xml.php | 2 +- src/SPC/builder/linux/LinuxBuilder.php | 2 +- 21 files changed, 53 insertions(+), 42 deletions(-) diff --git a/config/env.ini b/config/env.ini index 1a1fbaa7..49952645 100644 --- a/config/env.ini +++ b/config/env.ini @@ -81,7 +81,7 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime ; buildconf command SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force" ; configure command -SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg --with-pic" +SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=yes --enable-static=no --disable-all --disable-cgi --disable-phpdbg --with-pic" ; make command SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}" ; embed type for php, static (libphp.a) or shared (libphp.so) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 3b38019e..d32651f6 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -256,6 +256,10 @@ abstract class BuilderBase if (!$ext->isBuildShared()) { continue; } + if (Config::getExt($ext->getName(), 'type') === 'builtin') { + logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); + continue; + } logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); $ext->buildShared(); } @@ -272,9 +276,17 @@ abstract class BuilderBase public function makeStaticExtensionArgs(): string { $ret = []; - foreach ($this->getExts(false) as $ext) { - logger()->info($ext->getName() . ' is using ' . $ext->getConfigureArg()); - $ret[] = trim($ext->getConfigureArg()); + foreach ($this->getExts() as $ext) { + $arg = $ext->getConfigureArg(); + if ($ext->isBuildShared()) { + if (Config::getExt($ext->getName(), 'type') === 'builtin') { + $arg = $ext->getConfigureArg(true); + } else { + continue; + } + } + logger()->info($ext->getName() . ' is using ' . $arg); + $ret[] = trim($arg); } logger()->debug('Using configure: ' . implode(' ', $ret)); return implode(' ', $ret); diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 9322e49b..6b00bfae 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -9,7 +9,6 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; -use SPC\store\SourcePatcher; use SPC\util\SPCConfigUtil; class Extension @@ -60,20 +59,15 @@ class Extension * @throws FileSystemException * @throws WrongUsageException */ - public function getConfigureArg(): string + public function getConfigureArg(bool $shared = false): string { - $arg = $this->getEnableArg(); - switch (PHP_OS_FAMILY) { - case 'Windows': - $arg .= $this->getWindowsConfigureArg(); - break; - case 'Darwin': - case 'Linux': - case 'BSD': - $arg .= $this->getUnixConfigureArg(); - break; - } - return $arg; + return match (PHP_OS_FAMILY) { + 'Windows' => $this->getWindowsConfigureArg($shared), + 'Darwin', + 'Linux', + 'BSD' => $this->getUnixConfigureArg($shared), + default => throw new WrongUsageException(PHP_OS_FAMILY . ' build is not supported yet'), + }; } /** @@ -82,13 +76,13 @@ class Extension * @throws FileSystemException * @throws WrongUsageException */ - public function getEnableArg(): string + public function getEnableArg(bool $shared = false): string { $_name = str_replace('_', '-', $this->name); return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) { 'enable' => '--enable-' . $_name . ' ', - 'with' => '--with-' . $_name . ' ', - 'with-prefix' => '--with-' . $_name . '="' . BUILD_ROOT_PATH . '" ', + 'with' => '--with-' . $_name . ($shared ? '=shared' : '') . ' ', + 'with-prefix' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . '"' . BUILD_ROOT_PATH . '" ', 'none', 'custom' => '', default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-prefix] ."), }; @@ -151,15 +145,15 @@ class Extension return $this->name; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { - return ''; + return $this->getEnableArg(); // Windows is not supported yet } public function getUnixConfigureArg(bool $shared = false): string { - return ''; + return $this->getEnableArg($shared); } /** @@ -345,7 +339,7 @@ class Extension shell()->cd($this->source_dir) ->setEnv($env) - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static --with-pic') + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); diff --git a/src/SPC/builder/extension/amqp.php b/src/SPC/builder/extension/amqp.php index 8fbfea24..40a6131c 100644 --- a/src/SPC/builder/extension/amqp.php +++ b/src/SPC/builder/extension/amqp.php @@ -28,7 +28,7 @@ class amqp extends Extension return '--with-amqp --with-librabbitmq-dir=' . BUILD_ROOT_PATH; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg($shared = false): string { return '--with-amqp'; } diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php index bd7388f3..ec5a4d86 100644 --- a/src/SPC/builder/extension/dba.php +++ b/src/SPC/builder/extension/dba.php @@ -16,7 +16,7 @@ class dba extends Extension return '--enable-dba' . $qdbm; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { $qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : ''; return '--with-dba' . $qdbm; diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index a08fcd81..2d69ac64 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -30,7 +30,7 @@ class dom extends Extension return true; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg($shared = false): string { return '--with-dom --with-libxml'; } diff --git a/src/SPC/builder/extension/ffi.php b/src/SPC/builder/extension/ffi.php index 51c3efac..1d55397b 100644 --- a/src/SPC/builder/extension/ffi.php +++ b/src/SPC/builder/extension/ffi.php @@ -15,7 +15,7 @@ class ffi extends Extension return '--with-ffi --enable-zend-signals'; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { return '--with-ffi'; } diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php index 444b5d93..3ebb5228 100644 --- a/src/SPC/builder/extension/glfw.php +++ b/src/SPC/builder/extension/glfw.php @@ -35,7 +35,7 @@ class glfw extends Extension return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { return '--enable-glfw=static'; } diff --git a/src/SPC/builder/extension/ldap.php b/src/SPC/builder/extension/ldap.php index 4616bea8..18db78c1 100644 --- a/src/SPC/builder/extension/ldap.php +++ b/src/SPC/builder/extension/ldap.php @@ -20,4 +20,9 @@ class ldap extends Extension } return true; } + + public function getUnixConfigureArg(bool $shared = false): string + { + return '--with-ldap=' . BUILD_ROOT_PATH; + } } diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 492c4fbb..b7d174ff 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -16,7 +16,7 @@ class mbregex extends Extension return 'mbstring'; } - public function getConfigureArg(): string + public function getConfigureArg(bool $shared = false): string { return ''; } diff --git a/src/SPC/builder/extension/mbstring.php b/src/SPC/builder/extension/mbstring.php index aa86ee53..42249509 100644 --- a/src/SPC/builder/extension/mbstring.php +++ b/src/SPC/builder/extension/mbstring.php @@ -10,7 +10,7 @@ use SPC\util\CustomExt; #[CustomExt('mbstring')] class mbstring extends Extension { - public function getConfigureArg(): string + public function getConfigureArg(bool $shared = false): string { $arg = '--enable-mbstring'; if ($this->builder->getExt('mbregex') === null) { diff --git a/src/SPC/builder/extension/openssl.php b/src/SPC/builder/extension/openssl.php index add1aede..fc4831f3 100644 --- a/src/SPC/builder/extension/openssl.php +++ b/src/SPC/builder/extension/openssl.php @@ -26,6 +26,6 @@ class openssl extends Extension public function getUnixConfigureArg(bool $shared = false): string { $openssl_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : ' --with-openssl-dir=' . BUILD_ROOT_PATH; - return '--with-openssl=' . BUILD_ROOT_PATH . $openssl_dir; + return '--with-openssl=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $openssl_dir; } } diff --git a/src/SPC/builder/extension/pdo_odbc.php b/src/SPC/builder/extension/pdo_odbc.php index e436f381..ac1b7456 100644 --- a/src/SPC/builder/extension/pdo_odbc.php +++ b/src/SPC/builder/extension/pdo_odbc.php @@ -22,7 +22,7 @@ class pdo_odbc extends Extension return '--with-pdo-odbc=unixODBC,' . BUILD_ROOT_PATH; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { return '--with-pdo-odbc'; } diff --git a/src/SPC/builder/extension/pdo_pgsql.php b/src/SPC/builder/extension/pdo_pgsql.php index e29014cb..b1ca1a81 100644 --- a/src/SPC/builder/extension/pdo_pgsql.php +++ b/src/SPC/builder/extension/pdo_pgsql.php @@ -10,7 +10,7 @@ use SPC\util\CustomExt; #[CustomExt('pdo_pgsql')] class pdo_pgsql extends Extension { - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { return '--with-pdo-pgsql=yes'; } diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index 1c63f163..e4ac8ebb 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -45,7 +45,7 @@ class pgsql extends Extension * @throws WrongUsageException * @throws RuntimeException */ - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { if ($this->builder->getPHPVersionID() >= 80400) { return '--with-pgsql'; diff --git a/src/SPC/builder/extension/rdkafka.php b/src/SPC/builder/extension/rdkafka.php index 7af34d72..9f28c627 100644 --- a/src/SPC/builder/extension/rdkafka.php +++ b/src/SPC/builder/extension/rdkafka.php @@ -27,7 +27,7 @@ class rdkafka extends Extension return true; } - public function getConfigureArg(): string + public function getConfigureArg(bool $shared = false): string { $pkgconf_libs = shell()->execWithResult('pkg-config --libs --static rdkafka')[1]; $pkgconf_libs = trim(implode('', $pkgconf_libs)); diff --git a/src/SPC/builder/extension/redis.php b/src/SPC/builder/extension/redis.php index 0b60075c..75158ad7 100644 --- a/src/SPC/builder/extension/redis.php +++ b/src/SPC/builder/extension/redis.php @@ -24,7 +24,7 @@ class redis extends Extension return $arg; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { $arg = '--enable-redis'; $arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session'; diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index 27576635..390ec27f 100644 --- a/src/SPC/builder/extension/swow.php +++ b/src/SPC/builder/extension/swow.php @@ -18,7 +18,7 @@ class swow extends Extension } } - public function getConfigureArg(): string + public function getConfigureArg(bool $shared = false): string { $arg = '--enable-swow'; $arg .= $this->builder->getLib('openssl') ? ' --enable-swow-ssl' : ' --disable-swow-ssl'; diff --git a/src/SPC/builder/extension/xlswriter.php b/src/SPC/builder/extension/xlswriter.php index 2ceb8e5c..878168ad 100644 --- a/src/SPC/builder/extension/xlswriter.php +++ b/src/SPC/builder/extension/xlswriter.php @@ -20,7 +20,7 @@ class xlswriter extends Extension return $arg; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { return '--with-xlswriter'; } diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index b1a8c5f3..d36df758 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -41,7 +41,7 @@ class xml extends Extension return true; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { $arg = match ($this->name) { 'xml' => '--with-xml', diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 2db05b5e..9b901460 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -184,7 +184,6 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . - '--prefix=' . BUILD_ROOT_PATH . ' ' . ($enable_cli ? '--enable-cli ' : '--disable-cli ') . ($enable_fpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') . ($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') . @@ -323,6 +322,7 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') + ->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = ' . BUILD_MODULES_PATH . '|" Makefile') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); $this->patchPhpScripts(); } From 495e868a7122d2be8b7ce9376ec1f4f6f905a675 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 13:19:51 +0700 Subject: [PATCH 043/319] rework configure args --- config/ext.json | 15 +++++++++------ src/SPC/builder/BuilderBase.php | 6 +++++- src/SPC/builder/extension/bz2.php | 5 ----- src/SPC/builder/extension/curl.php | 7 +------ src/SPC/builder/extension/dba.php | 2 +- src/SPC/builder/extension/dom.php | 2 +- src/SPC/builder/extension/ffi.php | 2 +- src/SPC/builder/extension/gd.php | 2 +- src/SPC/builder/extension/ldap.php | 5 ----- src/SPC/builder/extension/mbstring.php | 2 +- src/SPC/builder/extension/xml.php | 4 +--- src/SPC/builder/linux/LinuxBuilder.php | 2 +- src/SPC/builder/unix/library/libxslt.php | 1 + src/SPC/store/SourcePatcher.php | 2 +- 14 files changed, 24 insertions(+), 33 deletions(-) diff --git a/config/ext.json b/config/ext.json index 1c74db74..89f17dc7 100644 --- a/config/ext.json +++ b/config/ext.json @@ -79,6 +79,9 @@ "xml" ], "shared-ext-depends": [ + "libxml", + "xmlreader", + "xmlwriter", "xml" ] }, @@ -413,22 +416,22 @@ }, "mysqli": { "type": "builtin", - "target": [ - "static" - ], "arg-type": "with", "ext-depends": [ "mysqlnd" + ], + "target": [ + "static" ] }, "mysqlnd": { "type": "builtin", - "target": [ - "static" - ], "arg-type-windows": "with", "lib-depends": [ "zlib" + ], + "target": [ + "static" ] }, "oci8": { diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index d32651f6..0e4c0603 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -257,7 +257,11 @@ abstract class BuilderBase continue; } if (Config::getExt($ext->getName(), 'type') === 'builtin') { - logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); + if (file_exists(BUILD_MODULES_PATH . '/' . $ext->getName() . '.so')) { + logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); + continue; + } + logger()->warning('Shared extension [' . $ext->getName() . '] was built statically by php-src/configure'); continue; } logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); diff --git a/src/SPC/builder/extension/bz2.php b/src/SPC/builder/extension/bz2.php index ee3f2996..88f22e56 100644 --- a/src/SPC/builder/extension/bz2.php +++ b/src/SPC/builder/extension/bz2.php @@ -24,9 +24,4 @@ class bz2 extends Extension FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lbz2/', $this->getLibFilesString() . $frameworks); return true; } - - public function getUnixConfigureArg(bool $shared = false): string - { - return $shared ? '--with-bz2=' . BUILD_ROOT_PATH : ''; - } } diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index 5ed224f6..0fd2b90b 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -53,6 +53,7 @@ class curl extends Extension { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lcurl/', $this->getLibFilesString() . $frameworks); + $this->patchBeforeSharedConfigure(); return true; } @@ -99,12 +100,6 @@ class curl extends Extension return true; } - - public function getUnixConfigureArg(bool $shared = false): string - { - return '--with-curl'; - } - public function buildUnixShared(): void { if (!$this->builder instanceof LinuxBuilder) { diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php index ec5a4d86..4a69c0a5 100644 --- a/src/SPC/builder/extension/dba.php +++ b/src/SPC/builder/extension/dba.php @@ -12,7 +12,7 @@ class dba extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : ''; + $qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : ''; return '--enable-dba' . $qdbm; } diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index 2d69ac64..46dae9e2 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -17,7 +17,7 @@ class dom extends Extension */ public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-dom'; + $arg = '--enable-dom' . ($shared ? '=shared' : ''); if (!$shared) { $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; } diff --git a/src/SPC/builder/extension/ffi.php b/src/SPC/builder/extension/ffi.php index 1d55397b..98547723 100644 --- a/src/SPC/builder/extension/ffi.php +++ b/src/SPC/builder/extension/ffi.php @@ -12,7 +12,7 @@ class ffi extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - return '--with-ffi --enable-zend-signals'; + return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals'; } public function getWindowsConfigureArg(bool $shared = false): string diff --git a/src/SPC/builder/extension/gd.php b/src/SPC/builder/extension/gd.php index f872733b..677b1522 100644 --- a/src/SPC/builder/extension/gd.php +++ b/src/SPC/builder/extension/gd.php @@ -12,7 +12,7 @@ class gd extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-gd'; + $arg = '--enable-gd' . ($shared ? '=shared' : ''); $arg .= $this->builder->getLib('freetype') ? ' --with-freetype' : ''; $arg .= $this->builder->getLib('libjpeg') ? ' --with-jpeg' : ''; $arg .= $this->builder->getLib('libwebp') ? ' --with-webp' : ''; diff --git a/src/SPC/builder/extension/ldap.php b/src/SPC/builder/extension/ldap.php index 18db78c1..4616bea8 100644 --- a/src/SPC/builder/extension/ldap.php +++ b/src/SPC/builder/extension/ldap.php @@ -20,9 +20,4 @@ class ldap extends Extension } return true; } - - public function getUnixConfigureArg(bool $shared = false): string - { - return '--with-ldap=' . BUILD_ROOT_PATH; - } } diff --git a/src/SPC/builder/extension/mbstring.php b/src/SPC/builder/extension/mbstring.php index 42249509..697ad3fe 100644 --- a/src/SPC/builder/extension/mbstring.php +++ b/src/SPC/builder/extension/mbstring.php @@ -23,7 +23,7 @@ class mbstring extends Extension public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-mbstring'; + $arg = '--enable-mbstring' . ($shared ? '=shared' : ''); if ($this->builder->getExt('mbregex') === null) { $arg .= ' --disable-mbregex'; } else { diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index d36df758..3c8b5dff 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -29,9 +29,7 @@ class xml extends Extension 'simplexml' => '--enable-simplexml', default => throw new RuntimeException('Not accept non-xml extension'), }; - if (!$shared) { - $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; - } + $arg .= ($shared ? '=shared' : '' ) . ' --with-libxml="' . BUILD_ROOT_PATH . '"'; return $arg; } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 9b901460..0a827c85 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -322,7 +322,7 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = ' . BUILD_MODULES_PATH . '|" Makefile') + ->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); $this->patchPhpScripts(); } diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 799c87c2..6de23e3e 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -47,5 +47,6 @@ trait libxslt ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH)); $this->patchPkgconfPrefix(['libexslt.pc']); + $this->patchLaDependencyPrefix(['libxslt.la', 'libexslt.la']); } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 24ba666c..0c02e155 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -95,7 +95,7 @@ class SourcePatcher */ public static function patchBeforeConfigure(BuilderBase $builder): void { - foreach ($builder->getExts(false) as $ext) { + foreach ($builder->getExts() as $ext) { if ($ext->patchBeforeConfigure() === true) { logger()->info('Extension [' . $ext->getName() . '] patched before configure'); } From 7698ceb10857051cd9a84fdfa55b40821bdb8c30 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 14:10:56 +0700 Subject: [PATCH 044/319] fixes for more configure args --- config/ext.json | 16 ++++++------- src/SPC/builder/Extension.php | 2 +- src/SPC/builder/extension/dba.php | 2 +- src/SPC/builder/extension/dom.php | 4 +--- src/SPC/builder/extension/mbstring.php | 2 +- src/SPC/builder/extension/odbc.php | 2 +- src/SPC/builder/extension/pdo_odbc.php | 2 +- src/SPC/builder/extension/pgsql.php | 4 ++-- src/SPC/builder/extension/readline.php | 2 +- src/SPC/builder/extension/sqlsrv.php | 32 ++++++++++++++++++++++++++ src/SPC/builder/extension/xhprof.php | 32 ++++++++++++++++++++++++++ src/SPC/command/BuildPHPCommand.php | 6 ++++- 12 files changed, 86 insertions(+), 20 deletions(-) diff --git a/config/ext.json b/config/ext.json index 89f17dc7..290a079b 100644 --- a/config/ext.json +++ b/config/ext.json @@ -77,12 +77,6 @@ ], "ext-depends-windows": [ "xml" - ], - "shared-ext-depends": [ - "libxml", - "xmlreader", - "xmlwriter", - "xml" ] }, "ds": { @@ -331,13 +325,16 @@ }, "type": "builtin", "arg-type": "none", - "ext-depends": [ - "xml" + "target": [ + "static" ] }, "mbregex": { "type": "builtin", "arg-type": "custom", + "target": [ + "static" + ], "ext-depends": [ "mbstring" ], @@ -1083,6 +1080,9 @@ "arg-type-windows": "enable", "lib-depends": [ "zlib" + ], + "target": [ + "static" ] }, "zstd": { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6b00bfae..3152dd3e 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -80,7 +80,7 @@ class Extension { $_name = str_replace('_', '-', $this->name); return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) { - 'enable' => '--enable-' . $_name . ' ', + 'enable' => '--enable-' . $_name . ($shared ? '=shared' : '') . ' ', 'with' => '--with-' . $_name . ($shared ? '=shared' : '') . ' ', 'with-prefix' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . '"' . BUILD_ROOT_PATH . '" ', 'none', 'custom' => '', diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php index 4a69c0a5..abda5651 100644 --- a/src/SPC/builder/extension/dba.php +++ b/src/SPC/builder/extension/dba.php @@ -13,7 +13,7 @@ class dba extends Extension public function getUnixConfigureArg(bool $shared = false): string { $qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : ''; - return '--enable-dba' . $qdbm; + return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm; } public function getWindowsConfigureArg(bool $shared = false): string diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index 46dae9e2..fb1a4e15 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -18,9 +18,7 @@ class dom extends Extension public function getUnixConfigureArg(bool $shared = false): string { $arg = '--enable-dom' . ($shared ? '=shared' : ''); - if (!$shared) { - $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; - } + $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; return $arg; } diff --git a/src/SPC/builder/extension/mbstring.php b/src/SPC/builder/extension/mbstring.php index 697ad3fe..3576877f 100644 --- a/src/SPC/builder/extension/mbstring.php +++ b/src/SPC/builder/extension/mbstring.php @@ -12,7 +12,7 @@ class mbstring extends Extension { public function getConfigureArg(bool $shared = false): string { - $arg = '--enable-mbstring'; + $arg = '--enable-mbstring' . ($shared ? '=shared' : ''); if ($this->builder->getExt('mbregex') === null) { $arg .= ' --disable-mbregex'; } else { diff --git a/src/SPC/builder/extension/odbc.php b/src/SPC/builder/extension/odbc.php index ac5c3e8f..278b5865 100644 --- a/src/SPC/builder/extension/odbc.php +++ b/src/SPC/builder/extension/odbc.php @@ -12,6 +12,6 @@ class odbc extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - return '--with-unixODBC=' . BUILD_ROOT_PATH; + return '--with-unixODBC=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } } diff --git a/src/SPC/builder/extension/pdo_odbc.php b/src/SPC/builder/extension/pdo_odbc.php index ac1b7456..c47144fe 100644 --- a/src/SPC/builder/extension/pdo_odbc.php +++ b/src/SPC/builder/extension/pdo_odbc.php @@ -19,7 +19,7 @@ class pdo_odbc extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--with-pdo-odbc=unixODBC,' . BUILD_ROOT_PATH; + return '--with-pdo-odbc=' . ($shared ? 'shared,' : '') . 'unixODBC,' . BUILD_ROOT_PATH; } public function getWindowsConfigureArg(bool $shared = false): string diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index e4ac8ebb..b45ba667 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -36,9 +36,9 @@ class pgsql extends Extension public function getUnixConfigureArg(bool $shared = false): string { if ($this->builder->getPHPVersionID() >= 80400) { - return '--with-pgsql PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"'; + return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"'; } - return '--with-pgsql=' . BUILD_ROOT_PATH; + return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } /** diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index dc4d15f7..5cb5eff3 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -27,7 +27,7 @@ class readline extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; + return '--without-libedit --with-readline=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } public function buildUnixShared(): void diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index edf5d919..22aef95b 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -7,6 +7,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('sqlsrv')] class sqlsrv extends Extension @@ -33,4 +34,35 @@ class sqlsrv extends Extension } return false; } + + public function buildUnixShared(): void + { + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'], + 'CXXFLAGS' => $config['cflags'], + 'LDFLAGS' => $config['ldflags'], + 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, + ]; + // prepare configure args + shell()->cd($this->source_dir) + ->setEnv($env) + ->execWithEnv(BUILD_BIN_PATH . '/phpize'); + + if ($this->patchBeforeSharedConfigure()) { + logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); + } + + shell()->cd($this->source_dir) + ->setEnv($env) + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency) + ->execWithEnv('make install'); + + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } } } diff --git a/src/SPC/builder/extension/xhprof.php b/src/SPC/builder/extension/xhprof.php index c3d98aac..118a34cd 100644 --- a/src/SPC/builder/extension/xhprof.php +++ b/src/SPC/builder/extension/xhprof.php @@ -7,6 +7,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('xhprof')] class xhprof extends Extension @@ -30,4 +31,35 @@ class xhprof extends Extension } return false; } + + public function buildUnixShared(): void + { + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'], + 'LDFLAGS' => $config['ldflags'], + 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, + ]; + // prepare configure args + shell()->cd($this->source_dir . '/extension') + ->setEnv($env) + ->execWithEnv(BUILD_BIN_PATH . '/phpize'); + + if ($this->patchBeforeSharedConfigure()) { + logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); + } + + shell()->cd($this->source_dir . '/extension') + ->setEnv($env) + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency) + ->execWithEnv('make install'); + + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } + } } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index edeb7c47..cd83c1c8 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -249,7 +249,11 @@ class BuildPHPCommand extends BuildCommand if (!empty($shared_extensions)) { foreach ($shared_extensions as $ext) { $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); - logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); + if (file_exists("{$build_root_path}/modules/{$ext}.so")) { + logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); + } else { + logger()->warning("Shared extension [{$ext}] not found, please check!"); + } } } From 3f8d297fb131ed1e66aa7ff7f42fd2c98f1396a1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 14:15:58 +0700 Subject: [PATCH 045/319] linter --- src/SPC/builder/Extension.php | 2 +- src/SPC/builder/extension/curl.php | 5 ++--- src/SPC/builder/extension/mbregex.php | 5 ----- src/SPC/builder/extension/sqlsrv.php | 3 ++- src/SPC/builder/extension/xml.php | 2 +- src/SPC/builder/traits/UnixLibraryTrait.php | 4 ++-- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 3152dd3e..0cda99b6 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -336,7 +336,7 @@ class Extension if ($this->patchBeforeSharedConfigure()) { logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); } - + shell()->cd($this->source_dir) ->setEnv($env) ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index 0fd2b90b..4779e67c 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -74,7 +74,6 @@ class curl extends Extension // Match the line containing PHP_CHECK_LIBRARY for curl $pattern = '/(PHP_CHECK_LIBRARY\(\[curl],\s*\[curl_easy_perform],)/'; - // Restore LIBS after the check — append this just after the macro block $restore = ' LIBS="$save_LIBS"'; @@ -87,13 +86,13 @@ class curl extends Extension // Inject restore after the matching PHP_CHECK_LIBRARY block $patched = preg_replace( '/(PHP_CHECK_LIBRARY\(\[curl],\s*\[curl_easy_perform],.*?\)\n)/s', - "$1$restore\n", + "$1{$restore}\n", $patched, 1 ); if ($patched === null) { - throw new \RuntimeException("Failed to patch config.m4 due to a regex error"); + throw new \RuntimeException('Failed to patch config.m4 due to a regex error'); } FileSystem::writeFile($file, $patched); diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index b7d174ff..1f169e1a 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -21,11 +21,6 @@ class mbregex extends Extension return ''; } - public function buildUnixShared(): void - { - print('mbregex is already built as part of mbstring, skipping build' . PHP_EOL); - } - /** * mbregex is not an extension, we need to overwrite the default check. */ diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index 22aef95b..f6cd21a0 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -64,5 +64,6 @@ class sqlsrv extends Extension // check shared extension with php-cli if (file_exists(BUILD_BIN_PATH . '/php')) { $this->runSharedExtensionCheckUnix(); - } } + } + } } diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index 3c8b5dff..bd64d346 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -29,7 +29,7 @@ class xml extends Extension 'simplexml' => '--enable-simplexml', default => throw new RuntimeException('Not accept non-xml extension'), }; - $arg .= ($shared ? '=shared' : '' ) . ' --with-libxml="' . BUILD_ROOT_PATH . '"'; + $arg .= ($shared ? '=shared' : '') . ' --with-libxml="' . BUILD_ROOT_PATH . '"'; return $arg; } diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 45de0cf4..962f257f 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -95,8 +95,8 @@ trait UnixLibraryTrait logger()->debug('Patching ' . $realpath); // replace prefix $file = FileSystem::readFile($realpath); - $file = str_replace(' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); - $file = preg_replace("/^libdir=.*$/m", "libdir='" . BUILD_LIB_PATH . "'", $file); + $file = str_replace(' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); + + $file = preg_replace('/^libdir=.*$/m', "libdir='" . BUILD_LIB_PATH . "'", $file); FileSystem::writeFile($realpath, $file); } } From d349627fa15b8a93c2fecb069762e651c6235515 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 14:29:49 +0700 Subject: [PATCH 046/319] linter --- config/ext.json | 3 +++ src/SPC/builder/extension/readline.php | 2 +- src/SPC/builder/traits/UnixLibraryTrait.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index 290a079b..eaa27d1b 100644 --- a/config/ext.json +++ b/config/ext.json @@ -643,6 +643,9 @@ "arg-type": "with-prefix", "lib-depends": [ "readline" + ], + "target": [ + "static" ] }, "redis": { diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index 5cb5eff3..dc4d15f7 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -27,7 +27,7 @@ class readline extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--without-libedit --with-readline=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; + return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; } public function buildUnixShared(): void diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 962f257f..869bf531 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -96,7 +96,7 @@ trait UnixLibraryTrait // replace prefix $file = FileSystem::readFile($realpath); $file = str_replace(' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); - + $file = preg_replace('/^libdir=.*$/m', "libdir='" . BUILD_LIB_PATH . "'", $file); + $file = preg_replace('/^libdir=.*$/m', "libdir='" . BUILD_LIB_PATH . "'", $file); FileSystem::writeFile($realpath, $file); } } From 11c116480f75c61705a3c3307a783c5ba23338fc Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 17:57:53 +0700 Subject: [PATCH 047/319] fix spx --- config/ext.json | 5 ++- src/SPC/builder/BuilderBase.php | 28 ++++++++++------- src/SPC/builder/Extension.php | 35 +++++++++++++++++++-- src/SPC/builder/extension/mbregex.php | 3 +- src/SPC/builder/extension/spx.php | 8 +++++ src/SPC/builder/traits/UnixLibraryTrait.php | 3 +- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 7 files changed, 67 insertions(+), 17 deletions(-) diff --git a/config/ext.json b/config/ext.json index eaa27d1b..629b753f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -95,7 +95,10 @@ "ev": { "type": "external", "source": "ev", - "arg-type-windows": "with" + "arg-type-windows": "with", + "shared-ext-depends": [ + "sockets" + ] }, "event": { "support": { diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 0e4c0603..2e0fe3ec 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -252,20 +252,26 @@ abstract class BuilderBase } file_put_contents(BUILD_BIN_PATH . '/php-config', implode('', $lines)); FileSystem::createDir(BUILD_MODULES_PATH); - foreach ($this->getExts() as $ext) { - if (!$ext->isBuildShared()) { - continue; - } - if (Config::getExt($ext->getName(), 'type') === 'builtin') { - if (file_exists(BUILD_MODULES_PATH . '/' . $ext->getName() . '.so')) { - logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); + try { + foreach ($this->getExts() as $ext) { + if (!$ext->isBuildShared()) { continue; } - logger()->warning('Shared extension [' . $ext->getName() . '] was built statically by php-src/configure'); - continue; + if (Config::getExt($ext->getName(), 'type') === 'builtin') { + if (file_exists(BUILD_MODULES_PATH . '/' . $ext->getName() . '.so')) { + logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); + continue; + } + logger()->warning('Shared extension [' . $ext->getName() . '] was built statically by php-src/configure'); + continue; + } + logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); + $ext->buildShared(); } - logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); - $ext->buildShared(); + } + catch (RuntimeException $e) { + FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); + throw $e; } FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); } diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 0cda99b6..e79c3db9 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -221,6 +221,36 @@ class Extension } } + public function getRequiredSharedExtensions(): string + { + $loaded = []; + $order = []; + + $resolve = function ($extension) use (&$resolve, &$loaded, &$order) { + if (isset($loaded[$extension->getName()])) { + return; + } + $loaded[$extension->getName()] = true; + + foreach ($this->dependencies as $dependency) { + $resolve($dependency); + } + + $order[] = $extension; + }; + + $resolve($this); + + $ret = ''; + foreach ($order as $ext) { + if ($ext instanceof Extension && $ext->isBuildShared()) { + $ret .= ' -d "extension=' . BUILD_MODULES_PATH . '/' . $ext->getName() . '.so"'; + } + } + + return $ret; + } + /** * @throws RuntimeException */ @@ -229,7 +259,8 @@ class Extension // Run compile check if build target is cli // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "' . $this->getDistName() . '"', false); + $sharedExtensions = $this->getRequiredSharedExtensions(); + [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); } @@ -242,7 +273,7 @@ class Extension file_get_contents(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php') ); - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "' . trim($test) . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"'); if ($ret !== 0) { if ($this->builder->getOption('debug')) { var_dump($out); diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 1f169e1a..a26e7024 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -26,7 +26,8 @@ class mbregex extends Extension */ public function runCliCheckUnix(): void { - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring" | grep regex', false); + $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=' . BUILD_MODULES_PATH . '/mbstring.so"' : ''; + [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); } diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index a797a126..dccf131c 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('spx')] @@ -18,4 +19,11 @@ class spx extends Extension } return $arg; } + + public function patchBeforeSharedConfigure(): bool + { + FileSystem::replaceFileStr($this->source_dir . '/config.m4', 'PHP_ARG_ENABLE(SPX-DEV,', 'PHP_ARG_ENABLE(spx-dev,'); + FileSystem::replaceFileStr($this->source_dir . '/config.m4', 'PHP_ARG_ENABLE(SPX,', 'PHP_ARG_ENABLE(spx,'); + return true; + } } diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 869bf531..2d71c8eb 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -95,7 +95,8 @@ trait UnixLibraryTrait logger()->debug('Patching ' . $realpath); // replace prefix $file = FileSystem::readFile($realpath); - $file = str_replace(' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); + $file = str_replace( + ' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); $file = preg_replace('/^libdir=.*$/m', "libdir='" . BUILD_LIB_PATH . "'", $file); FileSystem::writeFile($realpath, $file); } diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 48c82601..b92c2b7e 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -146,7 +146,7 @@ abstract class UnixBuilderBase extends BuilderBase throw new RuntimeException("cli failed sanity check: ret[{$ret}]. out[{$raw_output}]"); } - foreach ($this->getExts(false) as $ext) { + foreach ($this->getExts() as $ext) { logger()->debug('testing ext: ' . $ext->getName()); $ext->runCliCheckUnix(); } From 3ff31d20cf519c484a35641f80a20b21e790b2a0 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 17:58:11 +0700 Subject: [PATCH 048/319] fix undefined references to brotlicommon functions in gd.so --- src/SPC/builder/BuilderBase.php | 3 +-- src/SPC/builder/traits/UnixLibraryTrait.php | 5 ++++- src/SPC/builder/unix/library/brotli.php | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 2e0fe3ec..caece586 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -268,8 +268,7 @@ abstract class BuilderBase logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); $ext->buildShared(); } - } - catch (RuntimeException $e) { + } catch (RuntimeException $e) { FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); throw $e; } diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 2d71c8eb..74d8fd37 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -96,7 +96,10 @@ trait UnixLibraryTrait // replace prefix $file = FileSystem::readFile($realpath); $file = str_replace( - ' /lib/', ' ' . BUILD_LIB_PATH . '/', $file); + ' /lib/', + ' ' . BUILD_LIB_PATH . '/', + $file + ); $file = preg_replace('/^libdir=.*$/m', "libdir='" . BUILD_LIB_PATH . "'", $file); FileSystem::writeFile($realpath, $file); } diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 44be934d..30c862d2 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -36,6 +36,8 @@ trait brotli ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); + FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlidec.pc', 'Libs: -L${libdir} -lbrotlidec', 'Libs: -L${libdir} -lbrotlidec -lbrotlicommon'); + FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlienc.pc', 'Libs: -L${libdir} -lbrotlienc', 'Libs: -L${libdir} -lbrotlidec -lbrotlicommon'); shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a'); foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { From fc7df585bdd6908a2b2ad779932f546d4eb12955 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 18:01:41 +0700 Subject: [PATCH 049/319] msgpack requires session --- config/ext.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index 629b753f..02d778ce 100644 --- a/config/ext.json +++ b/config/ext.json @@ -412,7 +412,10 @@ "type": "external", "source": "msgpack", "arg-type-unix": "with", - "arg-type-win": "enable" + "arg-type-win": "enable", + "shared-ext-depends": [ + "sockets" + ] }, "mysqli": { "type": "builtin", From af51469b6285dcda7b76819a3aa5fbe4278d71c5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 18:04:38 +0700 Subject: [PATCH 050/319] session, not sockets... --- config/ext.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index 02d778ce..af3c48bc 100644 --- a/config/ext.json +++ b/config/ext.json @@ -414,7 +414,7 @@ "arg-type-unix": "with", "arg-type-win": "enable", "shared-ext-depends": [ - "sockets" + "session" ] }, "mysqli": { From b376d1682fc5ade4ef8ec61269cd1cf967cf3005 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 18:35:48 +0700 Subject: [PATCH 051/319] remove runSharedExtensionCheckUnix --- src/SPC/builder/BuilderBase.php | 5 ++++ src/SPC/builder/Extension.php | 35 ++++++++---------------- src/SPC/builder/extension/opcache.php | 16 ++++------- src/SPC/builder/extension/pdo_sqlsrv.php | 5 ---- src/SPC/builder/extension/sqlsrv.php | 5 ---- src/SPC/builder/extension/xdebug.php | 11 ++------ src/SPC/builder/extension/xhprof.php | 5 ---- src/SPC/builder/freebsd/BSDBuilder.php | 3 ++ src/SPC/builder/linux/LinuxBuilder.php | 3 ++ src/SPC/builder/macos/MacOSBuilder.php | 6 ++++ src/SPC/builder/unix/UnixBuilderBase.php | 10 +++++-- src/SPC/command/BuildPHPCommand.php | 2 ++ 12 files changed, 45 insertions(+), 61 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index caece586..08c580ea 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -234,6 +234,11 @@ abstract class BuilderBase */ abstract public function buildPHP(int $build_target = BUILD_TARGET_NONE); + /** + * Test PHP + */ + abstract public function testPHP(int $build_target = BUILD_TARGET_NONE); + /** * @throws WrongUsageException * @throws RuntimeException diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index e79c3db9..a0a1e6d2 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -206,21 +206,6 @@ class Extension return false; } - /** - * Run shared extension check when cli is enabled - * @throws RuntimeException - */ - public function runSharedExtensionCheckUnix(): void - { - [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "extension=' . BUILD_MODULES_PATH . '/' . $this->getName() . '.so" --ri ' . $this->getName()); - if ($ret !== 0) { - throw new RuntimeException($this->getName() . '.so failed to load'); - } - if ($this->isBuildStatic()) { - logger()->warning($this->getName() . '.so test succeeded, but has little significance since it is also compiled in statically.'); - } - } - public function getRequiredSharedExtensions(): string { $loaded = []; @@ -244,7 +229,11 @@ class Extension $ret = ''; foreach ($order as $ext) { if ($ext instanceof Extension && $ext->isBuildShared()) { - $ret .= ' -d "extension=' . BUILD_MODULES_PATH . '/' . $ext->getName() . '.so"'; + if ($ext->isZendExtension()) { + $ret .= ' -d "zend_extension=' . BUILD_MODULES_PATH . '/' . $ext->getName() . '.so"'; + } else { + $ret .= ' -d "extension=' . BUILD_MODULES_PATH . '/' . $ext->getName() . '.so"'; + } } } @@ -260,7 +249,7 @@ class Extension // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException $sharedExtensions = $this->getRequiredSharedExtensions(); - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); + [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); } @@ -273,7 +262,7 @@ class Extension file_get_contents(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php') ); - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' -r "' . trim($test) . '"'); if ($ret !== 0) { if ($this->builder->getOption('debug')) { var_dump($out); @@ -374,11 +363,6 @@ class Extension ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); - - // check shared extension with php-cli - if (file_exists(BUILD_BIN_PATH . '/php')) { - $this->runSharedExtensionCheckUnix(); - } } /** @@ -449,6 +433,11 @@ class Extension } } + protected function isZendExtension(): bool + { + return false; + } + private function getLibraryDependencies(bool $recursive = false): array { $ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase); diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index ec468cb8..865bf487 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -24,17 +24,6 @@ class opcache extends Extension } } - public function runSharedExtensionCheckUnix(): void - { - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_MODULES_PATH . '/opcache.so" -v'); - if ($ret !== 0) { - throw new RuntimeException('opcache.so failed to load.'); - } - if (!str_contains(join($out), 'with Zend OPcache')) { - throw new RuntimeException('opcache.so failed to load.'); - } - } - public function patchBeforeBuildconf(): bool { if (file_exists(SOURCE_PATH . '/php-src/.opcache_patched')) { @@ -62,4 +51,9 @@ class opcache extends Extension { return 'Zend Opcache'; } + + protected function isZendExtension(): bool + { + return true; + } } diff --git a/src/SPC/builder/extension/pdo_sqlsrv.php b/src/SPC/builder/extension/pdo_sqlsrv.php index 195eaffe..75166903 100644 --- a/src/SPC/builder/extension/pdo_sqlsrv.php +++ b/src/SPC/builder/extension/pdo_sqlsrv.php @@ -29,10 +29,5 @@ class pdo_sqlsrv extends Extension ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); - - // check shared extension with php-cli - if (file_exists(BUILD_BIN_PATH . '/php')) { - $this->runSharedExtensionCheckUnix(); - } } } diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index f6cd21a0..55a2b6a0 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -60,10 +60,5 @@ class sqlsrv extends Extension ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); - - // check shared extension with php-cli - if (file_exists(BUILD_BIN_PATH . '/php')) { - $this->runSharedExtensionCheckUnix(); - } } } diff --git a/src/SPC/builder/extension/xdebug.php b/src/SPC/builder/extension/xdebug.php index 367eb420..90f225ae 100644 --- a/src/SPC/builder/extension/xdebug.php +++ b/src/SPC/builder/extension/xdebug.php @@ -5,20 +5,13 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\exception\RuntimeException; use SPC\util\CustomExt; #[CustomExt('xdebug')] class xdebug extends Extension { - public function runSharedExtensionCheckUnix(): void + protected function isZendExtension(): bool { - [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -d "zend_extension=' . BUILD_MODULES_PATH . '/xdebug.so" -v'); - if ($ret !== 0) { - throw new RuntimeException('xdebug.so failed to load.'); - } - if (!str_contains(join($out), 'with Xdebug')) { - throw new RuntimeException('xdebug.so failed to load.'); - } + return str_contains($this->builder->getExt('zend')->getName(), 'xdebug'); } } diff --git a/src/SPC/builder/extension/xhprof.php b/src/SPC/builder/extension/xhprof.php index 118a34cd..589ac583 100644 --- a/src/SPC/builder/extension/xhprof.php +++ b/src/SPC/builder/extension/xhprof.php @@ -56,10 +56,5 @@ class xhprof extends Extension ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); - - // check shared extension with php-cli - if (file_exists(BUILD_BIN_PATH . '/php')) { - $this->runSharedExtensionCheckUnix(); - } } } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index b2e246b3..7c10881f 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -145,7 +145,10 @@ class BSDBuilder extends UnixBuilderBase } $this->buildEmbed(); } + } + public function testPHP(int $build_target = BUILD_TARGET_NONE) + { if (php_uname('m') === $this->getOption('arch')) { $this->emitPatchPoint('before-sanity-check'); $this->sanityCheck($build_target); diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 0a827c85..0a814907 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -222,7 +222,10 @@ class LinuxBuilder extends UnixBuilderBase } $this->buildEmbed(); } + } + public function testPHP(int $build_target = BUILD_TARGET_NONE) + { $this->emitPatchPoint('before-sanity-check'); $this->sanityCheck($build_target); } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 9f9ad684..7d82f191 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -209,6 +209,12 @@ class MacOSBuilder extends UnixBuilderBase $this->sanityCheck($build_target); } + public function testPHP(int $build_target = BUILD_TARGET_NONE) + { + $this->emitPatchPoint('before-sanity-check'); + $this->sanityCheck($build_target); + } + /** * Build cli sapi * diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index b92c2b7e..d645a68f 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -138,9 +138,9 @@ abstract class UnixBuilderBase extends BuilderBase protected function sanityCheck(int $build_target): void { // sanity check for php-cli - if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { + if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI || file_exists(BUILD_BIN_PATH . '/php')) { logger()->info('running cli sanity check'); - [$ret, $output] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "echo \"hello\";"'); + [$ret, $output] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -r "echo \"hello\";"'); $raw_output = implode('', $output); if ($ret !== 0 || trim($raw_output) !== 'hello') { throw new RuntimeException("cli failed sanity check: ret[{$ret}]. out[{$raw_output}]"); @@ -173,7 +173,11 @@ abstract class UnixBuilderBase extends BuilderBase } // sanity check for embed - if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) { + if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED || + file_exists(BUILD_BIN_PATH . '/php-config') && + file_exists(BUILD_BIN_PATH . '/phpize') && + (file_exists(BUILD_LIB_PATH . '/libphp.a') || file_exists(BUILD_LIB_PATH . '/libphp.so')) + ) { logger()->info('running embed sanity check'); $sample_file_path = SOURCE_PATH . '/embed-test'; if (!is_dir($sample_file_path)) { diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 550fad3f..6c64995c 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -218,6 +218,8 @@ class BuildPHPCommand extends BuildCommand $builder->buildSharedExts(); } + $builder->testPHP($rule); + // compile stopwatch :P $time = round(microtime(true) - START_TIME, 3); logger()->info(''); From b68d71b7b76e10d6b9b29d662c7087648fb40105 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 19:22:15 +0700 Subject: [PATCH 052/319] testPHP in windowsbuilder --- src/SPC/builder/windows/WindowsBuilder.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 7a604ca8..c7643143 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -146,7 +146,10 @@ class WindowsBuilder extends BuilderBase // logger()->info('building embed'); $this->buildEmbed(); } + } + public function testPHP(int $build_target = BUILD_TARGET_NONE) + { $this->sanityCheck($build_target); } From e3d7969b960bf108a70735c094c07a134cf9bb15 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 20:03:21 +0700 Subject: [PATCH 053/319] select all quick button --- docs/.vitepress/components/CliGenerator.vue | 23 +++++++++++++++++++++ src/SPC/builder/extension/pgsql.php | 7 ++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue index e3537d87..4c8d096a 100644 --- a/docs/.vitepress/components/CliGenerator.vue +++ b/docs/.vitepress/components/CliGenerator.vue @@ -30,6 +30,7 @@
{{ I18N[lang].selectCommon }}
+
{{ I18N[lang].selectAll }}
{{ I18N[lang].selectNone }}
@@ -246,6 +247,7 @@ const I18N = { no: '否', resultShow: '结果展示', selectCommon: '选择常用扩展', + selectAll: '选择全部', selectNone: '全部取消选择', useZTS: '是否编译线程安全版', hardcodedINI: '硬编码 INI 选项', @@ -280,6 +282,7 @@ const I18N = { no: 'No', resultShow: 'Result', selectCommon: 'Select common extensions', + selectAll: 'Select all', selectNone: 'Unselect all', useZTS: 'Enable ZTS', hardcodedINI: 'Hardcoded INI options', @@ -331,6 +334,26 @@ const selectCommon = () => { ]; }; +const selectAll = () => { + checkedExts.value = [ + 'amqp', 'apcu', 'ast', 'bcmath', 'bz2', 'calendar', 'ctype', 'curl', + 'dba', 'dio', 'dom', 'ds', 'ev', 'event', 'exif', 'ffi', 'fileinfo', + 'filter', 'ftp', 'gd', 'gettext', 'gmp', 'gmssl', 'grpc', 'iconv', + 'igbinary', 'imagick', 'imap', 'inotify', 'intl', 'ldap', 'libxml', + 'mbregex', 'mbstring', 'memcache', 'mongodb', 'msgpack', 'mysqli', + 'mysqlnd', 'odbc', 'opcache', 'openssl', 'opentelemetry', 'parallel', + 'password-argon2', 'pcntl', 'pdo', 'pdo_mysql', 'pdo_odbc', + 'pdo_pgsql', 'pdo_sqlite', 'pdo_sqlsrv', 'pgsql', 'phar', 'posix', + 'protobuf', 'rar', 'rdkafka', 'readline', 'redis', 'session', 'shmop', + 'simdjson', 'simplexml', 'snappy', 'soap', 'sockets', 'sodium', 'spx', + 'sqlite3', 'sqlsrv', 'ssh2', 'swoole', 'swoole-hook-mysql', + 'swoole-hook-pgsql', 'swoole-hook-sqlite', 'swow', 'sysvmsg', + 'sysvsem', 'sysvshm', 'tidy', 'tokenizer', 'uuid', 'uv', 'xdebug', + 'xhprof', 'xlswriter', 'xml', 'xmlreader', 'xmlwriter', 'xsl', 'yac', + 'zip', 'zlib', + ]; +}; + const extList = computed(() => { return checkedExts.value.join(','); }); diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index b45ba667..a70c1fb7 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -36,7 +36,12 @@ class pgsql extends Extension public function getUnixConfigureArg(bool $shared = false): string { if ($this->builder->getPHPVersionID() >= 80400) { - return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"'; + $libfiles = $this->getLibFilesString(); + $libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles); + $libfiles = str_replace('.a', '', $libfiles); + return '--with-pgsql' . ($shared ? '=shared' : '') . + ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . + ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"'; } return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } From 4a442825567c9423bada46fd16ef9fb1d2029ecf Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 20:12:12 +0700 Subject: [PATCH 054/319] shoehorn the lot in, I don't know how to fix this otherwise --- src/SPC/builder/extension/pgsql.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index a70c1fb7..a659ae72 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -39,9 +39,12 @@ class pgsql extends Extension $libfiles = $this->getLibFilesString(); $libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles); $libfiles = str_replace('.a', '', $libfiles); + $libfiles = str_replace(' -lpq', '', $libfiles); + $libfiles = str_replace(' -lpgport', '', $libfiles); + $libfiles = str_replace(' -lpgcommon', '', $libfiles); return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . - ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"'; + ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -Wl,--whole-archive -lpq -lpgport -lpgcommon -Wl,--no-whole-archive ' . $libfiles . '"'; } return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } From 64b6f98ce7e38d14c06984a7586da48c22697c07 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 21 May 2025 20:43:10 +0700 Subject: [PATCH 055/319] the flag doesn't fix it, the problem is something else --- src/SPC/builder/extension/pgsql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index a659ae72..df852f4b 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -44,7 +44,7 @@ class pgsql extends Extension $libfiles = str_replace(' -lpgcommon', '', $libfiles); return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . - ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -Wl,--whole-archive -lpq -lpgport -lpgcommon -Wl,--no-whole-archive ' . $libfiles . '"'; + ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon ' . $libfiles . '"'; } return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } From c29ca9722f995e3243d57152c72e29396a41bea3 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:26:25 +0700 Subject: [PATCH 056/319] add -lbrotlienc to curl --- src/SPC/builder/unix/library/curl.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index c37dedf6..be9351b5 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -65,6 +65,26 @@ trait curl ->execWithEnv('make install'); // patch pkgconf $this->patchPkgconfPrefix(['libcurl.pc']); + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', + '-lbrolienc -lbrotlidec -lbrotlicommon', + '-lbrotlidec -lbrotlicommon' + ); + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', + '-lbrotlidec -lbrotlicommon', + '-lbrolienc -lbrotlidec -lbrotlicommon' + ); + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', + 'libbrotlienc,libbrotlidec,libbrotlicommon', + 'libbrotlidec,libbrotlicommon' + ); + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', + 'libbrotlidec,libbrotlicommon', + 'libbrotlienc,libbrotlidec,libbrotlicommon' + ); shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/') ->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake"); } From 310be957b667837492a50bd0529ec96ec9783e6a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:27:01 +0700 Subject: [PATCH 057/319] new build-with-php key for extensions --- config/ext.json | 21 ++++++++++++++++----- src/SPC/builder/BuilderBase.php | 16 +++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/config/ext.json b/config/ext.json index af3c48bc..1cf99d1f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -370,6 +370,9 @@ "ext-depends": [ "zlib", "session" + ], + "shared-ext-depends": [ + "session" ] }, "memcached": { @@ -388,6 +391,9 @@ "ext-depends": [ "session", "zlib" + ], + "shared-ext-depends": [ + "session" ] }, "mongodb": { @@ -692,7 +698,8 @@ ], "ext-depends-windows": [ "xml" - ] + ], + "build-with-php": true }, "snappy": { "support": { @@ -912,7 +919,8 @@ ] }, "tokenizer": { - "type": "builtin" + "type": "builtin", + "build-with-php": true }, "uuid": { "support": { @@ -995,7 +1003,8 @@ ], "ext-depends-windows": [ "iconv" - ] + ], + "build-with-php": true }, "xmlreader": { "support": { @@ -1009,7 +1018,8 @@ "ext-depends-windows": [ "xml", "dom" - ] + ], + "build-with-php": true }, "xmlwriter": { "support": { @@ -1022,7 +1032,8 @@ ], "ext-depends-windows": [ "xml" - ] + ], + "build-with-php": true }, "xsl": { "support": { diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 08c580ea..599ccdc6 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -262,15 +262,17 @@ abstract class BuilderBase if (!$ext->isBuildShared()) { continue; } - if (Config::getExt($ext->getName(), 'type') === 'builtin') { + if (Config::getExt($ext->getName(), 'type') === 'builtin' || Config::getExt($ext->getName(), 'build-with-php') === true) { if (file_exists(BUILD_MODULES_PATH . '/' . $ext->getName() . '.so')) { logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); continue; } - logger()->warning('Shared extension [' . $ext->getName() . '] was built statically by php-src/configure'); - continue; + if (Config::getExt($ext->getName(), 'build-with-php') === true) { + logger()->warning('Shared extension [' . $ext->getName() . '] did not build with php-src/configure (' . $ext->getName() . '.so)'); + logger()->warning('Try deleting your build and source folders and running `spc build`` again.'); + continue; + } } - logger()->info('Building extension [' . $ext->getName() . '] as shared extension (' . $ext->getName() . '.so)'); $ext->buildShared(); } } catch (RuntimeException $e) { @@ -293,7 +295,11 @@ abstract class BuilderBase foreach ($this->getExts() as $ext) { $arg = $ext->getConfigureArg(); if ($ext->isBuildShared()) { - if (Config::getExt($ext->getName(), 'type') === 'builtin') { + if ( + (Config::getExt($ext->getName(), 'type') === 'builtin' && + !file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) || + Config::getExt($ext->getName(), 'build-with-php') === true + ) { $arg = $ext->getConfigureArg(true); } else { continue; From 3713ae8c93eee3b3e270cf004c540cd439050967 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:27:41 +0700 Subject: [PATCH 058/319] extra dependencies for extensions --- src/SPC/builder/Extension.php | 26 +++++++++++++++++---- src/SPC/builder/extension/spx.php | 10 +------- src/SPC/builder/extension/xdebug.php | 2 +- src/SPC/store/SourcePatcher.php | 2 +- src/SPC/util/SPCConfigUtil.php | 35 ++++++++++++++++++++++++---- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index a0a1e6d2..8d975837 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -313,6 +313,7 @@ class Extension */ public function buildShared(): void { + logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)'); if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { logger()->info('extension ' . $this->getName() . ' already built, skipping'); return; @@ -322,7 +323,10 @@ class Extension if ($dependencyExt === null) { throw new RuntimeException("extension {$this->name} requires shared extension {$name}"); } - $dependencyExt->buildShared(); + if ($dependencyExt->isBuildShared()) { + logger()->info('extension ' . $this->getName() . ' requires shared extension ' . $name); + $dependencyExt->buildShared(); + } } match (PHP_OS_FAMILY) { 'Darwin', 'Linux' => $this->buildUnixShared(), @@ -341,11 +345,25 @@ class Extension */ public function buildUnixShared(): void { - $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); + $sharedLibs = ''; + $staticLibs = ''; + foreach (explode('-l', $config['libs']) as $lib) { + $lib = trim($lib); + if ($lib === '') { + continue; + } + $static_lib = 'lib' . $lib . '.a'; + if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { + $staticLibs .= ' -l' . $lib; + } else { + $sharedLibs .= ' -l' . $lib; + } + } $env = [ 'CFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'], - 'LIBS' => $config['libs'], + 'LDFLAGS' => $config['ldflags'] . ' -Wl,--allow-multiple-definition', + 'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; // prepare configure args diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index dccf131c..ef9e95bf 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('spx')] @@ -13,17 +12,10 @@ class spx extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-spx'; + $arg = '--enable-SPX'; if ($this->builder->getExt('zlib') === null) { $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; } return $arg; } - - public function patchBeforeSharedConfigure(): bool - { - FileSystem::replaceFileStr($this->source_dir . '/config.m4', 'PHP_ARG_ENABLE(SPX-DEV,', 'PHP_ARG_ENABLE(spx-dev,'); - FileSystem::replaceFileStr($this->source_dir . '/config.m4', 'PHP_ARG_ENABLE(SPX,', 'PHP_ARG_ENABLE(spx,'); - return true; - } } diff --git a/src/SPC/builder/extension/xdebug.php b/src/SPC/builder/extension/xdebug.php index 90f225ae..cdfeea8c 100644 --- a/src/SPC/builder/extension/xdebug.php +++ b/src/SPC/builder/extension/xdebug.php @@ -12,6 +12,6 @@ class xdebug extends Extension { protected function isZendExtension(): bool { - return str_contains($this->builder->getExt('zend')->getName(), 'xdebug'); + return true; } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 0c02e155..f78928de 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -43,7 +43,7 @@ class SourcePatcher */ public static function patchBeforeBuildconf(BuilderBase $builder): void { - foreach ($builder->getExts(false) as $ext) { + foreach ($builder->getExts() as $ext) { if ($ext->patchBeforeBuildconf() === true) { logger()->info('Extension [' . $ext->getName() . '] patched before buildconf'); } diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index e0b92a2e..4b2fd19a 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -11,6 +11,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\store\FileSystem; use Symfony\Component\Console\Input\ArgvInput; class SPCConfigUtil @@ -42,7 +43,7 @@ class SPCConfigUtil * @throws WrongUsageException * @throws \Throwable */ - public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false): array + public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, $with_dependencies = false): array { [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); @@ -54,7 +55,7 @@ class SPCConfigUtil } ob_get_clean(); $ldflags = $this->getLdflagsString(); - $libs = $this->getLibsString($libraries); + $libs = $this->getLibsString($libraries, $with_dependencies); $cflags = $this->getIncludesString(); // embed @@ -97,13 +98,39 @@ class SPCConfigUtil return '-L' . BUILD_LIB_PATH; } - private function getLibsString(array $libraries): string + private function getLibsString(array $libraries, bool $withDependencies = false): string { $short_name = []; foreach (array_reverse($libraries) as $library) { $libs = Config::getLib($library, 'static-libs', []); foreach ($libs as $lib) { - $short_name[] = $this->getShortLibName($lib); + if ($withDependencies) { + $noExt = str_replace('.a', '', $lib); + $requiredLibs = []; + $pkgconfFile = BUILD_LIB_PATH . "/pkgconfig/{$noExt}.pc"; + if (file_exists($pkgconfFile)) { + $lines = file($pkgconfFile); + foreach ($lines as $value) { + if (str_starts_with($value, 'Libs')) { + $items = explode(' ', $value); + foreach ($items as $item) { + $item = trim($item); + if (str_starts_with($item, '-l')) { + $requiredLibs[] = $item; + } + } + } + } + } + foreach ($requiredLibs as $requiredLib) { + if (!in_array($requiredLib, $short_name)) { + $short_name[] = $requiredLib; + } + } + } + else { + $short_name[] = $this->getShortLibName($lib); + } } if (PHP_OS_FAMILY !== 'Darwin') { continue; From 4b8412dfdb44f995b088784f1402b7959c05bf74 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:28:00 +0700 Subject: [PATCH 059/319] shared for imagick --- src/SPC/builder/extension/imagick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index a4cb9386..f9189245 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -24,6 +24,6 @@ class imagick extends Extension public function getUnixConfigureArg(bool $shared = false): string { $disable_omp = getenv('SPC_LIBC') === 'musl' ? '' : ' ac_cv_func_omp_pause_resource_all=no'; - return '--with-imagick=' . BUILD_ROOT_PATH . $disable_omp; + return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp; } } From b91c83b6cd325dcd29d6b26242c92a51b43c433e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:29:19 +0700 Subject: [PATCH 060/319] linter --- src/SPC/util/SPCConfigUtil.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 4b2fd19a..d8ddabf5 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -11,7 +11,6 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; -use SPC\store\FileSystem; use Symfony\Component\Console\Input\ArgvInput; class SPCConfigUtil @@ -32,6 +31,7 @@ class SPCConfigUtil * @param array $libraries Additional library name list * @param bool $include_suggest_ext Include suggested extensions * @param bool $include_suggest_lib Include suggested libraries + * @param mixed $with_dependencies * @return array{ * cflags: string, * ldflags: string, @@ -127,8 +127,7 @@ class SPCConfigUtil $short_name[] = $requiredLib; } } - } - else { + } else { $short_name[] = $this->getShortLibName($lib); } } From 6a86b28977589a62f94f9d53c9788327e30d9d7c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:44:48 +0700 Subject: [PATCH 061/319] fix case of nonexistent pc --- src/SPC/util/SPCConfigUtil.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index d8ddabf5..a89c4947 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -122,6 +122,9 @@ class SPCConfigUtil } } } + else { + $requiredLibs[] = $this->getShortLibName($lib); + } foreach ($requiredLibs as $requiredLib) { if (!in_array($requiredLib, $short_name)) { $short_name[] = $requiredLib; From bc002d500eb4c6bd34eb060bc71f79282c2d133c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 12:45:06 +0700 Subject: [PATCH 062/319] linter again --- src/SPC/util/SPCConfigUtil.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index a89c4947..0a059463 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -121,8 +121,7 @@ class SPCConfigUtil } } } - } - else { + } else { $requiredLibs[] = $this->getShortLibName($lib); } foreach ($requiredLibs as $requiredLib) { From 396d4b341f89d4a83870b0831894f039e1990362 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 13:01:36 +0700 Subject: [PATCH 063/319] broli, hahahaha --- src/SPC/builder/unix/library/curl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index be9351b5..ab8a8bd7 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -67,13 +67,13 @@ trait curl $this->patchPkgconfPrefix(['libcurl.pc']); FileSystem::replaceFileStr( BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', - '-lbrolienc -lbrotlidec -lbrotlicommon', + '-lbrotlienc -lbrotlidec -lbrotlicommon', '-lbrotlidec -lbrotlicommon' ); FileSystem::replaceFileStr( BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', '-lbrotlidec -lbrotlicommon', - '-lbrolienc -lbrotlidec -lbrotlicommon' + '-lbrotlienc -lbrotlidec -lbrotlicommon' ); FileSystem::replaceFileStr( BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', From 0afe0e5f46f62120ceb03e521564b7e67a3bc779 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 15:46:42 +0700 Subject: [PATCH 064/319] last problems (?) --- config/ext.json | 9 ++++++--- src/SPC/builder/Extension.php | 2 +- src/SPC/builder/extension/intl.php | 2 -- src/SPC/builder/extension/memcache.php | 2 +- src/SPC/builder/extension/memcached.php | 2 +- src/SPC/builder/extension/sockets.php | 21 --------------------- 6 files changed, 9 insertions(+), 29 deletions(-) delete mode 100644 src/SPC/builder/extension/sockets.php diff --git a/config/ext.json b/config/ext.json index 1cf99d1f..d48646ae 100644 --- a/config/ext.json +++ b/config/ext.json @@ -373,7 +373,8 @@ ], "shared-ext-depends": [ "session" - ] + ], + "build-with-php": true }, "memcached": { "support": { @@ -677,7 +678,8 @@ ] }, "session": { - "type": "builtin" + "type": "builtin", + "build-with-php": true }, "shmop": { "type": "builtin" @@ -973,7 +975,8 @@ "source": "xhprof", "ext-depends": [ "ctype" - ] + ], + "build-with-php": true }, "xlswriter": { "support": { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 8d975837..b8dc8c4c 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -362,7 +362,7 @@ class Extension } $env = [ 'CFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'] . ' -Wl,--allow-multiple-definition', + 'LDFLAGS' => $config['ldflags'], 'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; diff --git a/src/SPC/builder/extension/intl.php b/src/SPC/builder/extension/intl.php index 819aee69..5676a489 100644 --- a/src/SPC/builder/extension/intl.php +++ b/src/SPC/builder/extension/intl.php @@ -18,8 +18,6 @@ class intl extends Extension // Also need to use clang++ -std=c++17 to force override the default C++ standard if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) { f_putenv('CXX=' . $env . ' -std=c++17'); - } else { - f_putenv('CXX=clang++ -std=c++17'); } return true; } diff --git a/src/SPC/builder/extension/memcache.php b/src/SPC/builder/extension/memcache.php index 4625cae2..479744fd 100644 --- a/src/SPC/builder/extension/memcache.php +++ b/src/SPC/builder/extension/memcache.php @@ -14,7 +14,7 @@ class memcache extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - return '--enable-memcache --with-zlib-dir=' . BUILD_ROOT_PATH; + return '--enable-memcache' . ($shared ? '=shared' : '') . ' --with-zlib-dir=' . BUILD_ROOT_PATH; } /** diff --git a/src/SPC/builder/extension/memcached.php b/src/SPC/builder/extension/memcached.php index 9c433954..12c2c193 100644 --- a/src/SPC/builder/extension/memcached.php +++ b/src/SPC/builder/extension/memcached.php @@ -14,6 +14,6 @@ class memcached extends Extension { $rootdir = BUILD_ROOT_PATH; $zlib_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : "--with-zlib-dir={$rootdir}"; - return "--enable-memcached {$zlib_dir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json"; + return "--enable-memcached" . ($shared ? '=shared' : '') . " {$zlib_dir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json"; } } diff --git a/src/SPC/builder/extension/sockets.php b/src/SPC/builder/extension/sockets.php deleted file mode 100644 index a0901415..00000000 --- a/src/SPC/builder/extension/sockets.php +++ /dev/null @@ -1,21 +0,0 @@ - Date: Thu, 22 May 2025 16:04:29 +0700 Subject: [PATCH 065/319] linter --- src/SPC/builder/extension/memcached.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/memcached.php b/src/SPC/builder/extension/memcached.php index 12c2c193..8ea8b81e 100644 --- a/src/SPC/builder/extension/memcached.php +++ b/src/SPC/builder/extension/memcached.php @@ -14,6 +14,6 @@ class memcached extends Extension { $rootdir = BUILD_ROOT_PATH; $zlib_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : "--with-zlib-dir={$rootdir}"; - return "--enable-memcached" . ($shared ? '=shared' : '') . " {$zlib_dir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json"; + return '--enable-memcached' . ($shared ? '=shared' : '') . " {$zlib_dir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json"; } } From 2a70b998e37e573f2bc41a0e48a5b0ddca03e068 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 16:07:52 +0700 Subject: [PATCH 066/319] change to count of Static Extensions --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 6c64995c..478ca291 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -137,7 +137,7 @@ class BuildPHPCommand extends BuildCommand $indent_texts = [ 'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')', 'Build SAPI' => $builder->getBuildTypeName($rule), - 'Extensions (' . count($extensions) . ')' => implode(',', $extensions), + 'Static Extensions (' . count($static_extensions) . ')' => implode(',', $extensions), 'Shared Extensions (' . count($shared_extensions) . ')' => implode(',', $shared_extensions), 'Libraries (' . count($libraries) . ')' => implode(',', $display_libs), 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', From 835fc1e360e64b36a70903c601b65f863b121087 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 16:08:09 +0700 Subject: [PATCH 067/319] oops --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 478ca291..cd831438 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -137,7 +137,7 @@ class BuildPHPCommand extends BuildCommand $indent_texts = [ 'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')', 'Build SAPI' => $builder->getBuildTypeName($rule), - 'Static Extensions (' . count($static_extensions) . ')' => implode(',', $extensions), + 'Static Extensions (' . count($static_extensions) . ')' => implode(',', $static_extensions), 'Shared Extensions (' . count($shared_extensions) . ')' => implode(',', $shared_extensions), 'Libraries (' . count($libraries) . ')' => implode(',', $display_libs), 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', From c2d5afc4e9db6ab34af0873ca4872115568f25d9 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 16:48:22 +0700 Subject: [PATCH 068/319] mysqli and mysqlnd can also be built shared --- config/ext.json | 11 +++++------ src/SPC/builder/Extension.php | 7 ++++--- src/SPC/builder/extension/mbregex.php | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/ext.json b/config/ext.json index d48646ae..bd98ac43 100644 --- a/config/ext.json +++ b/config/ext.json @@ -430,8 +430,8 @@ "ext-depends": [ "mysqlnd" ], - "target": [ - "static" + "shared-ext-depends": [ + "mysqlnd" ] }, "mysqlnd": { @@ -439,9 +439,6 @@ "arg-type-windows": "with", "lib-depends": [ "zlib" - ], - "target": [ - "static" ] }, "oci8": { @@ -682,7 +679,8 @@ "build-with-php": true }, "shmop": { - "type": "builtin" + "type": "builtin", + "build-with-php": true }, "simdjson": { "type": "external", @@ -792,6 +790,7 @@ "arg-type": "with-prefix", "arg-type-windows": "with", "lib-depends": [ + "openssl", "libssh2" ], "ext-depends-windows": [ diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index b8dc8c4c..f25b82a7 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -230,9 +230,9 @@ class Extension foreach ($order as $ext) { if ($ext instanceof Extension && $ext->isBuildShared()) { if ($ext->isZendExtension()) { - $ret .= ' -d "zend_extension=' . BUILD_MODULES_PATH . '/' . $ext->getName() . '.so"'; + $ret .= " -d \"zend_extension={$ext->getName()}\""; } else { - $ret .= ' -d "extension=' . BUILD_MODULES_PATH . '/' . $ext->getName() . '.so"'; + $ret .= " -d \"extension={$ext->getName()}\""; } } } @@ -249,7 +249,8 @@ class Extension // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException $sharedExtensions = $this->getRequiredSharedExtensions(); - [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"', false); + putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); + [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); } diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index a26e7024..5990b3a6 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -26,7 +26,7 @@ class mbregex extends Extension */ public function runCliCheckUnix(): void { - $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=' . BUILD_MODULES_PATH . '/mbstring.so"' : ''; + $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=mbstring.so"' : ''; [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); From 51891478e4612f306dbfb72495a1a887db238aac Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 22 May 2025 16:51:03 +0700 Subject: [PATCH 069/319] shared ssh2 wants openssl if mysqli or mysqlnd aren't built in --- config/ext.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index bd98ac43..dc69bf36 100644 --- a/config/ext.json +++ b/config/ext.json @@ -790,9 +790,11 @@ "arg-type": "with-prefix", "arg-type-windows": "with", "lib-depends": [ - "openssl", "libssh2" ], + "shared-ext-depends": [ + "openssl" + ], "ext-depends-windows": [ "openssl", "zlib" From 15dc672bcf4edb3a34511ba3e0d1aedc2cae42f8 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 23 May 2025 10:00:31 +0700 Subject: [PATCH 070/319] remove shared-ext-depends --- config/ext.json | 18 +++--------------- src/SPC/builder/Extension.php | 16 ++++++---------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/config/ext.json b/config/ext.json index dc69bf36..b9fc28a5 100644 --- a/config/ext.json +++ b/config/ext.json @@ -96,7 +96,7 @@ "type": "external", "source": "ev", "arg-type-windows": "with", - "shared-ext-depends": [ + "ext-depends": [ "sockets" ] }, @@ -371,9 +371,6 @@ "zlib", "session" ], - "shared-ext-depends": [ - "session" - ], "build-with-php": true }, "memcached": { @@ -392,9 +389,6 @@ "ext-depends": [ "session", "zlib" - ], - "shared-ext-depends": [ - "session" ] }, "mongodb": { @@ -420,7 +414,7 @@ "source": "msgpack", "arg-type-unix": "with", "arg-type-win": "enable", - "shared-ext-depends": [ + "ext-depends": [ "session" ] }, @@ -429,9 +423,6 @@ "arg-type": "with", "ext-depends": [ "mysqlnd" - ], - "shared-ext-depends": [ - "mysqlnd" ] }, "mysqlnd": { @@ -792,10 +783,7 @@ "lib-depends": [ "libssh2" ], - "shared-ext-depends": [ - "openssl" - ], - "ext-depends-windows": [ + "ext-depends": [ "openssl", "zlib" ] diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f25b82a7..6fd8b52f 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -121,9 +121,6 @@ class Extension foreach (Config::getExt($this->name, 'ext-suggests', []) as $name) { $this->addExtensionDependency($name, true); } - foreach (Config::getExt($this->name, 'shared-ext-depends', []) as $name) { - $this->addExtensionDependency($name); - } return $this; } @@ -319,14 +316,13 @@ class Extension logger()->info('extension ' . $this->getName() . ' already built, skipping'); return; } - foreach (Config::getExt($this->name, 'shared-ext-depends', []) as $name) { - $dependencyExt = $this->builder->getExt($name); - if ($dependencyExt === null) { - throw new RuntimeException("extension {$this->name} requires shared extension {$name}"); + foreach ($this->dependencies as $dependency) { + if (!$dependency instanceof Extension) { + continue; } - if ($dependencyExt->isBuildShared()) { - logger()->info('extension ' . $this->getName() . ' requires shared extension ' . $name); - $dependencyExt->buildShared(); + if (!$dependency->isBuildStatic()) { + logger()->info('extension ' . $this->getName() . ' requires extension ' . $dependency->getName()); + $dependency->buildShared(); } } match (PHP_OS_FAMILY) { From ed35b653907aefe005fd9b407fde83a637ba15d5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 23 May 2025 12:09:57 +0700 Subject: [PATCH 071/319] build all static exts no matter if we're also building shared versions --- src/SPC/builder/BuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 599ccdc6..b011a802 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -128,7 +128,7 @@ abstract class BuilderBase if ($including_shared) { return $this->exts; } - return array_filter($this->exts, fn ($ext) => !$ext->isBuildShared()); + return array_filter($this->exts, fn ($ext) => $ext->isBuildStatic()); } /** From 4ce7374ac9695ddb3ebea403d251f4e1ac1891ab Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 09:37:15 +0700 Subject: [PATCH 072/319] move zend extension check into config --- config/ext.json | 6 ++++-- src/SPC/builder/Extension.php | 7 +------ src/SPC/builder/extension/opcache.php | 5 ----- src/SPC/builder/extension/xdebug.php | 17 ----------------- 4 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 src/SPC/builder/extension/xdebug.php diff --git a/config/ext.json b/config/ext.json index b9fc28a5..0dca824b 100644 --- a/config/ext.json +++ b/config/ext.json @@ -455,7 +455,8 @@ }, "opcache": { "type": "builtin", - "arg-type-unix": "custom" + "arg-type-unix": "custom", + "zend-extension": true }, "openssl": { "notes": true, @@ -952,7 +953,8 @@ "Darwin": "partial", "Linux": "partial" }, - "notes": true + "notes": true, + "zend-extension": true }, "xhprof": { "support": { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6fd8b52f..22c35d33 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -226,7 +226,7 @@ class Extension $ret = ''; foreach ($order as $ext) { if ($ext instanceof Extension && $ext->isBuildShared()) { - if ($ext->isZendExtension()) { + if (Config::getExt($ext->getName(), 'zend_extension', false) === true) { $ret .= " -d \"zend_extension={$ext->getName()}\""; } else { $ret .= " -d \"extension={$ext->getName()}\""; @@ -448,11 +448,6 @@ class Extension } } - protected function isZendExtension(): bool - { - return false; - } - private function getLibraryDependencies(bool $recursive = false): array { $ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase); diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 865bf487..5d9dda0a 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -51,9 +51,4 @@ class opcache extends Extension { return 'Zend Opcache'; } - - protected function isZendExtension(): bool - { - return true; - } } diff --git a/src/SPC/builder/extension/xdebug.php b/src/SPC/builder/extension/xdebug.php deleted file mode 100644 index cdfeea8c..00000000 --- a/src/SPC/builder/extension/xdebug.php +++ /dev/null @@ -1,17 +0,0 @@ - Date: Sun, 25 May 2025 09:37:15 +0700 Subject: [PATCH 073/319] \$SPC_CMD_PREFIX_PHP_MAKE -> $SPC_CMD_PREFIX_PHP_MAKE --- src/SPC/builder/linux/LinuxBuilder.php | 9 ++++++--- src/SPC/builder/macos/MacOSBuilder.php | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 0a814907..324bce32 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -239,9 +239,10 @@ class LinuxBuilder extends UnixBuilderBase protected function buildCli(): void { $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); + $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); + ->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli') @@ -277,10 +278,11 @@ class LinuxBuilder extends UnixBuilderBase // patch fake cli for micro $vars['EXTRA_CFLAGS'] .= $enable_fake_cli; $vars = SystemUtil::makeEnvVarString($vars); + $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} micro"); + ->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} micro"); $this->processMicroUPX(); @@ -300,9 +302,10 @@ class LinuxBuilder extends UnixBuilderBase protected function buildFpm(): void { $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); + $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} fpm"); + ->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} fpm"); if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm') diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 7d82f191..85533045 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -226,7 +226,8 @@ class MacOSBuilder extends UnixBuilderBase $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); $shell = shell()->cd(SOURCE_PATH . '/php-src'); - $shell->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); + $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; + $shell->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); if (!$this->getOption('no-strip', false)) { $shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php'); } From a9d5dcf4a22808224508cb5694bfc248ac522960 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 10:47:32 +0700 Subject: [PATCH 074/319] fixer --- src/SPC/builder/linux/LinuxBuilder.php | 6 +++--- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 324bce32..0e0ac409 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -242,7 +242,7 @@ class LinuxBuilder extends UnixBuilderBase $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); + ->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli"); if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli') @@ -282,7 +282,7 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} micro"); + ->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} micro"); $this->processMicroUPX(); @@ -305,7 +305,7 @@ class LinuxBuilder extends UnixBuilderBase $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} fpm"); + ->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} fpm"); if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm') diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 85533045..cb2bac74 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -227,7 +227,7 @@ class MacOSBuilder extends UnixBuilderBase $shell = shell()->cd(SOURCE_PATH . '/php-src'); $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; - $shell->exec("$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); + $shell->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli"); if (!$this->getOption('no-strip', false)) { $shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php'); } From f83715c370502a153e90ad15bceaf87a3104548f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 10:52:46 +0700 Subject: [PATCH 075/319] add function description --- src/SPC/builder/Extension.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 22c35d33..ca627b9d 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -203,6 +203,15 @@ class Extension return false; } + /** + * @return string + * returns a command line string with all required shared extensions to load + * i.e.; pdo_pgsql would return: + * + * `-d "extension=pgsql" -d "extension=pdo_pgsql"` + * @throws FileSystemException + * @throws WrongUsageException + */ public function getRequiredSharedExtensions(): string { $loaded = []; From a8987d48edc9a53a76c2b654860c5b0396968032 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 11:00:38 +0700 Subject: [PATCH 076/319] the what now? --- src/SPC/builder/Extension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index ca627b9d..b997fe0a 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -205,8 +205,8 @@ class Extension /** * @return string - * returns a command line string with all required shared extensions to load - * i.e.; pdo_pgsql would return: + * returns a command line string with all required shared extensions to load + * i.e.; pdo_pgsql would return: * * `-d "extension=pgsql" -d "extension=pdo_pgsql"` * @throws FileSystemException From 9665473669feee84c218dc188d64463632729931 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 11:02:54 +0700 Subject: [PATCH 077/319] revert env --- config/env.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/env.ini b/config/env.ini index 49952645..e50c28bb 100644 --- a/config/env.ini +++ b/config/env.ini @@ -81,7 +81,7 @@ SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime ; buildconf command SPC_CMD_PREFIX_PHP_BUILDCONF="./buildconf --force" ; configure command -SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --enable-shared=yes --enable-static=no --disable-all --disable-cgi --disable-phpdbg --with-pic" +SPC_CMD_PREFIX_PHP_CONFIGURE="./configure --prefix= --with-valgrind=no --disable-shared --enable-static --disable-all --disable-cgi --disable-phpdbg --with-pic" ; make command SPC_CMD_PREFIX_PHP_MAKE="make -j${CPU_COUNT}" ; embed type for php, static (libphp.a) or shared (libphp.so) From 14ca782672927cbd3b0dd0bc5e397d99bb62a92d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 11:07:44 +0700 Subject: [PATCH 078/319] rename method --- src/SPC/builder/Extension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index b997fe0a..06c892a8 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -212,7 +212,7 @@ class Extension * @throws FileSystemException * @throws WrongUsageException */ - public function getRequiredSharedExtensions(): string + public function getSharedExtensionLoadString(): string { $loaded = []; $order = []; @@ -254,7 +254,7 @@ class Extension // Run compile check if build target is cli // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException - $sharedExtensions = $this->getRequiredSharedExtensions(); + $sharedExtensions = $this->getSharedExtensionLoadString(); putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); if ($ret !== 0) { From 234df8d11fad4b23fc51a1f426b9e97f1891e81e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 11:48:52 +0700 Subject: [PATCH 079/319] update spx, works static and shared --- config/source.json | 2 +- src/SPC/builder/extension/spx.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index 2beea67c..dcf2ec58 100644 --- a/config/source.json +++ b/config/source.json @@ -859,7 +859,7 @@ "spx": { "type": "git", "rev": "master", - "url": "https://github.com/NoiseByNorthwest/php-spx.git", + "url": "https://github.com/henderkes/php-spx.git", "path": "php-src/ext/spx", "license": { "type": "file", diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index ef9e95bf..9e3ead3a 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -12,7 +12,7 @@ class spx extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $arg = '--enable-SPX'; + $arg = '--enable-spx' . ($shared ? '=shared' : ''); if ($this->builder->getExt('zlib') === null) { $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; } From c972a94876009fed6e340f3f0353b50a56f515dc Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 15:52:11 +0700 Subject: [PATCH 080/319] another way where static extensions would be excluded if also compiled shared --- src/SPC/builder/BuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index b011a802..433d0b97 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -294,7 +294,7 @@ abstract class BuilderBase $ret = []; foreach ($this->getExts() as $ext) { $arg = $ext->getConfigureArg(); - if ($ext->isBuildShared()) { + if ($ext->isBuildShared() && !$ext->isBuildStatic()) { if ( (Config::getExt($ext->getName(), 'type') === 'builtin' && !file_exists(SOURCE_PATH . '/php-src/ext/' . $ext->getName() . '/config.m4')) || From 3662e079ac5d464e97b60b082b1a1c10da52b8b6 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 17:26:48 +0700 Subject: [PATCH 081/319] fix spc doctor command, gettext is installed by default, but doesn't provide all required autopoint stuff - check for gettextize instead, which is only installed with the gettext-devel package --- src/SPC/doctor/item/LinuxToolCheckList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 03702a84..bde53289 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -47,7 +47,7 @@ class LinuxToolCheckList private const PROVIDED_COMMAND = [ 'binutils-gold' => 'ld.gold', 'base-devel' => 'automake', - 'gettext-devel' => 'gettext', + 'gettext-devel' => 'gettextize', ]; /** @noinspection PhpUnused */ From d833d8946ca25805cffd2014938874f2851f8cce Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 18:03:07 +0700 Subject: [PATCH 082/319] fixes on arch64 --- src/SPC/builder/extension/amqp.php | 2 +- src/SPC/builder/extension/spx.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/amqp.php b/src/SPC/builder/extension/amqp.php index 40a6131c..7e0ea2de 100644 --- a/src/SPC/builder/extension/amqp.php +++ b/src/SPC/builder/extension/amqp.php @@ -25,7 +25,7 @@ class amqp extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--with-amqp --with-librabbitmq-dir=' . BUILD_ROOT_PATH; + return '--with-amqp' . ($shared ? '=shared' : '') . ' --with-librabbitmq-dir=' . BUILD_ROOT_PATH; } public function getWindowsConfigureArg($shared = false): string diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index 9e3ead3a..8436b96f 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -13,7 +13,7 @@ class spx extends Extension public function getUnixConfigureArg(bool $shared = false): string { $arg = '--enable-spx' . ($shared ? '=shared' : ''); - if ($this->builder->getExt('zlib') === null) { + if ($this->builder->getLib('zlib') !== null) { $arg .= ' --with-zlib-dir=' . BUILD_ROOT_PATH; } return $arg; From e2ea10d2eb47042af5f95d259f140a29b4e643c1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 18:29:34 +0700 Subject: [PATCH 083/319] set extension dir before --- src/SPC/builder/extension/mbregex.php | 3 ++- src/SPC/builder/extension/swoole_hook_mysql.php | 3 ++- src/SPC/builder/extension/swoole_hook_pgsql.php | 4 +++- src/SPC/builder/extension/swoole_hook_sqlite.php | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 5990b3a6..cdff2903 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -26,7 +26,8 @@ class mbregex extends Extension */ public function runCliCheckUnix(): void { - $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=mbstring.so"' : ''; + $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=mbstring"' : ''; + putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index e9684872..b7c9b8c1 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -29,7 +29,8 @@ class swoole_hook_mysql extends Extension if ($this->builder->getExt('swoole') === null) { return; } - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "swoole"', false); + putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n'. $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); $out = implode('', $out); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 113b8eb6..68661bd5 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -37,7 +37,9 @@ class swoole_hook_pgsql extends Extension if ($this->builder->getExt('swoole') === null) { return; } - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "swoole"', false); + $sharedExtensions = $this->getSharedExtensionLoadString(); + putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 7948dd29..cb217539 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -37,7 +37,9 @@ class swoole_hook_sqlite extends Extension if ($this->builder->getExt('swoole') === null) { return; } - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "swoole"', false); + $sharedExtensions = $this->getSharedExtensionLoadString(); + putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); From 92acb95a58940b829971344325e1436ef93f907f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 25 May 2025 18:39:11 +0700 Subject: [PATCH 084/319] linter --- src/SPC/builder/extension/swoole_hook_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index b7c9b8c1..55a58af3 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -30,7 +30,7 @@ class swoole_hook_mysql extends Extension return; } putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); - [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n'. $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); $out = implode('', $out); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); From b68701f51bc636edb7210f069ef7ca7f97d32ba7 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 27 May 2025 12:18:31 +0700 Subject: [PATCH 085/319] updated the static-php spx --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index dcf2ec58..a4b25cb8 100644 --- a/config/source.json +++ b/config/source.json @@ -859,7 +859,7 @@ "spx": { "type": "git", "rev": "master", - "url": "https://github.com/henderkes/php-spx.git", + "url": "https://github.com/static-php/php-spx.git", "path": "php-src/ext/spx", "license": { "type": "file", From 4299abf68b083035e5db00b1f4046491e8195ef7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 30 May 2025 15:38:06 +0800 Subject: [PATCH 086/319] Update vitepress version, fix selecting all options --- docs/.vitepress/components/CliGenerator.vue | 23 +- package.json | 2 +- yarn.lock | 1436 ++++++++++--------- 3 files changed, 799 insertions(+), 662 deletions(-) diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue index 4c8d096a..14a14af7 100644 --- a/docs/.vitepress/components/CliGenerator.vue +++ b/docs/.vitepress/components/CliGenerator.vue @@ -45,6 +45,7 @@

TIP

{{ I18N[lang].depTips }}

+

{{ I18N[lang].depTips2 }}

{{ I18N[lang].buildTarget }}

@@ -263,6 +264,7 @@ const I18N = { selectedSystem: '选择操作系统', buildLibs: '要构建的库', depTips: '选择扩展后,不可选中的项目为必需的依赖,编译的依赖库列表中可选的为现有扩展和依赖库的可选依赖。选择可选依赖后,将生成 --with-libs 参数。', + depTips2: '无法同时构建所有扩展,因为有些扩展之间相互冲突。请根据需要选择扩展。', microUnavailable: 'micro 不支持 PHP 7.4 及更早版本!', windowsSAPIUnavailable: 'Windows 目前不支持 fpm、embed 构建!', useUPX: '是否开启 UPX 压缩(减小二进制体积)', @@ -298,6 +300,7 @@ const I18N = { selectedSystem: 'Select Build OS', buildLibs: 'Select Dependencies', depTips: 'After selecting the extensions, the unselectable items are essential dependencies. In the compiled dependencies list, optional dependencies consist of existing extensions and optional dependencies of libraries. Optional dependencies will be added in --with-libs parameter.', + depTips2: 'It is not possible to build all extensions at the same time, as some extensions conflict with each other. Please select the extensions you need.', microUnavailable: 'Micro does not support PHP 7.4 and earlier versions!', windowsSAPIUnavailable: 'Windows does not support fpm and embed build!', useUPX: 'Enable UPX compression (reduce binary size)', @@ -335,23 +338,7 @@ const selectCommon = () => { }; const selectAll = () => { - checkedExts.value = [ - 'amqp', 'apcu', 'ast', 'bcmath', 'bz2', 'calendar', 'ctype', 'curl', - 'dba', 'dio', 'dom', 'ds', 'ev', 'event', 'exif', 'ffi', 'fileinfo', - 'filter', 'ftp', 'gd', 'gettext', 'gmp', 'gmssl', 'grpc', 'iconv', - 'igbinary', 'imagick', 'imap', 'inotify', 'intl', 'ldap', 'libxml', - 'mbregex', 'mbstring', 'memcache', 'mongodb', 'msgpack', 'mysqli', - 'mysqlnd', 'odbc', 'opcache', 'openssl', 'opentelemetry', 'parallel', - 'password-argon2', 'pcntl', 'pdo', 'pdo_mysql', 'pdo_odbc', - 'pdo_pgsql', 'pdo_sqlite', 'pdo_sqlsrv', 'pgsql', 'phar', 'posix', - 'protobuf', 'rar', 'rdkafka', 'readline', 'redis', 'session', 'shmop', - 'simdjson', 'simplexml', 'snappy', 'soap', 'sockets', 'sodium', 'spx', - 'sqlite3', 'sqlsrv', 'ssh2', 'swoole', 'swoole-hook-mysql', - 'swoole-hook-pgsql', 'swoole-hook-sqlite', 'swow', 'sysvmsg', - 'sysvsem', 'sysvshm', 'tidy', 'tokenizer', 'uuid', 'uv', 'xdebug', - 'xhprof', 'xlswriter', 'xml', 'xmlreader', 'xmlwriter', 'xsl', 'yac', - 'zip', 'zlib', - ]; + checkedExts.value = extFilter.value; }; const extList = computed(() => { @@ -381,7 +368,7 @@ const checkedTargets = ref(['cli']); const selectedEnv = ref('spc'); // chosen php version -const selectedPhpVersion = ref('8.2'); +const selectedPhpVersion = ref('8.4'); // chosen debug const debug = ref(0); diff --git a/package.json b/package.json index 4b448715..da1bbb88 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "docs:preview": "vitepress preview docs" }, "devDependencies": { - "vitepress": "^1.0.0-rc.35", + "vitepress": "^2.0.0-alpha.5", "vue": "^3.2.47" } } diff --git a/yarn.lock b/yarn.lock index 1e18c1b2..3e357ce9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,819 +2,969 @@ # yarn lockfile v1 -"@algolia/autocomplete-core@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.9.3.tgz#1d56482a768c33aae0868c8533049e02e8961be7" - integrity sha512-009HdfugtGCdC4JdXUbVJClA0q0zh24yyePn+KUGk3rP7j8FEe/m5Yo/z65gn6nP/cM39PxpzqKrL7A6fP6PPw== +"@algolia/autocomplete-core@1.17.9": + version "1.17.9" + resolved "https://registry.npmjs.org/@algolia/autocomplete-core/-/autocomplete-core-1.17.9.tgz" + integrity sha512-O7BxrpLDPJWWHv/DLA9DRFWs+iY1uOJZkqUwjS5HSZAGcl0hIVCQ97LTLewiZmZ402JYUrun+8NqFP+hCknlbQ== dependencies: - "@algolia/autocomplete-plugin-algolia-insights" "1.9.3" - "@algolia/autocomplete-shared" "1.9.3" + "@algolia/autocomplete-plugin-algolia-insights" "1.17.9" + "@algolia/autocomplete-shared" "1.17.9" -"@algolia/autocomplete-plugin-algolia-insights@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.9.3.tgz#9b7f8641052c8ead6d66c1623d444cbe19dde587" - integrity sha512-a/yTUkcO/Vyy+JffmAnTWbr4/90cLzw+CC3bRbhnULr/EM0fGNvM13oQQ14f2moLMcVDyAx/leczLlAOovhSZg== +"@algolia/autocomplete-plugin-algolia-insights@1.17.9": + version "1.17.9" + resolved "https://registry.npmjs.org/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.17.9.tgz" + integrity sha512-u1fEHkCbWF92DBeB/KHeMacsjsoI0wFhjZtlCq2ddZbAehshbZST6Hs0Avkc0s+4UyBGbMDnSuXHLuvRWK5iDQ== dependencies: - "@algolia/autocomplete-shared" "1.9.3" + "@algolia/autocomplete-shared" "1.17.9" -"@algolia/autocomplete-preset-algolia@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.9.3.tgz#64cca4a4304cfcad2cf730e83067e0c1b2f485da" - integrity sha512-d4qlt6YmrLMYy95n5TB52wtNDr6EgAIPH81dvvvW8UmuWRgxEtY0NJiPwl/h95JtG2vmRM804M0DSwMCNZlzRA== +"@algolia/autocomplete-preset-algolia@1.17.9": + version "1.17.9" + resolved "https://registry.npmjs.org/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.17.9.tgz" + integrity sha512-Na1OuceSJeg8j7ZWn5ssMu/Ax3amtOwk76u4h5J4eK2Nx2KB5qt0Z4cOapCsxot9VcEN11ADV5aUSlQF4RhGjQ== dependencies: - "@algolia/autocomplete-shared" "1.9.3" + "@algolia/autocomplete-shared" "1.17.9" -"@algolia/autocomplete-shared@1.9.3": - version "1.9.3" - resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.9.3.tgz#2e22e830d36f0a9cf2c0ccd3c7f6d59435b77dfa" - integrity sha512-Wnm9E4Ye6Rl6sTTqjoymD+l8DjSTHsHboVRYrKgEt8Q7UHm9nYbqhN/i0fhUYA3OAEH7WA8x3jfpnmJm3rKvaQ== +"@algolia/autocomplete-shared@1.17.9": + version "1.17.9" + resolved "https://registry.npmjs.org/@algolia/autocomplete-shared/-/autocomplete-shared-1.17.9.tgz" + integrity sha512-iDf05JDQ7I0b7JEA/9IektxN/80a2MZ1ToohfmNS3rfeuQnIKI3IJlIafD0xu4StbtQTghx9T3Maa97ytkXenQ== -"@algolia/cache-browser-local-storage@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.24.0.tgz#97bc6d067a9fd932b9c922faa6b7fd6e546e1348" - integrity sha512-t63W9BnoXVrGy9iYHBgObNXqYXM3tYXCjDSHeNwnsc324r4o5UiVKUiAB4THQ5z9U5hTj6qUvwg/Ez43ZD85ww== +"@algolia/client-abtesting@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-abtesting/-/client-abtesting-5.25.0.tgz" + integrity sha512-1pfQulNUYNf1Tk/svbfjfkLBS36zsuph6m+B6gDkPEivFmso/XnRgwDvjAx80WNtiHnmeNjIXdF7Gos8+OLHqQ== dependencies: - "@algolia/cache-common" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/cache-common@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/cache-common/-/cache-common-4.24.0.tgz#81a8d3a82ceb75302abb9b150a52eba9960c9744" - integrity sha512-emi+v+DmVLpMGhp0V9q9h5CdkURsNmFC+cOS6uK9ndeJm9J4TiqSvPYVu+THUP8P/S08rxf5x2P+p3CfID0Y4g== - -"@algolia/cache-in-memory@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/cache-in-memory/-/cache-in-memory-4.24.0.tgz#ffcf8872f3a10cb85c4f4641bdffd307933a6e44" - integrity sha512-gDrt2so19jW26jY3/MkFg5mEypFIPbPoXsQGQWAi6TrCPsNOSEYepBMPlucqWigsmEy/prp5ug2jy/N3PVG/8w== +"@algolia/client-analytics@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-analytics/-/client-analytics-5.25.0.tgz" + integrity sha512-AFbG6VDJX/o2vDd9hqncj1B6B4Tulk61mY0pzTtzKClyTDlNP0xaUiEKhl6E7KO9I/x0FJF5tDCm0Hn6v5x18A== dependencies: - "@algolia/cache-common" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/client-account@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/client-account/-/client-account-4.24.0.tgz#eba7a921d828e7c8c40a32d4add21206c7fe12f1" - integrity sha512-adcvyJ3KjPZFDybxlqnf+5KgxJtBjwTPTeyG2aOyoJvx0Y8dUQAEOEVOJ/GBxX0WWNbmaSrhDURMhc+QeevDsA== +"@algolia/client-common@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.25.0.tgz" + integrity sha512-il1zS/+Rc6la6RaCdSZ2YbJnkQC6W1wiBO8+SH+DE6CPMWBU6iDVzH0sCKSAtMWl9WBxoN6MhNjGBnCv9Yy2bA== + +"@algolia/client-insights@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-insights/-/client-insights-5.25.0.tgz" + integrity sha512-blbjrUH1siZNfyCGeq0iLQu00w3a4fBXm0WRIM0V8alcAPo7rWjLbMJMrfBtzL9X5ic6wgxVpDADXduGtdrnkw== dependencies: - "@algolia/client-common" "4.24.0" - "@algolia/client-search" "4.24.0" - "@algolia/transporter" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/client-analytics@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/client-analytics/-/client-analytics-4.24.0.tgz#9d2576c46a9093a14e668833c505ea697a1a3e30" - integrity sha512-y8jOZt1OjwWU4N2qr8G4AxXAzaa8DBvyHTWlHzX/7Me1LX8OayfgHexqrsL4vSBcoMmVw2XnVW9MhL+Y2ZDJXg== +"@algolia/client-personalization@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-personalization/-/client-personalization-5.25.0.tgz" + integrity sha512-aywoEuu1NxChBcHZ1pWaat0Plw7A8jDMwjgRJ00Mcl7wGlwuPt5dJ/LTNcg3McsEUbs2MBNmw0ignXBw9Tbgow== dependencies: - "@algolia/client-common" "4.24.0" - "@algolia/client-search" "4.24.0" - "@algolia/requester-common" "4.24.0" - "@algolia/transporter" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/client-common@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/client-common/-/client-common-4.24.0.tgz#77c46eee42b9444a1d1c1583a83f7df4398a649d" - integrity sha512-bc2ROsNL6w6rqpl5jj/UywlIYC21TwSSoFHKl01lYirGMW+9Eek6r02Tocg4gZ8HAw3iBvu6XQiM3BEbmEMoiA== +"@algolia/client-query-suggestions@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-query-suggestions/-/client-query-suggestions-5.25.0.tgz" + integrity sha512-a/W2z6XWKjKjIW1QQQV8PTTj1TXtaKx79uR3NGBdBdGvVdt24KzGAaN7sCr5oP8DW4D3cJt44wp2OY/fZcPAVA== dependencies: - "@algolia/requester-common" "4.24.0" - "@algolia/transporter" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/client-personalization@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/client-personalization/-/client-personalization-4.24.0.tgz#8b47789fb1cb0f8efbea0f79295b7c5a3850f6ae" - integrity sha512-l5FRFm/yngztweU0HdUzz1rC4yoWCFo3IF+dVIVTfEPg906eZg5BOd1k0K6rZx5JzyyoP4LdmOikfkfGsKVE9w== +"@algolia/client-search@>= 4.9.1 < 6", "@algolia/client-search@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.25.0.tgz" + integrity sha512-9rUYcMIBOrCtYiLX49djyzxqdK9Dya/6Z/8sebPn94BekT+KLOpaZCuc6s0Fpfq7nx5J6YY5LIVFQrtioK9u0g== dependencies: - "@algolia/client-common" "4.24.0" - "@algolia/requester-common" "4.24.0" - "@algolia/transporter" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/client-search@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/client-search/-/client-search-4.24.0.tgz#75e6c02d33ef3e0f34afd9962c085b856fc4a55f" - integrity sha512-uRW6EpNapmLAD0mW47OXqTP8eiIx5F6qN9/x/7HHO6owL3N1IXqydGwW5nhDFBrV+ldouro2W1VX3XlcUXEFCA== +"@algolia/ingestion@1.25.0": + version "1.25.0" + resolved "https://registry.npmjs.org/@algolia/ingestion/-/ingestion-1.25.0.tgz" + integrity sha512-jJeH/Hk+k17Vkokf02lkfYE4A+EJX+UgnMhTLR/Mb+d1ya5WhE+po8p5a/Nxb6lo9OLCRl6w3Hmk1TX1e9gVbQ== dependencies: - "@algolia/client-common" "4.24.0" - "@algolia/requester-common" "4.24.0" - "@algolia/transporter" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/logger-common@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/logger-common/-/logger-common-4.24.0.tgz#28d439976019ec0a46ba7a1a739ef493d4ef8123" - integrity sha512-LLUNjkahj9KtKYrQhFKCzMx0BY3RnNP4FEtO+sBybCjJ73E8jNdaKJ/Dd8A/VA4imVHP5tADZ8pn5B8Ga/wTMA== - -"@algolia/logger-console@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/logger-console/-/logger-console-4.24.0.tgz#c6ff486036cd90b81d07a95aaba04461da7e1c65" - integrity sha512-X4C8IoHgHfiUROfoRCV+lzSy+LHMgkoEEU1BbKcsfnV0i0S20zyy0NLww9dwVHUWNfPPxdMU+/wKmLGYf96yTg== +"@algolia/monitoring@1.25.0": + version "1.25.0" + resolved "https://registry.npmjs.org/@algolia/monitoring/-/monitoring-1.25.0.tgz" + integrity sha512-Ls3i1AehJ0C6xaHe7kK9vPmzImOn5zBg7Kzj8tRYIcmCWVyuuFwCIsbuIIz/qzUf1FPSWmw0TZrGeTumk2fqXg== dependencies: - "@algolia/logger-common" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/recommend@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/recommend/-/recommend-4.24.0.tgz#8a3f78aea471ee0a4836b78fd2aad4e9abcaaf34" - integrity sha512-P9kcgerfVBpfYHDfVZDvvdJv0lEoCvzNlOy2nykyt5bK8TyieYyiD0lguIJdRZZYGre03WIAFf14pgE+V+IBlw== +"@algolia/recommend@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/recommend/-/recommend-5.25.0.tgz" + integrity sha512-79sMdHpiRLXVxSjgw7Pt4R1aNUHxFLHiaTDnN2MQjHwJ1+o3wSseb55T9VXU4kqy3m7TUme3pyRhLk5ip/S4Mw== dependencies: - "@algolia/cache-browser-local-storage" "4.24.0" - "@algolia/cache-common" "4.24.0" - "@algolia/cache-in-memory" "4.24.0" - "@algolia/client-common" "4.24.0" - "@algolia/client-search" "4.24.0" - "@algolia/logger-common" "4.24.0" - "@algolia/logger-console" "4.24.0" - "@algolia/requester-browser-xhr" "4.24.0" - "@algolia/requester-common" "4.24.0" - "@algolia/requester-node-http" "4.24.0" - "@algolia/transporter" "4.24.0" + "@algolia/client-common" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -"@algolia/requester-browser-xhr@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/requester-browser-xhr/-/requester-browser-xhr-4.24.0.tgz#313c5edab4ed73a052e75803855833b62dd19c16" - integrity sha512-Z2NxZMb6+nVXSjF13YpjYTdvV3032YTBSGm2vnYvYPA6mMxzM3v5rsCiSspndn9rzIW4Qp1lPHBvuoKJV6jnAA== +"@algolia/requester-browser-xhr@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.25.0.tgz" + integrity sha512-JLaF23p1SOPBmfEqozUAgKHQrGl3z/Z5RHbggBu6s07QqXXcazEsub5VLonCxGVqTv6a61AAPr8J1G5HgGGjEw== dependencies: - "@algolia/requester-common" "4.24.0" + "@algolia/client-common" "5.25.0" -"@algolia/requester-common@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/requester-common/-/requester-common-4.24.0.tgz#1c60c198031f48fcdb9e34c4057a3ea987b9a436" - integrity sha512-k3CXJ2OVnvgE3HMwcojpvY6d9kgKMPRxs/kVohrwF5WMr2fnqojnycZkxPoEg+bXm8fi5BBfFmOqgYztRtHsQA== - -"@algolia/requester-node-http@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/requester-node-http/-/requester-node-http-4.24.0.tgz#4461593714031d02aa7da221c49df675212f482f" - integrity sha512-JF18yTjNOVYvU/L3UosRcvbPMGT9B+/GQWNWnenIImglzNVGpyzChkXLnrSf6uxwVNO6ESGu6oN8MqcGQcjQJw== +"@algolia/requester-fetch@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/requester-fetch/-/requester-fetch-5.25.0.tgz" + integrity sha512-rtzXwqzFi1edkOF6sXxq+HhmRKDy7tz84u0o5t1fXwz0cwx+cjpmxu/6OQKTdOJFS92JUYHsG51Iunie7xbqfQ== dependencies: - "@algolia/requester-common" "4.24.0" + "@algolia/client-common" "5.25.0" -"@algolia/transporter@4.24.0": - version "4.24.0" - resolved "https://registry.yarnpkg.com/@algolia/transporter/-/transporter-4.24.0.tgz#226bb1f8af62430374c1972b2e5c8580ab275102" - integrity sha512-86nI7w6NzWxd1Zp9q3413dRshDqAzSbsQjhcDhPIatEFiZrL1/TjnHL8S7jVKFePlIMzDsZWXAXwXzcok9c5oA== +"@algolia/requester-node-http@5.25.0": + version "5.25.0" + resolved "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.25.0.tgz" + integrity sha512-ZO0UKvDyEFvyeJQX0gmZDQEvhLZ2X10K+ps6hViMo1HgE2V8em00SwNsQ+7E/52a+YiBkVWX61pJJJE44juDMQ== dependencies: - "@algolia/cache-common" "4.24.0" - "@algolia/logger-common" "4.24.0" - "@algolia/requester-common" "4.24.0" + "@algolia/client-common" "5.25.0" -"@babel/parser@^7.24.7": - version "7.24.7" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.7.tgz#9a5226f92f0c5c8ead550b750f5608e766c8ce85" - integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw== +"@babel/helper-string-parser@^7.27.1": + version "7.27.1" + resolved "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz" + integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA== -"@docsearch/css@3.6.0", "@docsearch/css@^3.6.0": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-3.6.0.tgz#0e9f56f704b3a34d044d15fd9962ebc1536ba4fb" - integrity sha512-+sbxb71sWre+PwDK7X2T8+bhS6clcVMLwBPznX45Qu6opJcgRjAp7gYSDzVFp187J+feSj5dNBN1mJoi6ckkUQ== +"@babel/helper-validator-identifier@^7.27.1": + version "7.27.1" + resolved "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz" + integrity sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow== -"@docsearch/js@^3.6.0": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@docsearch/js/-/js-3.6.0.tgz#f9e46943449b9092d874944f7a80bcc071004cfb" - integrity sha512-QujhqINEElrkIfKwyyyTfbsfMAYCkylInLYMRqHy7PHc8xTBQCow73tlo/Kc7oIwBrCLf0P3YhjlOeV4v8hevQ== +"@babel/parser@^7.27.2": + version "7.27.3" + resolved "https://registry.npmjs.org/@babel/parser/-/parser-7.27.3.tgz" + integrity sha512-xyYxRj6+tLNDTWi0KCBcZ9V7yg3/lwL9DWh9Uwh/RIVlIfFidggcgxKX3GCXwCiswwcGRawBKbEg2LG/Y8eJhw== dependencies: - "@docsearch/react" "3.6.0" + "@babel/types" "^7.27.3" + +"@babel/types@^7.27.3": + version "7.27.3" + resolved "https://registry.npmjs.org/@babel/types/-/types-7.27.3.tgz" + integrity sha512-Y1GkI4ktrtvmawoSq+4FCVHNryea6uR+qUQy0AGxLSsjCX0nVmkYQMBLHDkXZuo5hGx7eYdnIaslsdBFm7zbUw== + dependencies: + "@babel/helper-string-parser" "^7.27.1" + "@babel/helper-validator-identifier" "^7.27.1" + +"@docsearch/css@^3.9.0", "@docsearch/css@3.9.0": + version "3.9.0" + resolved "https://registry.npmjs.org/@docsearch/css/-/css-3.9.0.tgz" + integrity sha512-cQbnVbq0rrBwNAKegIac/t6a8nWoUAn8frnkLFW6YARaRmAQr5/Eoe6Ln2fqkUCZ40KpdrKbpSAmgrkviOxuWA== + +"@docsearch/js@^3.9.0": + version "3.9.0" + resolved "https://registry.npmjs.org/@docsearch/js/-/js-3.9.0.tgz" + integrity sha512-4bKHcye6EkLgRE8ze0vcdshmEqxeiJM77M0JXjef7lrYZfSlMunrDOCqyLjiZyo1+c0BhUqA2QpFartIjuHIjw== + dependencies: + "@docsearch/react" "3.9.0" preact "^10.0.0" -"@docsearch/react@3.6.0": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-3.6.0.tgz#b4f25228ecb7fc473741aefac592121e86dd2958" - integrity sha512-HUFut4ztcVNmqy9gp/wxNbC7pTOHhgVVkHVGCACTuLhUKUhKAF9KYHJtMiLUJxEqiFLQiuri1fWF8zqwM/cu1w== +"@docsearch/react@3.9.0": + version "3.9.0" + resolved "https://registry.npmjs.org/@docsearch/react/-/react-3.9.0.tgz" + integrity sha512-mb5FOZYZIkRQ6s/NWnM98k879vu5pscWqTLubLFBO87igYYT4VzVazh4h5o/zCvTIZgEt3PvsCOMOswOUo9yHQ== dependencies: - "@algolia/autocomplete-core" "1.9.3" - "@algolia/autocomplete-preset-algolia" "1.9.3" - "@docsearch/css" "3.6.0" - algoliasearch "^4.19.1" + "@algolia/autocomplete-core" "1.17.9" + "@algolia/autocomplete-preset-algolia" "1.17.9" + "@docsearch/css" "3.9.0" + algoliasearch "^5.14.2" -"@esbuild/aix-ppc64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" - integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== +"@esbuild/darwin-arm64@0.25.5": + version "0.25.5" + resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz" + integrity sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ== -"@esbuild/android-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" - integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== - -"@esbuild/android-arm@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" - integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== - -"@esbuild/android-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" - integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== - -"@esbuild/darwin-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" - integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== - -"@esbuild/darwin-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" - integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== - -"@esbuild/freebsd-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" - integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== - -"@esbuild/freebsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" - integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== - -"@esbuild/linux-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" - integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== - -"@esbuild/linux-arm@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" - integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== - -"@esbuild/linux-ia32@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" - integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== - -"@esbuild/linux-loong64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" - integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== - -"@esbuild/linux-mips64el@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" - integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== - -"@esbuild/linux-ppc64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" - integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== - -"@esbuild/linux-riscv64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" - integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== - -"@esbuild/linux-s390x@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" - integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== - -"@esbuild/linux-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0" - integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== - -"@esbuild/netbsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" - integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== - -"@esbuild/openbsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" - integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== - -"@esbuild/sunos-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" - integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== - -"@esbuild/win32-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" - integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== - -"@esbuild/win32-ia32@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" - integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== - -"@esbuild/win32-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" - integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== - -"@jridgewell/sourcemap-codec@^1.4.15": - version "1.4.15" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" - integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== - -"@rollup/rollup-android-arm-eabi@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.0.tgz#bbd0e616b2078cd2d68afc9824d1fadb2f2ffd27" - integrity sha512-Tya6xypR10giZV1XzxmH5wr25VcZSncG0pZIjfePT0OVBvqNEurzValetGNarVrGiq66EBVAFn15iYX4w6FKgQ== - -"@rollup/rollup-android-arm64@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.0.tgz#97255ef6384c5f73f4800c0de91f5f6518e21203" - integrity sha512-avCea0RAP03lTsDhEyfy+hpfr85KfyTctMADqHVhLAF3MlIkq83CP8UfAHUssgXTYd+6er6PaAhx/QGv4L1EiA== - -"@rollup/rollup-darwin-arm64@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.0.tgz#b6dd74e117510dfe94541646067b0545b42ff096" - integrity sha512-IWfdwU7KDSm07Ty0PuA/W2JYoZ4iTj3TUQjkVsO/6U+4I1jN5lcR71ZEvRh52sDOERdnNhhHU57UITXz5jC1/w== - -"@rollup/rollup-darwin-x64@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.18.0.tgz#e07d76de1cec987673e7f3d48ccb8e106d42c05c" - integrity sha512-n2LMsUz7Ynu7DoQrSQkBf8iNrjOGyPLrdSg802vk6XT3FtsgX6JbE8IHRvposskFm9SNxzkLYGSq9QdpLYpRNA== - -"@rollup/rollup-linux-arm-gnueabihf@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.18.0.tgz#9f1a6d218b560c9d75185af4b8bb42f9f24736b8" - integrity sha512-C/zbRYRXFjWvz9Z4haRxcTdnkPt1BtCkz+7RtBSuNmKzMzp3ZxdM28Mpccn6pt28/UWUCTXa+b0Mx1k3g6NOMA== - -"@rollup/rollup-linux-arm-musleabihf@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.18.0.tgz#53618b92e6ffb642c7b620e6e528446511330549" - integrity sha512-l3m9ewPgjQSXrUMHg93vt0hYCGnrMOcUpTz6FLtbwljo2HluS4zTXFy2571YQbisTnfTKPZ01u/ukJdQTLGh9A== - -"@rollup/rollup-linux-arm64-gnu@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.0.tgz#99a7ba5e719d4f053761a698f7b52291cefba577" - integrity sha512-rJ5D47d8WD7J+7STKdCUAgmQk49xuFrRi9pZkWoRD1UeSMakbcepWXPF8ycChBoAqs1pb2wzvbY6Q33WmN2ftw== - -"@rollup/rollup-linux-arm64-musl@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.18.0.tgz#f53db99a45d9bc00ce94db8a35efa7c3c144a58c" - integrity sha512-be6Yx37b24ZwxQ+wOQXXLZqpq4jTckJhtGlWGZs68TgdKXJgw54lUUoFYrg6Zs/kjzAQwEwYbp8JxZVzZLRepQ== - -"@rollup/rollup-linux-powerpc64le-gnu@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.18.0.tgz#cbb0837408fe081ce3435cf3730e090febafc9bf" - integrity sha512-hNVMQK+qrA9Todu9+wqrXOHxFiD5YmdEi3paj6vP02Kx1hjd2LLYR2eaN7DsEshg09+9uzWi2W18MJDlG0cxJA== - -"@rollup/rollup-linux-riscv64-gnu@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.18.0.tgz#8ed09c1d1262ada4c38d791a28ae0fea28b80cc9" - integrity sha512-ROCM7i+m1NfdrsmvwSzoxp9HFtmKGHEqu5NNDiZWQtXLA8S5HBCkVvKAxJ8U+CVctHwV2Gb5VUaK7UAkzhDjlg== - -"@rollup/rollup-linux-s390x-gnu@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.0.tgz#938138d3c8e0c96f022252a28441dcfb17afd7ec" - integrity sha512-0UyyRHyDN42QL+NbqevXIIUnKA47A+45WyasO+y2bGJ1mhQrfrtXUpTxCOrfxCR4esV3/RLYyucGVPiUsO8xjg== - -"@rollup/rollup-linux-x64-gnu@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.0.tgz#1a7481137a54740bee1ded4ae5752450f155d942" - integrity sha512-xuglR2rBVHA5UsI8h8UbX4VJ470PtGCf5Vpswh7p2ukaqBGFTnsfzxUBetoWBWymHMxbIG0Cmx7Y9qDZzr648w== - -"@rollup/rollup-linux-x64-musl@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.18.0.tgz#f1186afc601ac4f4fc25fac4ca15ecbee3a1874d" - integrity sha512-LKaqQL9osY/ir2geuLVvRRs+utWUNilzdE90TpyoX0eNqPzWjRm14oMEE+YLve4k/NAqCdPkGYDaDF5Sw+xBfg== - -"@rollup/rollup-win32-arm64-msvc@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.0.tgz#ed6603e93636a96203c6915be4117245c1bd2daf" - integrity sha512-7J6TkZQFGo9qBKH0pk2cEVSRhJbL6MtfWxth7Y5YmZs57Pi+4x6c2dStAUvaQkHQLnEQv1jzBUW43GvZW8OFqA== - -"@rollup/rollup-win32-ia32-msvc@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.0.tgz#14e0b404b1c25ebe6157a15edb9c46959ba74c54" - integrity sha512-Txjh+IxBPbkUB9+SXZMpv+b/vnTEtFyfWZgJ6iyCmt2tdx0OF5WhFowLmnh8ENGNpfUlUZkdI//4IEmhwPieNg== - -"@rollup/rollup-win32-x64-msvc@4.18.0": - version "4.18.0" - resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.0.tgz#5d694d345ce36b6ecf657349e03eb87297e68da4" - integrity sha512-UOo5FdvOL0+eIVTgS4tIdbW+TtnBLWg1YBCcU2KWM7nuNwRz9bksDX1bekJJCpu25N1DVWaCwnT39dVQxzqS8g== - -"@shikijs/core@1.10.0", "@shikijs/core@^1.6.2": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@shikijs/core/-/core-1.10.0.tgz#ec3356ace7cb8b41f6baee0116f036fca85054cc" - integrity sha512-BZcr6FCmPfP6TXaekvujZcnkFmJHZ/Yglu97r/9VjzVndQA56/F4WjUKtJRQUnK59Wi7p/UTAOekMfCJv7jnYg== - -"@shikijs/transformers@^1.6.2": - version "1.10.0" - resolved "https://registry.yarnpkg.com/@shikijs/transformers/-/transformers-1.10.0.tgz#327a8d63d0d0fd5237ee41c4444376723b7c5a2c" - integrity sha512-5Eu/kuJu7/CzAjFlTJkyyPoLTLSVQZ31Ps81cjIeR/3PDJ2RUuX1/R8d0qFziBKToym1LXbNiXoJQq0mg5+Cwg== +"@iconify-json/simple-icons@^1.2.32": + version "1.2.36" + resolved "https://registry.npmjs.org/@iconify-json/simple-icons/-/simple-icons-1.2.36.tgz" + integrity sha512-ZMpVdoW/7hhbt2aHVSvudjH8eSVNNjKkAAjwAQHgiuPUiIfbvNakVin+H9uhUz4N9TbDT/nanzV/4Slb+6dDXw== dependencies: - shiki "1.10.0" + "@iconify/types" "*" -"@types/estree@1.0.5": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" - integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== - -"@types/linkify-it@^5": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-5.0.0.tgz#21413001973106cda1c3a9b91eedd4ccd5469d76" - integrity sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q== - -"@types/markdown-it@^14.1.1": - version "14.1.1" - resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-14.1.1.tgz#06bafb7a4e3f77b62b1f308acf7df76687887e0b" - integrity sha512-4NpsnpYl2Gt1ljyBGrKMxFYAYvpqbnnkgP/i/g+NLpjEUa3obn1XJCur9YbEXKDAkaXqsR1LbDnGEJ0MmKFxfg== - dependencies: - "@types/linkify-it" "^5" - "@types/mdurl" "^2" - -"@types/mdurl@^2": +"@iconify/types@*": version "2.0.0" - resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-2.0.0.tgz#d43878b5b20222682163ae6f897b20447233bdfd" - integrity sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg== + resolved "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz" + integrity sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg== -"@types/web-bluetooth@^0.0.20": - version "0.0.20" - resolved "https://registry.yarnpkg.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz#f066abfcd1cbe66267cdbbf0de010d8a41b41597" - integrity sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow== +"@jridgewell/sourcemap-codec@^1.5.0": + version "1.5.0" + resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== -"@vitejs/plugin-vue@^5.0.5": - version "5.0.5" - resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-5.0.5.tgz#e3dc11e427d4b818b7e3202766ad156e3d5e2eaa" - integrity sha512-LOjm7XeIimLBZyzinBQ6OSm3UBCNVCpLkxGC0oWmm2YPzVZoxMsdvNVimLTBzpAnR9hl/yn1SHGuRfe6/Td9rQ== +"@rollup/rollup-darwin-arm64@4.41.1": + version "4.41.1" + resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.41.1.tgz" + integrity sha512-5afxvwszzdulsU2w8JKWwY8/sJOLPzf0e1bFuvcW5h9zsEg+RQAojdW0ux2zyYAz7R8HvvzKCjLNJhVq965U7w== -"@vue/compiler-core@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.4.31.tgz#b51a76f1b30e9b5eba0553264dff0f171aedb7c6" - integrity sha512-skOiodXWTV3DxfDhB4rOf3OGalpITLlgCeOwb+Y9GJpfQ8ErigdBUHomBzvG78JoVE8MJoQsb+qhZiHfKeNeEg== +"@shikijs/core@^3.2.2", "@shikijs/core@3.4.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/core/-/core-3.4.2.tgz" + integrity sha512-AG8vnSi1W2pbgR2B911EfGqtLE9c4hQBYkv/x7Z+Kt0VxhgQKcW7UNDVYsu9YxwV6u+OJrvdJrMq6DNWoBjihQ== dependencies: - "@babel/parser" "^7.24.7" - "@vue/shared" "3.4.31" + "@shikijs/types" "3.4.2" + "@shikijs/vscode-textmate" "^10.0.2" + "@types/hast" "^3.0.4" + hast-util-to-html "^9.0.5" + +"@shikijs/engine-javascript@3.4.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/engine-javascript/-/engine-javascript-3.4.2.tgz" + integrity sha512-1/adJbSMBOkpScCE/SB6XkjJU17ANln3Wky7lOmrnpl+zBdQ1qXUJg2GXTYVHRq+2j3hd1DesmElTXYDgtfSOQ== + dependencies: + "@shikijs/types" "3.4.2" + "@shikijs/vscode-textmate" "^10.0.2" + oniguruma-to-es "^4.3.3" + +"@shikijs/engine-oniguruma@3.4.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/engine-oniguruma/-/engine-oniguruma-3.4.2.tgz" + integrity sha512-zcZKMnNndgRa3ORja6Iemsr3DrLtkX3cAF7lTJkdMB6v9alhlBsX9uNiCpqofNrXOvpA3h6lHcLJxgCIhVOU5Q== + dependencies: + "@shikijs/types" "3.4.2" + "@shikijs/vscode-textmate" "^10.0.2" + +"@shikijs/langs@3.4.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/langs/-/langs-3.4.2.tgz" + integrity sha512-H6azIAM+OXD98yztIfs/KH5H4PU39t+SREhmM8LaNXyUrqj2mx+zVkr8MWYqjceSjDw9I1jawm1WdFqU806rMA== + dependencies: + "@shikijs/types" "3.4.2" + +"@shikijs/themes@3.4.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/themes/-/themes-3.4.2.tgz" + integrity sha512-qAEuAQh+brd8Jyej2UDDf+b4V2g1Rm8aBIdvt32XhDPrHvDkEnpb7Kzc9hSuHUxz0Iuflmq7elaDuQAP9bHIhg== + dependencies: + "@shikijs/types" "3.4.2" + +"@shikijs/transformers@^3.2.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/transformers/-/transformers-3.4.2.tgz" + integrity sha512-I5baLVi/ynLEOZoWSAMlACHNnG+yw5HDmse0oe+GW6U1u+ULdEB3UHiVWaHoJSSONV7tlcVxuaMy74sREDkSvg== + dependencies: + "@shikijs/core" "3.4.2" + "@shikijs/types" "3.4.2" + +"@shikijs/types@^3.2.2", "@shikijs/types@3.4.2": + version "3.4.2" + resolved "https://registry.npmjs.org/@shikijs/types/-/types-3.4.2.tgz" + integrity sha512-zHC1l7L+eQlDXLnxvM9R91Efh2V4+rN3oMVS2swCBssbj2U/FBwybD1eeLaq8yl/iwT+zih8iUbTBCgGZOYlVg== + dependencies: + "@shikijs/vscode-textmate" "^10.0.2" + "@types/hast" "^3.0.4" + +"@shikijs/vscode-textmate@^10.0.2": + version "10.0.2" + resolved "https://registry.npmjs.org/@shikijs/vscode-textmate/-/vscode-textmate-10.0.2.tgz" + integrity sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg== + +"@types/estree@1.0.7": + version "1.0.7" + resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz" + integrity sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ== + +"@types/hast@^3.0.0", "@types/hast@^3.0.4": + version "3.0.4" + resolved "https://registry.npmjs.org/@types/hast/-/hast-3.0.4.tgz" + integrity sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ== + dependencies: + "@types/unist" "*" + +"@types/mdast@^4.0.0": + version "4.0.4" + resolved "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz" + integrity sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA== + dependencies: + "@types/unist" "*" + +"@types/unist@*", "@types/unist@^3.0.0": + version "3.0.3" + resolved "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz" + integrity sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q== + +"@types/web-bluetooth@^0.0.21": + version "0.0.21" + resolved "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz" + integrity sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA== + +"@ungap/structured-clone@^1.0.0": + version "1.3.0" + resolved "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz" + integrity sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g== + +"@vitejs/plugin-vue@^5.2.3": + version "5.2.4" + resolved "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-5.2.4.tgz" + integrity sha512-7Yx/SXSOcQq5HiiV3orevHUFn+pmMB4cgbEkDYgnkUWb0WfeQ/wa2yFv6D5ICiCQOVpjA7vYDXrC7AGO8yjDHA== + +"@vue/compiler-core@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.16.tgz" + integrity sha512-AOQS2eaQOaaZQoL1u+2rCJIKDruNXVBZSiUD3chnUrsoX5ZTQMaCvXlWNIfxBJuU15r1o7+mpo5223KVtIhAgQ== + dependencies: + "@babel/parser" "^7.27.2" + "@vue/shared" "3.5.16" entities "^4.5.0" estree-walker "^2.0.2" - source-map-js "^1.2.0" + source-map-js "^1.2.1" -"@vue/compiler-dom@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.4.31.tgz#30961ca847f5d6ad18ffa26236c219f61b195f6b" - integrity sha512-wK424WMXsG1IGMyDGyLqB+TbmEBFM78hIsOJ9QwUVLGrcSk0ak6zYty7Pj8ftm7nEtdU/DGQxAXp0/lM/2cEpQ== +"@vue/compiler-dom@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.16.tgz" + integrity sha512-SSJIhBr/teipXiXjmWOVWLnxjNGo65Oj/8wTEQz0nqwQeP75jWZ0n4sF24Zxoht1cuJoWopwj0J0exYwCJ0dCQ== dependencies: - "@vue/compiler-core" "3.4.31" - "@vue/shared" "3.4.31" + "@vue/compiler-core" "3.5.16" + "@vue/shared" "3.5.16" -"@vue/compiler-sfc@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/compiler-sfc/-/compiler-sfc-3.4.31.tgz#cc6bfccda17df8268cc5440842277f61623c591f" - integrity sha512-einJxqEw8IIJxzmnxmJBuK2usI+lJonl53foq+9etB2HAzlPjAS/wa7r0uUpXw5ByX3/0uswVSrjNb17vJm1kQ== +"@vue/compiler-sfc@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.16.tgz" + integrity sha512-rQR6VSFNpiinDy/DVUE0vHoIDUF++6p910cgcZoaAUm3POxgNOOdS/xgoll3rNdKYTYPnnbARDCZOyZ+QSe6Pw== dependencies: - "@babel/parser" "^7.24.7" - "@vue/compiler-core" "3.4.31" - "@vue/compiler-dom" "3.4.31" - "@vue/compiler-ssr" "3.4.31" - "@vue/shared" "3.4.31" + "@babel/parser" "^7.27.2" + "@vue/compiler-core" "3.5.16" + "@vue/compiler-dom" "3.5.16" + "@vue/compiler-ssr" "3.5.16" + "@vue/shared" "3.5.16" estree-walker "^2.0.2" - magic-string "^0.30.10" - postcss "^8.4.38" - source-map-js "^1.2.0" + magic-string "^0.30.17" + postcss "^8.5.3" + source-map-js "^1.2.1" -"@vue/compiler-ssr@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/compiler-ssr/-/compiler-ssr-3.4.31.tgz#f62ffecdf15bacb883d0099780cf9a1e3654bfc4" - integrity sha512-RtefmITAje3fJ8FSg1gwgDhdKhZVntIVbwupdyZDSifZTRMiWxWehAOTCc8/KZDnBOcYQ4/9VWxsTbd3wT0hAA== +"@vue/compiler-ssr@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.16.tgz" + integrity sha512-d2V7kfxbdsjrDSGlJE7my1ZzCXViEcqN6w14DOsDrUCHEA6vbnVCpRFfrc4ryCP/lCKzX2eS1YtnLE/BuC9f/A== dependencies: - "@vue/compiler-dom" "3.4.31" - "@vue/shared" "3.4.31" + "@vue/compiler-dom" "3.5.16" + "@vue/shared" "3.5.16" -"@vue/devtools-api@^7.2.1": - version "7.3.5" - resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-7.3.5.tgz#afd9f3bca50cfff96aebeea3cc3853fd127267f7" - integrity sha512-BSdBBu5hOIv+gBJC9jzYMh5bC27FQwjWLSb8fVAniqlL9gvsqvK27xTgczMf+hgctlszMYQnRm3bpY/j8vhPqw== +"@vue/devtools-api@^7.7.5": + version "7.7.6" + resolved "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.7.6.tgz" + integrity sha512-b2Xx0KvXZObePpXPYHvBRRJLDQn5nhKjXh7vUhMEtWxz1AYNFOVIsh5+HLP8xDGL7sy+Q7hXeUxPHB/KgbtsPw== dependencies: - "@vue/devtools-kit" "^7.3.5" + "@vue/devtools-kit" "^7.7.6" -"@vue/devtools-kit@^7.3.5": - version "7.3.5" - resolved "https://registry.yarnpkg.com/@vue/devtools-kit/-/devtools-kit-7.3.5.tgz#66669ee94da6c927fc28255477f65aae3f616316" - integrity sha512-wwfi10gJ1HMtjzcd8aIOnzBHlIRqsYDgcDyrKvkeyc0Gbcoe7UrkXRVHZUOtcxxoplHA0PwpT6wFg0uUCmi8Ww== +"@vue/devtools-kit@^7.7.6": + version "7.7.6" + resolved "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.6.tgz" + integrity sha512-geu7ds7tem2Y7Wz+WgbnbZ6T5eadOvozHZ23Atk/8tksHMFOFylKi1xgGlQlVn0wlkEf4hu+vd5ctj1G4kFtwA== dependencies: - "@vue/devtools-shared" "^7.3.5" - birpc "^0.2.17" + "@vue/devtools-shared" "^7.7.6" + birpc "^2.3.0" hookable "^5.5.3" mitt "^3.0.1" perfect-debounce "^1.0.0" speakingurl "^14.0.1" - superjson "^2.2.1" + superjson "^2.2.2" -"@vue/devtools-shared@^7.3.5": - version "7.3.5" - resolved "https://registry.yarnpkg.com/@vue/devtools-shared/-/devtools-shared-7.3.5.tgz#4c4020df6d71ab058518a8f3a272fc7f2682c5d8" - integrity sha512-Rqii3VazmWTi67a86rYopi61n5Ved05EybJCwyrfoO9Ok3MaS/4yRFl706ouoISMlyrASJFEzM0/AiDA6w4f9A== +"@vue/devtools-shared@^7.7.6": + version "7.7.6" + resolved "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.7.6.tgz" + integrity sha512-yFEgJZ/WblEsojQQceuyK6FzpFDx4kqrz2ohInxNj5/DnhoX023upTv4OD6lNPLAA5LLkbwPVb10o/7b+Y4FVA== dependencies: rfdc "^1.4.1" -"@vue/reactivity@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.4.31.tgz#eda80e90c4f9d7659efe1f5ed99c2dfdc9e93d77" - integrity sha512-VGkTani8SOoVkZNds1PfJ/T1SlAIOf8E58PGAhIOUDYPC4GAmFA2u/E14TDAFcf3vVDKunc4QqCe/SHr8xC65Q== +"@vue/reactivity@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.16.tgz" + integrity sha512-FG5Q5ee/kxhIm1p2bykPpPwqiUBV3kFySsHEQha5BJvjXdZTUfmya7wP7zC39dFuZAcf/PD5S4Lni55vGLMhvA== dependencies: - "@vue/shared" "3.4.31" + "@vue/shared" "3.5.16" -"@vue/runtime-core@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.4.31.tgz#ad3a41ad76385c0429e3e4dbefb81918494e10cf" - integrity sha512-LDkztxeUPazxG/p8c5JDDKPfkCDBkkiNLVNf7XZIUnJ+66GVGkP+TIh34+8LtPisZ+HMWl2zqhIw0xN5MwU1cw== +"@vue/runtime-core@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.16.tgz" + integrity sha512-bw5Ykq6+JFHYxrQa7Tjr+VSzw7Dj4ldR/udyBZbq73fCdJmyy5MPIFR9IX/M5Qs+TtTjuyUTCnmK3lWWwpAcFQ== dependencies: - "@vue/reactivity" "3.4.31" - "@vue/shared" "3.4.31" + "@vue/reactivity" "3.5.16" + "@vue/shared" "3.5.16" -"@vue/runtime-dom@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.4.31.tgz#bae7ad844f944af33699c73581bc36125bab96ce" - integrity sha512-2Auws3mB7+lHhTFCg8E9ZWopA6Q6L455EcU7bzcQ4x6Dn4cCPuqj6S2oBZgN2a8vJRS/LSYYxwFFq2Hlx3Fsaw== +"@vue/runtime-dom@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.16.tgz" + integrity sha512-T1qqYJsG2xMGhImRUV9y/RseB9d0eCYZQ4CWca9ztCuiPj/XWNNN+lkNBuzVbia5z4/cgxdL28NoQCvC0Xcfww== dependencies: - "@vue/reactivity" "3.4.31" - "@vue/runtime-core" "3.4.31" - "@vue/shared" "3.4.31" + "@vue/reactivity" "3.5.16" + "@vue/runtime-core" "3.5.16" + "@vue/shared" "3.5.16" csstype "^3.1.3" -"@vue/server-renderer@3.4.31": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/server-renderer/-/server-renderer-3.4.31.tgz#bbe990f793c36d62d05bdbbaf142511d53e159fd" - integrity sha512-D5BLbdvrlR9PE3by9GaUp1gQXlCNadIZytMIb8H2h3FMWJd4oUfkUTEH2wAr3qxoRz25uxbTcbqd3WKlm9EHQA== +"@vue/server-renderer@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.16.tgz" + integrity sha512-BrX0qLiv/WugguGsnQUJiYOE0Fe5mZTwi6b7X/ybGB0vfrPH9z0gD/Y6WOR1sGCgX4gc25L1RYS5eYQKDMoNIg== dependencies: - "@vue/compiler-ssr" "3.4.31" - "@vue/shared" "3.4.31" + "@vue/compiler-ssr" "3.5.16" + "@vue/shared" "3.5.16" -"@vue/shared@3.4.31", "@vue/shared@^3.4.27": - version "3.4.31" - resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.4.31.tgz#af9981f57def2c3f080c14bf219314fc0dc808a0" - integrity sha512-Yp3wtJk//8cO4NItOPpi3QkLExAr/aLBGZMmTtW9WpdwBCJpRM6zj9WgWktXAl8IDIozwNMByT45JP3tO3ACWA== +"@vue/shared@^3.5.13", "@vue/shared@3.5.16": + version "3.5.16" + resolved "https://registry.npmjs.org/@vue/shared/-/shared-3.5.16.tgz" + integrity sha512-c/0fWy3Jw6Z8L9FmTyYfkpM5zklnqqa9+a6dz3DvONRKW2NEbh46BP0FHuLFSWi2TnQEtp91Z6zOWNrU6QiyPg== -"@vueuse/core@10.11.0", "@vueuse/core@^10.10.0": - version "10.11.0" - resolved "https://registry.yarnpkg.com/@vueuse/core/-/core-10.11.0.tgz#b042585a8bf98bb29c177b33999bd0e3fcd9e65d" - integrity sha512-x3sD4Mkm7PJ+pcq3HX8PLPBadXCAlSDR/waK87dz0gQE+qJnaaFhc/dZVfJz+IUYzTMVGum2QlR7ImiJQN4s6g== +"@vueuse/core@^13.1.0", "@vueuse/core@13.3.0": + version "13.3.0" + resolved "https://registry.npmjs.org/@vueuse/core/-/core-13.3.0.tgz" + integrity sha512-uYRz5oEfebHCoRhK4moXFM3NSCd5vu2XMLOq/Riz5FdqZMy2RvBtazdtL3gEcmDyqkztDe9ZP/zymObMIbiYSg== dependencies: - "@types/web-bluetooth" "^0.0.20" - "@vueuse/metadata" "10.11.0" - "@vueuse/shared" "10.11.0" - vue-demi ">=0.14.8" + "@types/web-bluetooth" "^0.0.21" + "@vueuse/metadata" "13.3.0" + "@vueuse/shared" "13.3.0" -"@vueuse/integrations@^10.10.0": - version "10.11.0" - resolved "https://registry.yarnpkg.com/@vueuse/integrations/-/integrations-10.11.0.tgz#ce2746587172af9ab8faa713f42e619609ed0de1" - integrity sha512-Pp6MtWEIr+NDOccWd8j59Kpjy5YDXogXI61Kb1JxvSfVBO8NzFQkmrKmSZz47i+ZqHnIzxaT38L358yDHTncZg== +"@vueuse/integrations@^13.1.0": + version "13.3.0" + resolved "https://registry.npmjs.org/@vueuse/integrations/-/integrations-13.3.0.tgz" + integrity sha512-h5mGRYPbiTZTFP/AKELLPGnUDBly7z7Qd1pgEQlT3ItQ0NlZM0vB+8SOQycpSBOBlgg72Zgw+mi2r+4O/G8RuQ== dependencies: - "@vueuse/core" "10.11.0" - "@vueuse/shared" "10.11.0" - vue-demi ">=0.14.8" + "@vueuse/core" "13.3.0" + "@vueuse/shared" "13.3.0" -"@vueuse/metadata@10.11.0": - version "10.11.0" - resolved "https://registry.yarnpkg.com/@vueuse/metadata/-/metadata-10.11.0.tgz#27be47cf115ee98e947a1bfcd0b1b5b35d785fb6" - integrity sha512-kQX7l6l8dVWNqlqyN3ePW3KmjCQO3ZMgXuBMddIu83CmucrsBfXlH+JoviYyRBws/yLTQO8g3Pbw+bdIoVm4oQ== +"@vueuse/metadata@13.3.0": + version "13.3.0" + resolved "https://registry.npmjs.org/@vueuse/metadata/-/metadata-13.3.0.tgz" + integrity sha512-42IzJIOYCKIb0Yjv1JfaKpx8JlCiTmtCWrPxt7Ja6Wzoq0h79+YVXmBV03N966KEmDEESTbp5R/qO3AB5BDnGw== -"@vueuse/shared@10.11.0": - version "10.11.0" - resolved "https://registry.yarnpkg.com/@vueuse/shared/-/shared-10.11.0.tgz#be09262b2c5857069ed3dadd1680f22c4cb6f984" - integrity sha512-fyNoIXEq3PfX1L3NkNhtVQUSRtqYwJtJg+Bp9rIzculIZWHTkKSysujrOk2J+NrRulLTQH9+3gGSfYLWSEWU1A== +"@vueuse/shared@13.3.0": + version "13.3.0" + resolved "https://registry.npmjs.org/@vueuse/shared/-/shared-13.3.0.tgz" + integrity sha512-L1QKsF0Eg9tiZSFXTgodYnu0Rsa2P0En2LuLrIs/jgrkyiDuJSsPZK+tx+wU0mMsYHUYEjNsuE41uqqkuR8VhA== + +algoliasearch@^5.14.2, "algoliasearch@>= 4.9.1 < 6": + version "5.25.0" + resolved "https://registry.npmjs.org/algoliasearch/-/algoliasearch-5.25.0.tgz" + integrity sha512-n73BVorL4HIwKlfJKb4SEzAYkR3Buwfwbh+MYxg2mloFph2fFGV58E90QTzdbfzWrLn4HE5Czx/WTjI8fcHaMg== dependencies: - vue-demi ">=0.14.8" + "@algolia/client-abtesting" "5.25.0" + "@algolia/client-analytics" "5.25.0" + "@algolia/client-common" "5.25.0" + "@algolia/client-insights" "5.25.0" + "@algolia/client-personalization" "5.25.0" + "@algolia/client-query-suggestions" "5.25.0" + "@algolia/client-search" "5.25.0" + "@algolia/ingestion" "1.25.0" + "@algolia/monitoring" "1.25.0" + "@algolia/recommend" "5.25.0" + "@algolia/requester-browser-xhr" "5.25.0" + "@algolia/requester-fetch" "5.25.0" + "@algolia/requester-node-http" "5.25.0" -algoliasearch@^4.19.1: - version "4.24.0" - resolved "https://registry.yarnpkg.com/algoliasearch/-/algoliasearch-4.24.0.tgz#b953b3e2309ef8f25da9de311b95b994ac918275" - integrity sha512-bf0QV/9jVejssFBmz2HQLxUadxk574t4iwjCKp5E7NBzwKkrDEhKPISIIjAU/p6K5qDx3qoeh4+26zWN1jmw3g== - dependencies: - "@algolia/cache-browser-local-storage" "4.24.0" - "@algolia/cache-common" "4.24.0" - "@algolia/cache-in-memory" "4.24.0" - "@algolia/client-account" "4.24.0" - "@algolia/client-analytics" "4.24.0" - "@algolia/client-common" "4.24.0" - "@algolia/client-personalization" "4.24.0" - "@algolia/client-search" "4.24.0" - "@algolia/logger-common" "4.24.0" - "@algolia/logger-console" "4.24.0" - "@algolia/recommend" "4.24.0" - "@algolia/requester-browser-xhr" "4.24.0" - "@algolia/requester-common" "4.24.0" - "@algolia/requester-node-http" "4.24.0" - "@algolia/transporter" "4.24.0" +birpc@^2.3.0: + version "2.3.0" + resolved "https://registry.npmjs.org/birpc/-/birpc-2.3.0.tgz" + integrity sha512-ijbtkn/F3Pvzb6jHypHRyve2QApOCZDR25D/VnkY2G/lBNcXCTsnsCxgY4k4PkVB7zfwzYbY3O9Lcqe3xufS5g== -birpc@^0.2.17: - version "0.2.17" - resolved "https://registry.yarnpkg.com/birpc/-/birpc-0.2.17.tgz#d0bdb90d4d063061156637f03b7b0adea1779734" - integrity sha512-+hkTxhot+dWsLpp3gia5AkVHIsKlZybNT5gIYiDlNzJrmYPcTM9k5/w2uaj3IPpd7LlEYpmCj4Jj1nC41VhDFg== +ccount@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz" + integrity sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg== + +character-entities-html4@^2.0.0: + version "2.1.0" + resolved "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-2.1.0.tgz" + integrity sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA== + +character-entities-legacy@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz" + integrity sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ== + +comma-separated-tokens@^2.0.0: + version "2.0.3" + resolved "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz" + integrity sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg== copy-anything@^3.0.2: version "3.0.5" - resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-3.0.5.tgz#2d92dce8c498f790fa7ad16b01a1ae5a45b020a0" + resolved "https://registry.npmjs.org/copy-anything/-/copy-anything-3.0.5.tgz" integrity sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w== dependencies: is-what "^4.1.8" csstype@^3.1.3: version "3.1.3" - resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81" + resolved "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz" integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw== +dequal@^2.0.0: + version "2.0.3" + resolved "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz" + integrity sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA== + +devlop@^1.0.0: + version "1.1.0" + resolved "https://registry.npmjs.org/devlop/-/devlop-1.1.0.tgz" + integrity sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA== + dependencies: + dequal "^2.0.0" + entities@^4.5.0: version "4.5.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + resolved "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz" integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== -esbuild@^0.21.3: - version "0.21.5" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d" - integrity sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw== +esbuild@^0.25.0: + version "0.25.5" + resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz" + integrity sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ== optionalDependencies: - "@esbuild/aix-ppc64" "0.21.5" - "@esbuild/android-arm" "0.21.5" - "@esbuild/android-arm64" "0.21.5" - "@esbuild/android-x64" "0.21.5" - "@esbuild/darwin-arm64" "0.21.5" - "@esbuild/darwin-x64" "0.21.5" - "@esbuild/freebsd-arm64" "0.21.5" - "@esbuild/freebsd-x64" "0.21.5" - "@esbuild/linux-arm" "0.21.5" - "@esbuild/linux-arm64" "0.21.5" - "@esbuild/linux-ia32" "0.21.5" - "@esbuild/linux-loong64" "0.21.5" - "@esbuild/linux-mips64el" "0.21.5" - "@esbuild/linux-ppc64" "0.21.5" - "@esbuild/linux-riscv64" "0.21.5" - "@esbuild/linux-s390x" "0.21.5" - "@esbuild/linux-x64" "0.21.5" - "@esbuild/netbsd-x64" "0.21.5" - "@esbuild/openbsd-x64" "0.21.5" - "@esbuild/sunos-x64" "0.21.5" - "@esbuild/win32-arm64" "0.21.5" - "@esbuild/win32-ia32" "0.21.5" - "@esbuild/win32-x64" "0.21.5" + "@esbuild/aix-ppc64" "0.25.5" + "@esbuild/android-arm" "0.25.5" + "@esbuild/android-arm64" "0.25.5" + "@esbuild/android-x64" "0.25.5" + "@esbuild/darwin-arm64" "0.25.5" + "@esbuild/darwin-x64" "0.25.5" + "@esbuild/freebsd-arm64" "0.25.5" + "@esbuild/freebsd-x64" "0.25.5" + "@esbuild/linux-arm" "0.25.5" + "@esbuild/linux-arm64" "0.25.5" + "@esbuild/linux-ia32" "0.25.5" + "@esbuild/linux-loong64" "0.25.5" + "@esbuild/linux-mips64el" "0.25.5" + "@esbuild/linux-ppc64" "0.25.5" + "@esbuild/linux-riscv64" "0.25.5" + "@esbuild/linux-s390x" "0.25.5" + "@esbuild/linux-x64" "0.25.5" + "@esbuild/netbsd-arm64" "0.25.5" + "@esbuild/netbsd-x64" "0.25.5" + "@esbuild/openbsd-arm64" "0.25.5" + "@esbuild/openbsd-x64" "0.25.5" + "@esbuild/sunos-x64" "0.25.5" + "@esbuild/win32-arm64" "0.25.5" + "@esbuild/win32-ia32" "0.25.5" + "@esbuild/win32-x64" "0.25.5" estree-walker@^2.0.2: version "2.0.2" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" + resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz" integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== -focus-trap@^7.5.4: - version "7.5.4" - resolved "https://registry.yarnpkg.com/focus-trap/-/focus-trap-7.5.4.tgz#6c4e342fe1dae6add9c2aa332a6e7a0bbd495ba2" - integrity sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w== +fdir@^6.4.4: + version "6.4.5" + resolved "https://registry.npmjs.org/fdir/-/fdir-6.4.5.tgz" + integrity sha512-4BG7puHpVsIYxZUbiUE3RqGloLaSSwzYie5jvasC4LWuBWzZawynvYouhjbQKw2JuIGYdm0DzIxl8iVidKlUEw== + +focus-trap@^7, focus-trap@^7.6.4: + version "7.6.5" + resolved "https://registry.npmjs.org/focus-trap/-/focus-trap-7.6.5.tgz" + integrity sha512-7Ke1jyybbbPZyZXFxEftUtxFGLMpE2n6A+z//m4CRDlj0hW+o3iYSmh8nFlYMurOiJVDmJRilUQtJr08KfIxlg== dependencies: tabbable "^6.2.0" fsevents@~2.3.2, fsevents@~2.3.3: version "2.3.3" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== +hast-util-to-html@^9.0.5: + version "9.0.5" + resolved "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-9.0.5.tgz" + integrity sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw== + dependencies: + "@types/hast" "^3.0.0" + "@types/unist" "^3.0.0" + ccount "^2.0.0" + comma-separated-tokens "^2.0.0" + hast-util-whitespace "^3.0.0" + html-void-elements "^3.0.0" + mdast-util-to-hast "^13.0.0" + property-information "^7.0.0" + space-separated-tokens "^2.0.0" + stringify-entities "^4.0.0" + zwitch "^2.0.4" + +hast-util-whitespace@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz" + integrity sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw== + dependencies: + "@types/hast" "^3.0.0" + hookable@^5.5.3: version "5.5.3" - resolved "https://registry.yarnpkg.com/hookable/-/hookable-5.5.3.tgz#6cfc358984a1ef991e2518cb9ed4a778bbd3215d" + resolved "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz" integrity sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ== +html-void-elements@^3.0.0: + version "3.0.0" + resolved "https://registry.npmjs.org/html-void-elements/-/html-void-elements-3.0.0.tgz" + integrity sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg== + is-what@^4.1.8: version "4.1.16" - resolved "https://registry.yarnpkg.com/is-what/-/is-what-4.1.16.tgz#1ad860a19da8b4895ad5495da3182ce2acdd7a6f" + resolved "https://registry.npmjs.org/is-what/-/is-what-4.1.16.tgz" integrity sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A== -magic-string@^0.30.10: - version "0.30.10" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.10.tgz#123d9c41a0cb5640c892b041d4cfb3bd0aa4b39e" - integrity sha512-iIRwTIf0QKV3UAnYK4PU8uiEc4SRh5jX0mwpIwETPpHdhVM4f53RSwS/vXvN1JhGX+Cs7B8qIq3d6AH49O5fAQ== +magic-string@^0.30.17: + version "0.30.17" + resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz" + integrity sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA== dependencies: - "@jridgewell/sourcemap-codec" "^1.4.15" + "@jridgewell/sourcemap-codec" "^1.5.0" mark.js@8.11.1: version "8.11.1" - resolved "https://registry.yarnpkg.com/mark.js/-/mark.js-8.11.1.tgz#180f1f9ebef8b0e638e4166ad52db879beb2ffc5" + resolved "https://registry.npmjs.org/mark.js/-/mark.js-8.11.1.tgz" integrity sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ== -minisearch@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/minisearch/-/minisearch-6.3.0.tgz#985a2f1ca3c73c2d65af94f0616bfe57164b0b6b" - integrity sha512-ihFnidEeU8iXzcVHy74dhkxh/dn8Dc08ERl0xwoMMGqp4+LvRSCgicb+zGqWthVokQKvCSxITlh3P08OzdTYCQ== +mdast-util-to-hast@^13.0.0: + version "13.2.0" + resolved "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-13.2.0.tgz" + integrity sha512-QGYKEuUsYT9ykKBCMOEDLsU5JRObWQusAolFMeko/tYPufNkRffBAQjIE+99jbA87xv6FgmjLtwjh9wBWajwAA== + dependencies: + "@types/hast" "^3.0.0" + "@types/mdast" "^4.0.0" + "@ungap/structured-clone" "^1.0.0" + devlop "^1.0.0" + micromark-util-sanitize-uri "^2.0.0" + trim-lines "^3.0.0" + unist-util-position "^5.0.0" + unist-util-visit "^5.0.0" + vfile "^6.0.0" + +micromark-util-character@^2.0.0: + version "2.1.1" + resolved "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz" + integrity sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q== + dependencies: + micromark-util-symbol "^2.0.0" + micromark-util-types "^2.0.0" + +micromark-util-encode@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-encode/-/micromark-util-encode-2.0.1.tgz" + integrity sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw== + +micromark-util-sanitize-uri@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-sanitize-uri/-/micromark-util-sanitize-uri-2.0.1.tgz" + integrity sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ== + dependencies: + micromark-util-character "^2.0.0" + micromark-util-encode "^2.0.0" + micromark-util-symbol "^2.0.0" + +micromark-util-symbol@^2.0.0: + version "2.0.1" + resolved "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz" + integrity sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q== + +micromark-util-types@^2.0.0: + version "2.0.2" + resolved "https://registry.npmjs.org/micromark-util-types/-/micromark-util-types-2.0.2.tgz" + integrity sha512-Yw0ECSpJoViF1qTU4DC6NwtC4aWGt1EkzaQB8KPPyCRR8z9TWeV0HbEFGTO+ZY1wB22zmxnJqhPyTpOVCpeHTA== + +minisearch@^7.1.2: + version "7.1.2" + resolved "https://registry.npmjs.org/minisearch/-/minisearch-7.1.2.tgz" + integrity sha512-R1Pd9eF+MD5JYDDSPAp/q1ougKglm14uEkPMvQ/05RGmx6G9wvmLTrTI/Q5iPNJLYqNdsDQ7qTGIcNWR+FrHmA== mitt@^3.0.1: version "3.0.1" - resolved "https://registry.yarnpkg.com/mitt/-/mitt-3.0.1.tgz#ea36cf0cc30403601ae074c8f77b7092cdab36d1" + resolved "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz" integrity sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw== -nanoid@^3.3.7: - version "3.3.7" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" - integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== +nanoid@^3.3.11: + version "3.3.11" + resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz" + integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w== + +oniguruma-parser@^0.12.1: + version "0.12.1" + resolved "https://registry.npmjs.org/oniguruma-parser/-/oniguruma-parser-0.12.1.tgz" + integrity sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w== + +oniguruma-to-es@^4.3.3: + version "4.3.3" + resolved "https://registry.npmjs.org/oniguruma-to-es/-/oniguruma-to-es-4.3.3.tgz" + integrity sha512-rPiZhzC3wXwE59YQMRDodUwwT9FZ9nNBwQQfsd1wfdtlKEyCdRV0avrTcSZ5xlIvGRVPd/cx6ZN45ECmS39xvg== + dependencies: + oniguruma-parser "^0.12.1" + regex "^6.0.1" + regex-recursion "^6.0.2" perfect-debounce@^1.0.0: version "1.0.0" - resolved "https://registry.yarnpkg.com/perfect-debounce/-/perfect-debounce-1.0.0.tgz#9c2e8bc30b169cc984a58b7d5b28049839591d2a" + resolved "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz" integrity sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA== -picocolors@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.1.tgz#a8ad579b571952f0e5d25892de5445bcfe25aaa1" - integrity sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew== +picocolors@^1.1.1: + version "1.1.1" + resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz" + integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== -postcss@^8.4.38: - version "8.4.39" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.39.tgz#aa3c94998b61d3a9c259efa51db4b392e1bde0e3" - integrity sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw== +"picomatch@^3 || ^4", picomatch@^4.0.2: + version "4.0.2" + resolved "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz" + integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== + +postcss@^8, postcss@^8.5.3: + version "8.5.4" + resolved "https://registry.npmjs.org/postcss/-/postcss-8.5.4.tgz" + integrity sha512-QSa9EBe+uwlGTFmHsPKokv3B/oEMQZxfqW0QqNCyhpa6mB1afzulwn8hihglqAb2pOw+BJgNlmXQ8la2VeHB7w== dependencies: - nanoid "^3.3.7" - picocolors "^1.0.1" - source-map-js "^1.2.0" + nanoid "^3.3.11" + picocolors "^1.1.1" + source-map-js "^1.2.1" preact@^10.0.0: version "10.22.0" - resolved "https://registry.yarnpkg.com/preact/-/preact-10.22.0.tgz#a50f38006ae438d255e2631cbdaf7488e6dd4e16" + resolved "https://registry.npmjs.org/preact/-/preact-10.22.0.tgz" integrity sha512-RRurnSjJPj4rp5K6XoP45Ui33ncb7e4H7WiOHVpjbkvqvA3U+N8Z6Qbo0AE6leGYBV66n8EhEaFixvIu3SkxFw== +property-information@^7.0.0: + version "7.1.0" + resolved "https://registry.npmjs.org/property-information/-/property-information-7.1.0.tgz" + integrity sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ== + +regex-recursion@^6.0.2: + version "6.0.2" + resolved "https://registry.npmjs.org/regex-recursion/-/regex-recursion-6.0.2.tgz" + integrity sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg== + dependencies: + regex-utilities "^2.3.0" + +regex-utilities@^2.3.0: + version "2.3.0" + resolved "https://registry.npmjs.org/regex-utilities/-/regex-utilities-2.3.0.tgz" + integrity sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng== + +regex@^6.0.1: + version "6.0.1" + resolved "https://registry.npmjs.org/regex/-/regex-6.0.1.tgz" + integrity sha512-uorlqlzAKjKQZ5P+kTJr3eeJGSVroLKoHmquUj4zHWuR+hEyNqlXsSKlYYF5F4NI6nl7tWCs0apKJ0lmfsXAPA== + dependencies: + regex-utilities "^2.3.0" + rfdc@^1.4.1: version "1.4.1" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.4.1.tgz#778f76c4fb731d93414e8f925fbecf64cce7f6ca" + resolved "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz" integrity sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA== -rollup@^4.13.0: - version "4.18.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.18.0.tgz#497f60f0c5308e4602cf41136339fbf87d5f5dda" - integrity sha512-QmJz14PX3rzbJCN1SG4Xe/bAAX2a6NpCP8ab2vfu2GiUr8AQcr2nCV/oEO3yneFarB67zk8ShlIyWb2LGTb3Sg== +rollup@^4.34.9: + version "4.41.1" + resolved "https://registry.npmjs.org/rollup/-/rollup-4.41.1.tgz" + integrity sha512-cPmwD3FnFv8rKMBc1MxWCwVQFxwf1JEmSX3iQXrRVVG15zerAIXRjMFVWnd5Q5QvgKF7Aj+5ykXFhUl+QGnyOw== dependencies: - "@types/estree" "1.0.5" + "@types/estree" "1.0.7" optionalDependencies: - "@rollup/rollup-android-arm-eabi" "4.18.0" - "@rollup/rollup-android-arm64" "4.18.0" - "@rollup/rollup-darwin-arm64" "4.18.0" - "@rollup/rollup-darwin-x64" "4.18.0" - "@rollup/rollup-linux-arm-gnueabihf" "4.18.0" - "@rollup/rollup-linux-arm-musleabihf" "4.18.0" - "@rollup/rollup-linux-arm64-gnu" "4.18.0" - "@rollup/rollup-linux-arm64-musl" "4.18.0" - "@rollup/rollup-linux-powerpc64le-gnu" "4.18.0" - "@rollup/rollup-linux-riscv64-gnu" "4.18.0" - "@rollup/rollup-linux-s390x-gnu" "4.18.0" - "@rollup/rollup-linux-x64-gnu" "4.18.0" - "@rollup/rollup-linux-x64-musl" "4.18.0" - "@rollup/rollup-win32-arm64-msvc" "4.18.0" - "@rollup/rollup-win32-ia32-msvc" "4.18.0" - "@rollup/rollup-win32-x64-msvc" "4.18.0" + "@rollup/rollup-android-arm-eabi" "4.41.1" + "@rollup/rollup-android-arm64" "4.41.1" + "@rollup/rollup-darwin-arm64" "4.41.1" + "@rollup/rollup-darwin-x64" "4.41.1" + "@rollup/rollup-freebsd-arm64" "4.41.1" + "@rollup/rollup-freebsd-x64" "4.41.1" + "@rollup/rollup-linux-arm-gnueabihf" "4.41.1" + "@rollup/rollup-linux-arm-musleabihf" "4.41.1" + "@rollup/rollup-linux-arm64-gnu" "4.41.1" + "@rollup/rollup-linux-arm64-musl" "4.41.1" + "@rollup/rollup-linux-loongarch64-gnu" "4.41.1" + "@rollup/rollup-linux-powerpc64le-gnu" "4.41.1" + "@rollup/rollup-linux-riscv64-gnu" "4.41.1" + "@rollup/rollup-linux-riscv64-musl" "4.41.1" + "@rollup/rollup-linux-s390x-gnu" "4.41.1" + "@rollup/rollup-linux-x64-gnu" "4.41.1" + "@rollup/rollup-linux-x64-musl" "4.41.1" + "@rollup/rollup-win32-arm64-msvc" "4.41.1" + "@rollup/rollup-win32-ia32-msvc" "4.41.1" + "@rollup/rollup-win32-x64-msvc" "4.41.1" fsevents "~2.3.2" -shiki@1.10.0, shiki@^1.6.2: - version "1.10.0" - resolved "https://registry.yarnpkg.com/shiki/-/shiki-1.10.0.tgz#304ab080a12458abc78eb0cb83eb0f7ace546215" - integrity sha512-YD2sXQ+TMD/F9BimV9Jn0wj35pqOvywvOG/3PB6hGHyGKlM7TJ9tyJ02jOb2kF8F0HfJwKNYrh3sW7jEcuRlXA== - dependencies: - "@shikijs/core" "1.10.0" +"search-insights@>= 1 < 3": + version "2.17.3" + resolved "https://registry.npmjs.org/search-insights/-/search-insights-2.17.3.tgz" + integrity sha512-RQPdCYTa8A68uM2jwxoY842xDhvx3E5LFL1LxvxCNMev4o5mLuokczhzjAgGwUZBAmOKZknArSxLKmXtIi2AxQ== -source-map-js@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af" - integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== +shiki@^3.2.2: + version "3.4.2" + resolved "https://registry.npmjs.org/shiki/-/shiki-3.4.2.tgz" + integrity sha512-wuxzZzQG8kvZndD7nustrNFIKYJ1jJoWIPaBpVe2+KHSvtzMi4SBjOxrigs8qeqce/l3U0cwiC+VAkLKSunHQQ== + dependencies: + "@shikijs/core" "3.4.2" + "@shikijs/engine-javascript" "3.4.2" + "@shikijs/engine-oniguruma" "3.4.2" + "@shikijs/langs" "3.4.2" + "@shikijs/themes" "3.4.2" + "@shikijs/types" "3.4.2" + "@shikijs/vscode-textmate" "^10.0.2" + "@types/hast" "^3.0.4" + +source-map-js@^1.2.1: + version "1.2.1" + resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz" + integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== + +space-separated-tokens@^2.0.0: + version "2.0.2" + resolved "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz" + integrity sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q== speakingurl@^14.0.1: version "14.0.1" - resolved "https://registry.yarnpkg.com/speakingurl/-/speakingurl-14.0.1.tgz#f37ec8ddc4ab98e9600c1c9ec324a8c48d772a53" + resolved "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz" integrity sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ== -superjson@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/superjson/-/superjson-2.2.1.tgz#9377a7fa80fedb10c851c9dbffd942d4bcf79733" - integrity sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA== +stringify-entities@^4.0.0: + version "4.0.4" + resolved "https://registry.npmjs.org/stringify-entities/-/stringify-entities-4.0.4.tgz" + integrity sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg== + dependencies: + character-entities-html4 "^2.0.0" + character-entities-legacy "^3.0.0" + +superjson@^2.2.2: + version "2.2.2" + resolved "https://registry.npmjs.org/superjson/-/superjson-2.2.2.tgz" + integrity sha512-5JRxVqC8I8NuOUjzBbvVJAKNM8qoVuH0O77h4WInc/qC2q5IreqKxYwgkga3PfA22OayK2ikceb/B26dztPl+Q== dependencies: copy-anything "^3.0.2" tabbable@^6.2.0: version "6.2.0" - resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.2.0.tgz#732fb62bc0175cfcec257330be187dcfba1f3b97" + resolved "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz" integrity sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew== -vite@^5.2.12: - version "5.3.2" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.3.2.tgz#2f0a8531c71060467ed3e0a205a203f269b6d9c8" - integrity sha512-6lA7OBHBlXUxiJxbO5aAY2fsHHzDr1q7DvXYnyZycRs2Dz+dXBWuhpWHvmljTRTpQC2uvGmUFFkSHF2vGo90MA== +tinyglobby@^0.2.13: + version "0.2.14" + resolved "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz" + integrity sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ== dependencies: - esbuild "^0.21.3" - postcss "^8.4.38" - rollup "^4.13.0" + fdir "^6.4.4" + picomatch "^4.0.2" + +trim-lines@^3.0.0: + version "3.0.1" + resolved "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz" + integrity sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg== + +unist-util-is@^6.0.0: + version "6.0.0" + resolved "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz" + integrity sha512-2qCTHimwdxLfz+YzdGfkqNlH0tLi9xjTnHddPmJwtIG9MGsdbutfTc4P+haPD7l7Cjxf/WZj+we5qfVPvvxfYw== + dependencies: + "@types/unist" "^3.0.0" + +unist-util-position@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/unist-util-position/-/unist-util-position-5.0.0.tgz" + integrity sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA== + dependencies: + "@types/unist" "^3.0.0" + +unist-util-stringify-position@^4.0.0: + version "4.0.0" + resolved "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-4.0.0.tgz" + integrity sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ== + dependencies: + "@types/unist" "^3.0.0" + +unist-util-visit-parents@^6.0.0: + version "6.0.1" + resolved "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-6.0.1.tgz" + integrity sha512-L/PqWzfTP9lzzEa6CKs0k2nARxTdZduw3zyh8d2NVBnsyvHjSX4TWse388YrrQKbvI8w20fGjGlhgT96WwKykw== + dependencies: + "@types/unist" "^3.0.0" + unist-util-is "^6.0.0" + +unist-util-visit@^5.0.0: + version "5.0.0" + resolved "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-5.0.0.tgz" + integrity sha512-MR04uvD+07cwl/yhVuVWAtw+3GOR/knlL55Nd/wAdblk27GCVt3lqpTivy/tkJcZoNPzTwS1Y+KMojlLDhoTzg== + dependencies: + "@types/unist" "^3.0.0" + unist-util-is "^6.0.0" + unist-util-visit-parents "^6.0.0" + +vfile-message@^4.0.0: + version "4.0.2" + resolved "https://registry.npmjs.org/vfile-message/-/vfile-message-4.0.2.tgz" + integrity sha512-jRDZ1IMLttGj41KcZvlrYAaI3CfqpLpfpf+Mfig13viT6NKvRzWZ+lXz0Y5D60w6uJIBAOGq9mSHf0gktF0duw== + dependencies: + "@types/unist" "^3.0.0" + unist-util-stringify-position "^4.0.0" + +vfile@^6.0.0: + version "6.0.3" + resolved "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz" + integrity sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q== + dependencies: + "@types/unist" "^3.0.0" + vfile-message "^4.0.0" + +"vite@^5.0.0 || ^6.0.0", vite@^6.3.2: + version "6.3.5" + resolved "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz" + integrity sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ== + dependencies: + esbuild "^0.25.0" + fdir "^6.4.4" + picomatch "^4.0.2" + postcss "^8.5.3" + rollup "^4.34.9" + tinyglobby "^0.2.13" optionalDependencies: fsevents "~2.3.3" -vitepress@^1.0.0-rc.35: - version "1.2.3" - resolved "https://registry.yarnpkg.com/vitepress/-/vitepress-1.2.3.tgz#a507d2f5e86c1fbcdb5ec2212f1db4828504df34" - integrity sha512-GvEsrEeNLiDE1+fuwDAYJCYLNZDAna+EtnXlPajhv/MYeTjbNK6Bvyg6NoTdO1sbwuQJ0vuJR99bOlH53bo6lg== +vitepress@^2.0.0-alpha.5: + version "2.0.0-alpha.5" + resolved "https://registry.npmjs.org/vitepress/-/vitepress-2.0.0-alpha.5.tgz" + integrity sha512-fhuGpJ4CETS/lrAHjKu3m88HwesZvAjZLFeIRr9Jejmewyogn1tm2L6lsVg7PWxPmOGoMfihzl3+L6jg6hrTnA== dependencies: - "@docsearch/css" "^3.6.0" - "@docsearch/js" "^3.6.0" - "@shikijs/core" "^1.6.2" - "@shikijs/transformers" "^1.6.2" - "@types/markdown-it" "^14.1.1" - "@vitejs/plugin-vue" "^5.0.5" - "@vue/devtools-api" "^7.2.1" - "@vue/shared" "^3.4.27" - "@vueuse/core" "^10.10.0" - "@vueuse/integrations" "^10.10.0" - focus-trap "^7.5.4" + "@docsearch/css" "^3.9.0" + "@docsearch/js" "^3.9.0" + "@iconify-json/simple-icons" "^1.2.32" + "@shikijs/core" "^3.2.2" + "@shikijs/transformers" "^3.2.2" + "@shikijs/types" "^3.2.2" + "@vitejs/plugin-vue" "^5.2.3" + "@vue/devtools-api" "^7.7.5" + "@vue/shared" "^3.5.13" + "@vueuse/core" "^13.1.0" + "@vueuse/integrations" "^13.1.0" + focus-trap "^7.6.4" mark.js "8.11.1" - minisearch "^6.3.0" - shiki "^1.6.2" - vite "^5.2.12" - vue "^3.4.27" + minisearch "^7.1.2" + shiki "^3.2.2" + vite "^6.3.2" + vue "^3.5.13" -vue-demi@>=0.14.8: - version "0.14.8" - resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.14.8.tgz#00335e9317b45e4a68d3528aaf58e0cec3d5640a" - integrity sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q== - -vue@^3.2.47, vue@^3.4.27: - version "3.4.31" - resolved "https://registry.yarnpkg.com/vue/-/vue-3.4.31.tgz#83a3c4dab8302b0e974b0d4b92a2f6a6378ae797" - integrity sha512-njqRrOy7W3YLAlVqSKpBebtZpDVg21FPoaq1I7f/+qqBThK9ChAIjkRWgeP6Eat+8C+iia4P3OYqpATP21BCoQ== +vue@^3.2.25, vue@^3.2.47, vue@^3.5.0, vue@^3.5.13, vue@3.5.16: + version "3.5.16" + resolved "https://registry.npmjs.org/vue/-/vue-3.5.16.tgz" + integrity sha512-rjOV2ecxMd5SiAmof2xzh2WxntRcigkX/He4YFJ6WdRvVUrbt6DxC1Iujh10XLl8xCDRDtGKMeO3D+pRQ1PP9w== dependencies: - "@vue/compiler-dom" "3.4.31" - "@vue/compiler-sfc" "3.4.31" - "@vue/runtime-dom" "3.4.31" - "@vue/server-renderer" "3.4.31" - "@vue/shared" "3.4.31" + "@vue/compiler-dom" "3.5.16" + "@vue/compiler-sfc" "3.5.16" + "@vue/runtime-dom" "3.5.16" + "@vue/server-renderer" "3.5.16" + "@vue/shared" "3.5.16" + +zwitch@^2.0.4: + version "2.0.4" + resolved "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz" + integrity sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A== From 3867b9933de3eb1978b9998e63dd857f9eb96f15 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 30 May 2025 16:18:34 +0700 Subject: [PATCH 087/319] update doc for spx extension --- docs/en/guide/extension-notes.md | 3 +-- docs/zh/guide/extension-notes.md | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/en/guide/extension-notes.md b/docs/en/guide/extension-notes.md index 83c0b787..946fd123 100644 --- a/docs/en/guide/extension-notes.md +++ b/docs/en/guide/extension-notes.md @@ -149,8 +149,7 @@ Parallel is only supported on PHP 8.0 ZTS and above. ## spx -1. The [SPX extension](https://github.com/NoiseByNorthwest/php-spx) only supports NTS mode. -2. SPX does not support Windows, and the official repository does not support static compilation. static-php-cli uses a [modified version](https://github.com/static-php/php-spx). +1. SPX does not support Windows, and the official repository does not support static compilation. static-php-cli uses a [modified version](https://github.com/static-php/php-spx). ## mimalloc diff --git a/docs/zh/guide/extension-notes.md b/docs/zh/guide/extension-notes.md index 762d2df9..3bba17bb 100644 --- a/docs/zh/guide/extension-notes.md +++ b/docs/zh/guide/extension-notes.md @@ -139,8 +139,7 @@ parallel 扩展只支持 PHP 8.0 及以上版本,并只支持 ZTS 构建(`-- ## spx -1. [SPX 扩展](https://github.com/NoiseByNorthwest/php-spx) 只支持非线程模式。 -2. SPX 目前不支持 Windows,且官方仓库也不支持静态编译,static-php-cli 使用了 [修改版本](https://github.com/static-php/php-spx)。 +1. SPX 目前不支持 Windows,且官方仓库也不支持静态编译,static-php-cli 使用了 [修改版本](https://github.com/static-php/php-spx)。 ## mimalloc From 5382362168558b6707783946bd8da7f94053a797 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 30 May 2025 20:41:17 +0700 Subject: [PATCH 088/319] only disable openmp for rh devtoolset-10 --- src/SPC/builder/extension/imagick.php | 2 +- src/SPC/builder/unix/library/imagemagick.php | 7 +++++-- src/SPC/util/SPCConfigUtil.php | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index f9189245..6478a5b7 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -12,7 +12,7 @@ class imagick extends Extension { public function patchBeforeMake(): bool { - if (getenv('SPC_LIBC') !== 'musl') { + if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) { return false; } // imagick with calls omp_pause_all which requires -lgomp, on non-musl we build imagick without openmp diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index deb1e402..61c79e49 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -18,8 +18,11 @@ trait imagemagick */ protected function build(): void { - // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC -fPIE so we can't use openmp without depending on libgomp.so - $openmp = getenv('SPC_LIBC') === 'musl' ? '--enable-openmp' : '--disable-openmp'; + $openmp = '--enable-openmp'; + // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so + if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) { + $openmp = '--disable-openmp'; + } $extra = "--without-jxl --without-x {$openmp} "; $required_libs = ''; $optional_libs = [ diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 0a059463..9f75b41f 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -144,7 +144,7 @@ class SPCConfigUtil } } // patch: imagick (imagemagick wrapper) for linux needs libgomp - if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') { + if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux' && !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10'))) { $short_name[] = '-lgomp'; } return implode(' ', $short_name); From 2a5915f4b609110a7b23531f3380e61f8acb9062 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 30 May 2025 21:21:50 +0700 Subject: [PATCH 089/319] patched this in ext-spx before, do it here instead --- src/SPC/builder/extension/spx.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/SPC/builder/extension/spx.php b/src/SPC/builder/extension/spx.php index 8436b96f..f5e736d5 100644 --- a/src/SPC/builder/extension/spx.php +++ b/src/SPC/builder/extension/spx.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('spx')] @@ -18,4 +19,14 @@ class spx extends Extension } return $arg; } + + public function patchBeforeConfigure(): bool + { + FileSystem::replaceFileStr( + $this->source_dir . '/Makefile.frag', + '@cp -r assets/web-ui/*', + '@cp -r ' . $this->source_dir . '/assets/web-ui/*', + ); + return true; + } } From 614772131497d6b8cbdbf9d9d2cb9f0d53dea32e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 30 May 2025 22:26:43 +0700 Subject: [PATCH 090/319] dont disable openmp macro --- src/SPC/builder/extension/imagick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 6478a5b7..7b0e20f9 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -23,7 +23,7 @@ class imagick extends Extension public function getUnixConfigureArg(bool $shared = false): string { - $disable_omp = getenv('SPC_LIBC') === 'musl' ? '' : ' ac_cv_func_omp_pause_resource_all=no'; + $disable_omp = !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) ? '' : ' ac_cv_func_omp_pause_resource_all=no'; return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp; } } From 78b2a89b0acef2dda4c3a30bb93cd36a7284ebc5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:03:17 +0700 Subject: [PATCH 091/319] --with-pic for libpng --- src/SPC/builder/linux/library/libpng.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 16fdca60..6bc4df2b 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -53,6 +53,7 @@ class libpng extends LinuxLibraryBase './configure ' . '--disable-shared ' . '--enable-static ' . + '--with-pic ' . '--enable-hardware-optimizations ' . '--with-zlib-prefix="' . BUILD_ROOT_PATH . '" ' . $optimizations . From 4c124770ed689bd91ddf579081ae48fec1f70640 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:06:00 +0700 Subject: [PATCH 092/319] --with-pic for libffi --- src/SPC/builder/linux/library/libffi.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/linux/library/libffi.php b/src/SPC/builder/linux/library/libffi.php index d7421425..aa4cd662 100644 --- a/src/SPC/builder/linux/library/libffi.php +++ b/src/SPC/builder/linux/library/libffi.php @@ -30,6 +30,7 @@ class libffi extends LinuxLibraryBase './configure ' . '--enable-static ' . '--disable-shared ' . + '--with-pic ' . "--host={$arch}-unknown-linux " . "--target={$arch}-unknown-linux " . '--prefix= ' . From 764fdd4d08111fa98a4337545a3a69431b766382 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:09:35 +0700 Subject: [PATCH 093/319] --enable-pic for gettext --- src/SPC/builder/unix/library/gettext.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 16622560..42bbae54 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -26,6 +26,7 @@ trait gettext './configure ' . '--enable-static ' . '--disable-shared ' . + '--enable-pic ' . '--disable-java ' . '--disable-c++ ' . $zts . From 4c64707138ca0b4484770c2dd6c2e8c50c1d6696 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:19:04 +0700 Subject: [PATCH 094/319] -ldl and --with-pic for imagemagick --- src/SPC/builder/unix/library/gettext.php | 4 +++- src/SPC/builder/unix/library/imagemagick.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 42bbae54..01c12519 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -16,10 +16,12 @@ trait gettext $cflags = $this->builder->getOption('enable-zts') ? '-lpthread -D_REENTRANT' : ''; $ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : ''; + $ldl = $this->builder->getLib('libgomp') && getenv('SPC_LIBC') === 'glibc' ? '-ldl' : ''; + shell()->cd($this->source_dir) ->setEnv([ 'CFLAGS' => "{$this->getLibExtraCFlags()} {$cflags}", - 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, + 'LDFLAGS' => trim($this->getLibExtraLdFlags() . ' ' . $ldflags . ' ' . $ldl), 'LIBS' => $this->getLibExtraLibs(), ]) ->execWithEnv( diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 61c79e49..78bcced9 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -58,7 +58,7 @@ trait imagemagick ]) ->execWithEnv( './configure ' . - '--enable-static --disable-shared ' . + '--enable-static --disable-shared --with-pic ' . $extra . '--prefix=' ) From 8767181a8068a1ee0601db877ce2d3181dc31a62 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:21:55 +0700 Subject: [PATCH 095/319] --with-pic for ldap --- src/SPC/builder/unix/library/ldap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 93f889f0..6f8790f1 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -38,6 +38,7 @@ trait ldap ' ./configure ' . '--enable-static ' . '--disable-shared ' . + '--with-pic ' . '--disable-slapd ' . '--without-systemd ' . '--without-cyrus-sasl ' . From 2dbcbc69636f8a904b03bc93746394a761d80a58 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:35:59 +0700 Subject: [PATCH 096/319] --with-pic and --enable-pic for other libraries that support them --- src/SPC/builder/extension/pdo_sqlsrv.php | 2 +- src/SPC/builder/freebsd/library/openssl.php | 7 ++++++- src/SPC/builder/unix/library/libacl.php | 2 +- src/SPC/builder/unix/library/libiconv.php | 1 + src/SPC/builder/unix/library/libjpeg.php | 1 + src/SPC/builder/unix/library/libtiff.php | 2 +- src/SPC/builder/unix/library/libxslt.php | 1 + src/SPC/builder/unix/library/nghttp2.php | 1 + src/SPC/builder/unix/library/onig.php | 2 +- src/SPC/builder/unix/library/sqlite.php | 2 +- src/SPC/builder/unix/library/xz.php | 1 + 11 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/extension/pdo_sqlsrv.php b/src/SPC/builder/extension/pdo_sqlsrv.php index 75166903..ed501bb2 100644 --- a/src/SPC/builder/extension/pdo_sqlsrv.php +++ b/src/SPC/builder/extension/pdo_sqlsrv.php @@ -25,7 +25,7 @@ class pdo_sqlsrv extends Extension shell()->cd($this->source_dir) ->setEnv($env) ->execWithEnv(BUILD_BIN_PATH . '/phpize') - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static --with-pic') ->execWithEnv('make clean') ->execWithEnv('make -j' . $this->builder->concurrency) ->execWithEnv('make install'); diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index fb029a77..3c62ba2e 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -49,7 +49,12 @@ class openssl extends BSDLibraryBase } shell()->cd($this->source_dir) - ->exec( + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs() . " {$ex_lib}", + ]) + ->execWithEnv( "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . diff --git a/src/SPC/builder/unix/library/libacl.php b/src/SPC/builder/unix/library/libacl.php index 6abfbb5b..7e74c947 100644 --- a/src/SPC/builder/unix/library/libacl.php +++ b/src/SPC/builder/unix/library/libacl.php @@ -37,7 +37,7 @@ trait libacl ]) ->execWithEnv('libtoolize --force --copy') ->execWithEnv('./autogen.sh || autoreconf -if') - ->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls') + ->execWithEnv('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls --with-pic') ->execWithEnv("make -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index 72297646..a4f77d98 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -20,6 +20,7 @@ trait libiconv './configure ' . '--enable-static ' . '--disable-shared ' . + '--enable-pic ' . '--enable-extra-encodings ' . '--prefix=' ) diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index c4f9833d..5612e130 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -26,6 +26,7 @@ trait libjpeg "cmake {$this->builder->makeCmakeArgs()} " . '-DENABLE_STATIC=ON ' . '-DENABLE_SHARED=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index b4ed21ad..d2264dda 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -30,7 +30,7 @@ trait libtiff ]) ->execWithEnv( './configure ' . - '--enable-static --disable-shared ' . + '--enable-static --disable-shared --with-pic ' . "{$extra_libs} " . '--disable-cxx ' . '--prefix=' diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 6de23e3e..53061276 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -35,6 +35,7 @@ trait libxslt "{$this->builder->getOption('ld_library_path')} " . './configure ' . '--enable-static --disable-shared ' . + '--with-pic ' . '--without-python ' . '--without-mem-debug ' . '--without-crypto ' . diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index cd0c488f..b1c4433f 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -45,6 +45,7 @@ trait nghttp2 './configure ' . '--enable-static ' . '--disable-shared ' . + '--with-pic ' . '--enable-lib-only ' . '--with-boost=no ' . $args . ' ' . diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index 56f72413..458e9c47 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -23,7 +23,7 @@ trait onig 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv('./configure --enable-static --disable-shared --prefix=') + ->execWithEnv('./configure --enable-static --disable-shared --enable-pic --prefix=') ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") ->exec("make install DESTDIR={$destdir}"); diff --git a/src/SPC/builder/unix/library/sqlite.php b/src/SPC/builder/unix/library/sqlite.php index 7f9f31bd..131e0c3b 100644 --- a/src/SPC/builder/unix/library/sqlite.php +++ b/src/SPC/builder/unix/library/sqlite.php @@ -14,7 +14,7 @@ trait sqlite 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv('./configure --enable-static --disable-shared --prefix=') + ->execWithEnv('./configure --enable-static --disable-shared --with-pic --prefix=') ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 1869f589..c1c84f1f 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -20,6 +20,7 @@ trait xz './configure ' . '--enable-static ' . '--disable-shared ' . + '--enable-pic ' . '--disable-scripts ' . '--disable-doc ' . '--with-libiconv ' . From ad3860981a1019c52e1efb2159bdd74d92d58307 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 14:41:35 +0700 Subject: [PATCH 097/319] -DPOSITION_INDEPENDENT_CODE=ON --- src/SPC/builder/macos/library/glfw.php | 2 +- src/SPC/builder/macos/library/libxml2.php | 1 + src/SPC/builder/unix/library/brotli.php | 1 + src/SPC/builder/unix/library/curl.php | 2 +- src/SPC/builder/unix/library/freetype.php | 1 + src/SPC/builder/unix/library/gmssl.php | 2 +- src/SPC/builder/unix/library/libaom.php | 1 + src/SPC/builder/unix/library/libavif.php | 2 +- src/SPC/builder/unix/library/libde265.php | 1 + src/SPC/builder/unix/library/libevent.php | 1 + src/SPC/builder/unix/library/libheif.php | 1 + src/SPC/builder/unix/library/librabbitmq.php | 1 + src/SPC/builder/unix/library/libssh2.php | 1 + src/SPC/builder/unix/library/libuuid.php | 2 +- src/SPC/builder/unix/library/libuv.php | 2 +- src/SPC/builder/unix/library/libwebp.php | 1 + src/SPC/builder/unix/library/libyaml.php | 1 + src/SPC/builder/unix/library/libzip.php | 1 + src/SPC/builder/unix/library/mimalloc.php | 1 + src/SPC/builder/unix/library/snappy.php | 1 + src/SPC/builder/unix/library/tidy.php | 1 + 21 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/macos/library/glfw.php b/src/SPC/builder/macos/library/glfw.php index 355785ed..a3b88b6a 100644 --- a/src/SPC/builder/macos/library/glfw.php +++ b/src/SPC/builder/macos/library/glfw.php @@ -19,7 +19,7 @@ class glfw extends MacOSLibraryBase { // compile! shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') - ->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") + ->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DPOSITION_INDEPENDENT_CODE=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); // patch pkgconf diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index c0ed36c0..f8d75f83 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -33,6 +33,7 @@ class libxml2 extends MacOSLibraryBase "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . "-DLIBXML2_WITH_ICU={$enable_icu} " . "-DLIBXML2_WITH_LZMA={$enable_xz} " . diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 30c862d2..526f3341 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -30,6 +30,7 @@ trait brotli '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . '-DCMAKE_INSTALL_LIBDIR=lib ' . '-DSHARE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DBUILD_SHARED_LIBS=OFF ' . '..' ) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index ab8a8bd7..99444d76 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -60,7 +60,7 @@ trait curl 'LIBS' => $this->getLibExtraLibs(), ]) ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DPOSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install'); // patch pkgconf diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 6fb24212..7dfa9b0e 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -31,6 +31,7 @@ trait freetype ->execWithEnv( "cmake {$this->builder->makeCmakeArgs()} -DFT_DISABLE_HARFBUZZ=ON " . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . "{$extra_libs}.." ) ->execWithEnv('make clean') diff --git a/src/SPC/builder/unix/library/gmssl.php b/src/SPC/builder/unix/library/gmssl.php index 792a1c93..bf0abe8e 100644 --- a/src/SPC/builder/unix/library/gmssl.php +++ b/src/SPC/builder/unix/library/gmssl.php @@ -25,7 +25,7 @@ trait gmssl 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..") + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DPOSITION_INDEPENDENT_CODE=ON ..") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); } diff --git a/src/SPC/builder/unix/library/libaom.php b/src/SPC/builder/unix/library/libaom.php index 5ecf6704..d0de97d7 100644 --- a/src/SPC/builder/unix/library/libaom.php +++ b/src/SPC/builder/unix/library/libaom.php @@ -26,6 +26,7 @@ trait libaom "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DAOM_TARGET_CPU=generic ' . '..' ) diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index ddcf1d57..e0b0430d 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -27,7 +27,7 @@ trait libavif 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DAVIF_LIBYUV=OFF ..") + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DPOSITION_INDEPENDENT_CODE=ON -DAVIF_LIBYUV=OFF ..") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libde265.php b/src/SPC/builder/unix/library/libde265.php index df02bbb3..bf1546f2 100644 --- a/src/SPC/builder/unix/library/libde265.php +++ b/src/SPC/builder/unix/library/libde265.php @@ -26,6 +26,7 @@ trait libde265 "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DENABLE_SDL=OFF ' . // Disable SDL, currently not supported '..' ) diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index bd070fd5..437bd68d 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -53,6 +53,7 @@ trait libevent 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DCMAKE_BUILD_TYPE=Release ' . '-DEVENT__LIBRARY_TYPE=STATIC ' . '-DEVENT__DISABLE_BENCHMARK=ON ' . diff --git a/src/SPC/builder/unix/library/libheif.php b/src/SPC/builder/unix/library/libheif.php index e2d2a486..5725b737 100644 --- a/src/SPC/builder/unix/library/libheif.php +++ b/src/SPC/builder/unix/library/libheif.php @@ -27,6 +27,7 @@ trait libheif "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DWITH_EXAMPLES=OFF ' . '-DWITH_GDK_PIXBUF=OFF ' . '-DBUILD_TESTING=OFF ' . diff --git a/src/SPC/builder/unix/library/librabbitmq.php b/src/SPC/builder/unix/library/librabbitmq.php index 42ef553b..1f7fd0e3 100644 --- a/src/SPC/builder/unix/library/librabbitmq.php +++ b/src/SPC/builder/unix/library/librabbitmq.php @@ -27,6 +27,7 @@ trait librabbitmq '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_SHARED_LIBS=OFF ' . '-DBUILD_STATIC_LIBS=ON ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index 9e999ca9..b99b9e7b 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -27,6 +27,7 @@ trait libssh2 '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . '-DCMAKE_INSTALL_LIBDIR=lib ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DBUILD_EXAMPLES=OFF ' . '-DBUILD_TESTING=OFF ' . "-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " . diff --git a/src/SPC/builder/unix/library/libuuid.php b/src/SPC/builder/unix/library/libuuid.php index 65ed02ac..405941ed 100644 --- a/src/SPC/builder/unix/library/libuuid.php +++ b/src/SPC/builder/unix/library/libuuid.php @@ -20,7 +20,7 @@ trait libuuid shell()->cd($this->source_dir . '/build') ->exec( 'cmake ' . - "{$this->builder->makeCmakeArgs()} " . + "{$this->builder->makeCmakeArgs()} -DPOSITION_INDEPENDENT_CODE=ON " . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}"); diff --git a/src/SPC/builder/unix/library/libuv.php b/src/SPC/builder/unix/library/libuv.php index fda11c0a..2294a1e3 100644 --- a/src/SPC/builder/unix/library/libuv.php +++ b/src/SPC/builder/unix/library/libuv.php @@ -20,7 +20,7 @@ trait libuv FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..") + ->exec("cmake {$this->builder->makeCmakeArgs()} -DPOSITION_INDEPENDENT_CODE=ON -DLIBUV_BUILD_SHARED=OFF ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index efb78a68..79fc1e3e 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -26,6 +26,7 @@ trait libwebp 'cmake ' . $this->builder->makeCmakeArgs() . ' ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DWEBP_BUILD_EXTRAS=ON ' . '..' ) diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index 53962e9b..b519f709 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -41,6 +41,7 @@ trait libyaml '-DCMAKE_BUILD_TYPE=Release ' . '-DBUILD_TESTING=OFF ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DCMAKE_INSTALL_PREFIX=/ ' . "-DCMAKE_INSTALL_LIBDIR={$lib} " . "-DCMAKE_INSTALL_INCLUDEDIR={$include} " . diff --git a/src/SPC/builder/unix/library/libzip.php b/src/SPC/builder/unix/library/libzip.php index 5e2bd0d6..c206f3c9 100644 --- a/src/SPC/builder/unix/library/libzip.php +++ b/src/SPC/builder/unix/library/libzip.php @@ -36,6 +36,7 @@ trait libzip '-DENABLE_GNUTLS=OFF ' . '-DENABLE_MBEDTLS=OFF ' . '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DBUILD_DOC=OFF ' . '-DBUILD_EXAMPLES=OFF ' . '-DBUILD_REGRESS=OFF ' . diff --git a/src/SPC/builder/unix/library/mimalloc.php b/src/SPC/builder/unix/library/mimalloc.php index 40790a98..34b4f7be 100644 --- a/src/SPC/builder/unix/library/mimalloc.php +++ b/src/SPC/builder/unix/library/mimalloc.php @@ -28,6 +28,7 @@ trait mimalloc 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DCMAKE_BUILD_TYPE=Release ' . $args . '..' diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index f1b4c825..8d1c3b8a 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -24,6 +24,7 @@ trait snappy "{$this->builder->makeCmakeArgs()} " . '-DSNAPPY_BUILD_TESTS=OFF ' . '-DSNAPPY_BUILD_BENCHMARKS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '../..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/tidy.php b/src/SPC/builder/unix/library/tidy.php index 31c851d1..ce5cd462 100644 --- a/src/SPC/builder/unix/library/tidy.php +++ b/src/SPC/builder/unix/library/tidy.php @@ -22,6 +22,7 @@ trait tidy 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIB=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DSUPPORT_CONSOLE_APP=OFF ' . '..' ) From 3052b1cca5246af7de3b3c4c458b6502e00f621a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 31 May 2025 21:01:22 +0700 Subject: [PATCH 098/319] change extension_dir, the env variable only has an effect during compilation --- src/SPC/builder/Extension.php | 5 ++++- src/SPC/builder/extension/mbregex.php | 3 +-- src/SPC/builder/extension/swoole_hook_mysql.php | 1 - src/SPC/builder/extension/swoole_hook_pgsql.php | 1 - src/SPC/builder/extension/swoole_hook_sqlite.php | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 06c892a8..1ffc6dc3 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -243,6 +243,10 @@ class Extension } } + if ($ret !== '') { + $ret = ' -d "extension_dir=' . BUILD_MODULES_PATH . '"' . $ret; + } + return $ret; } @@ -255,7 +259,6 @@ class Extension // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException $sharedExtensions = $this->getSharedExtensionLoadString(); - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index cdff2903..0e1cad28 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -26,8 +26,7 @@ class mbregex extends Extension */ public function runCliCheckUnix(): void { - $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? ' -d "extension=mbstring"' : ''; - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); + $sharedext = $this->builder->getExt('mbstring')->isBuildShared() ? '-d "extension_dir=' . BUILD_MODULES_PATH . '" -d "extension=mbstring"' : ''; [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $sharedext . ' --ri "mbstring" | grep regex', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 55a58af3..b45516ee 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -29,7 +29,6 @@ class swoole_hook_mysql extends Extension if ($this->builder->getExt('swoole') === null) { return; } - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n' . $this->getSharedExtensionLoadString() . ' --ri "swoole"', false); $out = implode('', $out); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 68661bd5..dfbf7dc8 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -38,7 +38,6 @@ class swoole_hook_pgsql extends Extension return; } $sharedExtensions = $this->getSharedExtensionLoadString(); - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index cb217539..29e9ef84 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -38,7 +38,6 @@ class swoole_hook_sqlite extends Extension return; } $sharedExtensions = $this->getSharedExtensionLoadString(); - putenv('EXTENSION_DIR=' . BUILD_MODULES_PATH); [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); $out = implode('', $out); if ($ret !== 0) { From 8312ce4d4c676773c690771295303242656e4e22 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 31 May 2025 22:17:06 +0700 Subject: [PATCH 099/319] add ext-xz and ext-brotli --- config/ext.json | 16 ++++++++++++++++ config/source.json | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/config/ext.json b/config/ext.json index 0dca824b..fc8fb667 100644 --- a/config/ext.json +++ b/config/ext.json @@ -24,6 +24,14 @@ "bcmath": { "type": "builtin" }, + "brotli": { + "type": "external", + "source": "ext-brotli", + "arg-type": "enable", + "lib-depends": [ + "brotli" + ] + }, "bz2": { "type": "builtin", "arg-type-unix": "with-prefix", @@ -1044,6 +1052,14 @@ "dom" ] }, + "xz": { + "type": "external", + "source": "ext-xz", + "arg-type": "with", + "lib-depends": [ + "xz" + ] + }, "yac": { "support": { "BSD": "wip" diff --git a/config/source.json b/config/source.json index a4b25cb8..796e96f5 100644 --- a/config/source.json +++ b/config/source.json @@ -102,6 +102,16 @@ "path": "LICENSE" } }, + "ext-brotli": { + "type": "git", + "path": "php-src/ext/brotli", + "rev": "master", + "url": "https://github.com/kjdev/php-ext-brotli", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-ds": { "type": "url", "url": "https://pecl.php.net/get/ds", @@ -230,6 +240,16 @@ "path": "LICENSE" } }, + "ext-xz": { + "type": "git", + "path": "php-src/ext/xz", + "rev": "main", + "url": "https://github.com/codemasher/php-ext-xz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-zstd": { "type": "git", "path": "php-src/ext/zstd", From c44b8b1029e11b2b9a5d41ecd69af4758bc575d6 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 31 May 2025 22:20:03 +0700 Subject: [PATCH 100/319] test xz and brotli as well --- src/globals/test-extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index e2f0ca12..ed6c6970 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -45,13 +45,13 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'xsl,simplexml,xlswriter', + 'Linux', 'Darwin' => 'brotli,xsl,simplexml,xlswriter,xz', 'Windows' => 'xlswriter,openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'xdebug,intl,pgsql', + 'Linux' => 'xdebug,intl,pgsql,imagick', 'Windows', 'Darwin' => '', }; From 61837f0d689c59f15b113625efa57f5725882610 Mon Sep 17 00:00:00 2001 From: Marc Date: Sat, 31 May 2025 22:26:56 +0700 Subject: [PATCH 101/319] more os tests --- src/globals/test-extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ed6c6970..35cfca38 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - '8.1', + //'8.1', '8.2', '8.3', '8.4', @@ -26,7 +26,7 @@ $test_os = [ 'macos-15', 'ubuntu-latest', 'ubuntu-22.04', - // 'ubuntu-24.04', + 'ubuntu-24.04', 'ubuntu-22.04-arm', 'ubuntu-24.04-arm', // 'windows-latest', From 3bc5ac28beaea082235204bd2c3274a73539c9e3 Mon Sep 17 00:00:00 2001 From: Marc Date: Sat, 31 May 2025 22:33:30 +0700 Subject: [PATCH 102/319] space --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 1b8fc074..84be5c5c 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - //'8.1', + // '8.1', '8.2', '8.3', '8.4', From 55b4ba5832bb9f51d3dfc94f1ed8e50c30f94092 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:21:42 +0700 Subject: [PATCH 103/319] fix file_exists check in printing shared extension folder --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index cd831438..61781d2c 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -251,7 +251,7 @@ class BuildPHPCommand extends BuildCommand if (!empty($shared_extensions)) { foreach ($shared_extensions as $ext) { $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); - if (file_exists("{$build_root_path}/modules/{$ext}.so")) { + if (file_exists(BUILD_MODULES_PATH . "/{$ext}.so")) { logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); } else { logger()->warning("Shared extension [{$ext}] not found, please check!"); From febf9b1815120ee5125191e6e75514930245bedf Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:27:36 +0700 Subject: [PATCH 104/319] full test suite for shared extensions --- src/globals/test-extensions.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 84be5c5c..90ef882a 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,21 +14,21 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ // '8.1', - '8.2', - '8.3', + // '8.2', + // '8.3', '8.4', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', + // 'macos-13', // 'macos-14', - 'macos-15', + // 'macos-15', // 'ubuntu-latest', 'ubuntu-22.04', - 'ubuntu-24.04', + //'ubuntu-24.04', 'ubuntu-22.04-arm', - 'ubuntu-24.04-arm', + //'ubuntu-24.04-arm', // 'windows-latest', ]; @@ -45,13 +45,14 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'brotli,xsl,simplexml,xlswriter,xz', + 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', 'Windows' => 'xlswriter,openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'xdebug,intl,pgsql,imagick', + 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_p +gsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', 'Windows', 'Darwin' => '', }; From da7a125fafdea778281c8a4149a7e2ab5340ce57 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:51:05 +0700 Subject: [PATCH 105/319] librdkafka needs "which" to be installed --- bin/spc-gnu-docker | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 1ff87303..36e0420e 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -72,6 +72,7 @@ RUN yum update -y && \ yum install -y devtoolset-10-gcc-* RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc RUN source /etc/bashrc +RUN yum install -y which RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \ mkdir /cmake && \ From 396ddd3e6f549c32b95a52880d4e0d24e643daa1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:52:17 +0700 Subject: [PATCH 106/319] cs fix --- src/globals/test-extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 90ef882a..d39fead3 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -26,9 +26,9 @@ $test_os = [ // 'macos-15', // 'ubuntu-latest', 'ubuntu-22.04', - //'ubuntu-24.04', + // 'ubuntu-24.04', 'ubuntu-22.04-arm', - //'ubuntu-24.04-arm', + // 'ubuntu-24.04-arm', // 'windows-latest', ]; From 5ae5a3d75da16ee82823540db2ac8c872ee4e5a9 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:53:33 +0700 Subject: [PATCH 107/319] cs fix --- src/globals/test-extensions.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index d39fead3..3fe1586b 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -51,8 +51,7 @@ $extensions = match (PHP_OS_FAMILY) { // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_p -gsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', + 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', 'Windows', 'Darwin' => '', }; From 7c009b6dceebf737a7854564bdb7878bd1d637a2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:53:56 +0700 Subject: [PATCH 108/319] add rdkafka --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 3fe1586b..1b11a20f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -51,7 +51,7 @@ $extensions = match (PHP_OS_FAMILY) { // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', + 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', 'Windows', 'Darwin' => '', }; From 8b98792ccfefbda403e45a77da7be9d740ab9d01 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 1 Jun 2025 13:59:18 +0700 Subject: [PATCH 109/319] zts of course --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 1b11a20f..44013ab3 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -33,7 +33,7 @@ $test_os = [ ]; // whether enable thread safe -$zts = false; +$zts = true; $no_strip = false; From 108bf34cca8066be76198e6c1731efef35c49eea Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 2 Jun 2025 11:55:55 +0700 Subject: [PATCH 110/319] craft needs to download shared extensions too --- src/SPC/command/CraftCommand.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 9fa2f385..3764c549 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -48,7 +48,8 @@ class CraftCommand extends BaseCommand } } - $extensions = implode(',', $craft['extensions']); + $static_extensions = implode(',', $craft['extensions']); + $shared_extensions = implode(',', $craft['build-options']['build-shared']) ?? ''; $libs = implode(',', $craft['libs']); // init log @@ -67,7 +68,8 @@ class CraftCommand extends BaseCommand } // craft download if ($craft['craft-options']['download']) { - $args = ["--for-extensions={$extensions}"]; + $sharedAppend = $shared_extensions ? ',' . $shared_extensions : ''; + $args = ["--for-extensions={$static_extensions}{$sharedAppend}"]; if ($craft['libs'] !== []) { $args[] = "--for-libs={$libs}"; } @@ -90,7 +92,7 @@ class CraftCommand extends BaseCommand // craft build if ($craft['craft-options']['build']) { - $args = [$extensions, "--with-libs={$libs}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])]; + $args = [$static_extensions, "--with-libs={$libs}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])]; $this->optionsToArguments($craft['build-options'], $args); $retcode = $this->runCommand('build', ...$args); if ($retcode !== 0) { From ed87a7cd671312d0f1304605fad61789c0edd633 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 2 Jun 2025 12:00:20 +0700 Subject: [PATCH 111/319] don't force invalidate php-src if the download option is explicitly passed --- src/SPC/command/CraftCommand.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 3764c549..7b75c783 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -77,8 +77,6 @@ class CraftCommand extends BaseCommand $args[] = '--with-php=' . $craft['php-version']; if (!array_key_exists('ignore-cache-sources', $craft['download-options']) || $craft['download-options']['ignore-cache-sources'] === false) { $craft['download-options']['ignore-cache-sources'] = 'php-src'; - } elseif ($craft['download-options']['ignore-cache-sources'] !== null) { - $craft['download-options']['ignore-cache-sources'] .= ',php-src'; } } $this->optionsToArguments($craft['download-options'], $args); @@ -144,7 +142,6 @@ class CraftCommand extends BaseCommand }); } elseif (extension_loaded('pcntl')) { pcntl_signal(SIGINT, function () use ($process) { - /* @noinspection PhpComposerExtensionStubsInspection */ $process->signal(SIGINT); }); } else { From c53b06c3d27510b9e8504d07cd876ca5c7b0c0da Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 2 Jun 2025 12:27:58 +0700 Subject: [PATCH 112/319] shared-extensions instead of build-shared --- src/SPC/command/CraftCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 7b75c783..25fae675 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -49,7 +49,7 @@ class CraftCommand extends BaseCommand } $static_extensions = implode(',', $craft['extensions']); - $shared_extensions = implode(',', $craft['build-options']['build-shared']) ?? ''; + $shared_extensions = implode(',', $craft['shared-extensions']); $libs = implode(',', $craft['libs']); // init log @@ -90,7 +90,7 @@ class CraftCommand extends BaseCommand // craft build if ($craft['craft-options']['build']) { - $args = [$static_extensions, "--with-libs={$libs}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])]; + $args = [$static_extensions, "--with-libs={$libs}", "--build-shared={$shared_extensions}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])]; $this->optionsToArguments($craft['build-options'], $args); $retcode = $this->runCommand('build', ...$args); if ($retcode !== 0) { From 4b0fa94b3c97d97530a691f0f393422b3f0e80e5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 2 Jun 2025 12:32:53 +0700 Subject: [PATCH 113/319] stan --- src/SPC/util/ConfigValidator.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index d455dda5..eae2ef2b 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -120,6 +120,7 @@ class ConfigValidator * @return array{ * php-version?: string, * extensions: array, + * shared-extensions?: array, * libs?: array, * sapi: array, * debug?: bool, From 6b689f1584881546873334a8508e3ea9f8dd39c4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 2 Jun 2025 15:12:44 +0700 Subject: [PATCH 114/319] explicitly pass env to process handler, fails in docker otherwise (??????) --- src/SPC/command/CraftCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 25fae675..c5ddfb74 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -131,7 +131,8 @@ class CraftCommand extends BaseCommand } $prefix = PHP_SAPI === 'cli' ? [PHP_BINARY, $argv[0]] : [$argv[0]]; - $process = new Process([...$prefix, $cmd, '--no-motd', ...$args], timeout: null); + $env = getenv(); + $process = new Process([...$prefix, $cmd, '--no-motd', ...$args], env: $env, timeout: null); $this->log("Running: {$process->getCommandLine()}", true); if (PHP_OS_FAMILY === 'Windows') { From a9d37bb2a2e30c84043bb099fead9e810d94ac92 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 4 Jun 2025 08:58:46 +0700 Subject: [PATCH 115/319] add source patch for ffi on centos 7 --- src/SPC/store/SourcePatcher.php | 10 ++++++ .../patch/ffi_centos7_fix_O3_strncmp.patch | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/globals/patch/ffi_centos7_fix_O3_strncmp.patch diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index f78928de..6f6c7d45 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -22,6 +22,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']); FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchPhpLibxml212']); FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchGDWin32']); + FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchFfiCentos7FixO3strncmp']); FileSystem::addSourceExtractHook('sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('pdo_sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('yaml', [SourcePatcher::class, 'patchYamlWin32']); @@ -451,6 +452,15 @@ class SourcePatcher return false; } + public static function patchFfiCentos7FixO3strncmp(): bool + { + if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getLibcVersionIfExists() === '2.17') { + SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src'); + return true; + } + return false; + } + public static function patchLibaomForAlpine(): bool { if (PHP_OS_FAMILY === 'Linux' && SystemUtil::isMuslDist()) { diff --git a/src/globals/patch/ffi_centos7_fix_O3_strncmp.patch b/src/globals/patch/ffi_centos7_fix_O3_strncmp.patch new file mode 100644 index 00000000..815170be --- /dev/null +++ b/src/globals/patch/ffi_centos7_fix_O3_strncmp.patch @@ -0,0 +1,31 @@ +--- a/ext/ffi/ffi.c 2025-01-17 10:37:37 ++++ a/ext/ffi/ffi.c 2025-01-17 10:39:17 +@@ -57,6 +57,8 @@ + /* XXX need something better, perhaps with regard to SIMD, etc. */ + # define __BIGGEST_ALIGNMENT__ sizeof(size_t) + #endif ++ ++#define ZEND_STRNCMP(s,str) strncmp((s),(str),(sizeof(str)-1)) + + ZEND_DECLARE_MODULE_GLOBALS(ffi) + +@@ -5046,16 +5048,16 @@ static char *zend_ffi_parse_directives(const char *fil + *scope_name = NULL; + *lib = NULL; + while (*code_pos == '#') { +- if (strncmp(code_pos, ZEND_STRL("#define")) == 0) { ++ if (ZEND_STRNCMP(code_pos, "#define") == 0) { + p = zend_ffi_skip_ws_and_comments(code_pos + sizeof("#define") - 1, false); + + char **target = NULL; + const char *target_name = NULL; +- if (strncmp(p, ZEND_STRL("FFI_SCOPE")) == 0) { ++ if (ZEND_STRNCMP(p, "FFI_SCOPE") == 0) { + p = zend_ffi_skip_ws_and_comments(p + sizeof("FFI_SCOPE") - 1, false); + target = scope_name; + target_name = "FFI_SCOPE"; +- } else if (strncmp(p, ZEND_STRL("FFI_LIB")) == 0) { ++ } else if (ZEND_STRNCMP(p, "FFI_LIB") == 0) { + p = zend_ffi_skip_ws_and_comments(p + sizeof("FFI_LIB") - 1, false); + target = lib; + target_name = "FFI_LIB"; From 161a5539480ae16ea129d6df2d8841e536e2198d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 5 Jun 2025 13:54:17 +0700 Subject: [PATCH 116/319] -release (soname) compilation support for linux shared embed --- config/env.ini | 2 ++ src/SPC/builder/linux/LinuxBuilder.php | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/config/env.ini b/config/env.ini index f70ad0a2..85990e2e 100644 --- a/config/env.ini +++ b/config/env.ini @@ -100,6 +100,8 @@ SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm" +; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so +SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS="" ; EXTRA_LDFLAGS_PROGRAM for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie" diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index e38714f1..7de9eaf2 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -311,6 +311,18 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); + + $ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'); + if (preg_match('/-release\s+(\S+)/', $ldflags, $matches)) { + $release = $matches[1]; + $realLibName = 'libphp-' . $release . '.so'; + $realLib = BUILD_LIB_PATH . '/' . $realLibName; + rename(BUILD_LIB_PATH . '/libphp.so', $realLib); + $cwd = getcwd(); + chdir(BUILD_LIB_PATH); + symlink($realLibName, 'libphp.so'); + chdir($cwd); + } $this->patchPhpScripts(); } @@ -319,6 +331,7 @@ class LinuxBuilder extends UnixBuilderBase return [ 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), 'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'), + 'EXTRA_LDFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), 'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'), ]; } From e2191113b0b09073c80a3db7cc3c7c4b54f7d1db Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 5 Jun 2025 16:42:52 +0700 Subject: [PATCH 117/319] tests for brotli and xz --- src/globals/ext-tests/brotli.php | 8 ++++++++ src/globals/ext-tests/xz.php | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/globals/ext-tests/brotli.php create mode 100644 src/globals/ext-tests/xz.php diff --git a/src/globals/ext-tests/brotli.php b/src/globals/ext-tests/brotli.php new file mode 100644 index 00000000..7c8e94d2 --- /dev/null +++ b/src/globals/ext-tests/brotli.php @@ -0,0 +1,8 @@ + Date: Thu, 5 Jun 2025 17:32:54 +0700 Subject: [PATCH 118/319] doms --- src/globals/ext-tests/brotli.php | 2 +- src/globals/ext-tests/xz.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/ext-tests/brotli.php b/src/globals/ext-tests/brotli.php index 7c8e94d2..dbdb1f14 100644 --- a/src/globals/ext-tests/brotli.php +++ b/src/globals/ext-tests/brotli.php @@ -1,4 +1,4 @@ - Date: Thu, 5 Jun 2025 19:57:59 +0700 Subject: [PATCH 119/319] only apply ffi patch at version >= 8.3.16 --- src/SPC/store/SourcePatcher.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 6f6c7d45..e16e84a4 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -454,6 +454,16 @@ class SourcePatcher public static function patchFfiCentos7FixO3strncmp(): bool { + $version = null; + if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + $file = SOURCE_PATH . '/php-src/main/php_version.h'; + $cnt = preg_match('/PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match); + if (!$cnt) return false; + $version = $match[1]; + } + if (version_compare($version, '8.3.16', '<')) { + return false; + } if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getLibcVersionIfExists() === '2.17') { SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src'); return true; From 86541b1aa870a3a4c24feb2d11823486f8bddcc7 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 5 Jun 2025 19:58:38 +0700 Subject: [PATCH 120/319] only apply ffi patch at version >= 8.3.16 --- src/SPC/store/SourcePatcher.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index e16e84a4..656e34cd 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -454,6 +454,9 @@ class SourcePatcher public static function patchFfiCentos7FixO3strncmp(): bool { + if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() >= '2.17') { + return false; + } $version = null; if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { $file = SOURCE_PATH . '/php-src/main/php_version.h'; @@ -464,11 +467,8 @@ class SourcePatcher if (version_compare($version, '8.3.16', '<')) { return false; } - if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getLibcVersionIfExists() === '2.17') { - SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src'); - return true; - } - return false; + SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src'); + return true; } public static function patchLibaomForAlpine(): bool From 17b4c18830ae2d156c330c78c54d2d83f6007ae1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 5 Jun 2025 19:59:45 +0700 Subject: [PATCH 121/319] accidental space --- src/globals/ext-tests/brotli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/ext-tests/brotli.php b/src/globals/ext-tests/brotli.php index dbdb1f14..2b24941d 100644 --- a/src/globals/ext-tests/brotli.php +++ b/src/globals/ext-tests/brotli.php @@ -4,5 +4,5 @@ declare(strict_types=1); $str = 'brotli_compress ( string $data, int $level = BROTLI_COMPRESS_LEVEL_DEFAULT, int $mode = BROTLI_GENERIC, string|null $dict = null ): string|false'; assert(function_exists('brotli_compress')); -assert(function_exists('brotli_uncompress ')); +assert(function_exists('brotli_uncompress')); assert(brotli_uncompress(brotli_compress($str)) === $str); From 01a79fcc6eae92393ea74d584015d15e95916c72 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 5 Jun 2025 20:07:55 +0700 Subject: [PATCH 122/319] unify tests for all compression extensions --- src/globals/ext-tests/brotli.php | 11 +++++++++-- src/globals/ext-tests/bz2.php | 13 ++++++++++--- src/globals/ext-tests/xz.php | 11 +++++++++-- src/globals/ext-tests/zlib.php | 11 ++++++++++- src/globals/ext-tests/zstd.php | 15 +++++++++++++++ 5 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 src/globals/ext-tests/zstd.php diff --git a/src/globals/ext-tests/brotli.php b/src/globals/ext-tests/brotli.php index 2b24941d..bfe9f259 100644 --- a/src/globals/ext-tests/brotli.php +++ b/src/globals/ext-tests/brotli.php @@ -2,7 +2,14 @@ declare(strict_types=1); -$str = 'brotli_compress ( string $data, int $level = BROTLI_COMPRESS_LEVEL_DEFAULT, int $mode = BROTLI_GENERIC, string|null $dict = null ): string|false'; assert(function_exists('brotli_compress')); assert(function_exists('brotli_uncompress')); -assert(brotli_uncompress(brotli_compress($str)) === $str); + +$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10); +$compressed = brotli_compress($input); +assert(is_string($compressed)); +assert(strlen($compressed) < strlen($input)); + +$uncompressed = brotli_uncompress($compressed); +assert(is_string($uncompressed)); +assert($uncompressed === $input); diff --git a/src/globals/ext-tests/bz2.php b/src/globals/ext-tests/bz2.php index 7550bee1..f5402dcf 100644 --- a/src/globals/ext-tests/bz2.php +++ b/src/globals/ext-tests/bz2.php @@ -2,7 +2,14 @@ declare(strict_types=1); -$str = 'This is bz2 extension test'; -assert(function_exists('bzdecompress')); assert(function_exists('bzcompress')); -assert(bzdecompress(bzcompress($str, 9)) === $str); +assert(function_exists('bzdecompress')); + +$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10); +$compressed = bzcompress($input); +assert(is_string($compressed)); +assert(strlen($compressed) < strlen($input)); + +$uncompressed = bzdecompress($compressed); +assert(is_string($uncompressed)); +assert($uncompressed === $input); diff --git a/src/globals/ext-tests/xz.php b/src/globals/ext-tests/xz.php index bae345fa..5f7503d7 100644 --- a/src/globals/ext-tests/xz.php +++ b/src/globals/ext-tests/xz.php @@ -2,7 +2,14 @@ declare(strict_types=1); -$str = 'Data you would like compressed.'; assert(function_exists('xzencode')); assert(function_exists('xzdecode')); -assert(xzdecode(xzencode($str)) === $str); + +$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10); +$compressed = xzencode($input); +assert(is_string($compressed)); +assert(strlen($compressed) < strlen($input)); + +$uncompressed = xzdecode($compressed); +assert(is_string($uncompressed)); +assert($uncompressed === $input); diff --git a/src/globals/ext-tests/zlib.php b/src/globals/ext-tests/zlib.php index 1fae531f..699fc759 100644 --- a/src/globals/ext-tests/zlib.php +++ b/src/globals/ext-tests/zlib.php @@ -3,4 +3,13 @@ declare(strict_types=1); assert(function_exists('gzcompress')); -assert(gzdecode(gzencode('aaa')) === 'aaa'); +assert(function_exists('gzdecode')); + +$input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10); +$compressed = gzcompress($input); +assert(is_string($compressed)); +assert(strlen($compressed) < strlen($input)); + +$uncompressed = gzdecode($compressed); +assert(is_string($uncompressed)); +assert($uncompressed === $input); diff --git a/src/globals/ext-tests/zstd.php b/src/globals/ext-tests/zstd.php new file mode 100644 index 00000000..3ebaf2a2 --- /dev/null +++ b/src/globals/ext-tests/zstd.php @@ -0,0 +1,15 @@ + Date: Thu, 5 Jun 2025 20:14:02 +0700 Subject: [PATCH 123/319] cs fix --- src/SPC/store/SourcePatcher.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 656e34cd..6abcf52d 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -461,7 +461,9 @@ class SourcePatcher if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { $file = SOURCE_PATH . '/php-src/main/php_version.h'; $cnt = preg_match('/PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match); - if (!$cnt) return false; + if (!$cnt) { + return false; + } $version = $match[1]; } if (version_compare($version, '8.3.16', '<')) { From 31652e8b0460a27e4c8b8caaa6384ea25bf75c24 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 5 Jun 2025 20:26:41 +0700 Subject: [PATCH 124/319] I HATE WINDOWS --- src/globals/ext-tests/zstd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/ext-tests/zstd.php b/src/globals/ext-tests/zstd.php index 3ebaf2a2..72c7e273 100644 --- a/src/globals/ext-tests/zstd.php +++ b/src/globals/ext-tests/zstd.php @@ -1,4 +1,4 @@ - Date: Thu, 5 Jun 2025 21:29:20 +0700 Subject: [PATCH 125/319] gzencode, of course --- src/globals/ext-tests/zlib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/ext-tests/zlib.php b/src/globals/ext-tests/zlib.php index 699fc759..ed81775c 100644 --- a/src/globals/ext-tests/zlib.php +++ b/src/globals/ext-tests/zlib.php @@ -2,11 +2,11 @@ declare(strict_types=1); -assert(function_exists('gzcompress')); +assert(function_exists('gzencode')); assert(function_exists('gzdecode')); $input = str_repeat('The quick brown fox jumps over the lazy dog. ', 10); -$compressed = gzcompress($input); +$compressed = gzencode($input); assert(is_string($compressed)); assert(strlen($compressed) < strlen($input)); From 861010af0ed3f0b3afb52ed26f2d143524de00ae Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 09:35:05 +0700 Subject: [PATCH 126/319] trim envs --- src/SPC/util/UnixShell.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index 44e97bfe..f8a80aff 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -72,10 +72,10 @@ class UnixShell public function setEnv(array $env): UnixShell { foreach ($env as $k => $v) { - if ($v === '') { + if (trim($v) === '') { continue; } - $this->env[$k] = $v; + $this->env[$k] = trim($v); } return $this; } From 3b9670c202ceeba11f70da8841d155b51abd9c84 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 09:57:20 +0700 Subject: [PATCH 127/319] fpic for liblzma --- src/SPC/builder/unix/library/xz.php | 13 +++++++++---- src/SPC/command/CraftCommand.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index c1c84f1f..e9ce3026 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -16,7 +16,12 @@ trait xz public function build(): void { shell()->cd($this->source_dir) - ->exec( + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags(), + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv( './configure ' . '--enable-static ' . '--disable-shared ' . @@ -26,9 +31,9 @@ trait xz '--with-libiconv ' . '--prefix=' ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->execWithEnv('make clean') + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['liblzma.pc']); } } diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index c5ddfb74..8d3cc2be 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -75,7 +75,7 @@ class CraftCommand extends BaseCommand } if (isset($craft['php-version'])) { $args[] = '--with-php=' . $craft['php-version']; - if (!array_key_exists('ignore-cache-sources', $craft['download-options']) || $craft['download-options']['ignore-cache-sources'] === false) { + if (!array_key_exists('ignore-cache-sources', $craft['download-options'])) { $craft['download-options']['ignore-cache-sources'] = 'php-src'; } } From 7c4c8c6275d79da2f90f5d79b8df455032dfdbf2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 13:10:28 +0700 Subject: [PATCH 128/319] cache libc version --- src/SPC/builder/linux/SystemUtil.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index e49830d2..e873667a 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -9,6 +9,7 @@ use SPC\exception\RuntimeException; class SystemUtil { + static ?string $libc_version = null; use UnixSystemUtilTrait; /** @noinspection PhpMissingBreakStatementInspection */ @@ -188,6 +189,9 @@ class SystemUtil */ public static function getLibcVersionIfExists(): ?string { + if (self::$libc_version !== null) { + return self::$libc_version; + } if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'glibc') { $result = shell()->execWithResult('ldd --version', false); if ($result[0] !== 0) { @@ -198,7 +202,8 @@ class SystemUtil // match ldd version: "ldd (some useless text) 2.17" match 2.17 $pattern = '/ldd\s+\(.*?\)\s+(\d+\.\d+)/'; if (preg_match($pattern, $first_line, $matches)) { - return $matches[1]; + self::$libc_version = $matches[1]; + return self::$libc_version; } return null; } @@ -212,7 +217,8 @@ class SystemUtil // match ldd version: "Version 1.2.3" match 1.2.3 $pattern = '/Version\s+(\d+\.\d+\.\d+)/'; if (preg_match($pattern, $result[1][1] ?? '', $matches)) { - return $matches[1]; + self::$libc_version = $matches[1]; + return self::$libc_version; } } return null; From 3761a9c8baa944535bd62593659e5e15a4a40cb2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 13:18:49 +0700 Subject: [PATCH 129/319] brotli was matching /dev/null, which should not be used --- config/source.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index 796e96f5..803734e9 100644 --- a/config/source.json +++ b/config/source.json @@ -50,8 +50,9 @@ } }, "brotli": { - "type": "ghtar", + "type": "ghtag", "repo": "google/brotli", + "match": "v1\\.\\d\\d", "provide-pre-built": true, "license": { "type": "file", From 1479bef00da211edb2677942498063628a8aab35 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 13:21:20 +0700 Subject: [PATCH 130/319] brotli was matching /dev/null, which should not be used --- config/source.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index 803734e9..f5987c3c 100644 --- a/config/source.json +++ b/config/source.json @@ -50,9 +50,9 @@ } }, "brotli": { - "type": "ghtag", + "type": "ghtagtar", "repo": "google/brotli", - "match": "v1\\.\\d\\d", + "match": "v1\\.\\d.*", "provide-pre-built": true, "license": { "type": "file", From 4582e1f508c81cfdb60a1767d407ec2e8286a624 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 13:57:45 +0700 Subject: [PATCH 131/319] cs fix --- src/SPC/builder/extension/lz4.php | 2 +- src/SPC/builder/linux/SystemUtil.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/lz4.php b/src/SPC/builder/extension/lz4.php index 541b1ecd..5727a97d 100644 --- a/src/SPC/builder/extension/lz4.php +++ b/src/SPC/builder/extension/lz4.php @@ -15,7 +15,7 @@ class lz4 extends Extension return '--enable-lz4' . ($shared ? '=shared' : '') . ' --with-lz4-includedir=' . BUILD_ROOT_PATH; } - public function getWindowsConfigureArg(): string + public function getWindowsConfigureArg(bool $shared = false): string { return '--enable-lz4'; } diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index e873667a..a85f3dec 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -9,9 +9,10 @@ use SPC\exception\RuntimeException; class SystemUtil { - static ?string $libc_version = null; use UnixSystemUtilTrait; + public static ?string $libc_version = null; + /** @noinspection PhpMissingBreakStatementInspection */ public static function getOSRelease(): array { From b6a118287622d817f2ec48716fc0b092621dfbf3 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 14:26:06 +0700 Subject: [PATCH 132/319] patch la files --- src/SPC/builder/unix/library/nghttp2.php | 1 + src/SPC/builder/unix/library/nghttp3.php | 1 + src/SPC/builder/unix/library/ngtcp2.php | 1 + src/SPC/builder/unix/library/xz.php | 1 + 4 files changed, 4 insertions(+) diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index 25cf1746..5fe5bc9b 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -53,5 +53,6 @@ trait nghttp2 ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv("make install DESTDIR={$destdir}"); $this->patchPkgconfPrefix(['libnghttp2.pc']); + $this->patchLaDependencyPrefix(['libnghttp2.la']); } } diff --git a/src/SPC/builder/unix/library/nghttp3.php b/src/SPC/builder/unix/library/nghttp3.php index 6f677869..2b2e0615 100644 --- a/src/SPC/builder/unix/library/nghttp3.php +++ b/src/SPC/builder/unix/library/nghttp3.php @@ -41,5 +41,6 @@ trait nghttp3 ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libnghttp3.pc']); + $this->patchLaDependencyPrefix(['libnghttp3.la']); } } diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 20620499..7b075ed9 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -45,5 +45,6 @@ trait ngtcp2 ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libngtcp2.pc']); $this->patchPkgconfPrefix(['libngtcp2_crypto_ossl.pc']); + $this->patchLaDependencyPrefix(['libngtcp2.la', 'libngtcp2_crypto_ossl.la']); } } diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index e9ce3026..f3b4d934 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -35,5 +35,6 @@ trait xz ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['liblzma.pc']); + $this->patchLaDependencyPrefix(['liblzma.la']); } } From a68212672bd24e6954433387c75ead9a384d6f1c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 23:49:58 +0700 Subject: [PATCH 133/319] apply suggestions --- src/SPC/builder/Extension.php | 8 +++++- src/SPC/builder/extension/curl.php | 6 ++--- src/SPC/builder/extension/dom.php | 2 +- src/SPC/builder/extension/pdo_sqlsrv.php | 33 ------------------------ src/SPC/builder/extension/pgsql.php | 5 +--- src/SPC/builder/linux/LinuxBuilder.php | 12 --------- src/SPC/command/BuildPHPCommand.php | 2 +- src/SPC/store/SourcePatcher.php | 13 +++------- 8 files changed, 17 insertions(+), 64 deletions(-) delete mode 100644 src/SPC/builder/extension/pdo_sqlsrv.php diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 1ffc6dc3..f4207dc6 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -235,7 +235,7 @@ class Extension $ret = ''; foreach ($order as $ext) { if ($ext instanceof Extension && $ext->isBuildShared()) { - if (Config::getExt($ext->getName(), 'zend_extension', false) === true) { + if (Config::getExt($ext->getName(), 'zend-extension', false) === true) { $ret .= " -d \"zend_extension={$ext->getName()}\""; } else { $ret .= " -d \"extension={$ext->getName()}\""; @@ -371,6 +371,7 @@ class Extension } $env = [ 'CFLAGS' => $config['cflags'], + 'CXXFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], 'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, @@ -485,6 +486,11 @@ class Extension } } + if (array_key_exists(0, $deps)) { + $zero = [0 => $deps[0]]; + unset($deps[0]); + return $zero + $deps; + } return $deps; } } diff --git a/src/SPC/builder/extension/curl.php b/src/SPC/builder/extension/curl.php index 4779e67c..0c5de6a5 100644 --- a/src/SPC/builder/extension/curl.php +++ b/src/SPC/builder/extension/curl.php @@ -22,7 +22,7 @@ class curl extends Extension { logger()->info('patching before-configure for curl checks'); $file1 = "AC_DEFUN([PHP_CHECK_LIBRARY], [\n $3\n])"; - $files = FileSystem::readFile(SOURCE_PATH . '/php-src/ext/curl/config.m4'); + $files = FileSystem::readFile($this->source_dir . '/config.m4'); $file2 = 'AC_DEFUN([PHP_CHECK_LIBRARY], [ save_old_LDFLAGS=$LDFLAGS ac_stuff="$5" @@ -41,7 +41,7 @@ class curl extends Extension $4 ])dnl ])'; - file_put_contents(SOURCE_PATH . '/php-src/ext/curl/config.m4', $file1 . "\n" . $files . "\n" . $file2); + file_put_contents($this->source_dir . '/config.m4', $file1 . "\n" . $files . "\n" . $file2); return true; } @@ -59,7 +59,7 @@ class curl extends Extension public function patchBeforeSharedConfigure(): bool { - $file = SOURCE_PATH . '/php-src/ext/curl/config.m4'; + $file = $this->source_dir . '/config.m4'; $content = FileSystem::readFile($file); // Inject patch before it diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index fb1a4e15..85437f62 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -30,6 +30,6 @@ class dom extends Extension public function getWindowsConfigureArg($shared = false): string { - return '--with-dom --with-libxml'; + return '--with-dom'; } } diff --git a/src/SPC/builder/extension/pdo_sqlsrv.php b/src/SPC/builder/extension/pdo_sqlsrv.php deleted file mode 100644 index ed501bb2..00000000 --- a/src/SPC/builder/extension/pdo_sqlsrv.php +++ /dev/null @@ -1,33 +0,0 @@ -builder))->config([$this->getName()]); - $env = [ - 'CFLAGS' => $config['cflags'], - 'CXXFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'], - 'LIBS' => $config['libs'], - 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, - ]; - // prepare configure args - shell()->cd($this->source_dir) - ->setEnv($env) - ->execWithEnv(BUILD_BIN_PATH . '/phpize') - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static --with-pic') - ->execWithEnv('make clean') - ->execWithEnv('make -j' . $this->builder->concurrency) - ->execWithEnv('make install'); - } -} diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index df852f4b..a70c1fb7 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -39,12 +39,9 @@ class pgsql extends Extension $libfiles = $this->getLibFilesString(); $libfiles = str_replace(BUILD_LIB_PATH . '/lib', '-l', $libfiles); $libfiles = str_replace('.a', '', $libfiles); - $libfiles = str_replace(' -lpq', '', $libfiles); - $libfiles = str_replace(' -lpgport', '', $libfiles); - $libfiles = str_replace(' -lpgcommon', '', $libfiles); return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . - ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon ' . $libfiles . '"'; + ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' ' . $libfiles . '"'; } return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index c40f8871..61a436eb 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -109,18 +109,6 @@ class LinuxBuilder extends UnixBuilderBase */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { - if ($build_target === BUILD_TARGET_EMBED && - file_exists(BUILD_BIN_PATH . '/php-config') && - file_exists(BUILD_BIN_PATH . '/phpize') - ) { - $embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static'; - if ($embed_type === 'shared' && file_exists(BUILD_LIB_PATH . '/libphp.so')) { - return; - } - if (file_exists(BUILD_LIB_PATH . '/libphp.a')) { - return; - } - } // ---------- Update extra-libs ---------- $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; // bloat means force-load all static libraries, even if they are not used diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 61781d2c..24900d6d 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -208,7 +208,7 @@ class BuildPHPCommand extends BuildCommand SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); // start to build - $builder->buildPHP($rule); + // $builder->buildPHP($rule); SourcePatcher::patchBeforeSharedBuild($builder); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 6abcf52d..d61020b8 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -457,16 +457,11 @@ class SourcePatcher if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() >= '2.17') { return false; } - $version = null; - if (file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { - $file = SOURCE_PATH . '/php-src/main/php_version.h'; - $cnt = preg_match('/PHP_VERSION "(\d+\.\d+\.\d+)"/', file_get_contents($file), $match); - if (!$cnt) { - return false; - } - $version = $match[1]; + if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + return false; } - if (version_compare($version, '8.3.16', '<')) { + $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); + if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0 && intval($match[1]) < 80316) { return false; } SourcePatcher::patchFile('ffi_centos7_fix_O3_strncmp.patch', SOURCE_PATH . '/php-src'); From 715650c4db11a6df437c035138fc91a1c7827c9d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 23:51:58 +0700 Subject: [PATCH 134/319] add "which" to spc doctor --- src/SPC/doctor/item/LinuxToolCheckList.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 88a44a8e..2522eb58 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -21,7 +21,7 @@ class LinuxToolCheckList 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', 'g++', 'patch', 'binutils-gold', - 'libtoolize', + 'libtoolize', 'which', ]; public const TOOLS_DEBIAN = [ @@ -29,14 +29,14 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'autopoint', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', - 'xz', 'libtoolize', + 'xz', 'libtoolize', 'which', ]; public const TOOLS_RHEL = [ 'perl', 'make', 'bison', 'flex', 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'gcc', - 'bzip2', 'cmake', 'patch', + 'bzip2', 'cmake', 'patch', 'which', 'xz', 'libtool', 'gettext-devel', ]; From 0d91ad7d94fc62d34ae28df40e39718bdfc79e82 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 23:57:48 +0700 Subject: [PATCH 135/319] remove buildUnixShared method from sqlsrv --- src/SPC/builder/extension/sqlsrv.php | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index 55a2b6a0..edf5d919 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -7,7 +7,6 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\store\FileSystem; use SPC\util\CustomExt; -use SPC\util\SPCConfigUtil; #[CustomExt('sqlsrv')] class sqlsrv extends Extension @@ -34,31 +33,4 @@ class sqlsrv extends Extension } return false; } - - public function buildUnixShared(): void - { - $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); - $env = [ - 'CFLAGS' => $config['cflags'], - 'CXXFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'], - 'LIBS' => $config['libs'], - 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, - ]; - // prepare configure args - shell()->cd($this->source_dir) - ->setEnv($env) - ->execWithEnv(BUILD_BIN_PATH . '/phpize'); - - if ($this->patchBeforeSharedConfigure()) { - logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); - } - - shell()->cd($this->source_dir) - ->setEnv($env) - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') - ->execWithEnv('make clean') - ->execWithEnv('make -j' . $this->builder->concurrency) - ->execWithEnv('make install'); - } } From f29ee9517621cf09dbb27567a116104928db1373 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 6 Jun 2025 23:58:33 +0700 Subject: [PATCH 136/319] remove buildUnixShared method from xhprof --- src/SPC/builder/extension/xhprof.php | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/SPC/builder/extension/xhprof.php b/src/SPC/builder/extension/xhprof.php index 589ac583..afb22257 100644 --- a/src/SPC/builder/extension/xhprof.php +++ b/src/SPC/builder/extension/xhprof.php @@ -31,30 +31,4 @@ class xhprof extends Extension } return false; } - - public function buildUnixShared(): void - { - $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); - $env = [ - 'CFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'], - 'LIBS' => $config['libs'], - 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, - ]; - // prepare configure args - shell()->cd($this->source_dir . '/extension') - ->setEnv($env) - ->execWithEnv(BUILD_BIN_PATH . '/phpize'); - - if ($this->patchBeforeSharedConfigure()) { - logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); - } - - shell()->cd($this->source_dir . '/extension') - ->setEnv($env) - ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') - ->execWithEnv('make clean') - ->execWithEnv('make -j' . $this->builder->concurrency) - ->execWithEnv('make install'); - } } From 111de20a5766550a19830ae1cb4f0e115618522b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 00:00:17 +0700 Subject: [PATCH 137/319] fix cs --- src/SPC/builder/extension/xhprof.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/extension/xhprof.php b/src/SPC/builder/extension/xhprof.php index afb22257..c3d98aac 100644 --- a/src/SPC/builder/extension/xhprof.php +++ b/src/SPC/builder/extension/xhprof.php @@ -7,7 +7,6 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\store\FileSystem; use SPC\util\CustomExt; -use SPC\util\SPCConfigUtil; #[CustomExt('xhprof')] class xhprof extends Extension From e31942bf1e64187c2c65a5625f1178a91a331353 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 08:21:56 +0700 Subject: [PATCH 138/319] uncommented buildphp, haha --- src/SPC/command/BuildPHPCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 24900d6d..61781d2c 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -208,7 +208,7 @@ class BuildPHPCommand extends BuildCommand SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); // start to build - // $builder->buildPHP($rule); + $builder->buildPHP($rule); SourcePatcher::patchBeforeSharedBuild($builder); From 2dde53760a8a8d041b004485c9f034ed1b9a902d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 20:09:50 +0700 Subject: [PATCH 139/319] makeCmakeArgs --- src/SPC/builder/linux/library/icu.php | 2 +- src/SPC/builder/linux/library/libxml2.php | 8 +------ src/SPC/builder/macos/library/glfw.php | 2 +- src/SPC/builder/macos/library/libxml2.php | 8 +------ src/SPC/builder/unix/UnixBuilderBase.php | 3 +++ src/SPC/builder/unix/library/curl.php | 2 +- src/SPC/builder/unix/library/freetype.php | 4 +--- src/SPC/builder/unix/library/gmssl.php | 2 +- src/SPC/builder/unix/library/libaom.php | 11 +--------- src/SPC/builder/unix/library/libavif.php | 2 +- src/SPC/builder/unix/library/libde265.php | 11 +--------- src/SPC/builder/unix/library/libevent.php | 11 +++++----- src/SPC/builder/unix/library/libheif.php | 7 +------ src/SPC/builder/unix/library/libjpeg.php | 1 - src/SPC/builder/unix/library/librabbitmq.php | 11 +--------- src/SPC/builder/unix/library/libssh2.php | 8 +------ src/SPC/builder/unix/library/libuuid.php | 6 +----- src/SPC/builder/unix/library/libuv.php | 2 +- src/SPC/builder/unix/library/libwebp.php | 9 +------- src/SPC/builder/unix/library/libyaml.php | 22 ++++++-------------- src/SPC/builder/unix/library/libzip.php | 7 +------ src/SPC/builder/unix/library/mimalloc.php | 10 +-------- src/SPC/builder/unix/library/snappy.php | 4 +--- src/SPC/builder/unix/library/tidy.php | 13 +++++------- src/SPC/builder/unix/library/zstd.php | 13 +++--------- 25 files changed, 41 insertions(+), 138 deletions(-) diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index ddcfe1b2..87a92234 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -15,7 +15,7 @@ class icu extends LinuxLibraryBase protected function build(): void { $cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"'; - $cxxflags = 'CXXFLAGS="-std=c++17 -fPIC -fno-ident"'; + $cxxflags = 'CXXFLAGS="-std=c++17 -DPIC -fPIC -fno-ident"'; $ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : ''; shell()->cd($this->source_dir . '/source') ->setEnv([ diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 6d9470ae..5f4f1dc9 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -30,13 +30,7 @@ class libxml2 extends LinuxLibraryBase 'LIBS' => $this->getLibExtraLibs(), ]) ->execWithEnv( - 'cmake ' . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - '-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . + "cmake {$this->builder->makeCmakeArgs()} " . '-DIconv_IS_BUILT_IN=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . diff --git a/src/SPC/builder/macos/library/glfw.php b/src/SPC/builder/macos/library/glfw.php index a3b88b6a..8ab84770 100644 --- a/src/SPC/builder/macos/library/glfw.php +++ b/src/SPC/builder/macos/library/glfw.php @@ -19,7 +19,7 @@ class glfw extends MacOSLibraryBase { // compile! shell()->cd(SOURCE_PATH . '/ext-glfw/vendor/glfw') - ->exec("cmake . {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DPOSITION_INDEPENDENT_CODE=ON -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") + ->exec("cmake . {$this->builder->makeCmakeArgs()} -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF") ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); // patch pkgconf diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index f8d75f83..d4646dba 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -25,15 +25,9 @@ class libxml2 extends MacOSLibraryBase FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - 'cmake ' . + "cmake {$this->builder->makeCmakeArgs()} " . // '--debug-find ' . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - '-DCMAKE_INSTALL_LIBDIR=' . BUILD_LIB_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DBUILD_SHARED_LIBS=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . "-DLIBXML2_WITH_ICU={$enable_icu} " . "-DLIBXML2_WITH_LZMA={$enable_xz} " . diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index d645a68f..26b5747b 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -60,6 +60,9 @@ abstract class UnixBuilderBase extends BuilderBase { $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : ''; return $extra . + '-DBUILD_STATIC_LIBS=ON ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DCMAKE_BUILD_TYPE=Release ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . '-DCMAKE_INSTALL_BINDIR=bin ' . diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index 5296d636..7a166b20 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -86,7 +86,7 @@ trait curl 'LIBS' => $this->getLibExtraLibs(), ]) ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DPOSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install'); // patch pkgconf diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 903d3746..187ebeff 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -33,9 +33,7 @@ trait freetype 'LIBS' => $this->getLibExtraLibs(), ]) ->execWithEnv( - "cmake {$this->builder->makeCmakeArgs()} -DFT_DISABLE_HARFBUZZ=ON " . - '-DBUILD_SHARED_LIBS=OFF ' . - "{$extra}.." + "cmake {$this->builder->makeCmakeArgs()} -DFT_DISABLE_HARFBUZZ=ON {$extra}.." ) ->execWithEnv('make clean') ->execWithEnv("make -j{$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/gmssl.php b/src/SPC/builder/unix/library/gmssl.php index bf0abe8e..5e2fe153 100644 --- a/src/SPC/builder/unix/library/gmssl.php +++ b/src/SPC/builder/unix/library/gmssl.php @@ -25,7 +25,7 @@ trait gmssl 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DPOSITION_INDEPENDENT_CODE=ON ..") + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} ..") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); } diff --git a/src/SPC/builder/unix/library/libaom.php b/src/SPC/builder/unix/library/libaom.php index d0de97d7..38e0b95a 100644 --- a/src/SPC/builder/unix/library/libaom.php +++ b/src/SPC/builder/unix/library/libaom.php @@ -20,16 +20,7 @@ trait libaom FileSystem::resetDir($this->source_dir . '/builddir'); // Start build shell()->cd($this->source_dir . '/builddir') - ->exec( - 'cmake ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DAOM_TARGET_CPU=generic ' . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} -DAOM_TARGET_CPU=generic ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); $this->patchPkgconfPrefix(['aom.pc']); diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index e0b0430d..3c01c102 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -27,7 +27,7 @@ trait libavif 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DPOSITION_INDEPENDENT_CODE=ON -DAVIF_LIBYUV=OFF ..") + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DAVIF_LIBYUV=OFF ..") ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libde265.php b/src/SPC/builder/unix/library/libde265.php index bf1546f2..0f7d44a1 100644 --- a/src/SPC/builder/unix/library/libde265.php +++ b/src/SPC/builder/unix/library/libde265.php @@ -20,16 +20,7 @@ trait libde265 FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec( - 'cmake ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DENABLE_SDL=OFF ' . // Disable SDL, currently not supported - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); $this->patchPkgconfPrefix(['libde265.pc']); diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index 437bd68d..58b1b879 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -39,8 +39,11 @@ trait libevent */ protected function build(): void { - [$lib, $include, $destdir] = SEPARATED_PATH; // CMake needs a clean build directory + $extra = ''; + if (version_compare(get_cmake_version(), '4.0.0', '>=')) { + $extra .= '-DCMAKE_POLICY_VERSION_MINIMUM=3.10 '; + } FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') @@ -50,11 +53,7 @@ trait libevent 'LIBS' => $this->getLibExtraLibs(), ]) ->execWithEnv( - 'cmake ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DCMAKE_BUILD_TYPE=Release ' . + "cmake {$this->builder->makeCmakeArgs()} {$extra}" . '-DEVENT__LIBRARY_TYPE=STATIC ' . '-DEVENT__DISABLE_BENCHMARK=ON ' . '-DEVENT__DISABLE_THREAD_SUPPORT=ON ' . diff --git a/src/SPC/builder/unix/library/libheif.php b/src/SPC/builder/unix/library/libheif.php index 5725b737..9e92cf22 100644 --- a/src/SPC/builder/unix/library/libheif.php +++ b/src/SPC/builder/unix/library/libheif.php @@ -21,13 +21,8 @@ trait libheif // Start build shell()->cd($this->source_dir . '/build') ->exec( - 'cmake ' . + "cmake {$this->builder->makeCmakeArgs()} " . '--preset=release ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DWITH_EXAMPLES=OFF ' . '-DWITH_GDK_PIXBUF=OFF ' . '-DBUILD_TESTING=OFF ' . diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 5612e130..c4f9833d 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -26,7 +26,6 @@ trait libjpeg "cmake {$this->builder->makeCmakeArgs()} " . '-DENABLE_STATIC=ON ' . '-DENABLE_SHARED=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/librabbitmq.php b/src/SPC/builder/unix/library/librabbitmq.php index 1f7fd0e3..d4044b46 100644 --- a/src/SPC/builder/unix/library/librabbitmq.php +++ b/src/SPC/builder/unix/library/librabbitmq.php @@ -20,16 +20,7 @@ trait librabbitmq FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec( - 'cmake ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DBUILD_STATIC_LIBS=ON ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); } diff --git a/src/SPC/builder/unix/library/libssh2.php b/src/SPC/builder/unix/library/libssh2.php index b99b9e7b..f2132fc8 100644 --- a/src/SPC/builder/unix/library/libssh2.php +++ b/src/SPC/builder/unix/library/libssh2.php @@ -21,13 +21,7 @@ trait libssh2 FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - 'cmake ' . - '-DCMAKE_BUILD_TYPE=Release ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - '-DCMAKE_INSTALL_LIBDIR=lib ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . + "cmake {$this->builder->makeCmakeArgs()} " . '-DBUILD_EXAMPLES=OFF ' . '-DBUILD_TESTING=OFF ' . "-DENABLE_ZLIB_COMPRESSION={$enable_zlib} " . diff --git a/src/SPC/builder/unix/library/libuuid.php b/src/SPC/builder/unix/library/libuuid.php index 405941ed..cb13c66b 100644 --- a/src/SPC/builder/unix/library/libuuid.php +++ b/src/SPC/builder/unix/library/libuuid.php @@ -18,11 +18,7 @@ trait libuuid { FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->exec( - 'cmake ' . - "{$this->builder->makeCmakeArgs()} -DPOSITION_INDEPENDENT_CODE=ON " . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} ..") ->exec("cmake --build . -j {$this->builder->concurrency}"); copy($this->source_dir . '/build/libuuid.a', BUILD_LIB_PATH . '/libuuid.a'); FileSystem::createDir(BUILD_INCLUDE_PATH . '/uuid'); diff --git a/src/SPC/builder/unix/library/libuv.php b/src/SPC/builder/unix/library/libuv.php index 2294a1e3..fda11c0a 100644 --- a/src/SPC/builder/unix/library/libuv.php +++ b/src/SPC/builder/unix/library/libuv.php @@ -20,7 +20,7 @@ trait libuv FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec("cmake {$this->builder->makeCmakeArgs()} -DPOSITION_INDEPENDENT_CODE=ON -DLIBUV_BUILD_SHARED=OFF ..") + ->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index 79fc1e3e..29076c6d 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -22,14 +22,7 @@ trait libwebp FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec( - 'cmake ' . - $this->builder->makeCmakeArgs() . ' ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DWEBP_BUILD_EXTRAS=ON ' . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} -DWEBP_BUILD_EXTRAS=ON ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); // patch pkgconfig diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index b519f709..6907535d 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -31,24 +31,14 @@ trait libyaml */ protected function build(): void { - [$lib, $include, $destdir] = SEPARATED_PATH; - + $extra = ''; + if (version_compare(get_cmake_version(), '4.0.0', '>=')) { + $extra .= '-DCMAKE_POLICY_VERSION_MINIMUM=3.5'; + } FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->exec( - 'cmake ' . - // '--debug-find ' . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_TESTING=OFF ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DCMAKE_INSTALL_PREFIX=/ ' . - "-DCMAKE_INSTALL_LIBDIR={$lib} " . - "-DCMAKE_INSTALL_INCLUDEDIR={$include} " . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} {$extra} -DBUILD_TESTING=OFF ..") ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); } } diff --git a/src/SPC/builder/unix/library/libzip.php b/src/SPC/builder/unix/library/libzip.php index c206f3c9..9c00d6a2 100644 --- a/src/SPC/builder/unix/library/libzip.php +++ b/src/SPC/builder/unix/library/libzip.php @@ -29,14 +29,9 @@ trait libzip FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') ->exec( - 'cmake ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . + "cmake {$this->builder->makeCmakeArgs()} " . '-DENABLE_GNUTLS=OFF ' . '-DENABLE_MBEDTLS=OFF ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . '-DBUILD_DOC=OFF ' . '-DBUILD_EXAMPLES=OFF ' . '-DBUILD_REGRESS=OFF ' . diff --git a/src/SPC/builder/unix/library/mimalloc.php b/src/SPC/builder/unix/library/mimalloc.php index 34b4f7be..bbf80bbd 100644 --- a/src/SPC/builder/unix/library/mimalloc.php +++ b/src/SPC/builder/unix/library/mimalloc.php @@ -24,15 +24,7 @@ trait mimalloc $args .= '-DMI_INSTALL_TOPLEVEL=ON '; FileSystem::resetDir($this->source_dir . '/build'); shell()->cd($this->source_dir . '/build') - ->execWithEnv( - 'cmake ' . - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DCMAKE_BUILD_TYPE=Release ' . - $args . - '..' - ) + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} {$args} ..") ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install'); } diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index 8d1c3b8a..e1a1d415 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -20,11 +20,9 @@ trait snappy shell()->cd($this->source_dir . '/cmake/build') ->exec( - 'cmake ' . - "{$this->builder->makeCmakeArgs()} " . + "cmake {$this->builder->makeCmakeArgs()} " . '-DSNAPPY_BUILD_TESTS=OFF ' . '-DSNAPPY_BUILD_BENCHMARKS=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . '../..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") diff --git a/src/SPC/builder/unix/library/tidy.php b/src/SPC/builder/unix/library/tidy.php index ce5cd462..b9bc6951 100644 --- a/src/SPC/builder/unix/library/tidy.php +++ b/src/SPC/builder/unix/library/tidy.php @@ -16,16 +16,13 @@ trait tidy */ protected function build(): void { + $extra = ''; + if (version_compare(get_cmake_version(), '4.0.0', '>=')) { + $extra .= '-DCMAKE_POLICY_VERSION_MINIMUM=3.5'; + } FileSystem::resetDir($this->source_dir . '/build-dir'); shell()->cd($this->source_dir . '/build-dir') - ->exec( - 'cmake ' . - "{$this->builder->makeCmakeArgs()} " . - '-DBUILD_SHARED_LIB=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '-DSUPPORT_CONSOLE_APP=OFF ' . - '..' - ) + ->exec("cmake {$this->builder->makeCmakeArgs()} {$extra} -DSUPPORT_CONSOLE_APP=OFF ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); $this->patchPkgconfPrefix(['tidy.pc']); diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index 939567f2..a8fe34bc 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -23,16 +23,9 @@ trait zstd 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->exec( - 'cmake ' . - "{$this->builder->makeCmakeArgs()} " . - '-DZSTD_BUILD_STATIC=ON ' . - '-DZSTD_BUILD_SHARED=OFF ' . - '-DPOSITION_INDEPENDENT_CODE=ON ' . - '..' - ) - ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install'); + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} ..") + ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") + ->execWithEnv('make install'); $this->patchPkgconfPrefix(['libzstd.pc']); } } From a6ea49981d331233283c9879a7b9040332cfcc78 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 20:29:19 +0700 Subject: [PATCH 140/319] ngtcp2 patch la files --- src/SPC/builder/unix/library/ngtcp2.php | 1 + src/globals/test-extensions.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 8ea280a8..bfe44900 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -49,6 +49,7 @@ trait ngtcp2 ->execWithEnv("make -j{$this->builder->concurrency}") ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']); + $this->patchLaDependencyPrefix(['libngtcp2.la', 'libngtcp2_crypto_ossl.la']); // on macOS, the static library may contain other static libraries? // ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 62963ce6..cdd03264 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -57,7 +57,7 @@ $shared_extensions = match (PHP_OS_FAMILY) { // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => '', + 'Linux', 'Darwin' => 'ngtcp2,nghttp2,nghttp3,libavif', 'Windows' => '', }; From a3025479e7cdab7d1803c17ab453c0fb638a5755 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 20:50:46 +0700 Subject: [PATCH 141/319] fix libyaml install dir --- src/SPC/builder/unix/library/libyaml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index 6907535d..145f5b57 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -39,6 +39,6 @@ trait libyaml shell()->cd($this->source_dir . '/build') ->exec("cmake {$this->builder->makeCmakeArgs()} {$extra} -DBUILD_TESTING=OFF ..") ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make install'); } } From 0b8543e6ddb7657cb8a953d5860c6c238afee2b5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 20:50:54 +0700 Subject: [PATCH 142/319] thread safety for pgsql? --- src/SPC/builder/unix/library/postgresql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 5a0da5de..acddc14f 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -91,7 +91,7 @@ trait postgresql ->execWithEnv( "{$envs} ../configure " . "--prefix={$builddir} " . - '--disable-thread-safety ' . + ($this->builder->getOption('enable-zts') ? '--enable-thread-safety ' : '--disable-thread-safety ') . '--enable-coverage=no ' . '--with-ssl=openssl ' . '--with-readline ' . From 23be5484e3a6263354ffff72d38371704028132a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 21:16:15 +0700 Subject: [PATCH 143/319] thread safety for pgsql (in version 17, remove this entirely) --- config/source.json | 5 +++-- src/SPC/builder/unix/library/ldap.php | 2 ++ src/SPC/builder/unix/library/postgresql.php | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config/source.json b/config/source.json index 10fd7472..98d37eb4 100644 --- a/config/source.json +++ b/config/source.json @@ -822,8 +822,9 @@ } }, "postgresql": { - "type": "url", - "url": "https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.bz2", + "type": "ghtagtar", + "repo": "postgres/postgres", + "match": "REL_16_\\d+", "license": { "type": "file", "path": "COPYRIGHT" diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 6f8790f1..3a05e3df 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -50,6 +50,8 @@ trait ldap ->exec('sed -i -e "s/SUBDIRS= include libraries clients servers tests doc/SUBDIRS= include libraries clients servers/g" Makefile') ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + + FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/ldap.pc', 'Libs: -L${libdir} -lldap', 'Libs: -L${libdir} -lldap -llber'); $this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']); $this->patchLaDependencyPrefix(['libldap.la', 'liblber.la']); } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index acddc14f..cdeb22fc 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -22,7 +22,7 @@ trait postgresql $packages = 'zlib openssl readline libxml-2.0'; $optional_packages = [ 'zstd' => 'libzstd', - // 'ldap' => 'ldap', + 'ldap' => 'ldap', 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; @@ -97,8 +97,8 @@ trait postgresql '--with-readline ' . '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - // ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . - '--without-ldap ' . + ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . + // '--without-ldap ' . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . From e5f483de1df0151d96d2588c31e75e0937703a7d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 21:16:53 +0700 Subject: [PATCH 144/319] libtidy uses strange cmake options --- src/SPC/builder/unix/library/tidy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/tidy.php b/src/SPC/builder/unix/library/tidy.php index b9bc6951..18040c92 100644 --- a/src/SPC/builder/unix/library/tidy.php +++ b/src/SPC/builder/unix/library/tidy.php @@ -22,7 +22,7 @@ trait tidy } FileSystem::resetDir($this->source_dir . '/build-dir'); shell()->cd($this->source_dir . '/build-dir') - ->exec("cmake {$this->builder->makeCmakeArgs()} {$extra} -DSUPPORT_CONSOLE_APP=OFF ..") + ->exec("cmake {$this->builder->makeCmakeArgs()} {$extra} -DBUILD_SHARED_LIB=OFF -DSUPPORT_CONSOLE_APP=OFF ..") ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); $this->patchPkgconfPrefix(['tidy.pc']); From 2093b4ec85a04e3e720900ded0f7bf6824b8df86 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 21:19:17 +0700 Subject: [PATCH 145/319] cs fix --- src/SPC/builder/unix/library/postgresql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index cdeb22fc..ff894ecf 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -91,7 +91,7 @@ trait postgresql ->execWithEnv( "{$envs} ../configure " . "--prefix={$builddir} " . - ($this->builder->getOption('enable-zts') ? '--enable-thread-safety ' : '--disable-thread-safety ') . + ($this->builder->getOption('enable-zts') ? '--enable-thread-safety ' : '--disable-thread-safety ') . '--enable-coverage=no ' . '--with-ssl=openssl ' . '--with-readline ' . From f4771b4f21c31bcc8c7d4af2bcb2a18015b5b9ed Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 21:33:02 +0700 Subject: [PATCH 146/319] test macos too --- src/globals/test-extensions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index cdd03264..33d4bd82 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -21,9 +21,9 @@ $test_php_version = [ // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-13', + 'macos-13', // 'macos-14', - // 'macos-15', + 'macos-15', // 'ubuntu-latest', 'ubuntu-22.04', // 'ubuntu-24.04', @@ -52,7 +52,8 @@ $extensions = match (PHP_OS_FAMILY) { // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', - 'Windows', 'Darwin' => '', + 'Darwin' => '', + 'Windows' => '', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From bb1f0866746e90541bac62c314558125a9d2c684 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 21:57:04 +0700 Subject: [PATCH 147/319] pq forgets to link against -llber, only links against -lldap --- src/SPC/builder/unix/library/postgresql.php | 3 +++ src/globals/test-extensions.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index ff894ecf..6f5cccaf 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use Hoa\File\File; use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; @@ -119,6 +120,8 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so.*") ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); + + FileSystem::replaceFileStr(BUILD_LIB_PATH . '/libpq.pc', '-lldap', '-lldap -llber'); } private function getVersion(): string diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 33d4bd82..79aff1dd 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -51,7 +51,7 @@ $extensions = match (PHP_OS_FAMILY) { // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd,spx', + 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', 'Darwin' => '', 'Windows' => '', }; From 08d3849c4385f4ddcb4baa2cd067bb5bff28a364 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 22:00:01 +0700 Subject: [PATCH 148/319] cs fix --- src/SPC/builder/unix/library/postgresql.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 6f5cccaf..6a42c29b 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\unix\library; -use Hoa\File\File; use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; From 2f53915064f6dfeaa3cd9e57eb3642dcc0bb7a61 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 23:00:26 +0700 Subject: [PATCH 149/319] fix ldap for postgresql --- config/lib.json | 4 ++-- src/SPC/builder/Extension.php | 10 ++++++---- src/SPC/builder/unix/library/libxslt.php | 3 +++ src/SPC/builder/unix/library/postgresql.php | 2 +- src/SPC/util/SPCConfigUtil.php | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/config/lib.json b/config/lib.json index 0d4941f0..36d93a6e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -234,8 +234,8 @@ "ldap": { "source": "ldap", "static-libs-unix": [ - "liblber.a", - "libldap.a" + "libldap.a", + "liblber.a" ], "lib-depends": [ "openssl", diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f4207dc6..c6342784 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -356,16 +356,18 @@ class Extension { $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); $sharedLibs = ''; - $staticLibs = ''; + $staticLibs = $this->getLibFilesString(); + $staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs); + $staticLibs = str_replace('.a', '', $staticLibs); foreach (explode('-l', $config['libs']) as $lib) { $lib = trim($lib); if ($lib === '') { continue; } $static_lib = 'lib' . $lib . '.a'; - if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { + if (file_exists(BUILD_LIB_PATH . '/' . $static_lib) && !str_contains($staticLibs, '-llib')) { $staticLibs .= ' -l' . $lib; - } else { + } elseif (!str_contains($sharedLibs, '-l' . $lib)) { $sharedLibs .= ' -l' . $lib; } } @@ -373,7 +375,7 @@ class Extension 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], - 'LIBS' => '-Wl,-Bstatic ' . $staticLibs . ' -Wl,-Bdynamic ' . $sharedLibs, + 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibs . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibs, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; // prepare configure args diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 53061276..8a9bafaa 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -49,5 +49,8 @@ trait libxslt ->execWithEnv('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH)); $this->patchPkgconfPrefix(['libexslt.pc']); $this->patchLaDependencyPrefix(['libxslt.la', 'libexslt.la']); + shell()->cd(BUILD_LIB_PATH) + ->exec("ar -t libxslt.a | grep '\\.a$' | xargs -n1 ar d libxslt.a") + ->exec("ar -t libexslt.a | grep '\\.a$' | xargs -n1 ar d libexslt.a"); } } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 6a42c29b..69907556 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -120,7 +120,7 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); - FileSystem::replaceFileStr(BUILD_LIB_PATH . '/libpq.pc', '-lldap', '-lldap -llber'); + FileSystem::replaceFileStr(BUILD_LIB_PATH . '/pkgconfig/libpq.pc', '-lldap', '-lldap -llber'); } private function getVersion(): string diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 9f75b41f..60db9ba2 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -31,7 +31,7 @@ class SPCConfigUtil * @param array $libraries Additional library name list * @param bool $include_suggest_ext Include suggested extensions * @param bool $include_suggest_lib Include suggested libraries - * @param mixed $with_dependencies + * @param bool $with_dependencies * @return array{ * cflags: string, * ldflags: string, @@ -43,7 +43,7 @@ class SPCConfigUtil * @throws WrongUsageException * @throws \Throwable */ - public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, $with_dependencies = false): array + public function config(array $extensions = [], array $libraries = [], bool $include_suggest_ext = false, bool $include_suggest_lib = false, bool $with_dependencies = false): array { [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); From 0ebd44bc4f293043716adc4cc359680b9fe94cf3 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 7 Jun 2025 23:19:32 +0700 Subject: [PATCH 150/319] bring back zstd cmake flags --- src/SPC/builder/unix/library/zstd.php | 7 ++++++- src/SPC/util/SPCConfigUtil.php | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/zstd.php b/src/SPC/builder/unix/library/zstd.php index a8fe34bc..6e2b67e4 100644 --- a/src/SPC/builder/unix/library/zstd.php +++ b/src/SPC/builder/unix/library/zstd.php @@ -23,7 +23,12 @@ trait zstd 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs(), ]) - ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} ..") + ->execWithEnv( + "cmake {$this->builder->makeCmakeArgs()} " . + '-DZSTD_BUILD_STATIC=ON ' . + '-DZSTD_BUILD_SHARED=OFF ' . + '..' + ) ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->execWithEnv('make install'); $this->patchPkgconfPrefix(['libzstd.pc']); diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 60db9ba2..375d40cd 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -31,7 +31,6 @@ class SPCConfigUtil * @param array $libraries Additional library name list * @param bool $include_suggest_ext Include suggested extensions * @param bool $include_suggest_lib Include suggested libraries - * @param bool $with_dependencies * @return array{ * cflags: string, * ldflags: string, From a99c4a3fee14b53c3c63904265d90343b1ffb9b1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 8 Jun 2025 08:13:03 +0700 Subject: [PATCH 151/319] remove getLibFilesString from Extension buildUnixShared --- src/SPC/builder/Extension.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index c6342784..6083e2d3 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -356,9 +356,7 @@ class Extension { $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); $sharedLibs = ''; - $staticLibs = $this->getLibFilesString(); - $staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs); - $staticLibs = str_replace('.a', '', $staticLibs); + $staticLibs = ''; foreach (explode('-l', $config['libs']) as $lib) { $lib = trim($lib); if ($lib === '') { From 6ed440d8615d1c91eac1ef478f7b252ef42c14b4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 8 Jun 2025 14:45:09 +0700 Subject: [PATCH 152/319] refactor out method to get static and shared libraries --- src/SPC/builder/Extension.php | 48 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6083e2d3..2dad0a80 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -343,6 +343,37 @@ class Extension }; } + /** + * Get required static and shared libraries as a pair of strings in format -l{libname} -l{libname2} + * + * @return array [staticLibString, sharedLibString] + */ + private function getStaticAndSharedLibs(): array + { + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); + $sharedLibString = ''; + $staticLibString = ''; + $staticLibs = $this->getLibFilesString(); + $staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs); + $staticLibs = str_replace('.a', '', $staticLibs); + $staticLibs = explode('-l', $staticLibs . ' ' . $config['libs']); + foreach ($staticLibs as $lib) { + $lib = trim($lib); + if ($lib === '') { + continue; + } + $static_lib = 'lib' . $lib . '.a'; + if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { + if (!str_contains($staticLibString, '-l' . $lib . ' ')) { + $staticLibString .= '-l' . $lib . ' '; + } + } elseif (!str_contains($sharedLibString, '-l' . $lib . ' ')) { + $sharedLibString .= '-l' . $lib . ' '; + } + } + return [$staticLibString, $sharedLibString]; + } + /** * Build shared extension for Unix * @@ -355,25 +386,12 @@ class Extension public function buildUnixShared(): void { $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); - $sharedLibs = ''; - $staticLibs = ''; - foreach (explode('-l', $config['libs']) as $lib) { - $lib = trim($lib); - if ($lib === '') { - continue; - } - $static_lib = 'lib' . $lib . '.a'; - if (file_exists(BUILD_LIB_PATH . '/' . $static_lib) && !str_contains($staticLibs, '-llib')) { - $staticLibs .= ' -l' . $lib; - } elseif (!str_contains($sharedLibs, '-l' . $lib)) { - $sharedLibs .= ' -l' . $lib; - } - } + [$staticLibString, $sharedLibString] = $this->getStaticAndSharedLibs(); $env = [ 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], - 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibs . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibs, + 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibString . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; // prepare configure args From 53eb6dcc80bca55032f5207de917f4c0cd6a4cdf Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 8 Jun 2025 14:49:06 +0700 Subject: [PATCH 153/319] cs fix hook isn't working on windows --- src/SPC/builder/Extension.php | 62 +++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 2dad0a80..d0df37b5 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -343,37 +343,6 @@ class Extension }; } - /** - * Get required static and shared libraries as a pair of strings in format -l{libname} -l{libname2} - * - * @return array [staticLibString, sharedLibString] - */ - private function getStaticAndSharedLibs(): array - { - $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); - $sharedLibString = ''; - $staticLibString = ''; - $staticLibs = $this->getLibFilesString(); - $staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs); - $staticLibs = str_replace('.a', '', $staticLibs); - $staticLibs = explode('-l', $staticLibs . ' ' . $config['libs']); - foreach ($staticLibs as $lib) { - $lib = trim($lib); - if ($lib === '') { - continue; - } - $static_lib = 'lib' . $lib . '.a'; - if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { - if (!str_contains($staticLibString, '-l' . $lib . ' ')) { - $staticLibString .= '-l' . $lib . ' '; - } - } elseif (!str_contains($sharedLibString, '-l' . $lib . ' ')) { - $sharedLibString .= '-l' . $lib . ' '; - } - } - return [$staticLibString, $sharedLibString]; - } - /** * Build shared extension for Unix * @@ -479,6 +448,37 @@ class Extension } } + /** + * Get required static and shared libraries as a pair of strings in format -l{libname} -l{libname2} + * + * @return array [staticLibString, sharedLibString] + */ + private function getStaticAndSharedLibs(): array + { + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); + $sharedLibString = ''; + $staticLibString = ''; + $staticLibs = $this->getLibFilesString(); + $staticLibs = str_replace(BUILD_LIB_PATH . '/lib', '-l', $staticLibs); + $staticLibs = str_replace('.a', '', $staticLibs); + $staticLibs = explode('-l', $staticLibs . ' ' . $config['libs']); + foreach ($staticLibs as $lib) { + $lib = trim($lib); + if ($lib === '') { + continue; + } + $static_lib = 'lib' . $lib . '.a'; + if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { + if (!str_contains($staticLibString, '-l' . $lib . ' ')) { + $staticLibString .= '-l' . $lib . ' '; + } + } elseif (!str_contains($sharedLibString, '-l' . $lib . ' ')) { + $sharedLibString .= '-l' . $lib . ' '; + } + } + return [$staticLibString, $sharedLibString]; + } + private function getLibraryDependencies(bool $recursive = false): array { $ret = array_filter($this->dependencies, fn ($x) => $x instanceof LibraryBase); From 187d51e5010cd9742d51371f1994e4c3a80f3d89 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 9 Jun 2025 14:41:14 +0700 Subject: [PATCH 154/319] -DPOSITION_INDEPENDENT_CODE=ON for cmake --- src/SPC/util/executor/UnixCMakeExecutor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/util/executor/UnixCMakeExecutor.php b/src/SPC/util/executor/UnixCMakeExecutor.php index 4b8ec2e2..55a74578 100644 --- a/src/SPC/util/executor/UnixCMakeExecutor.php +++ b/src/SPC/util/executor/UnixCMakeExecutor.php @@ -137,6 +137,7 @@ class UnixCMakeExecutor extends Executor '-DCMAKE_INSTALL_BINDIR=bin', '-DCMAKE_INSTALL_LIBDIR=lib', '-DCMAKE_INSTALL_INCLUDEDIR=include', + '-DPOSITION_INDEPENDENT_CODE=ON', '-DBUILD_SHARED_LIBS=OFF', "-DCMAKE_TOOLCHAIN_FILE={$this->makeCmakeToolchainFile()}", ]); From 20f222d19e8eecc86e446cb5b38a101dc7808c50 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 9 Jun 2025 14:48:05 +0700 Subject: [PATCH 155/319] post merge fixes --- src/SPC/builder/freebsd/library/openssl.php | 9 ++------- src/SPC/builder/linux/library/icu.php | 15 +++++---------- src/SPC/builder/linux/library/libpng.php | 6 +++--- src/SPC/builder/unix/library/libsodium.php | 15 +++++---------- src/SPC/builder/unix/library/postgresql.php | 15 +++++++-------- src/SPC/builder/unix/library/unixodbc.php | 15 +++++---------- src/SPC/builder/unix/library/xz.php | 15 +++++---------- src/SPC/util/WindowsCmd.php | 20 -------------------- 8 files changed, 32 insertions(+), 78 deletions(-) diff --git a/src/SPC/builder/freebsd/library/openssl.php b/src/SPC/builder/freebsd/library/openssl.php index 3c62ba2e..1bbabf52 100644 --- a/src/SPC/builder/freebsd/library/openssl.php +++ b/src/SPC/builder/freebsd/library/openssl.php @@ -48,13 +48,8 @@ class openssl extends BSDLibraryBase $ex_lib = trim($zlib->getStaticLibFiles() . ' ' . $ex_lib); } - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs() . " {$ex_lib}", - ]) - ->execWithEnv( + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec( "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ "--libdir={$lib} " . diff --git a/src/SPC/builder/linux/library/icu.php b/src/SPC/builder/linux/library/icu.php index 87a92234..aa2825b7 100644 --- a/src/SPC/builder/linux/library/icu.php +++ b/src/SPC/builder/linux/library/icu.php @@ -17,13 +17,8 @@ class icu extends LinuxLibraryBase $cppflags = 'CPPFLAGS="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=1 -DU_STATIC_IMPLEMENTATION=1 -DPIC -fPIC"'; $cxxflags = 'CXXFLAGS="-std=c++17 -DPIC -fPIC -fno-ident"'; $ldflags = getenv('SPC_LIBC') !== 'glibc' ? 'LDFLAGS="-static"' : ''; - shell()->cd($this->source_dir . '/source') - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv( + shell()->cd($this->source_dir . '/source')->initializeEnv($this) + ->exec( "{$cppflags} {$cxxflags} {$ldflags} " . './runConfigureICU Linux ' . '--enable-static ' . @@ -38,9 +33,9 @@ class icu extends LinuxLibraryBase '--enable-samples=no ' . '--prefix=' . BUILD_ROOT_PATH ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install'); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); $this->patchPkgconfPrefix(['icu-i18n.pc', 'icu-io.pc', 'icu-uc.pc'], PKGCONF_PATCH_PREFIX); FileSystem::removeDir(BUILD_LIB_PATH . '/icu'); diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index 4e911c54..da660aff 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -55,9 +55,9 @@ class libpng extends LinuxLibraryBase $optimizations . '--prefix=' ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") - ->execWithEnv('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") + ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); $this->cleanLaFiles(); } diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index c6bc6168..894310bd 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -8,16 +8,11 @@ trait libsodium { protected function build(): void { - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv('./configure --with-pic --enable-static --disable-shared --prefix=') - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec('./configure --with-pic --enable-static --disable-shared --prefix=') + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX); } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 69907556..21dce791 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -86,9 +86,8 @@ trait postgresql 'LIBS' => $this->getLibExtraLibs(), ]; // configure - shell()->cd($this->source_dir . '/build') - ->setEnv($env) - ->execWithEnv( + shell()->cd($this->source_dir . '/build')->initializeEnv($this) + ->exec( "{$envs} ../configure " . "--prefix={$builddir} " . ($this->builder->getOption('enable-zts') ? '--enable-thread-safety ' : '--disable-thread-safety ') . @@ -108,11 +107,11 @@ trait postgresql '--without-bonjour ' . '--without-tcl ' ) - ->execWithEnv($envs . ' make -C src/bin/pg_config install') - ->execWithEnv($envs . ' make -C src/include install') - ->execWithEnv($envs . ' make -C src/common install') - ->execWithEnv($envs . ' make -C src/port install') - ->execWithEnv($envs . ' make -C src/interfaces/libpq install'); + ->exec($envs . ' make -C src/bin/pg_config install') + ->exec($envs . ' make -C src/include install') + ->exec($envs . ' make -C src/common install') + ->exec($envs . ' make -C src/port install') + ->exec($envs . ' make -C src/interfaces/libpq install'); // remove dynamic libs shell()->cd($this->source_dir . '/build') diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index be7e9297..0e40629d 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -15,13 +15,8 @@ trait unixodbc */ protected function build(): void { - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv( + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec( './configure ' . '--enable-static --disable-shared ' . '--disable-debug ' . @@ -32,9 +27,9 @@ trait unixodbc '--enable-gui=no ' . '--prefix=' ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); $this->cleanLaFiles(); } diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index f3b4d934..3aed6a15 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -15,13 +15,8 @@ trait xz */ public function build(): void { - shell()->cd($this->source_dir) - ->setEnv([ - 'CFLAGS' => $this->getLibExtraCFlags(), - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]) - ->execWithEnv( + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec( './configure ' . '--enable-static ' . '--disable-shared ' . @@ -31,9 +26,9 @@ trait xz '--with-libiconv ' . '--prefix=' ) - ->execWithEnv('make clean') - ->execWithEnv("make -j{$this->builder->concurrency}") - ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['liblzma.pc']); $this->patchLaDependencyPrefix(['liblzma.la']); } diff --git a/src/SPC/util/WindowsCmd.php b/src/SPC/util/WindowsCmd.php index ca06dc25..4398dc44 100644 --- a/src/SPC/util/WindowsCmd.php +++ b/src/SPC/util/WindowsCmd.php @@ -75,24 +75,4 @@ class WindowsCmd $this->env = array_merge($this->env, $env); return $this; } - - /** - * @throws RuntimeException - */ - public function execWithEnv(string $cmd): WindowsCmd - { - if ($this->getEnvString() !== '') { - return $this->exec($this->getEnvString() . "call {$cmd}"); - } - return $this->exec($cmd); - } - - private function getEnvString(): string - { - $str = ''; - foreach ($this->env as $k => $v) { - $str .= 'set ' . $k . '=' . $v . ' && '; - } - return $str; - } } From c9e9119bff0735a6d4f88d19af6f7a7c91f51e31 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 9 Jun 2025 14:48:42 +0700 Subject: [PATCH 156/319] remove gd from static extension test --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index b382ec38..cba13c5e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -45,7 +45,7 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', + 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', 'Windows' => 'xlswriter,openssl', }; From 978975d396d374abe752572234450eaf3ff61661 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 9 Jun 2025 14:54:58 +0700 Subject: [PATCH 157/319] import class --- src/SPC/builder/unix/library/curl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index c903170d..bd15d27e 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait curl From aedcc86fc5a99d6b0123a541535a7980c8aa4fc9 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 9 Jun 2025 15:52:17 +0700 Subject: [PATCH 158/319] fix cmake minimum version for libtidy --- src/SPC/builder/unix/library/libxml2.php | 17 ++++++++++++++--- src/SPC/builder/unix/library/tidy.php | 9 ++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/unix/library/libxml2.php b/src/SPC/builder/unix/library/libxml2.php index 72a418ef..85a6e8b6 100644 --- a/src/SPC/builder/unix/library/libxml2.php +++ b/src/SPC/builder/unix/library/libxml2.php @@ -17,7 +17,13 @@ trait libxml2 public function build(): void { $cmake = UnixCMakeExecutor::create($this) - ->optionalLib('zlib', "-DLIBXML2_WITH_ZLIB=ON -DZLIB_LIBRARY={$this->getLibDir()}/libz.a -DZLIB_INCLUDE_DIR={$this->getIncludeDir()}", '-DLIBXML2_WITH_ZLIB=OFF') + ->optionalLib( + 'zlib', + '-DLIBXML2_WITH_ZLIB=ON ' . + "-DZLIB_LIBRARY={$this->getLibDir()}/libz.a " . + "-DZLIB_INCLUDE_DIR={$this->getIncludeDir()}", + '-DLIBXML2_WITH_ZLIB=OFF', + ) ->optionalLib('icu', ...cmake_boolean_args('LIBXML2_WITH_ICU')) ->optionalLib('xz', ...cmake_boolean_args('LIBXML2_WITH_LZMA')) ->addConfigureArgs( @@ -35,8 +41,13 @@ trait libxml2 FileSystem::replaceFileStr( BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc', - '-licudata -licui18n -licuuc', - '-licui18n -licuuc -licudata' + '-lxml2 -liconv', + '-lxml2' + ); + FileSystem::replaceFileStr( + BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc', + '-lxml2', + '-lxml2 -liconv' ); } } diff --git a/src/SPC/builder/unix/library/tidy.php b/src/SPC/builder/unix/library/tidy.php index d842dc6d..33405a47 100644 --- a/src/SPC/builder/unix/library/tidy.php +++ b/src/SPC/builder/unix/library/tidy.php @@ -16,13 +16,16 @@ trait tidy */ protected function build(): void { - UnixCMakeExecutor::create($this) + $cmake = UnixCMakeExecutor::create($this) ->setBuildDir("{$this->source_dir}/build-dir") ->addConfigureArgs( '-DSUPPORT_CONSOLE_APP=OFF', '-DBUILD_SHARED_LIB=OFF' - ) - ->build(); + ); + if (version_compare(get_cmake_version(), '4.0.0', '>=')) { + $cmake->addConfigureArgs('-DCMAKE_POLICY_VERSION_MINIMUM=3.5'); + } + $cmake->build(); $this->patchPkgconfPrefix(['tidy.pc']); } } From 684b5d45344a80c88a8d44974990e4292683e8b6 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 9 Jun 2025 16:16:54 +0700 Subject: [PATCH 159/319] remove alpine tests for now https://github.com/php/php-src/pull/18779 --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index cba13c5e..982b134f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -24,7 +24,7 @@ $test_os = [ 'macos-13', // 'macos-14', 'macos-15', - 'ubuntu-latest', + // 'ubuntu-latest', 'ubuntu-22.04', // 'ubuntu-24.04', 'ubuntu-22.04-arm', From 720251458f124820b00b057b4d18b5b531f0f991 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 19:32:31 +0800 Subject: [PATCH 160/319] Add autoconf executor --- src/SPC/builder/LibraryBase.php | 5 + src/SPC/builder/linux/library/libffi.php | 23 +--- src/SPC/builder/linux/library/libpng.php | 32 ++--- src/SPC/builder/macos/library/libffi.php | 18 +-- .../builder/macos/library/libmemcached.php | 17 +-- src/SPC/builder/macos/library/libpng.php | 35 +++-- src/SPC/builder/unix/library/attr.php | 10 +- src/SPC/builder/unix/library/gettext.php | 46 ++++--- src/SPC/builder/unix/library/gmp.php | 7 +- src/SPC/builder/unix/library/imagemagick.php | 70 +++++----- src/SPC/builder/unix/library/ldap.php | 38 ++---- src/SPC/builder/unix/library/libacl.php | 10 +- src/SPC/builder/unix/library/libcares.php | 7 +- src/SPC/builder/unix/library/libiconv.php | 19 +-- src/SPC/builder/unix/library/librdkafka.php | 37 +++--- src/SPC/builder/unix/library/libsodium.php | 9 +- src/SPC/builder/unix/library/libtiff.php | 37 +++--- src/SPC/builder/unix/library/libxslt.php | 39 ++---- src/SPC/builder/unix/library/ncurses.php | 44 +++---- src/SPC/builder/unix/library/nghttp2.php | 61 ++++----- src/SPC/builder/unix/library/nghttp3.php | 14 +- src/SPC/builder/unix/library/ngtcp2.php | 43 +++--- src/SPC/builder/unix/library/onig.php | 9 +- src/SPC/builder/unix/library/pkgconfig.php | 35 +++-- src/SPC/builder/unix/library/postgresql.php | 6 +- src/SPC/builder/unix/library/qdbm.php | 13 +- src/SPC/builder/unix/library/readline.php | 17 +-- src/SPC/builder/unix/library/sqlite.php | 8 +- src/SPC/builder/unix/library/unixodbc.php | 23 ++-- src/SPC/builder/unix/library/xz.php | 21 ++- src/SPC/builder/unix/library/zlib.php | 7 +- src/SPC/util/UnixShell.php | 2 +- .../util/executor/UnixAutoconfExecutor.php | 124 ++++++++++++++++++ src/globals/functions.php | 5 + 34 files changed, 437 insertions(+), 454 deletions(-) create mode 100644 src/SPC/util/executor/UnixAutoconfExecutor.php diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 0d8ab739..a8b311f6 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -328,6 +328,11 @@ abstract class LibraryBase return false; } + public function getBinDir(): string + { + return BUILD_BIN_PATH; + } + public function getIncludeDir(): string { return BUILD_INCLUDE_PATH; diff --git a/src/SPC/builder/linux/library/libffi.php b/src/SPC/builder/linux/library/libffi.php index fa221bd1..ecb3e142 100644 --- a/src/SPC/builder/linux/library/libffi.php +++ b/src/SPC/builder/linux/library/libffi.php @@ -6,6 +6,7 @@ namespace SPC\builder\linux\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; class libffi extends LinuxLibraryBase { @@ -17,24 +18,14 @@ class libffi extends LinuxLibraryBase */ public function build(): void { - [$lib, , $destdir] = SEPARATED_PATH; $arch = getenv('SPC_ARCH'); - - shell()->cd($this->source_dir) - ->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--with-pic ' . - "--host={$arch}-unknown-linux " . - "--target={$arch}-unknown-linux " . - '--prefix= ' . - "--libdir={$lib}" + UnixAutoconfExecutor::create($this) + ->configure( + "--host={$arch}-unknown-linux", + "--target={$arch}-unknown-linux", + "--libdir={$this->getLibDir()}" ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); + ->make(); if (is_file(BUILD_ROOT_PATH . '/lib64/libffi.a')) { copy(BUILD_ROOT_PATH . '/lib64/libffi.a', BUILD_ROOT_PATH . '/lib/libffi.a'); diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index da660aff..ec63f9ad 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -24,6 +24,7 @@ namespace SPC\builder\linux\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\util\executor\UnixAutoconfExecutor; class libpng extends LinuxLibraryBase { @@ -36,28 +37,21 @@ class libpng extends LinuxLibraryBase */ public function build(): void { - $optimizations = match (getenv('SPC_ARCH')) { - 'x86_64' => '--enable-intel-sse ', - 'aarch64' => '--enable-arm-neon ', - default => '', - }; - shell()->cd($this->source_dir)->initializeEnv($this) + UnixAutoconfExecutor::create($this) ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') - ->exec( - 'LDFLAGS="-L' . BUILD_LIB_PATH . '" ' . - './configure ' . - '--disable-shared ' . - '--enable-static ' . - '--with-pic ' . - '--enable-hardware-optimizations ' . - '--with-zlib-prefix="' . BUILD_ROOT_PATH . '" ' . - $optimizations . - '--prefix=' + ->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"]) + ->configure( + '--enable-hardware-optimizations', + "--with-zlib-prefix={$this->getBuildRootPath()}", + match (getenv('SPC_ARCH')) { + 'x86_64' => '--enable-intel-sse', + 'aarch64' => '--enable-arm-neon', + default => '', + } ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") - ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); + ->make('libpng16.la', 'install-libLTLIBRARIES install-data-am', after_env_vars: ['DEFAULT_INCLUDES' => "-I{$this->source_dir} -I{$this->getIncludeDir()}"]); + $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); $this->cleanLaFiles(); } diff --git a/src/SPC/builder/macos/library/libffi.php b/src/SPC/builder/macos/library/libffi.php index fb054b81..992a1b75 100644 --- a/src/SPC/builder/macos/library/libffi.php +++ b/src/SPC/builder/macos/library/libffi.php @@ -6,6 +6,7 @@ namespace SPC\builder\macos\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; class libffi extends MacOSLibraryBase { @@ -17,20 +18,13 @@ class libffi extends MacOSLibraryBase */ protected function build(): void { - [, , $destdir] = SEPARATED_PATH; $arch = getenv('SPC_ARCH'); - shell()->cd($this->source_dir) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - "--host={$arch}-apple-darwin " . - "--target={$arch}-apple-darwin " . - '--prefix= ' // use prefix=/ + UnixAutoconfExecutor::create($this) + ->configure( + "--host={$arch}-apple-darwin", + "--target={$arch}-apple-darwin", ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); + ->make(); $this->patchPkgconfPrefix(['libffi.pc']); } } diff --git a/src/SPC/builder/macos/library/libmemcached.php b/src/SPC/builder/macos/library/libmemcached.php index 09a600a2..4b4c5485 100644 --- a/src/SPC/builder/macos/library/libmemcached.php +++ b/src/SPC/builder/macos/library/libmemcached.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace SPC\builder\macos\library; +use SPC\util\executor\UnixAutoconfExecutor; + /** * gmp is a template library class for unix */ @@ -13,19 +15,6 @@ class libmemcached extends MacOSLibraryBase public function build(): void { - $rootdir = BUILD_ROOT_PATH; - - shell()->cd($this->source_dir) - ->exec('chmod +x configure') - ->exec( - './configure ' . - '--enable-static --disable-shared ' . - '--disable-sasl ' . - "--prefix={$rootdir}" - ) - ->exec('make clean') - ->exec('sed -ie "s/-Werror//g" ' . $this->source_dir . '/Makefile') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + UnixAutoconfExecutor::create($this)->configure('--disable-sasl')->exec("sed -ie 's/-Werror//g' ./Makefile")->make(); } } diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index f273bff6..5efc1318 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -24,6 +24,7 @@ namespace SPC\builder\macos\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\util\executor\UnixAutoconfExecutor; class libpng extends MacOSLibraryBase { @@ -36,28 +37,24 @@ class libpng extends MacOSLibraryBase */ protected function build(): void { - $optimizations = match (php_uname('m')) { - 'x86_64' => '--enable-intel-sse ', - 'arm64' => '--enable-arm-neon ', - default => '', - }; - shell()->cd($this->source_dir) + $arch = arch2gnu(php_uname('m')); + UnixAutoconfExecutor::create($this) ->exec('chmod +x ./configure') ->exec('chmod +x ./install-sh') - ->exec( - './configure ' . - '--host=' . arch2gnu(php_uname('m')) . '-apple-darwin ' . - '--disable-shared ' . - '--enable-static ' . - '--enable-hardware-optimizations ' . - $optimizations . - '--prefix=' + ->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"]) + ->configure( + "--host={$arch}-apple-darwin", + '--enable-hardware-optimizations', + "--with-zlib-prefix={$this->getBuildRootPath()}", + match (getenv('SPC_ARCH')) { + 'x86_64' => '--enable-intel-sse', + 'aarch64' => '--enable-arm-neon', + default => '', + } ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I. -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") - ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH) - ->cd(BUILD_LIB_PATH) - ->exec('ln -sf libpng16.a libpng.a'); + ->make('libpng16.la', 'install-libLTLIBRARIES install-data-am', after_env_vars: ['DEFAULT_INCLUDES' => "-I{$this->source_dir} -I{$this->getIncludeDir()}"]); + + shell()->cd(BUILD_LIB_PATH)->exec('ln -sf libpng16.a libpng.a'); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); $this->patchLaDependencyPrefix(['libpng16.la']); $this->cleanLaFiles(); diff --git a/src/SPC/builder/unix/library/attr.php b/src/SPC/builder/unix/library/attr.php index b6254720..439acf38 100644 --- a/src/SPC/builder/unix/library/attr.php +++ b/src/SPC/builder/unix/library/attr.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait attr { @@ -13,14 +14,11 @@ trait attr */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->appendEnv(['CFLAGS' => "-I{$this->getIncludeDir()}", 'LDFLAGS' => "-L{$this->getLibDir()}"]) + UnixAutoconfExecutor::create($this) ->exec('libtoolize --force --copy') ->exec('./autogen.sh || autoreconf -if') - ->exec('./configure --prefix= --enable-static --disable-shared --with-pic --disable-nls') - ->exec("make -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - + ->configure('--disable-nls') + ->make(); $this->patchPkgconfPrefix(['libattr.pc'], PKGCONF_PATCH_PREFIX); } } diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 15a6b6c7..cfe01798 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -4,36 +4,34 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\util\executor\UnixAutoconfExecutor; + trait gettext { protected function build(): void { - $extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : ''; - $extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : ''; + $autoconf = UnixAutoconfExecutor::create($this) + ->optionalLib('ncurses', "--with-libncurses-prefix={$this->getBuildRootPath()}") + ->optionalLib('libxml2', "--with-libxml2-prefix={$this->getBuildRootPath()}") + ->addConfigureArgs( + '--disable-java', + '--disable-c++', + '--with-included-gettext', + "--with-iconv-prefix={$this->getBuildRootPath()}", + ); - $zts = $this->builder->getOption('enable-zts') ? '--enable-threads=isoc+posix ' : '--disable-threads '; + // zts + if ($this->builder->getOption('enable-zts')) { + $autoconf->addConfigureArgs('--enable-threads=isoc+posix') + ->appendEnv([ + 'CFLAGS' => '-lpthread -D_REENTRANT', + 'LDFLGAS' => '-lpthread', + ]); + } else { + $autoconf->addConfigureArgs('--disable-threads'); + } - $cflags = $this->builder->getOption('enable-zts') ? '-lpthread -D_REENTRANT' : ''; - $ldflags = $this->builder->getOption('enable-zts') ? '-lpthread' : ''; - - shell()->cd($this->source_dir)->initializeEnv($this) - ->appendEnv(['CFLAGS' => $cflags, 'LDFLAGS' => $ldflags]) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--enable-pic ' . - '--disable-java ' . - '--disable-c++ ' . - $zts . - $extra . - '--with-included-gettext ' . - '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . - '--prefix=' . BUILD_ROOT_PATH - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + $autoconf->configure()->make(with_clean: true); $this->patchLaDependencyPrefix(['libintl.la']); } } diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index 57c58018..a8e4d15c 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait gmp { @@ -15,11 +16,7 @@ trait gmp */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec('./configure --enable-static --disable-shared --with-pic --prefix=') - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + UnixAutoconfExecutor::create($this)->configure()->make(); $this->patchPkgconfPrefix(['gmp.pc']); } } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 1284305c..e3805ab5 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -9,6 +9,7 @@ use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; +use SPC\util\executor\UnixAutoconfExecutor; trait imagemagick { @@ -18,48 +19,39 @@ trait imagemagick */ protected function build(): void { - $openmp = '--enable-openmp'; - // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so - if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) { - $openmp = '--disable-openmp'; - } - $extra = "--without-jxl --without-x {$openmp} "; - $required_libs = ''; - $optional_libs = [ - 'libzip' => 'zip', - 'libjpeg' => 'jpeg', - 'libpng' => 'png', - 'libwebp' => 'webp', - 'libxml2' => 'xml', - 'libheif' => 'heic', - 'zlib' => 'zlib', - 'xz' => 'lzma', - 'zstd' => 'zstd', - 'freetype' => 'freetype', - 'bzip2' => 'bzlib', - ]; - foreach ($optional_libs as $lib => $option) { - $extra .= $this->builder->getLib($lib) ? "--with-{$option} " : "--without-{$option} "; - if ($this->builder->getLib($lib) instanceof LinuxLibraryBase) { - $required_libs .= ' ' . $this->builder->getLib($lib)->getStaticLibFiles(); - } - } + $ac = UnixAutoconfExecutor::create($this) + ->optionalLib('libzip', ...ac_with_args('zip')) + ->optionalLib('libjpeg', ...ac_with_args('jpeg')) + ->optionalLib('libpng', ...ac_with_args('png')) + ->optionalLib('libwebp', ...ac_with_args('webp')) + ->optionalLib('libxml2', ...ac_with_args('xml')) + ->optionalLib('libheif', ...ac_with_args('heic')) + ->optionalLib('zlib', ...ac_with_args('zlib')) + ->optionalLib('xz', ...ac_with_args('lzma')) + ->optionalLib('zstd', ...ac_with_args('zstd')) + ->optionalLib('freetype', ...ac_with_args('freetype')) + ->optionalLib('bzip2', ...ac_with_args('bzlib')) + ->addConfigureArgs( + // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so + getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10') ? '--enable-openmp' : '--disable-openmp', + '--without-jxl', + '--without-x', + ); + // special: linux musl needs `-static` $ldflags = ($this instanceof LinuxLibraryBase) && getenv('SPC_LIBC') !== 'glibc' ? ('-static -ldl') : '-ldl'; - // libxml iconv patch - $required_libs .= $this instanceof MacOSLibraryBase ? ('-liconv') : ''; - shell()->cd($this->source_dir)->initializeEnv($this) - ->appendEnv(['LDFLAGS' => $ldflags, 'LIBS' => $required_libs, 'PKG_CONFIG' => '$PKG_CONFIG --static']) - ->exec( - './configure ' . - '--enable-static --disable-shared --with-pic ' . - $extra . - '--prefix=' - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + // special: macOS needs -iconv + $libs = $this instanceof MacOSLibraryBase ? '-liconv' : ''; + + $ac->appendEnv([ + 'LDFLAGS' => $ldflags, + 'LIBS' => $libs, + 'PKG_CONFIG' => '$PKG_CONFIG --static', + ]); + + $ac->configure()->make(); + $filelist = [ 'ImageMagick.pc', 'ImageMagick-7.Q16HDRI.pc', diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 501654de..276f8e99 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\store\FileSystem; +use SPC\util\executor\UnixAutoconfExecutor; trait ldap { @@ -17,34 +18,19 @@ trait ldap protected function build(): void { - $alt = ''; - // openssl support - $alt .= $this->builder->getLib('openssl') ? '--with-tls=openssl ' : ''; - // gmp support - $alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : ''; - // libsodium support - $alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : '--enable-argon2=no '; - f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); - f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); - shell()->cd($this->source_dir)->initializeEnv($this) - ->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"]) - ->exec( - $this->builder->makeAutoconfFlags(AUTOCONF_CPPFLAGS) . - ' ./configure ' . - '--enable-static ' . - '--disable-shared ' . - '--with-pic ' . - '--disable-slapd ' . - '--without-systemd ' . - '--without-cyrus-sasl ' . - $alt . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->optionalLib('openssl', '--with-tls=openssl') + ->optionalLib('gmp', '--with-mp=gmp') + ->optionalLib('libsodium', '--with-argon2=libsodium', '--enable-argon2=no') + ->addConfigureArgs( + '--disable-slapd', + '--without-systemd', + '--without-cyrus-sasl', ) - ->exec('make clean') - // remove tests and doc to prevent compile failed with error: soelim not found + ->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"]) + ->configure() ->exec('sed -i -e "s/SUBDIRS= include libraries clients servers tests doc/SUBDIRS= include libraries clients servers/g" Makefile') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->make(); FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/ldap.pc', 'Libs: -L${libdir} -lldap', 'Libs: -L${libdir} -lldap -llber'); $this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']); diff --git a/src/SPC/builder/unix/library/libacl.php b/src/SPC/builder/unix/library/libacl.php index 7a371f9e..c25e7336 100644 --- a/src/SPC/builder/unix/library/libacl.php +++ b/src/SPC/builder/unix/library/libacl.php @@ -7,6 +7,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; +use SPC\util\executor\UnixAutoconfExecutor; trait libacl { @@ -29,14 +30,11 @@ trait libacl */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->appendEnv(['CFLAGS' => "-I{$this->getIncludeDir()}", 'LDFLAGS' => "-L{$this->getLibDir()}"]) + UnixAutoconfExecutor::create($this) ->exec('libtoolize --force --copy') ->exec('./autogen.sh || autoreconf -if') - ->exec('./configure --prefix= --enable-static --disable-shared --disable-tests --disable-nls --with-pic') - ->exec("make -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - + ->configure('--disable-nls', '--disable-tests') + ->make(); $this->patchPkgconfPrefix(['libacl.pc'], PKGCONF_PATCH_PREFIX); } } diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php index 61683bbf..59d9852e 100644 --- a/src/SPC/builder/unix/library/libcares.php +++ b/src/SPC/builder/unix/library/libcares.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\RuntimeException; use SPC\store\FileSystem; +use SPC\util\executor\UnixAutoconfExecutor; trait libcares { @@ -24,11 +25,7 @@ trait libcares */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec('./configure --prefix= --enable-static --disable-shared --disable-tests --with-pic') - ->exec("make -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - + UnixAutoconfExecutor::create($this)->configure('--disable-tests')->make(); $this->patchPkgconfPrefix(['libcares.pc'], PKGCONF_PATCH_PREFIX); } } diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index 36ef136e..49ac47bc 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -4,23 +4,18 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\util\executor\UnixAutoconfExecutor; + trait libiconv { protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--enable-pic ' . - '--enable-extra-encodings ' . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->configure( + '--enable-pic', + '--enable-extra-encodings', ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - + ->make(); $this->patchLaDependencyPrefix(['libiconv.la']); } } diff --git a/src/SPC/builder/unix/library/librdkafka.php b/src/SPC/builder/unix/library/librdkafka.php index 5ee4c0c8..69fe04d4 100644 --- a/src/SPC/builder/unix/library/librdkafka.php +++ b/src/SPC/builder/unix/library/librdkafka.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait librdkafka { @@ -15,25 +16,29 @@ trait librdkafka */ protected function build(): void { - $builddir = BUILD_ROOT_PATH; - - $zstd_option = $this->builder->getLib('zstd') ? ("STATIC_LIB_libzstd={$builddir}/lib/libzstd.a ") : ''; - shell()->cd($this->source_dir) - ->exec( - $zstd_option . - './configure ' . - '--enable-static --disable-shared --disable-curl --disable-sasl --disable-valgrind --disable-zlib --disable-ssl ' . - ($zstd_option == '' ? '--disable-zstd ' : '') . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->optionalLib( + 'zstd', + function ($lib) { + putenv("STATIC_LIB_libzstd={$lib->getLibDir()}/libzstd.a"); + return ''; + }, + '--disable-zstd' ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$builddir}"); + ->configure( + '--disable-curl', + '--disable-sasl', + '--disable-valgrind', + '--disable-zlib', + '--disable-ssl', + ) + ->make(); + $this->patchPkgconfPrefix(['rdkafka.pc', 'rdkafka-static.pc', 'rdkafka++.pc', 'rdkafka++-static.pc']); // remove dynamic libs shell() - ->exec("rm -rf {$builddir}/lib/*.so.*") - ->exec("rm -rf {$builddir}/lib/*.so") - ->exec("rm -rf {$builddir}/lib/*.dylib"); + ->exec("rm -rf {$this->getLibDir()}/*.so.*") + ->exec("rm -rf {$this->getLibDir()}/*.so") + ->exec("rm -rf {$this->getLibDir()}/*.dylib"); } } diff --git a/src/SPC/builder/unix/library/libsodium.php b/src/SPC/builder/unix/library/libsodium.php index 894310bd..441166c9 100644 --- a/src/SPC/builder/unix/library/libsodium.php +++ b/src/SPC/builder/unix/library/libsodium.php @@ -4,16 +4,13 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\util\executor\UnixAutoconfExecutor; + trait libsodium { protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec('./configure --with-pic --enable-static --disable-shared --prefix=') - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - + UnixAutoconfExecutor::create($this)->configure()->make(); $this->patchPkgconfPrefix(['libsodium.pc'], PKGCONF_PATCH_PREFIX); } } diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index 8f59fcae..f615019a 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait libtiff { @@ -15,24 +16,26 @@ trait libtiff */ protected function build(): void { - // zlib - $extra_libs = '--enable-zlib --with-zlib-include-dir=' . BUILD_ROOT_PATH . '/include --with-zlib-lib-dir=' . BUILD_ROOT_PATH . '/lib'; - // libjpeg - $extra_libs .= ' --enable-jpeg --disable-old-jpeg --disable-jpeg12 --with-jpeg-include-dir=' . BUILD_ROOT_PATH . '/include --with-jpeg-lib-dir=' . BUILD_ROOT_PATH . '/lib'; - // We disabled lzma, zstd, webp, libdeflate by default to reduce the size of the binary - $extra_libs .= ' --disable-lzma --disable-zstd --disable-webp --disable-libdeflate'; - - $shell = shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static --disable-shared --with-pic ' . - "{$extra_libs} " . - '--disable-cxx ' . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->configure( + // zlib deps + '--enable-zlib', + "--with-zlib-include-dir={$this->getIncludeDir()}", + "--with-zlib-lib-dir={$this->getLibDir()}", + // libjpeg deps + '--enable-jpeg', + '--disable-old-jpeg', + '--disable-jpeg12', + "--with-jpeg-include-dir={$this->getIncludeDir()}", + "--with-jpeg-lib-dir={$this->getLibDir()}", + // We disabled lzma, zstd, webp, libdeflate by default to reduce the size of the binary + '--disable-lzma', + '--disable-zstd', + '--disable-webp', + '--disable-libdeflate', + '--disable-cxx', ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->make(); $this->patchPkgconfPrefix(['libtiff-4.pc']); } } diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 10975145..af85b052 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -8,6 +8,7 @@ use SPC\builder\linux\library\LinuxLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\util\executor\UnixAutoconfExecutor; trait libxslt { @@ -18,35 +19,23 @@ trait libxslt */ protected function build(): void { - $required_libs = ''; - foreach ($this->getDependencies() as $dep) { - if ($dep instanceof LinuxLibraryBase) { - $required_libs .= ' ' . $dep->getStaticLibFiles(); - } - } - shell()->cd($this->source_dir)->initializeEnv($this) + $static_libs = $this instanceof LinuxLibraryBase ? $this->getStaticLibFiles() : ''; + $ac = UnixAutoconfExecutor::create($this) ->appendEnv([ 'CFLAGS' => "-I{$this->getIncludeDir()}", 'LDFLAGS' => "-L{$this->getLibDir()}", - 'LIBS' => "{$required_libs} -lstdc++", + 'LIBS' => "{$static_libs} -lstdc++", ]) - ->exec( - "{$this->builder->getOption('library_path')} " . - "{$this->builder->getOption('ld_library_path')} " . - './configure ' . - '--enable-static --disable-shared ' . - '--with-pic ' . - '--without-python ' . - '--without-mem-debug ' . - '--without-crypto ' . - '--without-debug ' . - '--without-debugger ' . - '--with-libxml-prefix=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' . - '--prefix=' - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH)); + ->addConfigureArgs( + '--without-python', + '--without-mem-debug', + '--without-crypto', + '--without-debug', + '--without-debugger', + "--with-libxml-prefix={$this->getBuildRootPath()}", + ); + $ac->exec("{$this->builder->getOption('library_path')} {$this->builder->getOption('ld_library_path')} ./configure {$ac->getConfigureArgsString()}")->make(); + $this->patchPkgconfPrefix(['libexslt.pc']); $this->patchLaDependencyPrefix(['libxslt.la', 'libexslt.la']); shell()->cd(BUILD_LIB_PATH) diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index 7d33c76a..720e0900 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -5,37 +5,33 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\store\FileSystem; +use SPC\util\executor\UnixAutoconfExecutor; trait ncurses { protected function build(): void { $filelist = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true); - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--enable-overwrite ' . - '--with-curses-h ' . - '--enable-pc-files ' . - '--enable-echo ' . - '--disable-widec ' . - '--with-normal ' . - '--with-ticlib ' . - '--without-tests ' . - '--without-dlsym ' . - '--without-debug ' . - '-enable-symlinks ' . - '--bindir=' . BUILD_ROOT_PATH . '/bin ' . - '--includedir=' . BUILD_ROOT_PATH . '/include ' . - '--libdir=' . BUILD_ROOT_PATH . '/lib ' . - '--prefix=' . BUILD_ROOT_PATH - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + UnixAutoconfExecutor::create($this) + ->configure( + '--enable-overwrite', + '--with-curses-h', + '--enable-c-files', + '--enable-echo', + '--disable-widec', + '--with-normal', + '--with-ticlib', + '--without-tests', + '--without-dlsym', + '--without-debug', + '-enable-symlinks', + "--bindir={$this->getBinDir()}", + "--includedir={$this->getIncludeDir()}", + "--libdir={$this->getLibDir()}", + "--prefix={$this->getBuildRootPath()}", + ) + ->make(); $final = FileSystem::scanDirFiles(BUILD_BIN_PATH, relative: true); // Remove the new files $new_files = array_diff($final, $filelist); diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index e09832d9..6390f1d5 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -7,6 +7,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\util\executor\UnixAutoconfExecutor; trait nghttp2 { @@ -17,42 +18,32 @@ trait nghttp2 */ protected function build(): void { - $args = $this->builder->makeAutoconfArgs(static::NAME, [ - 'zlib' => null, - 'openssl' => null, - 'libxml2' => null, - 'libev' => null, - 'libcares' => null, - 'libngtcp2' => null, - 'libnghttp3' => null, - 'libbpf' => null, - 'libevent-openssl' => null, - 'jansson' => null, - 'jemalloc' => null, - 'systemd' => null, - ]); - if ($brotli = $this->builder->getLib('brotli')) { - /* @phpstan-ignore-next-line */ - $args .= ' --with-libbrotlidec=yes LIBBROTLIDEC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIDEC_LIBS="' . $brotli->getStaticLibFiles() . '"'; - /* @phpstan-ignore-next-line */ - $args .= ' --with-libbrotlienc=yes LIBBROTLIENC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIENC_LIBS="' . $brotli->getStaticLibFiles() . '"'; - } - - [,,$destdir] = SEPARATED_PATH; - - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--with-pic ' . - '--enable-lib-only ' . - $args . ' ' . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->optionalLib('zlib', ...ac_with_args('zlib', true)) + ->optionalLib('openssl', ...ac_with_args('openssl', true)) + ->optionalLib('libxml2', ...ac_with_args('libxml2', true)) + ->optionalLib('libev', ...ac_with_args('libev', true)) + ->optionalLib('libcares', ...ac_with_args('libcares', true)) + ->optionalLib('ngtcp2', ...ac_with_args('libngtcp2', true)) + ->optionalLib('nghttp3', ...ac_with_args('libnghttp3', true)) + // ->optionalLib('libbpf', ...ac_with_args('libbpf', true)) + // ->optionalLib('libevent-openssl', ...ac_with_args('libevent-openssl', true)) + // ->optionalLib('jansson', ...ac_with_args('jansson', true)) + // ->optionalLib('jemalloc', ...ac_with_args('jemalloc', true)) + // ->optionalLib('systemd', ...ac_with_args('systemd', true)) + ->optionalLib( + 'brotli', + fn ($lib) => implode(' ', [ + '--with-brotlidec=yes', + "LIBBROTLIDEC_CFLAGS=\"-I{$lib->getIncludeDir()}\"", + "LIBBROTLIDEC_LIBS=\"{$lib->getStaticLibFiles()}\"", + '--with-libbrotlienc=yes', + "LIBBROTLIENC_CFLAGS=\"-I{$lib->getIncludeDir()}\"", + "LIBBROTLIENC_LIBS=\"{$lib->getStaticLibFiles()}\"", + ]) ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); + ->configure('--enable-lib-only') + ->make(); $this->patchPkgconfPrefix(['libnghttp2.pc']); $this->patchLaDependencyPrefix(['libnghttp2.la']); } diff --git a/src/SPC/builder/unix/library/nghttp3.php b/src/SPC/builder/unix/library/nghttp3.php index ca2862a2..c3dadcf0 100644 --- a/src/SPC/builder/unix/library/nghttp3.php +++ b/src/SPC/builder/unix/library/nghttp3.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait nghttp3 { @@ -15,18 +16,7 @@ trait nghttp3 */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--with-pic ' . - '--enable-lib-only ' . - '--prefix=' - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + UnixAutoconfExecutor::create($this)->configure('--enable-lib-only')->make(); $this->patchPkgconfPrefix(['libnghttp3.pc']); $this->patchLaDependencyPrefix(['libnghttp3.la']); } diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 94e9c570..23c85e1e 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -7,6 +7,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\util\executor\UnixAutoconfExecutor; trait ngtcp2 { @@ -17,32 +18,24 @@ trait ngtcp2 */ protected function build(): void { - $args = $this->builder->makeAutoconfArgs(static::NAME, [ - 'openssl' => null, - 'libev' => null, - 'jemalloc' => null, - 'libnghttp3' => null, - ]); - if ($brotli = $this->builder->getLib('brotli')) { - /* @phpstan-ignore-next-line */ - $args .= ' --with-libbrotlidec=yes LIBBROTLIDEC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIDEC_LIBS="' . $brotli->getStaticLibFiles() . '"'; - /* @phpstan-ignore-next-line */ - $args .= ' --with-libbrotlienc=yes LIBBROTLIENC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIENC_LIBS="' . $brotli->getStaticLibFiles() . '"'; - } - - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--with-pic ' . - '--enable-lib-only ' . - $args . ' ' . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->optionalLib('openssl', ...ac_with_args('openssl', true)) + ->optionalLib('libev', ...ac_with_args('libev', true)) + ->optionalLib('nghttp3', ...ac_with_args('libnghttp3', true)) + ->optionalLib('jemalloc', ...ac_with_args('jemalloc', true)) + ->optionalLib( + 'brotli', + fn ($lib) => implode(' ', [ + '--with-brotlidec=yes', + "LIBBROTLIDEC_CFLAGS=\"-I{$lib->getIncludeDir()}\"", + "LIBBROTLIDEC_LIBS=\"{$lib->getStaticLibFiles()}\"", + '--with-libbrotlienc=yes', + "LIBBROTLIENC_CFLAGS=\"-I{$lib->getIncludeDir()}\"", + "LIBBROTLIENC_LIBS=\"{$lib->getStaticLibFiles()}\"", + ]) ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->configure('--enable-lib-only') + ->make(); $this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']); $this->patchLaDependencyPrefix(['libngtcp2.la', 'libngtcp2_crypto_ossl.la']); diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index 62e8f606..eb47c0b8 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait onig { @@ -15,13 +16,7 @@ trait onig */ protected function build(): void { - [,,$destdir] = SEPARATED_PATH; - - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec('./configure --enable-static --disable-shared --enable-pic --prefix=') - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); + UnixAutoconfExecutor::create($this)->configure('--enable-pic')->make(); $this->patchPkgconfPrefix(['oniguruma.pc']); } } diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 51fa586b..05727f96 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -5,32 +5,27 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; +use SPC\util\executor\UnixAutoconfExecutor; trait pkgconfig { protected function build(): void { - $cflags = PHP_OS_FAMILY !== 'Linux' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : ''; - $ldflags = !($this instanceof LinuxLibraryBase) || getenv('SPC_LIBC') === 'glibc' ? '' : '--static'; - - shell()->cd($this->source_dir)->initializeEnv($this) - ->appendEnv(['CFLAGS' => $cflags, 'LDFLAGS' => $ldflags]) - ->exec( - './configure ' . - '--disable-shared ' . - '--enable-static ' . - '--with-internal-glib ' . - '--disable-host-tool ' . - '--with-pic ' . - '--prefix=' . BUILD_ROOT_PATH . ' ' . - '--without-sysroot ' . - '--without-system-include-path ' . - '--without-system-library-path ' . - '--without-pc-path' + UnixAutoconfExecutor::create($this) + ->appendEnv([ + 'CFLAGS' => PHP_OS_FAMILY !== 'Linux' ? '-Wimplicit-function-declaration -Wno-int-conversion' : '', + 'LDFLAGS' => !($this instanceof LinuxLibraryBase) || getenv('SPC_LIBC') === 'glibc' ? '' : '--static', + ]) + ->configure( + '--with-internal-glib', + '--disable-host-tool', + '--without-sysroot', + '--without-system-include-path', + '--without-system-library-path', + '--without-pc-path', ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install-exec'); + ->make(with_install: 'install-exec'); + shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config'); } } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 21dce791..1de3e4c2 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -80,13 +80,9 @@ trait postgresql throw new RuntimeException('Unsupported version for postgresql: ' . $version . ' !'); } - $env = [ - 'CFLAGS' => $this->getLibExtraCFlags() . ' ' . $cflags, - 'LDFLAGS' => $this->getLibExtraLdFlags(), - 'LIBS' => $this->getLibExtraLibs(), - ]; // configure shell()->cd($this->source_dir . '/build')->initializeEnv($this) + ->appendEnv(['CFLAGS' => $cflags]) ->exec( "{$envs} ../configure " . "--prefix={$builddir} " . diff --git a/src/SPC/builder/unix/library/qdbm.php b/src/SPC/builder/unix/library/qdbm.php index 21eff478..b7a43cdf 100644 --- a/src/SPC/builder/unix/library/qdbm.php +++ b/src/SPC/builder/unix/library/qdbm.php @@ -8,6 +8,7 @@ use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; +use SPC\util\executor\UnixAutoconfExecutor; trait qdbm { @@ -17,17 +18,9 @@ trait qdbm */ protected function build(): void { - shell()->cd($this->source_dir) - ->exec( - './configure ' . - '--enable-static --disable-shared ' . - '--prefix=' - ) - ->exec('make clean'); + $ac = UnixAutoconfExecutor::create($this)->configure(); FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/MYLIBS = libqdbm.a.*/m', 'MYLIBS = libqdbm.a'); - shell()->cd($this->source_dir) - ->exec("make -j{$this->builder->concurrency}" . ($this instanceof MacOSLibraryBase ? ' mac' : '')) - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $ac->make($this instanceof MacOSLibraryBase ? 'mac' : ''); $this->patchPkgconfPrefix(['qdbm.pc']); } } diff --git a/src/SPC/builder/unix/library/readline.php b/src/SPC/builder/unix/library/readline.php index c0fe9078..8cfca0ab 100644 --- a/src/SPC/builder/unix/library/readline.php +++ b/src/SPC/builder/unix/library/readline.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait readline { @@ -15,18 +16,12 @@ trait readline */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static=yes ' . - '--enable-shared=no ' . - '--prefix= ' . - '--with-curses ' . - '--enable-multibyte=yes' + UnixAutoconfExecutor::create($this) + ->configure( + '--with-curses', + '--enable-multibyte=yes', ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->make(); $this->patchPkgconfPrefix(['readline.pc']); } } diff --git a/src/SPC/builder/unix/library/sqlite.php b/src/SPC/builder/unix/library/sqlite.php index ca21cc9d..8f9add24 100644 --- a/src/SPC/builder/unix/library/sqlite.php +++ b/src/SPC/builder/unix/library/sqlite.php @@ -4,15 +4,13 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\util\executor\UnixAutoconfExecutor; + trait sqlite { protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec('./configure --enable-static --disable-shared --with-pic --prefix=') - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + UnixAutoconfExecutor::create($this)->configure()->make(); $this->patchPkgconfPrefix(['sqlite3.pc']); } } diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index 0e40629d..3e3423b5 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait unixodbc { @@ -15,21 +16,15 @@ trait unixodbc */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static --disable-shared ' . - '--disable-debug ' . - '--with-pic ' . - '--disable-dependency-tracking ' . - '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . - '--with-included-ltdl ' . - '--enable-gui=no ' . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->configure( + '--disable-debug', + '--disable-dependency-tracking', + "--with-libiconv-prefix={$this->getBuildRootPath()}", + '--with-included-ltdl', + '--enable-gui=no', ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->make(); $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); $this->cleanLaFiles(); } diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 3aed6a15..abad7cee 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait xz { @@ -15,20 +16,14 @@ trait xz */ public function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - '--enable-pic ' . - '--disable-scripts ' . - '--disable-doc ' . - '--with-libiconv ' . - '--prefix=' + UnixAutoconfExecutor::create($this) + ->configure( + '--enable-pic', + '--disable-scripts', + '--disable-doc', + '--with-libiconv', ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->make(); $this->patchPkgconfPrefix(['liblzma.pc']); $this->patchLaDependencyPrefix(['liblzma.la']); } diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index cd5dab48..b7729973 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -6,6 +6,7 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\util\executor\UnixAutoconfExecutor; trait zlib { @@ -15,11 +16,7 @@ trait zlib */ protected function build(): void { - shell()->cd($this->source_dir)->initializeEnv($this) - ->exec('./configure --static --prefix=') - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + UnixAutoconfExecutor::create($this)->configure('--static')->make(); $this->patchPkgconfPrefix(['zlib.pc']); } } diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index e31d6410..0f320d50 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -118,7 +118,7 @@ class UnixShell return $this; } - private function getEnvString(): string + public function getEnvString(): string { $str = ''; foreach ($this->env as $k => $v) { diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php new file mode 100644 index 00000000..d7b43368 --- /dev/null +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -0,0 +1,124 @@ +initShell(); + } + + /** + * Run ./configure + */ + public function configure(...$args): static + { + $configure_args = implode(' ', array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args)); + + $this->shell->exec("./configure {$configure_args}"); + return $this; + } + + public function getConfigureArgsString(): string + { + return implode(' ', array_merge($this->getDefaultConfigureArgs(), $this->configure_args)); + } + + /** + * Run make + * + * @param string $target Build target + * @throws RuntimeException + */ + public function make(string $target = '', false|string $with_install = 'install', bool $with_clean = true, array $after_env_vars = []): static + { + if ($with_clean) { + $this->shell->exec('make clean'); + } + $after_env_vars_str = $after_env_vars !== [] ? shell()->setEnv($after_env_vars)->getEnvString() : ''; + $this->shell->exec("make -j{$this->library->getBuilder()->concurrency} {$target} {$after_env_vars_str}"); + if ($with_install !== false) { + $this->shell->exec("make {$with_install}"); + } + return $this; + } + + public function exec(string $cmd): static + { + $this->shell->exec($cmd); + return $this; + } + + /** + * Add optional library configuration. + * This method checks if a library is available and adds the corresponding arguments to the CMake configuration. + * + * @param string $name library name to check + * @param \Closure|string $true_args arguments to use if the library is available (allow closure, returns string) + * @param string $false_args arguments to use if the library is not available + * @return $this + */ + public function optionalLib(string $name, \Closure|string $true_args, string $false_args = ''): static + { + if ($get = $this->library->getBuilder()->getLib($name)) { + $args = $true_args instanceof \Closure ? $true_args($get) : $true_args; + } else { + $args = $false_args; + } + $this->addConfigureArgs($args); + return $this; + } + + /** + * Add configure args. + */ + public function addConfigureArgs(...$args): static + { + $this->configure_args = [...$this->configure_args, ...$args]; + return $this; + } + + public function appendEnv(array $env): static + { + $this->shell->appendEnv($env); + return $this; + } + + /** + * Returns the default autoconf ./configure arguments + */ + private function getDefaultConfigureArgs(): array + { + return [ + '--disable-shared', + '--enable-static', + "--prefix={$this->library->getBuildRootPath()}", + '--with-pic', + ]; + } + + /** + * Initialize UnixShell class. + */ + private function initShell(): void + { + $this->shell = shell()->cd($this->library->getSourceDir())->initializeEnv($this->library)->appendEnv([ + 'CFLAGS' => "-I{$this->library->getIncludeDir()}", + 'LDFLAGS' => "-L{$this->library->getLibDir()}", + ]); + } +} diff --git a/src/globals/functions.php b/src/globals/functions.php index ea96df58..8718f4ab 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -216,3 +216,8 @@ function cmake_boolean_args(string $arg_name, bool $negative = false): array $res = ["-D{$arg_name}=ON", "-D{$arg_name}=OFF"]; return $negative ? array_reverse($res) : $res; } + +function ac_with_args(string $arg_name, bool $use_value = false): array +{ + return $use_value ? ["--with-{$arg_name}=yes", "--with-{$arg_name}=no"] : ["--with-{$arg_name}", "--without-{$arg_name}"]; +} From 8b09e1a446117d2841735121ed3b574408315c81 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 19:51:55 +0800 Subject: [PATCH 161/319] Fix zlib autoconf builder --- src/SPC/builder/unix/library/zlib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/zlib.php b/src/SPC/builder/unix/library/zlib.php index b7729973..717ec3fb 100644 --- a/src/SPC/builder/unix/library/zlib.php +++ b/src/SPC/builder/unix/library/zlib.php @@ -16,7 +16,7 @@ trait zlib */ protected function build(): void { - UnixAutoconfExecutor::create($this)->configure('--static')->make(); + UnixAutoconfExecutor::create($this)->exec("./configure --static --prefix={$this->getBuildRootPath()}")->make(); $this->patchPkgconfPrefix(['zlib.pc']); } } From 1b08a250f63c11428829832c52227d10ac3daf1b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 19:54:46 +0800 Subject: [PATCH 162/319] Add --enable-pic for default autoconf args --- src/SPC/builder/unix/library/libiconv.php | 7 +------ src/SPC/builder/unix/library/onig.php | 2 +- src/SPC/builder/unix/library/xz.php | 1 - src/SPC/util/executor/UnixAutoconfExecutor.php | 1 + 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index 49ac47bc..f4f30ed9 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -10,12 +10,7 @@ trait libiconv { protected function build(): void { - UnixAutoconfExecutor::create($this) - ->configure( - '--enable-pic', - '--enable-extra-encodings', - ) - ->make(); + UnixAutoconfExecutor::create($this)->configure('--enable-extra-encodings')->make(); $this->patchLaDependencyPrefix(['libiconv.la']); } } diff --git a/src/SPC/builder/unix/library/onig.php b/src/SPC/builder/unix/library/onig.php index eb47c0b8..368c852b 100644 --- a/src/SPC/builder/unix/library/onig.php +++ b/src/SPC/builder/unix/library/onig.php @@ -16,7 +16,7 @@ trait onig */ protected function build(): void { - UnixAutoconfExecutor::create($this)->configure('--enable-pic')->make(); + UnixAutoconfExecutor::create($this)->configure()->make(); $this->patchPkgconfPrefix(['oniguruma.pc']); } } diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index abad7cee..62bcf304 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -18,7 +18,6 @@ trait xz { UnixAutoconfExecutor::create($this) ->configure( - '--enable-pic', '--disable-scripts', '--disable-doc', '--with-libiconv', diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index d7b43368..dc1741fd 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -108,6 +108,7 @@ class UnixAutoconfExecutor extends Executor '--enable-static', "--prefix={$this->library->getBuildRootPath()}", '--with-pic', + '--enable-pic', ]; } From 8896d477aa95a39c698f8e001d61e9567afd3c75 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 19:57:12 +0800 Subject: [PATCH 163/319] Add tests for autoconf libs --- src/globals/test-extensions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 982b134f..f9d60ce2 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,9 +13,9 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - '8.1', - '8.2', - '8.3', + // '8.1', + // '8.2', + // '8.3', '8.4', ]; @@ -45,20 +45,20 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', + 'Linux', 'Darwin' => 'zlib', 'Windows' => 'xlswriter,openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', + 'Linux' => '', 'Darwin' => '', 'Windows' => '', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'ngtcp2,nghttp2,nghttp3,libavif', + 'Linux', 'Darwin' => 'libffi,libpng,gettext,gmp,imagemagick,ldap,attr,libacl,libcares,libiconv,librdkafka,libsodium,libtiff,libxslt,ncurses,nghttp2,nghttp3,ngtcp2,onig,qdbm,readline,sqlite,unixodbc,xz,zlib', 'Windows' => '', }; From 0ed6f2924e91e83fefad62bec65c5cce88e8211a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 19:58:40 +0800 Subject: [PATCH 164/319] Add tests for autoconf libs --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index f9d60ce2..58935085 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -58,7 +58,7 @@ $shared_extensions = match (PHP_OS_FAMILY) { // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libffi,libpng,gettext,gmp,imagemagick,ldap,attr,libacl,libcares,libiconv,librdkafka,libsodium,libtiff,libxslt,ncurses,nghttp2,nghttp3,ngtcp2,onig,qdbm,readline,sqlite,unixodbc,xz,zlib', + 'Linux', 'Darwin' => 'libffi,libpng,gettext,gmp,imagemagick,ldap,attr,postgresql,libacl,libcares,libiconv,librdkafka,libsodium,libtiff,libxslt,ncurses,nghttp2,nghttp3,ngtcp2,onig,qdbm,readline,sqlite,unixodbc,xz,zlib', 'Windows' => '', }; From 4c8f9e154deaf8b2df1fa633b91934a6ff85c83e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 20:09:05 +0800 Subject: [PATCH 165/319] Remove attr and libacl tests --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 58935085..be69531f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -58,7 +58,7 @@ $shared_extensions = match (PHP_OS_FAMILY) { // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libffi,libpng,gettext,gmp,imagemagick,ldap,attr,postgresql,libacl,libcares,libiconv,librdkafka,libsodium,libtiff,libxslt,ncurses,nghttp2,nghttp3,ngtcp2,onig,qdbm,readline,sqlite,unixodbc,xz,zlib', + 'Linux', 'Darwin' => 'libffi,libpng,gettext,gmp,imagemagick,ldap,postgresql,libcares,libiconv,librdkafka,libsodium,libtiff,libxslt,ncurses,nghttp2,nghttp3,ngtcp2,onig,qdbm,readline,sqlite,unixodbc,xz,zlib', 'Windows' => '', }; From ae56bed032c5f47aa2115ddc57b4caf0e442e22f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 9 Jun 2025 22:54:44 +0800 Subject: [PATCH 166/319] Fix ncurses build --- src/SPC/builder/unix/library/ncurses.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index 720e0900..14d2a6dc 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -17,7 +17,7 @@ trait ncurses ->configure( '--enable-overwrite', '--with-curses-h', - '--enable-c-files', + '--enable-pc-files', '--enable-echo', '--disable-widec', '--with-normal', From 25c2bafa881a81879cf19a345c67cc6fd445376d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 00:13:55 +0800 Subject: [PATCH 167/319] Fix brotlienc pkgconfig patching --- src/SPC/builder/unix/library/brotli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 588d27bb..6de9c15c 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -24,7 +24,7 @@ trait brotli $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlidec.pc', 'Libs: -L${libdir} -lbrotlidec', 'Libs: -L${libdir} -lbrotlidec -lbrotlicommon'); - FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlienc.pc', 'Libs: -L${libdir} -lbrotlienc', 'Libs: -L${libdir} -lbrotlidec -lbrotlicommon'); + FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/libbrotlienc.pc', 'Libs: -L${libdir} -lbrotlienc', 'Libs: -L${libdir} -lbrotlienc -lbrotlicommon'); shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a'); foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { if (str_starts_with($filename, 'libbrotli') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { From 9e8119e69cdcd22a2df2d24d6c9e50f0b5ba392c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 12:28:28 +0800 Subject: [PATCH 168/319] Fix ldap build --- src/SPC/builder/unix/library/ldap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 276f8e99..36894a6f 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -27,7 +27,10 @@ trait ldap '--without-systemd', '--without-cyrus-sasl', ) - ->appendEnv(['LDFLAGS' => "-L{$this->getLibDir()}"]) + ->appendEnv([ + 'LDFLAGS' => "-L{$this->getLibDir()}", + 'CPPFLAGS' => "-I{$this->getIncludeDir()}", + ]) ->configure() ->exec('sed -i -e "s/SUBDIRS= include libraries clients servers tests doc/SUBDIRS= include libraries clients servers/g" Makefile') ->make(); From 6cb2cdd5a2f9c0cdc6b32623ef5b761197d3fbba Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 12:42:37 +0800 Subject: [PATCH 169/319] Add ignoreConfigureArgs for UnixAutoconfExecutor --- src/SPC/builder/unix/library/librdkafka.php | 4 ++++ src/SPC/util/executor/UnixAutoconfExecutor.php | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/librdkafka.php b/src/SPC/builder/unix/library/librdkafka.php index 69fe04d4..28290ea0 100644 --- a/src/SPC/builder/unix/library/librdkafka.php +++ b/src/SPC/builder/unix/library/librdkafka.php @@ -25,6 +25,10 @@ trait librdkafka }, '--disable-zstd' ) + ->ignoreConfigureArgs( + '--with-pic', + '--enable-pic', + ) ->configure( '--disable-curl', '--disable-sasl', diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index dc1741fd..46eb678d 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -16,6 +16,8 @@ class UnixAutoconfExecutor extends Executor protected array $configure_args = []; + protected array $ignore_args = []; + public function __construct(protected BSDLibraryBase|LinuxLibraryBase|MacOSLibraryBase $library) { parent::__construct($library); @@ -27,7 +29,10 @@ class UnixAutoconfExecutor extends Executor */ public function configure(...$args): static { - $configure_args = implode(' ', array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args)); + // remove all the ignored args + $args = array_merge($args, $this->getDefaultConfigureArgs(), $this->configure_args); + $args = array_diff($args, $this->ignore_args); + $configure_args = implode(' ', $args); $this->shell->exec("./configure {$configure_args}"); return $this; @@ -92,6 +97,15 @@ class UnixAutoconfExecutor extends Executor return $this; } + /** + * Ignore some configure args, to bypass the configure option checking for some libs. + */ + public function ignoreConfigureArgs(...$args): static + { + $this->ignore_args = [...$this->ignore_args, ...$args]; + return $this; + } + public function appendEnv(array $env): static { $this->shell->appendEnv($env); From 11f21304f9b4dcf72e973b2f2a0ff3fc6546d0d9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 15:33:41 +0800 Subject: [PATCH 170/319] Fix libxslt lib compile bug --- src/SPC/builder/freebsd/library/curl.php | 4 ++-- src/SPC/builder/linux/library/curl.php | 4 ++-- src/SPC/builder/linux/library/openssl.php | 4 ++-- src/SPC/builder/traits/UnixLibraryTrait.php | 4 ++-- src/SPC/builder/unix/library/libxslt.php | 3 +-- src/SPC/builder/windows/library/WindowsLibraryBase.php | 4 ++-- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/SPC/builder/freebsd/library/curl.php b/src/SPC/builder/freebsd/library/curl.php index bb5c9265..4eeab20d 100644 --- a/src/SPC/builder/freebsd/library/curl.php +++ b/src/SPC/builder/freebsd/library/curl.php @@ -10,9 +10,9 @@ class curl extends BSDLibraryBase public const NAME = 'curl'; - public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string { - $libs = parent::getStaticLibFiles($style, $recursive); + $libs = parent::getStaticLibFiles($style, $recursive, $include_self); if ($this->builder->getLib('openssl')) { $this->builder->setOption('extra-libs', $this->builder->getOption('extra-libs') . ' /usr/lib/libpthread.a /usr/lib/libdl.a'); } diff --git a/src/SPC/builder/linux/library/curl.php b/src/SPC/builder/linux/library/curl.php index d45492c4..f382773f 100644 --- a/src/SPC/builder/linux/library/curl.php +++ b/src/SPC/builder/linux/library/curl.php @@ -10,9 +10,9 @@ class curl extends LinuxLibraryBase public const NAME = 'curl'; - public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string { - $libs = parent::getStaticLibFiles($style, $recursive); + $libs = parent::getStaticLibFiles($style, $recursive, $include_self); if ($this->builder->getLib('openssl')) { $libs .= ' -ldl -lpthread'; } diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 11c60067..252eb47f 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -92,9 +92,9 @@ class openssl extends LinuxLibraryBase FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")'); } - public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string { - $libFiles = parent::getStaticLibFiles($style, $recursive); + $libFiles = parent::getStaticLibFiles($style, $recursive, $include_self); if (!str_contains('-ldl -lpthread', $libFiles)) { $libFiles .= ' -ldl -lpthread'; } diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index fbca595f..73037447 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -17,9 +17,9 @@ trait UnixLibraryTrait * @throws FileSystemException * @throws WrongUsageException */ - public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string { - $libs = [$this]; + $libs = $include_self ? [$this] : []; if ($recursive) { array_unshift($libs, ...array_values($this->getDependencies(recursive: true))); } diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index af85b052..a1a39a08 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -19,7 +19,7 @@ trait libxslt */ protected function build(): void { - $static_libs = $this instanceof LinuxLibraryBase ? $this->getStaticLibFiles() : ''; + $static_libs = $this instanceof LinuxLibraryBase ? $this->getStaticLibFiles(include_self: false) : ''; $ac = UnixAutoconfExecutor::create($this) ->appendEnv([ 'CFLAGS' => "-I{$this->getIncludeDir()}", @@ -28,7 +28,6 @@ trait libxslt ]) ->addConfigureArgs( '--without-python', - '--without-mem-debug', '--without-crypto', '--without-debug', '--without-debugger', diff --git a/src/SPC/builder/windows/library/WindowsLibraryBase.php b/src/SPC/builder/windows/library/WindowsLibraryBase.php index e8de629e..076afa03 100644 --- a/src/SPC/builder/windows/library/WindowsLibraryBase.php +++ b/src/SPC/builder/windows/library/WindowsLibraryBase.php @@ -29,9 +29,9 @@ abstract class WindowsLibraryBase extends LibraryBase * @throws FileSystemException * @throws WrongUsageException */ - public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true, bool $include_self = true): string { - $libs = [$this]; + $libs = $include_self ? [$this] : []; if ($recursive) { array_unshift($libs, ...array_values($this->getDependencies(recursive: true))); } From da45aa7f15445fc903ead83dcf525a0adfc20abf Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 15:37:39 +0800 Subject: [PATCH 171/319] Fix ngtcp2 and libheif build missing lib bug --- src/SPC/builder/macos/library/libheif.php | 15 --------------- src/SPC/builder/unix/library/libheif.php | 14 ++++++++++++++ src/SPC/builder/unix/library/ngtcp2.php | 10 +++++++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/SPC/builder/macos/library/libheif.php b/src/SPC/builder/macos/library/libheif.php index e785809d..af99740b 100644 --- a/src/SPC/builder/macos/library/libheif.php +++ b/src/SPC/builder/macos/library/libheif.php @@ -4,24 +4,9 @@ declare(strict_types=1); namespace SPC\builder\macos\library; -use SPC\store\FileSystem; - class libheif extends MacOSLibraryBase { use \SPC\builder\unix\library\libheif; public const NAME = 'libheif'; - - public function patchBeforeBuild(): bool - { - if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) { - FileSystem::replaceFileStr( - $this->source_dir . '/CMakeLists.txt', - 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")', - 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")' - ); - return true; - } - return false; - } } diff --git a/src/SPC/builder/unix/library/libheif.php b/src/SPC/builder/unix/library/libheif.php index 131a330d..680f3321 100644 --- a/src/SPC/builder/unix/library/libheif.php +++ b/src/SPC/builder/unix/library/libheif.php @@ -6,10 +6,24 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait libheif { + public function patchBeforeBuild(): bool + { + if (!str_contains(file_get_contents($this->source_dir . '/CMakeLists.txt'), 'libbrotlienc')) { + FileSystem::replaceFileStr( + $this->source_dir . '/CMakeLists.txt', + 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")', + 'list(APPEND REQUIRES_PRIVATE "libbrotlidec")' . "\n" . ' list(APPEND REQUIRES_PRIVATE "libbrotlienc")' + ); + return true; + } + return false; + } + /** * @throws RuntimeException * @throws FileSystemException diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 23c85e1e..2d0e8765 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -19,7 +19,11 @@ trait ngtcp2 protected function build(): void { UnixAutoconfExecutor::create($this) - ->optionalLib('openssl', ...ac_with_args('openssl', true)) + ->optionalLib('openssl', fn ($lib) => implode(' ', [ + '--with-openssl=yes', + "OPENSSL_LIBS=\"{$lib->getStaticLibFiles()}\"", + "OPENSSL_CFLAGS=\"-I{$lib->getIncludeDir()}\"", + ]), '--with-openssl=no') ->optionalLib('libev', ...ac_with_args('libev', true)) ->optionalLib('nghttp3', ...ac_with_args('libnghttp3', true)) ->optionalLib('jemalloc', ...ac_with_args('jemalloc', true)) @@ -34,6 +38,7 @@ trait ngtcp2 "LIBBROTLIENC_LIBS=\"{$lib->getStaticLibFiles()}\"", ]) ) + ->appendEnv(['PKG_CONFIG' => '$PKG_CONFIG --static']) ->configure('--enable-lib-only') ->make(); $this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']); @@ -41,7 +46,6 @@ trait ngtcp2 // on macOS, the static library may contain other static libraries? // ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a - shell()->cd(BUILD_LIB_PATH) - ->exec("ar -t libngtcp2_crypto_ossl.a | grep '\\.a$' | xargs -n1 ar d libngtcp2_crypto_ossl.a"); + shell()->cd(BUILD_LIB_PATH)->exec("ar -t libngtcp2_crypto_ossl.a | grep '\\.a$' | xargs -n1 ar d libngtcp2_crypto_ossl.a"); } } From 474fe63ad338b68cdd30376f7d0591793aa58caf Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 15:37:54 +0800 Subject: [PATCH 172/319] Add optional lib log --- src/SPC/util/executor/UnixAutoconfExecutor.php | 2 ++ src/SPC/util/executor/UnixCMakeExecutor.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index 46eb678d..0e83a58d 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -80,8 +80,10 @@ class UnixAutoconfExecutor extends Executor public function optionalLib(string $name, \Closure|string $true_args, string $false_args = ''): static { if ($get = $this->library->getBuilder()->getLib($name)) { + logger()->info("Building library [{$this->library->getName()}] with {$name} support"); $args = $true_args instanceof \Closure ? $true_args($get) : $true_args; } else { + logger()->info("Building library [{$this->library->getName()}] without {$name} support"); $args = $false_args; } $this->addConfigureArgs($args); diff --git a/src/SPC/util/executor/UnixCMakeExecutor.php b/src/SPC/util/executor/UnixCMakeExecutor.php index 55a74578..b9c7ef58 100644 --- a/src/SPC/util/executor/UnixCMakeExecutor.php +++ b/src/SPC/util/executor/UnixCMakeExecutor.php @@ -58,8 +58,10 @@ class UnixCMakeExecutor extends Executor public function optionalLib(string $name, \Closure|string $true_args, string $false_args = ''): static { if ($get = $this->library->getBuilder()->getLib($name)) { + logger()->info("Building library [{$this->library->getName()}] with {$name} support"); $args = $true_args instanceof \Closure ? $true_args($get) : $true_args; } else { + logger()->info("Building library [{$this->library->getName()}] without {$name} support"); $args = $false_args; } $this->addConfigureArgs($args); @@ -193,6 +195,7 @@ SET(CMAKE_INSTALL_PREFIX "{$root}") SET(CMAKE_INSTALL_LIBDIR "lib") set(PKG_CONFIG_EXECUTABLE "{$root}/bin/pkg-config") +list(APPEND PKG_CONFIG_EXECUTABLE "--static") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) From b320eb853a6d37454a430fad0b52178d1e960603 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 15:39:14 +0800 Subject: [PATCH 173/319] Rename ignoreConfigureArgs to removeConfigureArgs --- src/SPC/builder/unix/library/librdkafka.php | 2 +- src/SPC/util/executor/UnixAutoconfExecutor.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/librdkafka.php b/src/SPC/builder/unix/library/librdkafka.php index 28290ea0..32f389e1 100644 --- a/src/SPC/builder/unix/library/librdkafka.php +++ b/src/SPC/builder/unix/library/librdkafka.php @@ -25,7 +25,7 @@ trait librdkafka }, '--disable-zstd' ) - ->ignoreConfigureArgs( + ->removeConfigureArgs( '--with-pic', '--enable-pic', ) diff --git a/src/SPC/util/executor/UnixAutoconfExecutor.php b/src/SPC/util/executor/UnixAutoconfExecutor.php index 0e83a58d..1c9f496e 100644 --- a/src/SPC/util/executor/UnixAutoconfExecutor.php +++ b/src/SPC/util/executor/UnixAutoconfExecutor.php @@ -100,9 +100,9 @@ class UnixAutoconfExecutor extends Executor } /** - * Ignore some configure args, to bypass the configure option checking for some libs. + * Remove some configure args, to bypass the configure option checking for some libs. */ - public function ignoreConfigureArgs(...$args): static + public function removeConfigureArgs(...$args): static { $this->ignore_args = [...$this->ignore_args, ...$args]; return $this; From 145fe7ce1378b19949b0bf40b20e4fc5399b9327 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 10 Jun 2025 15:52:56 +0800 Subject: [PATCH 174/319] Remove curl libbrotli patches --- src/SPC/builder/unix/library/curl.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index bd15d27e..0d0b8d8d 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -6,7 +6,6 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; -use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; trait curl @@ -38,26 +37,6 @@ trait curl // patch pkgconf $this->patchPkgconfPrefix(['libcurl.pc']); - FileSystem::replaceFileStr( - BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', - '-lbrotlienc -lbrotlidec -lbrotlicommon', - '-lbrotlidec -lbrotlicommon' - ); - FileSystem::replaceFileStr( - BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', - '-lbrotlidec -lbrotlicommon', - '-lbrotlienc -lbrotlidec -lbrotlicommon' - ); - FileSystem::replaceFileStr( - BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', - 'libbrotlienc,libbrotlidec,libbrotlicommon', - 'libbrotlidec,libbrotlicommon' - ); - FileSystem::replaceFileStr( - BUILD_LIB_PATH . '/pkgconfig/libcurl.pc', - 'libbrotlidec,libbrotlicommon', - 'libbrotlienc,libbrotlidec,libbrotlicommon' - ); shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/') ->exec("sed -ie 's|\"/lib/libcurl.a\"|\"" . BUILD_LIB_PATH . "/libcurl.a\"|g' CURLTargets-release.cmake"); } From 9ed62b02b6bd3419f8c63a5d2aa2df464a080ab4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 10 Jun 2025 19:46:55 +0700 Subject: [PATCH 175/319] make patchLaDependencyPrefix argument optional, remove cleanLaFiles --- src/SPC/builder/linux/library/libpng.php | 2 +- src/SPC/builder/macos/library/libpng.php | 3 +- src/SPC/builder/traits/UnixLibraryTrait.php | 31 ++++++++------------ src/SPC/builder/unix/library/freetype.php | 2 -- src/SPC/builder/unix/library/gettext.php | 2 +- src/SPC/builder/unix/library/imagemagick.php | 6 +--- src/SPC/builder/unix/library/ldap.php | 2 +- src/SPC/builder/unix/library/libavif.php | 1 - src/SPC/builder/unix/library/libiconv.php | 2 +- src/SPC/builder/unix/library/libjpeg.php | 1 - src/SPC/builder/unix/library/libwebp.php | 2 -- src/SPC/builder/unix/library/libxslt.php | 4 +-- src/SPC/builder/unix/library/nghttp2.php | 2 +- src/SPC/builder/unix/library/nghttp3.php | 2 +- src/SPC/builder/unix/library/ngtcp2.php | 2 +- src/SPC/builder/unix/library/unixodbc.php | 2 +- src/SPC/builder/unix/library/xz.php | 2 +- 17 files changed, 26 insertions(+), 42 deletions(-) diff --git a/src/SPC/builder/linux/library/libpng.php b/src/SPC/builder/linux/library/libpng.php index da660aff..5510a023 100644 --- a/src/SPC/builder/linux/library/libpng.php +++ b/src/SPC/builder/linux/library/libpng.php @@ -59,6 +59,6 @@ class libpng extends LinuxLibraryBase ->exec("make -j{$this->builder->concurrency} DEFAULT_INCLUDES='-I{$this->source_dir} -I" . BUILD_INCLUDE_PATH . "' LIBS= libpng16.la") ->exec('make install-libLTLIBRARIES install-data-am DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); - $this->cleanLaFiles(); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index f273bff6..090e069e 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -59,7 +59,6 @@ class libpng extends MacOSLibraryBase ->cd(BUILD_LIB_PATH) ->exec('ln -sf libpng16.a libpng.a'); $this->patchPkgconfPrefix(['libpng16.pc'], PKGCONF_PATCH_PREFIX); - $this->patchLaDependencyPrefix(['libpng16.la']); - $this->cleanLaFiles(); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index fbca595f..ffb6ade1 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -84,13 +84,24 @@ trait UnixLibraryTrait } } - public function patchLaDependencyPrefix(array $files): void + public function patchLaDependencyPrefix(?array $files = null): void { logger()->info('Patching library [' . static::NAME . '] la files'); + $throwOnMissing = true; + if ($files === null) { + $files = $this->getStaticLibs(); + $files = array_map(fn ($name) => str_replace('.a', '.la', $name), $files); + $throwOnMissing = false; + } foreach ($files as $name) { $realpath = realpath(BUILD_LIB_PATH . '/' . $name); if ($realpath === false) { - throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); + if ($throwOnMissing) { + throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); + } else { + logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); + continue; + } } logger()->debug('Patching ' . $realpath); // replace prefix @@ -105,22 +116,6 @@ trait UnixLibraryTrait } } - /** - * remove libtool archive files - * - * @throws FileSystemException - * @throws WrongUsageException - */ - public function cleanLaFiles(): void - { - foreach ($this->getStaticLibs() as $lib) { - $filename = pathinfo($lib, PATHINFO_FILENAME) . '.la'; - if (file_exists(BUILD_LIB_PATH . '/' . $filename)) { - unlink(BUILD_LIB_PATH . '/' . $filename); - } - } - } - public function getLibExtraCFlags(): string { $env = getenv($this->getSnakeCaseName() . '_CFLAGS') ?: ''; diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 35e62602..581a5e75 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -38,7 +38,5 @@ trait freetype ' -L/lib ', ' -L' . BUILD_ROOT_PATH . '/lib ' ); - - $this->cleanLaFiles(); } } diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 15a6b6c7..576df385 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -34,6 +34,6 @@ trait gettext ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install'); - $this->patchLaDependencyPrefix(['libintl.la']); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 1284305c..714fdff5 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -78,10 +78,6 @@ trait imagemagick 'includearchdir=${prefix}/include/ImageMagick-7' ); } - $this->patchLaDependencyPrefix([ - 'libMagick++-7.Q16HDRI.la', - 'libMagickCore-7.Q16HDRI.la', - 'libMagickWand-7.Q16HDRI.la', - ]); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 501654de..b2c5e65b 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -48,6 +48,6 @@ trait ldap FileSystem::replaceFileLineContainsString(BUILD_LIB_PATH . '/pkgconfig/ldap.pc', 'Libs: -L${libdir} -lldap', 'Libs: -L${libdir} -lldap -llber'); $this->patchPkgconfPrefix(['ldap.pc', 'lber.pc']); - $this->patchLaDependencyPrefix(['libldap.la', 'liblber.la']); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index cbec640b..dea45c6e 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -23,6 +23,5 @@ trait libavif ->build(); // patch pkgconfig $this->patchPkgconfPrefix(['libavif.pc']); - $this->cleanLaFiles(); } } diff --git a/src/SPC/builder/unix/library/libiconv.php b/src/SPC/builder/unix/library/libiconv.php index 36ef136e..98b40c10 100644 --- a/src/SPC/builder/unix/library/libiconv.php +++ b/src/SPC/builder/unix/library/libiconv.php @@ -21,6 +21,6 @@ trait libiconv ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - $this->patchLaDependencyPrefix(['libiconv.la']); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/libjpeg.php b/src/SPC/builder/unix/library/libjpeg.php index 3f8aff9e..6196f8af 100644 --- a/src/SPC/builder/unix/library/libjpeg.php +++ b/src/SPC/builder/unix/library/libjpeg.php @@ -26,6 +26,5 @@ trait libjpeg ->build(); // patch pkgconfig $this->patchPkgconfPrefix(['libjpeg.pc', 'libturbojpeg.pc']); - $this->cleanLaFiles(); } } diff --git a/src/SPC/builder/unix/library/libwebp.php b/src/SPC/builder/unix/library/libwebp.php index e4f45eb4..32331ea2 100644 --- a/src/SPC/builder/unix/library/libwebp.php +++ b/src/SPC/builder/unix/library/libwebp.php @@ -24,8 +24,6 @@ trait libwebp // patch pkgconfig $this->patchPkgconfPrefix(['libsharpyuv.pc', 'libwebp.pc', 'libwebpdecoder.pc', 'libwebpdemux.pc', 'libwebpmux.pc'], PKGCONF_PATCH_PREFIX | PKGCONF_PATCH_LIBDIR); $this->patchPkgconfPrefix(['libsharpyuv.pc'], PKGCONF_PATCH_CUSTOM, ['/^includedir=.*$/m', 'includedir=${prefix}/include/webp']); - $this->cleanLaFiles(); - // fix imagemagick binary linking issue $this->patchPkgconfPrefix(['libwebp.pc'], PKGCONF_PATCH_CUSTOM, ['/-lwebp$/m', '-lwebp -lsharpyuv']); } } diff --git a/src/SPC/builder/unix/library/libxslt.php b/src/SPC/builder/unix/library/libxslt.php index 10975145..0fd641b3 100644 --- a/src/SPC/builder/unix/library/libxslt.php +++ b/src/SPC/builder/unix/library/libxslt.php @@ -47,8 +47,8 @@ trait libxslt ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . escapeshellarg(BUILD_ROOT_PATH)); - $this->patchPkgconfPrefix(['libexslt.pc']); - $this->patchLaDependencyPrefix(['libxslt.la', 'libexslt.la']); + $this->patchPkgconfPrefix(['libxslt.pc', 'libexslt.pc']); + $this->patchLaDependencyPrefix(); shell()->cd(BUILD_LIB_PATH) ->exec("ar -t libxslt.a | grep '\\.a$' | xargs -n1 ar d libxslt.a") ->exec("ar -t libexslt.a | grep '\\.a$' | xargs -n1 ar d libexslt.a"); diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php index e09832d9..23f5b3c7 100644 --- a/src/SPC/builder/unix/library/nghttp2.php +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -54,6 +54,6 @@ trait nghttp2 ->exec("make -j{$this->builder->concurrency}") ->exec("make install DESTDIR={$destdir}"); $this->patchPkgconfPrefix(['libnghttp2.pc']); - $this->patchLaDependencyPrefix(['libnghttp2.la']); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/nghttp3.php b/src/SPC/builder/unix/library/nghttp3.php index ca2862a2..bf8f1bd2 100644 --- a/src/SPC/builder/unix/library/nghttp3.php +++ b/src/SPC/builder/unix/library/nghttp3.php @@ -28,6 +28,6 @@ trait nghttp3 ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libnghttp3.pc']); - $this->patchLaDependencyPrefix(['libnghttp3.la']); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/ngtcp2.php b/src/SPC/builder/unix/library/ngtcp2.php index 94e9c570..f36d44cb 100644 --- a/src/SPC/builder/unix/library/ngtcp2.php +++ b/src/SPC/builder/unix/library/ngtcp2.php @@ -44,7 +44,7 @@ trait ngtcp2 ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']); - $this->patchLaDependencyPrefix(['libngtcp2.la', 'libngtcp2_crypto_ossl.la']); + $this->patchLaDependencyPrefix(); // on macOS, the static library may contain other static libraries? // ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index 0e40629d..c694cb86 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -31,6 +31,6 @@ trait unixodbc ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['odbc.pc', 'odbccr.pc', 'odbcinst.pc']); - $this->cleanLaFiles(); + $this->patchLaDependencyPrefix(); } } diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 3aed6a15..5f90cc4d 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -30,6 +30,6 @@ trait xz ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['liblzma.pc']); - $this->patchLaDependencyPrefix(['liblzma.la']); + $this->patchLaDependencyPrefix(); } } From 6d3e2d9316e74188490eace2b1cd08d4f7974695 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 10 Jun 2025 19:57:31 +0700 Subject: [PATCH 176/319] revert extension tests --- src/globals/test-extensions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index be69531f..9706740a 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -45,20 +45,20 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'zlib', + 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', 'Windows' => 'xlswriter,openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => '', + 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', 'Darwin' => '', 'Windows' => '', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libffi,libpng,gettext,gmp,imagemagick,ldap,postgresql,libcares,libiconv,librdkafka,libsodium,libtiff,libxslt,ncurses,nghttp2,nghttp3,ngtcp2,onig,qdbm,readline,sqlite,unixodbc,xz,zlib', + 'Linux', 'Darwin' => 'libavif,nghttp2,nghttp3,ngtcp2', 'Windows' => '', }; From 63656cf3833a033b73b810faa5732cd83dedb47e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 10 Jun 2025 19:58:25 +0700 Subject: [PATCH 177/319] cs fixer, of course --- src/SPC/builder/traits/UnixLibraryTrait.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 3b378c4e..e98a6f3a 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -98,10 +98,9 @@ trait UnixLibraryTrait if ($realpath === false) { if ($throwOnMissing) { throw new RuntimeException('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); - } else { - logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); - continue; } + logger()->warning('Cannot find library [' . static::NAME . '] la file [' . $name . '] !'); + continue; } logger()->debug('Patching ' . $realpath); // replace prefix From c3aa7356ecdd800582f4672333d2b71fdfba2331 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 11:43:00 +0700 Subject: [PATCH 178/319] update tests to all static --- src/globals/test-extensions.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 9706740a..575a40d3 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -45,20 +45,23 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', + 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib,amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', 'Windows' => 'xlswriter,openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xdebug,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', + 'Linux' => 'xdebug', 'Darwin' => '', 'Windows' => '', }; -// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). +// If you want to test lib-suggests for all extensions and libraries, set it to true. +$with_suggested_libs = true; + +// If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true. $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libavif,nghttp2,nghttp3,ngtcp2', + 'Linux', 'Darwin' => '', 'Windows' => '', }; @@ -169,6 +172,7 @@ if ($argv[1] === 'build_cmd' || $argv[1] === 'build_embed_cmd') { $build_cmd = 'build '; $build_cmd .= quote2($final_extensions) . ' '; $build_cmd .= $shared_cmd; + $build_cmd .= $with_suggested_libs ? '--with-suggested-libs ' : ''; $build_cmd .= $zts ? '--enable-zts ' : ''; $build_cmd .= $no_strip ? '--no-strip ' : ''; $build_cmd .= $upx ? '--with-upx-pack ' : ''; From 311de9381c74d30b239e61f5928f1babc2dd9c07 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 13:47:32 +0700 Subject: [PATCH 179/319] fix gomp error --- src/SPC/builder/unix/library/imagemagick.php | 2 +- src/globals/test-extensions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index 2011363c..ead786a2 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -33,7 +33,7 @@ trait imagemagick ->optionalLib('bzip2', ...ac_with_args('bzlib')) ->addConfigureArgs( // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so - getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10') ? '--enable-openmp' : '--disable-openmp', + getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10') ? '--disable-openmp' : '--enable-openmp', '--without-jxl', '--without-x', ); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 575a40d3..7f4e05ca 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -45,7 +45,7 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib,amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,inotify,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', + 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib,amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', 'Windows' => 'xlswriter,openssl', }; From a7771e95f28566a80c0c55fa356750f50aa36c7a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 13:49:38 +0700 Subject: [PATCH 180/319] enable musl too --- src/globals/test-extensions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 7f4e05ca..fe245f49 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -26,9 +26,9 @@ $test_os = [ 'macos-15', // 'ubuntu-latest', 'ubuntu-22.04', - // 'ubuntu-24.04', + 'ubuntu-24.04', 'ubuntu-22.04-arm', - // 'ubuntu-24.04-arm', + 'ubuntu-24.04-arm', // 'windows-latest', ]; From a503aaa8a00648e058f61557f5b2509e5e1cdc7d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 15:01:16 +0700 Subject: [PATCH 181/319] -lomp on macos --- src/SPC/builder/extension/imagick.php | 8 ++++++-- src/SPC/builder/unix/library/imagemagick.php | 2 +- src/SPC/util/SPCConfigUtil.php | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 7b0e20f9..4bd4ddcc 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -15,8 +15,12 @@ class imagick extends Extension if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) { return false; } - // imagick with calls omp_pause_all which requires -lgomp, on non-musl we build imagick without openmp - $extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp'); + // imagick with calls omp_pause_all which requires openmp, on non-musl we build imagick without openmp + $extra_libs = match (PHP_OS_FAMILY) { + 'Linux' => trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp'), + 'Darwin' => trim(getenv('SPC_EXTRA_LIBS') . ' -lomp'), + default => '' + }; f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); return true; } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index ead786a2..bf0b2931 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -33,7 +33,7 @@ trait imagemagick ->optionalLib('bzip2', ...ac_with_args('bzlib')) ->addConfigureArgs( // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so - getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10') ? '--disable-openmp' : '--enable-openmp', + getenv('SPC_LIBC') === 'musl' ? '--enable-openmp' : '--disable-openmp', '--without-jxl', '--without-x', ); diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 375d40cd..da52d3b8 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -146,6 +146,9 @@ class SPCConfigUtil if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux' && !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10'))) { $short_name[] = '-lgomp'; } + if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Darwin') { + $short_name[] = '-lomp'; + } return implode(' ', $short_name); } From d322be16664f44661430c996acaca87e81f270bf Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 15:02:07 +0700 Subject: [PATCH 182/319] err, add it back in --- src/SPC/builder/unix/library/imagemagick.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index bf0b2931..ead786a2 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -33,7 +33,7 @@ trait imagemagick ->optionalLib('bzip2', ...ac_with_args('bzlib')) ->addConfigureArgs( // TODO: glibc rh 10 toolset's libgomp.a was built without -fPIC so we can't use openmp without depending on libgomp.so - getenv('SPC_LIBC') === 'musl' ? '--enable-openmp' : '--disable-openmp', + getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10') ? '--disable-openmp' : '--enable-openmp', '--without-jxl', '--without-x', ); From 518ed3a7fd19d23ad489ad4723f23736b7a11195 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 15:38:43 +0700 Subject: [PATCH 183/319] don't add -lomp on macos (not required) --- src/SPC/builder/extension/imagick.php | 11 +++++------ src/SPC/util/SPCConfigUtil.php | 3 --- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 4bd4ddcc..d78627ef 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -12,15 +12,14 @@ class imagick extends Extension { public function patchBeforeMake(): bool { + if (PHP_OS_FAMILY !== 'Linux') { + return false; + } if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) { return false; } - // imagick with calls omp_pause_all which requires openmp, on non-musl we build imagick without openmp - $extra_libs = match (PHP_OS_FAMILY) { - 'Linux' => trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp'), - 'Darwin' => trim(getenv('SPC_EXTRA_LIBS') . ' -lomp'), - default => '' - }; + // imagick with calls omp_pause_all, which requires openmp, on non-musl we build imagick without openmp + $extra_libs = trim(getenv('SPC_EXTRA_LIBS') . ' -lgomp'); f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); return true; } diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index da52d3b8..375d40cd 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -146,9 +146,6 @@ class SPCConfigUtil if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Linux' && !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10'))) { $short_name[] = '-lgomp'; } - if (in_array('imagemagick', $libraries) && PHP_OS_FAMILY === 'Darwin') { - $short_name[] = '-lomp'; - } return implode(' ', $short_name); } From 5a7db86471b1a3993587d2bc7e0abb7bbbbf77a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Wed, 11 Jun 2025 14:20:24 +0200 Subject: [PATCH 184/319] Better exception --- src/SPC/store/Downloader.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index c17e5b98..7efcfb3b 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -537,10 +537,10 @@ class Downloader } f_exec($cmd, $output, $ret); if ($ret === 2 || $ret === -1073741510) { - throw new RuntimeException('failed http fetch'); + throw new RuntimeException(sprintf('Failed to fetch "%s"', $url)); } if ($ret !== 0) { - throw new DownloaderException('failed http fetch'); + throw new DownloaderException(sprintf('Failed to fetch "%s"', $url)); } $cache[$cmd]['cache'] = implode("\n", $output); $cache[$cmd]['expire'] = time() + 3600; @@ -549,10 +549,10 @@ class Downloader } f_exec($cmd, $output, $ret); if ($ret === 2 || $ret === -1073741510) { - throw new RuntimeException('failed http fetch'); + throw new RuntimeException(sprintf('Failed to fetch "%s"', $url)); } if ($ret !== 0) { - throw new DownloaderException('failed http fetch'); + throw new DownloaderException(sprintf('Failed to fetch "%s"', $url)); } return implode("\n", $output); } From a1ccddb53ceb2ff56447dc68b335e448cf9623a2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 11 Jun 2025 20:57:43 +0800 Subject: [PATCH 185/319] Test macOS 15 for all php version --- src/globals/test-extensions.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index fe245f49..efcfb1f1 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,22 +13,22 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - // '8.1', - // '8.2', - // '8.3', + '8.1', + '8.2', + '8.3', '8.4', ]; // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', + // 'macos-13', // 'macos-14', 'macos-15', // 'ubuntu-latest', - 'ubuntu-22.04', - 'ubuntu-24.04', - 'ubuntu-22.04-arm', - 'ubuntu-24.04-arm', + // 'ubuntu-22.04', + // 'ubuntu-24.04', + // 'ubuntu-22.04-arm', + // 'ubuntu-24.04-arm', // 'windows-latest', ]; From 70b91867cbbac931ff8773802b65f93a5ed463a5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 11 Jun 2025 21:37:00 +0800 Subject: [PATCH 186/319] Lets' fuzz it --- .github/workflows/ext-matrix-tests.yml | 109 +++++++++---------------- 1 file changed, 38 insertions(+), 71 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index da30d008..a43bfff2 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -15,81 +15,48 @@ jobs: fail-fast: false matrix: extension: - - amqp - - apcu - - bcmath - - bz2 - - calendar - - ctype - - curl - - dba - - dom - - ds - - event - - exif - - filter - - fileinfo - - ftp - - gd - - gettext - - gmp - - iconv - - igbinary - - imagick - - imap - - intl - - ldap - - mbstring,mbregex - - memcache - - mysqli,mysqlnd,pdo_mysql - - opcache - - openssl - - pcntl - - password-argon2 - - pcntl - - pdo - - pgsql,pdo_pgsql - - phar - - posix - - rar - - protobuf - - readline - - redis - - session - - shmop - - simdjson - - simplexml,xml - - snappy - - soap - - sockets - - sodium - - sqlite3,pdo_sqlite - - sqlsrv - - ssh2 - - swoole - - swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite - - swow - - sysvmsg,sysvsem,sysvshm - - tidy - - tokenizer - - uuid - - uv - - xhprof - - xlswriter - - xmlwriter,xmlreader - - xsl - - yac - - yaml - - zip - - zlib - - zstd + - dom,amqp + - dom,ast + - dom,brotli + - dom,dio + - dom,ds + - dom,ev + - dom,ffi + - dom,gettext + - dom,gmssl + - dom,igbinary + - dom,ldap + - dom,libxml + - dom,lz4 + - dom,memcache + - dom,mongodb + - dom,msgpack + - dom,odbc + - dom,opentelemetry + - dom,parallel + - dom,pdo_odbc + - dom,pdo_sqlsrv + - dom,rar + - dom,rdkafka + - dom,spx + - dom,sqlsrv + - dom,ssh2 + - dom,tidy + - dom,uuid + - dom,uv + - dom,xhprof + - dom,xlswriter + - dom,xz + - dom,yac + - dom,yaml + - dom,zstd php-version: - "8.4" operating-system: - - "ubuntu-latest" + #- "ubuntu-latest" #- "macos-13" #- "debian-arm64-self-hosted" - - "macos-14" + - "macos-15" steps: - name: "Checkout" @@ -145,4 +112,4 @@ jobs: ./bin/spc install-pkg upx UPX=--with-upx-pack fi - ./bin/spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts + ./bin/spc build --build-embed ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts --enable-zts From 80f2912026fa5681857aa67cf81ee4f2a8fe7936 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 11 Jun 2025 22:40:43 +0800 Subject: [PATCH 187/319] Fix rdkafka with zstd build failed bug, reset test-extensions --- src/SPC/builder/extension/rdkafka.php | 19 +++++++++---------- src/globals/test-extensions.php | 10 +++++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/SPC/builder/extension/rdkafka.php b/src/SPC/builder/extension/rdkafka.php index 9f28c627..cb1792c5 100644 --- a/src/SPC/builder/extension/rdkafka.php +++ b/src/SPC/builder/extension/rdkafka.php @@ -11,6 +11,13 @@ use SPC\util\CustomExt; #[CustomExt('rdkafka')] class rdkafka extends Extension { + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileStr("{$this->source_dir}/config.m4", "-L\$RDKAFKA_DIR/\$PHP_LIBDIR -lm\n", "-L\$RDKAFKA_DIR/\$PHP_LIBDIR -lm \$RDKAFKA_LIBS\n"); + FileSystem::replaceFileStr("{$this->source_dir}/config.m4", "-L\$RDKAFKA_DIR/\$PHP_LIBDIR -lm\"\n", '-L$RDKAFKA_DIR/$PHP_LIBDIR -lm $RDKAFKA_LIBS"'); + return true; + } + public function patchBeforeMake(): bool { // when compiling rdkafka with inline builds, it shows some errors, I don't know why. @@ -27,18 +34,10 @@ class rdkafka extends Extension return true; } - public function getConfigureArg(bool $shared = false): string + public function getUnixConfigureArg(bool $shared = false): string { $pkgconf_libs = shell()->execWithResult('pkg-config --libs --static rdkafka')[1]; $pkgconf_libs = trim(implode('', $pkgconf_libs)); - return '--with-rdkafka=' . BUILD_ROOT_PATH . ' LIBS="' . $pkgconf_libs . '"'; - } - - public function getUnixConfigureArg(bool $shared = false): string - { - if ($shared) { - return '--with-rdkafka=' . BUILD_ROOT_PATH; - } - return parent::getUnixConfigureArg($shared); + return '--with-rdkafka=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . ' RDKAFKA_LIBS="' . $pkgconf_libs . '"'; } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index efcfb1f1..744028d3 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,9 +13,9 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - '8.1', - '8.2', - '8.3', + // '8.1', + // '8.2', + // '8.3', '8.4', ]; @@ -45,13 +45,13 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib,amqp,brotli,bz2,dio,ds,ev,event,ffi,ftp,gd,gettext,gmp,gmssl,igbinary,imagick,intl,ldap,lz4,memcache,mongodb,msgpack,odbc,opentelemetry,parallel,pdo_odbc,pdo_pgsql,pdo_sqlsrv,pgsql,protobuf,rar,redis,rdkafka,shmop,spx,sqlsrv,ssh2,swoole,sysvmsg,sysvsem,sysvshm,tidy,uuid,uv,xhprof,xlswriter,xsl,xz,yac,yaml,zstd', + 'Linux', 'Darwin' => 'dom', 'Windows' => 'xlswriter,openssl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => 'xdebug', + 'Linux' => '', 'Darwin' => '', 'Windows' => '', }; From cec5274ea3ecdcdb13add007b31d97808d565fd2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 11 Jun 2025 22:42:26 +0800 Subject: [PATCH 188/319] Re-test --- .github/workflows/ext-matrix-tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index a43bfff2..a8006e0b 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -100,7 +100,9 @@ jobs: - name: "Download sources" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src + run: | + ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src + ./bin/spc download pkg-config --prefer-pre-built --debug - name: "Build library: ${{ matrix.library }}" run: | @@ -112,4 +114,4 @@ jobs: ./bin/spc install-pkg upx UPX=--with-upx-pack fi - ./bin/spc build --build-embed ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts --enable-zts + ./bin/spc build --build-embed ${{ matrix.extension }} --debug $UPX --enable-zts From 62a581393d3cfcad1230392befc643374b53bda8 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 21:54:59 +0700 Subject: [PATCH 189/319] compatibility with RHEL 10? --- src/SPC/builder/Extension.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index c11644dd..1dbbdd30 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -363,6 +363,13 @@ class Extension 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibString . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; + + FileSystem::replaceFileRegex( + $this->source_dir . '/config.m4', + '/(\$PKG_CONFIG\s+[^\s]+)\s+--libs/', + '$1 --static --libs' + ); + // prepare configure args shell()->cd($this->source_dir) ->setEnv($env) From 4be1e75128557783893eb8c8c0449def82b3e77a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 22:41:55 +0700 Subject: [PATCH 190/319] dirty as fuck, I don't understand why AMQP_SHARED_LIBADD is not available in ./configure --- src/SPC/builder/Extension.php | 48 ++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 1dbbdd30..c502b395 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -359,15 +359,36 @@ class Extension $env = [ 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'], - 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibString . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, + 'LDFLAGS' => $config['ldflags'] + . ' -Wl,--require-defined=SSL_CTX_use_RSAPrivateKey' + . ' -Wl,--undefined=SSL_connect' + . ' -Wl,--undefined=SSL_ctrl' + . ' -Wl,--undefined=SSL_CTX_ctrl' + . ' -Wl,--undefined=SSL_CTX_free' + . ' -Wl,--undefined=SSL_CTX_load_verify_locations' + . ' -Wl,--undefined=SSL_CTX_new' + . ' -Wl,--undefined=SSL_CTX_set_default_passwd_cb_userdata' + . ' -Wl,--undefined=SSL_CTX_set_default_verify_paths' + . ' -Wl,--undefined=SSL_CTX_use_certificate_chain_file' + . ' -Wl,--undefined=SSL_CTX_use_PrivateKey_file' + . ' -Wl,--undefined=SSL_CTX_use_RSAPrivateKey' + . ' -Wl,--undefined=SSL_free' + . ' -Wl,--undefined=SSL_get1_peer_certificate' + . ' -Wl,--undefined=SSL_get_error' + . ' -Wl,--undefined=SSL_get_verify_result' + . ' -Wl,--undefined=SSL_new' + . ' -Wl,--undefined=SSL_read' + . ' -Wl,--undefined=SSL_set_bio' + . ' -Wl,--undefined=SSL_shutdown' + . ' -Wl,--undefined=SSL_write', + 'LIBS' => '-Wl,-Bstatic -Wl,--start-group -Wl,--whole-archive ' . $staticLibString . ' -Wl,--no-whole-archive -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; FileSystem::replaceFileRegex( $this->source_dir . '/config.m4', - '/(\$PKG_CONFIG\s+[^\s]+)\s+--libs/', - '$1 --static --libs' + '/=(.\$PKG_CONFIG\s+(?:[^\s]+\s+)*?)--libs.*/', + '"' . $staticLibString . '"' ); // prepare configure args @@ -381,8 +402,21 @@ class Extension shell()->cd($this->source_dir) ->setEnv($env) - ->exec('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') - ->exec('make clean') + ->exec( + './configure ' . $this->getUnixConfigureArg(true) . + ' --with-php-config=' . BUILD_BIN_PATH . '/php-config ' . + '--enable-shared --disable-static' + ); + + FileSystem::replaceFileRegex( + $this->source_dir . '/Makefile', + '/^(.*_SHARED_LIBADD\s*=.*)$/m', + '$1 ' . $staticLibString + ); + + shell()->cd($this->source_dir) + ->setEnv($env) + ->exec('make clean') ->exec('make -j' . $this->builder->concurrency) ->exec('make install'); } @@ -483,7 +517,7 @@ class Extension $sharedLibString .= '-l' . $lib . ' '; } } - return [$staticLibString, $sharedLibString]; + return [trim($staticLibString), trim($sharedLibString)]; } private function getLibraryDependencies(bool $recursive = false): array From 0e092284eb4e1bc1ee6b999702d5d730256b6616 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 22:43:41 +0700 Subject: [PATCH 191/319] err --- src/SPC/builder/Extension.php | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index c502b395..f280ca95 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -359,28 +359,7 @@ class Extension $env = [ 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], - 'LDFLAGS' => $config['ldflags'] - . ' -Wl,--require-defined=SSL_CTX_use_RSAPrivateKey' - . ' -Wl,--undefined=SSL_connect' - . ' -Wl,--undefined=SSL_ctrl' - . ' -Wl,--undefined=SSL_CTX_ctrl' - . ' -Wl,--undefined=SSL_CTX_free' - . ' -Wl,--undefined=SSL_CTX_load_verify_locations' - . ' -Wl,--undefined=SSL_CTX_new' - . ' -Wl,--undefined=SSL_CTX_set_default_passwd_cb_userdata' - . ' -Wl,--undefined=SSL_CTX_set_default_verify_paths' - . ' -Wl,--undefined=SSL_CTX_use_certificate_chain_file' - . ' -Wl,--undefined=SSL_CTX_use_PrivateKey_file' - . ' -Wl,--undefined=SSL_CTX_use_RSAPrivateKey' - . ' -Wl,--undefined=SSL_free' - . ' -Wl,--undefined=SSL_get1_peer_certificate' - . ' -Wl,--undefined=SSL_get_error' - . ' -Wl,--undefined=SSL_get_verify_result' - . ' -Wl,--undefined=SSL_new' - . ' -Wl,--undefined=SSL_read' - . ' -Wl,--undefined=SSL_set_bio' - . ' -Wl,--undefined=SSL_shutdown' - . ' -Wl,--undefined=SSL_write', + 'LDFLAGS' => $config['ldflags'], 'LIBS' => '-Wl,-Bstatic -Wl,--start-group -Wl,--whole-archive ' . $staticLibString . ' -Wl,--no-whole-archive -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; From 78b3778442c6e67c561da22797b695d29fff9486 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 22:43:51 +0700 Subject: [PATCH 192/319] err --- src/SPC/builder/Extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f280ca95..ad7f6b6c 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -360,7 +360,7 @@ class Extension 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], - 'LIBS' => '-Wl,-Bstatic -Wl,--start-group -Wl,--whole-archive ' . $staticLibString . ' -Wl,--no-whole-archive -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, + 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibString . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; From 9f35c954acd28c3917ef1126144935a8b62dde5c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 22:45:08 +0700 Subject: [PATCH 193/319] cs fix --- src/SPC/builder/Extension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index ad7f6b6c..78a5a039 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -395,7 +395,7 @@ class Extension shell()->cd($this->source_dir) ->setEnv($env) - ->exec('make clean') + ->exec('make clean') ->exec('make -j' . $this->builder->concurrency) ->exec('make install'); } From 84fb354bc0ef1f441ca67c21c181e96afd537e09 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 11 Jun 2025 22:46:22 +0700 Subject: [PATCH 194/319] this is not needed anymore --- src/SPC/builder/Extension.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 78a5a039..6581414b 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -364,12 +364,6 @@ class Extension 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; - FileSystem::replaceFileRegex( - $this->source_dir . '/config.m4', - '/=(.\$PKG_CONFIG\s+(?:[^\s]+\s+)*?)--libs.*/', - '"' . $staticLibString . '"' - ); - // prepare configure args shell()->cd($this->source_dir) ->setEnv($env) From c0ea47ce759b05c0ac71833d4de4d7cdf7eb30f2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 12 Jun 2025 00:41:33 +0800 Subject: [PATCH 195/319] I really got redundant test error --- src/SPC/builder/unix/UnixBuilderBase.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index d5d5ca29..2aa7860e 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -186,11 +186,7 @@ abstract class UnixBuilderBase extends BuilderBase } // sanity check for embed - if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED || - file_exists(BUILD_BIN_PATH . '/php-config') && - file_exists(BUILD_BIN_PATH . '/phpize') && - (file_exists(BUILD_LIB_PATH . '/libphp.a') || file_exists(BUILD_LIB_PATH . '/libphp.so')) - ) { + if (($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) { logger()->info('running embed sanity check'); $sample_file_path = SOURCE_PATH . '/embed-test'; if (!is_dir($sample_file_path)) { From 2ea8a7e662e539124520797081157a7d26984251 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 12 Jun 2025 01:16:30 +0800 Subject: [PATCH 196/319] Fix macOS embed re-archive bug --- src/SPC/builder/macos/MacOSBuilder.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 1d4a2949..f83b07ad 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -271,14 +271,7 @@ class MacOSBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install") - // Workaround for https://github.com/php/php-src/issues/12082 - ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o') - ->exec('mkdir ' . BUILD_ROOT_PATH . '/lib/php-o') - ->cd(BUILD_ROOT_PATH . '/lib/php-o') - ->exec('ar x ' . BUILD_ROOT_PATH . '/lib/libphp.a') - ->exec('rm ' . BUILD_ROOT_PATH . '/lib/libphp.a') - ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') - ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); + ->exec('ar -t ' . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 ar d " . BUILD_LIB_PATH . '/libphp.a'); $this->patchPhpScripts(); } From e0734fe848ed756eb3c705bb268124cc19f21b01 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 12 Jun 2025 01:16:57 +0800 Subject: [PATCH 197/319] Add frameworks for extension --- config/ext.json | 4 ++++ src/SPC/builder/Extension.php | 5 +++++ src/SPC/builder/macos/MacOSBuilder.php | 4 ++++ src/SPC/util/SPCConfigUtil.php | 19 ++++++++++++++++++- 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index ad42071d..9f9d5c5f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -424,6 +424,10 @@ "openssl", "zstd", "zlib" + ], + "frameworks": [ + "CoreFoundation", + "Security" ] }, "msgpack": { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6581414b..6ec68b6f 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -53,6 +53,11 @@ class Extension } } + public function getFrameworks(): array + { + return Config::getExt($this->getName(), 'frameworks', []); + } + /** * 获取开启该扩展的 PHP 编译添加的参数 * diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index f83b07ad..2205f4a0 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -67,6 +67,10 @@ class MacOSBuilder extends UnixBuilderBase array_push($frameworks, ...$lib->getFrameworks()); } + foreach ($this->exts as $ext) { + array_push($frameworks, ...$ext->getFrameworks()); + } + if ($asString) { return implode(' ', array_map(fn ($x) => "-framework {$x}", $frameworks)); } diff --git a/src/SPC/util/SPCConfigUtil.php b/src/SPC/util/SPCConfigUtil.php index 375d40cd..8e69e89c 100644 --- a/src/SPC/util/SPCConfigUtil.php +++ b/src/SPC/util/SPCConfigUtil.php @@ -55,10 +55,13 @@ class SPCConfigUtil ob_get_clean(); $ldflags = $this->getLdflagsString(); $libs = $this->getLibsString($libraries, $with_dependencies); + if (PHP_OS_FAMILY === 'Darwin') { + $libs .= " {$this->getFrameworksString($extensions)}"; + } $cflags = $this->getIncludesString(); // embed - $libs = '-lphp -lc ' . $libs; + $libs = trim("-lphp -lc {$libs}"); $extra_env = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'); if (is_string($extra_env)) { $libs .= ' ' . trim($extra_env, '"'); @@ -157,4 +160,18 @@ class SPCConfigUtil // get short name return '-l' . substr($lib, 3, -2); } + + private function getFrameworksString(array $extensions): string + { + $list = []; + foreach ($extensions as $extension) { + foreach (Config::getExt($extension, 'frameworks', []) as $fw) { + $ks = '-framework ' . $fw; + if (!in_array($ks, $list)) { + $list[] = $ks; + } + } + } + return implode(' ', $list); + } } From 28e5e584b49d06573c63b003ec93bcd71630e197 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 12 Jun 2025 01:20:02 +0800 Subject: [PATCH 198/319] Revert ext-matrix-tests and test-extensions --- .github/workflows/ext-matrix-tests.yml | 113 ++++++++++++++++--------- src/globals/test-extensions.php | 12 +-- 2 files changed, 78 insertions(+), 47 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index a8006e0b..da30d008 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -15,48 +15,81 @@ jobs: fail-fast: false matrix: extension: - - dom,amqp - - dom,ast - - dom,brotli - - dom,dio - - dom,ds - - dom,ev - - dom,ffi - - dom,gettext - - dom,gmssl - - dom,igbinary - - dom,ldap - - dom,libxml - - dom,lz4 - - dom,memcache - - dom,mongodb - - dom,msgpack - - dom,odbc - - dom,opentelemetry - - dom,parallel - - dom,pdo_odbc - - dom,pdo_sqlsrv - - dom,rar - - dom,rdkafka - - dom,spx - - dom,sqlsrv - - dom,ssh2 - - dom,tidy - - dom,uuid - - dom,uv - - dom,xhprof - - dom,xlswriter - - dom,xz - - dom,yac - - dom,yaml - - dom,zstd + - amqp + - apcu + - bcmath + - bz2 + - calendar + - ctype + - curl + - dba + - dom + - ds + - event + - exif + - filter + - fileinfo + - ftp + - gd + - gettext + - gmp + - iconv + - igbinary + - imagick + - imap + - intl + - ldap + - mbstring,mbregex + - memcache + - mysqli,mysqlnd,pdo_mysql + - opcache + - openssl + - pcntl + - password-argon2 + - pcntl + - pdo + - pgsql,pdo_pgsql + - phar + - posix + - rar + - protobuf + - readline + - redis + - session + - shmop + - simdjson + - simplexml,xml + - snappy + - soap + - sockets + - sodium + - sqlite3,pdo_sqlite + - sqlsrv + - ssh2 + - swoole + - swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite + - swow + - sysvmsg,sysvsem,sysvshm + - tidy + - tokenizer + - uuid + - uv + - xhprof + - xlswriter + - xmlwriter,xmlreader + - xsl + - yac + - yaml + - zip + - zlib + - zstd php-version: - "8.4" operating-system: - #- "ubuntu-latest" + - "ubuntu-latest" #- "macos-13" #- "debian-arm64-self-hosted" - - "macos-15" + - "macos-14" steps: - name: "Checkout" @@ -100,9 +133,7 @@ jobs: - name: "Download sources" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src - ./bin/spc download pkg-config --prefer-pre-built --debug + run: ./bin/spc download --with-php=${{ matrix.php-version }} --for-extensions=${{ matrix.extension }} --debug --ignore-cache-sources=php-src - name: "Build library: ${{ matrix.library }}" run: | @@ -114,4 +145,4 @@ jobs: ./bin/spc install-pkg upx UPX=--with-upx-pack fi - ./bin/spc build --build-embed ${{ matrix.extension }} --debug $UPX --enable-zts + ./bin/spc build --build-cli --build-micro --build-fpm ${{ matrix.extension }} --debug $UPX --with-suggested-libs --with-suggested-exts diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 744028d3..cfde83f6 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -21,14 +21,14 @@ $test_php_version = [ // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - // 'macos-13', + 'macos-13', // 'macos-14', 'macos-15', // 'ubuntu-latest', - // 'ubuntu-22.04', - // 'ubuntu-24.04', - // 'ubuntu-22.04-arm', - // 'ubuntu-24.04-arm', + 'ubuntu-22.04', + 'ubuntu-24.04', + 'ubuntu-22.04-arm', + 'ubuntu-24.04-arm', // 'windows-latest', ]; @@ -45,7 +45,7 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'dom', + 'Linux', 'Darwin' => 'dom,mongodb', 'Windows' => 'xlswriter,openssl', }; From e2efaab2b278c1556655225d6e5df2c0c263db36 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 08:18:32 +0700 Subject: [PATCH 199/319] fix attempted ar deletions when building shared libphp --- src/SPC/builder/macos/MacOSBuilder.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 2205f4a0..c71dabce 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -274,8 +274,12 @@ class MacOSBuilder extends UnixBuilderBase $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); shell()->cd(SOURCE_PATH . '/php-src') - ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install") - ->exec('ar -t ' . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 ar d " . BUILD_LIB_PATH . '/libphp.a'); + ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); + + if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') { + shell()->cd(SOURCE_PATH . '/php-src') + ->exec('ar -t ' . BUILD_LIB_PATH . "/libphp.a | grep '\\.a$' | xargs -n1 ar d " . BUILD_LIB_PATH . '/libphp.a'); + } $this->patchPhpScripts(); } From bfba598ef4ec1b799a1cae8c34cc3626deb5d411 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 12 Jun 2025 10:58:58 +0800 Subject: [PATCH 200/319] Fix glfw source path --- src/SPC/builder/LibraryBase.php | 25 ++++--------------------- src/SPC/util/GlobalValueTrait.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 src/SPC/util/GlobalValueTrait.php diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index a8b311f6..6780a695 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -11,9 +11,12 @@ use SPC\store\Config; use SPC\store\Downloader; use SPC\store\FileSystem; use SPC\store\SourceManager; +use SPC\util\GlobalValueTrait; abstract class LibraryBase { + use GlobalValueTrait; + /** @var string */ public const NAME = 'unknown'; @@ -31,7 +34,7 @@ abstract class LibraryBase if (static::NAME === 'unknown') { throw new RuntimeException('no unknown!!!!!'); } - $this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . static::NAME); + $this->source_dir = $source_dir ?? (SOURCE_PATH . '/' . Config::getLib(static::NAME, 'source')); } /** @@ -328,26 +331,6 @@ abstract class LibraryBase return false; } - public function getBinDir(): string - { - return BUILD_BIN_PATH; - } - - public function getIncludeDir(): string - { - return BUILD_INCLUDE_PATH; - } - - public function getBuildRootPath(): string - { - return BUILD_ROOT_PATH; - } - - public function getLibDir(): string - { - return BUILD_LIB_PATH; - } - /** * Build this library. * diff --git a/src/SPC/util/GlobalValueTrait.php b/src/SPC/util/GlobalValueTrait.php new file mode 100644 index 00000000..d815b1f0 --- /dev/null +++ b/src/SPC/util/GlobalValueTrait.php @@ -0,0 +1,28 @@ + Date: Thu, 12 Jun 2025 10:46:26 +0700 Subject: [PATCH 201/319] add fastlz, libmemcached for linux --- config/ext.json | 30 +++++++++++-------- config/lib.json | 13 +++++++- config/source.json | 17 ++++++++--- src/SPC/builder/extension/memcached.php | 9 ++++-- src/SPC/builder/extension/yac.php | 2 +- src/SPC/builder/linux/library/fastlz.php | 12 ++++++++ .../builder/linux/library/libmemcached.php | 9 ++---- src/SPC/builder/macos/library/fastlz.php | 12 ++++++++ .../builder/macos/library/libmemcached.php | 7 ++--- src/SPC/builder/unix/library/fastlz.php | 22 ++++++++++++++ 10 files changed, 101 insertions(+), 32 deletions(-) create mode 100644 src/SPC/builder/linux/library/fastlz.php create mode 100644 src/SPC/builder/macos/library/fastlz.php create mode 100644 src/SPC/builder/unix/library/fastlz.php diff --git a/config/ext.json b/config/ext.json index 9f9d5c5f..f8630697 100644 --- a/config/ext.json +++ b/config/ext.json @@ -330,6 +330,16 @@ "openssl" ] }, + "libxml": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "none", + "target": [ + "static" + ] + }, "lz4": { "support": { "Windows": "wip", @@ -342,16 +352,6 @@ "liblz4" ] }, - "libxml": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "none", - "target": [ - "static" - ] - }, "mbregex": { "type": "builtin", "arg-type": "custom", @@ -396,8 +396,7 @@ "memcached": { "support": { "Windows": "wip", - "BSD": "wip", - "Linux": "no" + "BSD": "wip" }, "type": "external", "source": "memcached", @@ -406,6 +405,10 @@ "lib-depends": [ "libmemcached" ], + "lib-depends-unix": [ + "libmemcached", + "fastlz" + ], "ext-depends": [ "session", "zlib" @@ -1083,6 +1086,9 @@ "type": "external", "source": "yac", "arg-type-unix": "custom", + "lib-depends-unix": [ + "fastlz" + ], "ext-depends-unix": [ "igbinary" ] diff --git a/config/lib.json b/config/lib.json index 36d93a6e..160d43f2 100644 --- a/config/lib.json +++ b/config/lib.json @@ -101,6 +101,15 @@ "SystemConfiguration" ] }, + "fastlz": { + "source": "fastlz", + "static-libs-unix": [ + "libfastlz.a" + ], + "headers": [ + "fastlz/fastlz.h" + ] + }, "freetype": { "source": "freetype", "static-libs-unix": [ @@ -389,7 +398,9 @@ "source": "libmemcached", "static-libs-unix": [ "libmemcached.a", - "libmemcachedutil.a" + "libmemcachedprotocol.a", + "libmemcachedutil.a", + "libhashkit.a" ] }, "libpng": { diff --git a/config/source.json b/config/source.json index 98d37eb4..2ad8ec87 100644 --- a/config/source.json +++ b/config/source.json @@ -272,6 +272,15 @@ "path": "LICENSE" } }, + "fastlz": { + "type": "git", + "url": "https://github.com/ariya/FastLZ.git", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE.MIT" + } + }, "freetype": { "type": "git", "rev": "VER-2-13-2", @@ -528,12 +537,12 @@ } }, "libmemcached": { - "type": "git", - "url": "https://github.com/static-php/libmemcached-macos.git", - "rev": "master", + "type": "ghtagtar", + "repo": "awesomized/libmemcached", + "match": "1.\\d.\\d", "license": { "type": "file", - "path": "COPYING" + "path": "LICENSE" } }, "libpng": { diff --git a/src/SPC/builder/extension/memcached.php b/src/SPC/builder/extension/memcached.php index 8ea8b81e..a1b88ac6 100644 --- a/src/SPC/builder/extension/memcached.php +++ b/src/SPC/builder/extension/memcached.php @@ -12,8 +12,11 @@ class memcached extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - $rootdir = BUILD_ROOT_PATH; - $zlib_dir = $this->builder->getPHPVersionID() >= 80400 ? '' : "--with-zlib-dir={$rootdir}"; - return '--enable-memcached' . ($shared ? '=shared' : '') . " {$zlib_dir} --with-libmemcached-dir={$rootdir} --disable-memcached-sasl --enable-memcached-json"; + return '--enable-memcached' . ($shared ? '=shared' : '') . ' ' . + '--with-zlib-dir=' . BUILD_ROOT_PATH . ' ' . + '--with-libmemcached-dir=' . BUILD_ROOT_PATH . ' ' . + '--disable-memcached-sasl ' . + '--enable-memcached-json ' . + '--with-system-fastlz'; } } diff --git a/src/SPC/builder/extension/yac.php b/src/SPC/builder/extension/yac.php index bb085133..07589b2e 100644 --- a/src/SPC/builder/extension/yac.php +++ b/src/SPC/builder/extension/yac.php @@ -21,6 +21,6 @@ class yac extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--enable-yac --enable-igbinary --enable-json'; + return '--enable-yac ' . ($shared ? '=shared' : '') . ' --enable-igbinary --enable-json --with-system-fastlz'; } } diff --git a/src/SPC/builder/linux/library/fastlz.php b/src/SPC/builder/linux/library/fastlz.php new file mode 100644 index 00000000..07bee9bb --- /dev/null +++ b/src/SPC/builder/linux/library/fastlz.php @@ -0,0 +1,12 @@ +build(); } } diff --git a/src/SPC/builder/macos/library/fastlz.php b/src/SPC/builder/macos/library/fastlz.php new file mode 100644 index 00000000..db0f517a --- /dev/null +++ b/src/SPC/builder/macos/library/fastlz.php @@ -0,0 +1,12 @@ +configure('--disable-sasl')->exec("sed -ie 's/-Werror//g' ./Makefile")->make(); + UnixCMakeExecutor::create($this)->build(); } } diff --git a/src/SPC/builder/unix/library/fastlz.php b/src/SPC/builder/unix/library/fastlz.php new file mode 100644 index 00000000..5989893c --- /dev/null +++ b/src/SPC/builder/unix/library/fastlz.php @@ -0,0 +1,22 @@ +cd($this->source_dir)->initializeEnv($this) + ->exec((getenv('CC') ?? 'cc') . ' -c -O3 -fPIC fastlz.c -o fastlz.o') + ->exec((getenv('AR') ?? 'ar') . ' rcs libfastlz.a fastlz.o'); + + if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) { + throw new \RuntimeException('Failed to copy fastlz.h'); + } + if (!copy($this->source_dir . '/libfastlz.a', BUILD_LIB_PATH . '/libfastlz.a')) { + throw new \RuntimeException('Failed to copy libfastlz.a'); + } + } +} From fcfbb59637913e813cbfd5a61caa133fdbe3d689 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 10:48:15 +0700 Subject: [PATCH 202/319] fix phpstan --- src/SPC/builder/unix/library/fastlz.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/fastlz.php b/src/SPC/builder/unix/library/fastlz.php index 5989893c..db0b7f79 100644 --- a/src/SPC/builder/unix/library/fastlz.php +++ b/src/SPC/builder/unix/library/fastlz.php @@ -9,8 +9,8 @@ trait fastlz protected function build(): void { shell()->cd($this->source_dir)->initializeEnv($this) - ->exec((getenv('CC') ?? 'cc') . ' -c -O3 -fPIC fastlz.c -o fastlz.o') - ->exec((getenv('AR') ?? 'ar') . ' rcs libfastlz.a fastlz.o'); + ->exec((getenv('CC') ?: 'cc') . ' -c -O3 -fPIC fastlz.c -o fastlz.o') + ->exec((getenv('AR') ?: 'ar') . ' rcs libfastlz.a fastlz.o'); if (!copy($this->source_dir . '/fastlz.h', BUILD_INCLUDE_PATH . '/fastlz.h')) { throw new \RuntimeException('Failed to copy fastlz.h'); From 8bd7794a2e1b597b7a01a522cbf3b1e3375e1386 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 12 Jun 2025 11:57:42 +0800 Subject: [PATCH 203/319] Add `-v` compatibility for command --- src/SPC/command/BaseCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index c04b3fa8..832ced97 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -80,7 +80,7 @@ abstract class BaseCommand extends Command $this->output = $output; global $ob_logger; - if ($input->getOption('debug')) { + if ($input->getOption('debug') || $output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) { $ob_logger = new ConsoleLogger(LogLevel::DEBUG, decorated: !$input->getOption('no-ansi')); define('DEBUG_MODE', true); } else { From 01ab0d35305d2c15142dc2e4470e08e6b4463b9f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 11:01:05 +0700 Subject: [PATCH 204/319] update default flags --- config/env.ini | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/config/env.ini b/config/env.ini index 5e2288ab..8b5d516d 100644 --- a/config/env.ini +++ b/config/env.ini @@ -68,8 +68,8 @@ CXX=${SPC_LINUX_DEFAULT_CXX} AR=${SPC_LINUX_DEFAULT_AR} LD=ld.gold ; default compiler flags, used in CMake toolchain file, openssl and pkg-config build -SPC_DEFAULT_C_FLAGS="-fPIC" -SPC_DEFAULT_CXX_FLAGS= +SPC_DEFAULT_C_FLAGS="-fpic -Os" +SPC_DEFAULT_CXX_FLAGS="fpic -Os" ; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) SPC_EXTRA_LIBS= ; upx executable path @@ -89,7 +89,7 @@ SPC_CMD_VAR_PHP_EMBED_TYPE="static" ; *** default build vars for building php *** ; CFLAGS for configuring php -SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE" +SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fpie" ; CPPFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" ; LDFLAGS for configuring php @@ -97,7 +97,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; LIBS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -fno-ident -fPIE -fPIC" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -Os -fno-ident -fpic -fpie" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm" ; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so @@ -110,8 +110,8 @@ SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-all-static -Wl,-O1 -pie" CC=clang CXX=clang++ ; default compiler flags, used in CMake toolchain file, openssl and pkg-config build -SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin" -SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin" +SPC_DEFAULT_C_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os" +SPC_DEFAULT_CXX_FLAGS="--target=${MAC_ARCH}-apple-darwin -Os" ; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) SPC_EXTRA_LIBS= ; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches @@ -133,7 +133,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" ; LDFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv" ; embed type for php, static (libphp.a) or shared (libphp.dylib) From d9f7aa760e2fa67acca9198c20bb32baac244327 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 11:40:32 +0700 Subject: [PATCH 205/319] update default env (shouldn't we pass -fpic to default c flags on macos?) --- config/env.ini | 8 ++++---- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/env.ini b/config/env.ini index 8b5d516d..fddb5deb 100644 --- a/config/env.ini +++ b/config/env.ini @@ -69,7 +69,7 @@ AR=${SPC_LINUX_DEFAULT_AR} LD=ld.gold ; default compiler flags, used in CMake toolchain file, openssl and pkg-config build SPC_DEFAULT_C_FLAGS="-fpic -Os" -SPC_DEFAULT_CXX_FLAGS="fpic -Os" +SPC_DEFAULT_CXX_FLAGS="-fpic -Os" ; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) SPC_EXTRA_LIBS= ; upx executable path @@ -91,13 +91,13 @@ SPC_CMD_VAR_PHP_EMBED_TYPE="static" ; CFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fpie" ; CPPFLAGS for configuring php -SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" +SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="${SPC_DEFAULT_CXX_FLAGS} -I${BUILD_INCLUDE_PATH} -fpie" ; LDFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; LIBS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -Os -fno-ident -fpic -fpie" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fpie ${SPC_DEFAULT_C_FLAGS}" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm" ; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so @@ -133,7 +133,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" ; LDFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie -Os" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fpic -fpie ${SPC_DEFAULT_C_FLAGS}" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-lresolv" ; embed type for php, static (libphp.a) or shared (libphp.dylib) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 2aa7860e..0d367de1 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -151,7 +151,7 @@ abstract class UnixBuilderBase extends BuilderBase protected function sanityCheck(int $build_target): void { // sanity check for php-cli - if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI || file_exists(BUILD_BIN_PATH . '/php')) { + if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { logger()->info('running cli sanity check'); [$ret, $output] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n -r "echo \"hello\";"'); $raw_output = implode('', $output); From 0ee9a0cfa457b525525f71644d87a81314d986fc Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 11:45:47 +0700 Subject: [PATCH 206/319] oops, don't pass -fpic to CPPflags, I misread it as CXXflags --- config/env.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/env.ini b/config/env.ini index fddb5deb..ba8652d5 100644 --- a/config/env.ini +++ b/config/env.ini @@ -91,7 +91,7 @@ SPC_CMD_VAR_PHP_EMBED_TYPE="static" ; CFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fpie" ; CPPFLAGS for configuring php -SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="${SPC_DEFAULT_CXX_FLAGS} -I${BUILD_INCLUDE_PATH} -fpie" +SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" ; LDFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; LIBS for configuring php From db109e3586f12267c239cd9415b9004a8ff301fa Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 12:07:35 +0700 Subject: [PATCH 207/319] update documentation for glibc --- docs/en/guide/build-with-glibc.md | 4 +--- docs/zh/guide/build-with-glibc.md | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/en/guide/build-with-glibc.md b/docs/en/guide/build-with-glibc.md index 0d6c1736..9024f6b0 100644 --- a/docs/en/guide/build-with-glibc.md +++ b/docs/en/guide/build-with-glibc.md @@ -61,6 +61,4 @@ If you have related issues or requirements, please indicate that you are buildin If you need to build glibc-based binaries without using Docker, please refer to the `bin/spc-gnu-docker` script to manually create a similar environment. -Since glibc binaries are not the main goal of the project, -we generally do not test the compatibility of various libraries and extensions under glibc. -If any specific library builds successfully on musl-libc but fails on glibc, please submit an issue. +Please keep in mind that we only support glibc build with `bin/spc-gnu-docker`. Compilation on RHEL 9 & 10 has been tested and is stable, but if you run into issues, we may choose not to fix them. diff --git a/docs/zh/guide/build-with-glibc.md b/docs/zh/guide/build-with-glibc.md index b025769b..7d7632d0 100644 --- a/docs/zh/guide/build-with-glibc.md +++ b/docs/zh/guide/build-with-glibc.md @@ -51,5 +51,4 @@ glibc 构建为扩展的特性,不属于默认 static-php 的支持范围。 如果你需要不使用 Docker 构建基于 glibc 的二进制,请参考 `bin/spc-gnu-docker` 脚本,手动构建一个类似的环境。 -由于 glibc 二进制不是项目的主要目标,一般情况下我们不会额外测试 glibc 下的各个库和扩展的兼容性。 -任何特定库如果在 musl-libc 上构建成功,但在 glibc 上构建失败,请提交 issue,我们将会单独解决。 +请注意,我们仅支持使用 bin/spc-gnu-docker 构建的 glibc 版本。已在 RHEL 9 和 10 上进行了编译测试并验证其稳定性,但如果您遇到问题,我们可能不会进行修复。 From d9cd4d7e368ba54fa19c3e723ba57eed3dfcc482 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 12 Jun 2025 13:02:25 +0800 Subject: [PATCH 208/319] Update version to 2.6.0 --- src/SPC/ConsoleApplication.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 0ec10ced..c74c9bdc 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -33,7 +33,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.5.2'; + public const VERSION = '2.6.0'; public function __construct() { From 29339b962c0512a504b5a86618bac8c07df6126f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 14:20:04 +0700 Subject: [PATCH 209/319] remove incorrect space after --enable-yac --- src/SPC/builder/extension/yac.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/yac.php b/src/SPC/builder/extension/yac.php index 07589b2e..335aafa1 100644 --- a/src/SPC/builder/extension/yac.php +++ b/src/SPC/builder/extension/yac.php @@ -21,6 +21,6 @@ class yac extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--enable-yac ' . ($shared ? '=shared' : '') . ' --enable-igbinary --enable-json --with-system-fastlz'; + return '--enable-yac' . ($shared ? '=shared' : '') . ' --enable-igbinary --enable-json --with-system-fastlz'; } } From 5a3a8db772b8a16ad3999839ea05f321e26a7943 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 19:17:44 +0700 Subject: [PATCH 210/319] rebuild shared extensions even if they already exist --- src/SPC/builder/Extension.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6ec68b6f..74be112c 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -329,10 +329,6 @@ class Extension public function buildShared(): void { logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)'); - if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { - logger()->info('extension ' . $this->getName() . ' already built, skipping'); - return; - } foreach ($this->dependencies as $dependency) { if (!$dependency instanceof Extension) { continue; From 52f40b7f9f32934718c7408dce3cde1d183d9934 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 20:19:21 +0700 Subject: [PATCH 211/319] the release option also affects shared extensions, which is unwanted, patchelf their soname back and rename them --- src/SPC/builder/linux/LinuxBuilder.php | 18 ++++++++++++++++++ src/SPC/doctor/item/LinuxToolCheckList.php | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 00732619..315d7df9 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -293,6 +293,24 @@ class LinuxBuilder extends UnixBuilderBase $cwd = getcwd(); chdir(BUILD_LIB_PATH); symlink($realLibName, 'libphp.so'); + chdir(BUILD_MODULES_PATH); + foreach ($this->getExts() as $ext) { + if (!$ext->isBuildShared()) { + continue; + } + $name = $ext->getName(); + $versioned = "{$name}-{$release}.so"; + $unversioned = "{$name}.so"; + if (is_file(BUILD_MODULES_PATH . "/{$versioned}")) { + rename(BUILD_MODULES_PATH . "/{$versioned}", BUILD_MODULES_PATH . "/{$unversioned}"); + shell()->cd(BUILD_MODULES_PATH) + ->exec(sprintf( + 'patchelf --set-soname %s %s', + escapeshellarg($unversioned), + escapeshellarg($unversioned) + )); + } + } chdir($cwd); } $this->patchPhpScripts(); diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 2522eb58..56235b0c 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -22,6 +22,7 @@ class LinuxToolCheckList 'bzip2', 'cmake', 'gcc', 'g++', 'patch', 'binutils-gold', 'libtoolize', 'which', + 'patchelf', ]; public const TOOLS_DEBIAN = [ @@ -30,6 +31,7 @@ class LinuxToolCheckList 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', 'xz', 'libtoolize', 'which', + 'patchelf', ]; public const TOOLS_RHEL = [ @@ -38,6 +40,7 @@ class LinuxToolCheckList 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', 'which', 'xz', 'libtool', 'gettext-devel', + 'perl', 'patchelf', ]; public const TOOLS_ARCH = [ From 0a24a6af1f8fdbccd8fb2fcc4cdce7fe972a551c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 20:51:17 +0700 Subject: [PATCH 212/319] move check when to build to extension.php instead of builder --- src/SPC/builder/BuilderBase.php | 11 ----------- src/SPC/builder/Extension.php | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 433d0b97..7fc78e44 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -262,17 +262,6 @@ abstract class BuilderBase if (!$ext->isBuildShared()) { continue; } - if (Config::getExt($ext->getName(), 'type') === 'builtin' || Config::getExt($ext->getName(), 'build-with-php') === true) { - if (file_exists(BUILD_MODULES_PATH . '/' . $ext->getName() . '.so')) { - logger()->info('Shared extension [' . $ext->getName() . '] was already built by php-src/configure (' . $ext->getName() . '.so)'); - continue; - } - if (Config::getExt($ext->getName(), 'build-with-php') === true) { - logger()->warning('Shared extension [' . $ext->getName() . '] did not build with php-src/configure (' . $ext->getName() . '.so)'); - logger()->warning('Try deleting your build and source folders and running `spc build`` again.'); - continue; - } - } $ext->buildShared(); } } catch (RuntimeException $e) { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 74be112c..5b35aade 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -328,6 +328,17 @@ class Extension */ public function buildShared(): void { + if (Config::getExt($this->getName(), 'type') === 'builtin' || Config::getExt($this->getName(), 'build-with-php') === true) { + if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { + logger()->info('Shared extension [' . $this->getName() . '] was already built by php-src/configure (' . $this->getName() . '.so)'); + return; + } + if (Config::getExt($this->getName(), 'build-with-php') === true) { + logger()->warning('Shared extension [' . $this->getName() . '] did not build with php-src/configure (' . $this->getName() . '.so)'); + logger()->warning('Try deleting your build and source folders and running `spc build`` again.'); + return; + } + } logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)'); foreach ($this->dependencies as $dependency) { if (!$dependency instanceof Extension) { From d249391816efaea776be714628d1a729375c57ba Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 12 Jun 2025 23:37:18 +0700 Subject: [PATCH 213/319] don't add configure command to phpinfo when -release is set --- src/SPC/builder/LibraryBase.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 6780a695..338aff37 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -214,6 +214,19 @@ abstract class LibraryBase */ public function tryBuild(bool $force_build = false): int { + if (str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), '-release')) { + FileSystem::replaceFileLineContainsString( + SOURCE_PATH . '/php-src/ext/standard/info.c', + '#ifdef CONFIGURE_COMMAND', + '#ifdef NO_CONFIGURE_COMMAND', + ); + } else { + FileSystem::replaceFileLineContainsString( + SOURCE_PATH . '/php-src/ext/standard/info.c', + '#ifdef NO_CONFIGURE_COMMAND', + '#ifdef CONFIGURE_COMMAND', + ); + } if (file_exists($this->source_dir . '/.spc.patched')) { $this->patched = true; } From 302cf8345de443b0e3a095251ca9e4dd2dfbff64 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 13 Jun 2025 13:01:02 +0700 Subject: [PATCH 214/319] properly handle different php versions, clean up only required files --- src/SPC/command/BuildPHPCommand.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 61781d2c..353605b1 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -6,6 +6,7 @@ namespace SPC\command; use SPC\builder\BuilderProvider; use SPC\exception\ExceptionHandler; +use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; @@ -158,14 +159,24 @@ class BuildPHPCommand extends BuildCommand if ($this->input->getOption('with-upx-pack') && in_array(PHP_OS_FAMILY, ['Linux', 'Windows'])) { $indent_texts['UPX Pack'] = 'enabled'; } + try { - $ver = $builder->getPHPVersion(); - $indent_texts['PHP Version'] = $ver; - } catch (\Throwable) { - if (($ver = $builder->getPHPVersionFromArchive()) !== false) { - $indent_texts['PHP Version'] = $ver; + $cleanPhpSrc = $builder->getPHPVersion() !== $builder->getPHPVersionFromArchive(); + } catch (RuntimeException|WrongUsageException) { + $cleanPhpSrc = true; + } + if ($cleanPhpSrc) { + logger()->info('Cleaning previous php build due to mismatching versions...'); + FileSystem::removeDir(SOURCE_PATH . '/php-src'); + FileSystem::removeDir(BUILD_MODULES_PATH); + $binFiles = glob(BUILD_BIN_PATH . '/php*'); + $libFiles = glob(BUILD_LIB_PATH . '/libphp*'); + foreach ([...$binFiles, ...$libFiles] as $file) { + unlink($file); } } + $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(); + $indent_texts['PHP Version'] = $ver; if (!empty($not_included)) { $indent_texts['Extra Exts (' . count($not_included) . ')'] = implode(', ', $not_included); From b265d6dd5625665a0477047f367e7a20673e313a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 13 Jun 2025 16:25:31 +0700 Subject: [PATCH 215/319] don't set unknown linker flags on macos --- src/SPC/builder/Extension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 5b35aade..d0448389 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -368,11 +368,16 @@ class Extension { $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); [$staticLibString, $sharedLibString] = $this->getStaticAndSharedLibs(); + + // macOS ld64 doesn't understand these, while Linux and BSD do + // use them to make sure that all symbols are picked up, even if a library has already been visited before + $preStatic = PHP_OS_FAMILY !== 'Darwin' ? '-Wl,-Bstatic -Wl,--start-group ' : ''; + $postStatic = PHP_OS_FAMILY !== 'Darwin' ? ' -Wl,--end-group -Wl,-Bdynamic ' : ' '; $env = [ 'CFLAGS' => $config['cflags'], 'CXXFLAGS' => $config['cflags'], 'LDFLAGS' => $config['ldflags'], - 'LIBS' => '-Wl,-Bstatic -Wl,--start-group ' . $staticLibString . ' -Wl,--end-group -Wl,-Bdynamic ' . $sharedLibString, + 'LIBS' => $preStatic . $staticLibString . $postStatic . $sharedLibString, 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; @@ -393,6 +398,7 @@ class Extension '--enable-shared --disable-static' ); + // some extensions don't define their dependencies well, this patch is only needed for a few FileSystem::replaceFileRegex( $this->source_dir . '/Makefile', '/^(.*_SHARED_LIBADD\s*=.*)$/m', From 962de5b25fe3363a2edfbaf29d3819510e0746bf Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 13 Jun 2025 22:51:35 +0700 Subject: [PATCH 216/319] add edant/watcher, to make spc-packages easier --- config/lib.json | 9 +++++++ config/source.json | 9 +++++++ src/SPC/builder/freebsd/library/watcher.php | 12 +++++++++ src/SPC/builder/linux/library/watcher.php | 12 +++++++++ src/SPC/builder/macos/library/watcher.php | 12 +++++++++ src/SPC/builder/unix/library/watcher.php | 28 +++++++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 src/SPC/builder/freebsd/library/watcher.php create mode 100644 src/SPC/builder/linux/library/watcher.php create mode 100644 src/SPC/builder/macos/library/watcher.php create mode 100644 src/SPC/builder/unix/library/watcher.php diff --git a/config/lib.json b/config/lib.json index 160d43f2..dc792c3b 100644 --- a/config/lib.json +++ b/config/lib.json @@ -854,5 +854,14 @@ "zstd.h", "zstd_errors.h" ] + }, + "watcher": { + "source": "watcher", + "static-libs-unix": [ + "libwatcher-c.a" + ], + "headers": [ + "wtr/watcher-c.h" + ] } } diff --git a/config/source.json b/config/source.json index 2ad8ec87..57a10a4e 100644 --- a/config/source.json +++ b/config/source.json @@ -1070,5 +1070,14 @@ "type": "file", "path": "LICENSE" } + }, + "watcher": { + "type": "ghtar", + "repo": "e-dant/watcher", + "prefer-stable": true, + "license": { + "type": "file", + "path": "license" + } } } diff --git a/src/SPC/builder/freebsd/library/watcher.php b/src/SPC/builder/freebsd/library/watcher.php new file mode 100644 index 00000000..1a08dd24 --- /dev/null +++ b/src/SPC/builder/freebsd/library/watcher.php @@ -0,0 +1,12 @@ +cd($this->source_dir . '/watcher-c') + ->initializeEnv($this) + ->exec(getenv('CC') . ' -c -o libwatcher-c.o ./src/watcher-c.cpp -I ./include -I ../include -std=c++17 -Wall -Wextra -fPIC') + ->exec(getenv('AR') . ' rcs libwatcher-c.a libwatcher-c.o'); + + copy($this->source_dir . '/watcher-c/libwatcher-c.a', BUILD_LIB_PATH . '/libwatcher-c.a'); + FileSystem::createDir(BUILD_INCLUDE_PATH . '/wtr'); + copy($this->source_dir . '/watcher-c/include/wtr/watcher-c.h', BUILD_INCLUDE_PATH . '/wtr/watcher-c.h'); + } +} From 3efabee1533f4a38729ad4d7a94e2c4542f4b847 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 01:13:33 +0800 Subject: [PATCH 217/319] Remove redundant sanity check call --- src/SPC/builder/macos/MacOSBuilder.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index c71dabce..a0522120 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -180,9 +180,6 @@ class MacOSBuilder extends UnixBuilderBase } $this->buildEmbed(); } - - $this->emitPatchPoint('before-sanity-check'); - $this->sanityCheck($build_target); } public function testPHP(int $build_target = BUILD_TARGET_NONE) From 1468bb99f0d367c6473f8fc46a500d50654684d8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 02:06:12 +0800 Subject: [PATCH 218/319] Add commit tests {craft} extensions: curl,ast sapi: cli,micro {/craft} --- .github/workflows/commit-tests.yml | 128 +++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 .github/workflows/commit-tests.yml diff --git a/.github/workflows/commit-tests.yml b/.github/workflows/commit-tests.yml new file mode 100644 index 00000000..a99d8631 --- /dev/null +++ b/.github/workflows/commit-tests.yml @@ -0,0 +1,128 @@ +name: Single Test +on: + push: + +permissions: read-all + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + parse-commit: + runs-on: ubuntu-latest + outputs: + skip_craft: ${{ steps.parse_commit.outputs.skip_craft }} + craft: ${{ steps.parse_commit.outputs.craft }} + skip_bash: ${{ steps.parse_commit.outputs.skip_bash }} + bash: ${{ steps.parse_commit.outputs.bash }} + build_os: ${{ steps.parse_commit.outputs.build_os }} + spc_prefix: ${{ steps.parse_commit.outputs.spc_prefix }} + steps: + - name: "Parse commit message" + id: parse_commit + run: | + # parse the commit message, see if it has {craft} and {/craft} tags + COMMIT_MESSAGE=$(git log -1 --pretty=%B) + # judge it, it it's not exist, then skip this test + if [[ "$COMMIT_MESSAGE" != *"{craft}"* ]] || [[ "$COMMIT_MESSAGE" != *"{/craft}"* ]]; then + echo "No {craft} tags found in commit message. Skipping test." + echo "skip_craft=yes" >> $GITHUB_OUTPUT + exit 0 + else + echo "\e[32mCraft tags found in commit message.\e[0m" + # get the craft content + CRAFT_CONTENT=$(echo "$COMMIT_MESSAGE" | sed -nz 's/.*{craft}\(.*\){\/craft}.*/\1/p') + echo "Craft content: $CRAFT_CONTENT" + # set the output variable + echo "craft=$CRAFT_CONTENT" >> $GITHUB_OUTPUT + fi + + # parse the bash test script from the commit message + if [[ "$COMMIT_MESSAGE" != *"{bash}"* ]] || [[ "$COMMIT_MESSAGE" != *"{/bash}"* ]]; then + echo "No {bash} tags found in commit message. Skipping bash test." + echo "skip_bash=yes" >> $GITHUB_OUTPUT + else + echo "\e[32mBash tags found in commit message.\e[0m" + # get the bash content + BASH_CONTENT=$(echo "$COMMIT_MESSAGE" | sed -nz 's/.*{bash}\(.*\){\/bash}.*/\1/p') + echo "Bash content: $BASH_CONTENT" + # set the output variable + echo "bash=$BASH_CONTENT" >> $GITHUB_OUTPUT + fi + + # parse spc_prefix from commit message, e.g. [spc_prefix:bin/spc-gnu-docker], default: bin/spc + if [[ "$COMMIT_MESSAGE" =~ \[spc_prefix:([^\]]+)\] ]]; then + SPC_PREFIX=${BASH_REMATCH[1]} + echo "SPC prefix found: $SPC_PREFIX" + else + SPC_PREFIX="bin/spc" + echo "No SPC prefix found, using default: $SPC_PREFIX" + fi + echo "spc_prefix=$SPC_PREFIX" >> $GITHUB_OUTPUT + + # parse build_os from commit message, e.g. [build_os:ubuntu-latest], default: ubuntu-latest + if [[ "$COMMIT_MESSAGE" =~ \[build_os:([^\]]+)\] ]]; then + BUILD_OS=${BASH_REMATCH[1]} + echo "Build OS found: $BUILD_OS" + else + BUILD_OS="ubuntu-latest" + echo "No Build OS found, using default: $BUILD_OS" + fi + echo "build_os=$BUILD_OS" >> $GITHUB_OUTPUT + + craft-test: + needs: parse-commit + if: needs.parse-commit.outputs.skip_craft != 'yes' + runs-on: ${{ needs.parse-commit.outputs.build_os }} + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: composer + + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: "Doctor" + run: ${{ needs.parse-commit.outputs.spc_prefix }} doctor --auto-fix --debug + + - name: "Run Craft Test" + run: | + echo "Running craft test with content:" + echo "${{ needs.parse-commit.outputs.craft }}" + echo "${{ needs.parse-commit.outputs.craft }}" > craft.yml + ${{ needs.parse-commit.outputs.spc_prefix }} craft --debug + + bash-test: + needs: parse-commit + if: needs.parse-commit.outputs.skip_bash != 'yes' + runs-on: ${{ needs.parse-commit.outputs.build_os }} + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: composer + + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: "Doctor" + run: ${{ needs.parse-commit.outputs.spc_prefix }} doctor --auto-fix --debug + + - name: "Run Bash Test" + run: | + echo "Running bash test with content:" + echo "${{ needs.parse-commit.outputs.bash }}" + echo "${{ needs.parse-commit.outputs.bash }}" | bash From 45ec0cef242a8baea6fbd7564596b9446e1bc426 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 02:20:52 +0800 Subject: [PATCH 219/319] Add checkout {craft} extensions: curl,ast sapi: cli,micro {/craft} --- .github/workflows/commit-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/commit-tests.yml b/.github/workflows/commit-tests.yml index a99d8631..45a5c391 100644 --- a/.github/workflows/commit-tests.yml +++ b/.github/workflows/commit-tests.yml @@ -18,6 +18,9 @@ jobs: build_os: ${{ steps.parse_commit.outputs.build_os }} spc_prefix: ${{ steps.parse_commit.outputs.spc_prefix }} steps: + - name: "Checkout" + uses: actions/checkout@v4 + - name: "Parse commit message" id: parse_commit run: | From 3a0d21eb44d2a9a79fd81fe44eec4d55f204f51c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 02:27:48 +0800 Subject: [PATCH 220/319] Support multi-line {craft} extensions: curl,ast sapi: cli,micro {/craft} --- .github/workflows/commit-tests.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/commit-tests.yml b/.github/workflows/commit-tests.yml index 45a5c391..8878fac1 100644 --- a/.github/workflows/commit-tests.yml +++ b/.github/workflows/commit-tests.yml @@ -32,12 +32,14 @@ jobs: echo "skip_craft=yes" >> $GITHUB_OUTPUT exit 0 else - echo "\e[32mCraft tags found in commit message.\e[0m" + echo -e "\e[32mCraft tags found in commit message.\e[0m" # get the craft content CRAFT_CONTENT=$(echo "$COMMIT_MESSAGE" | sed -nz 's/.*{craft}\(.*\){\/craft}.*/\1/p') echo "Craft content: $CRAFT_CONTENT" # set the output variable - echo "craft=$CRAFT_CONTENT" >> $GITHUB_OUTPUT + echo "craft<> $GITHUB_OUTPUT + echo "$CRAFT_CONTENT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT fi # parse the bash test script from the commit message @@ -45,12 +47,14 @@ jobs: echo "No {bash} tags found in commit message. Skipping bash test." echo "skip_bash=yes" >> $GITHUB_OUTPUT else - echo "\e[32mBash tags found in commit message.\e[0m" + echo -e "\e[32mBash tags found in commit message.\e[0m" # get the bash content BASH_CONTENT=$(echo "$COMMIT_MESSAGE" | sed -nz 's/.*{bash}\(.*\){\/bash}.*/\1/p') echo "Bash content: $BASH_CONTENT" # set the output variable - echo "bash=$BASH_CONTENT" >> $GITHUB_OUTPUT + echo "bash<> $GITHUB_OUTPUT + echo "$BASH_CONTENT" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT fi # parse spc_prefix from commit message, e.g. [spc_prefix:bin/spc-gnu-docker], default: bin/spc From fe455bf9013a69566113b0dde62c1b9054c22d31 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 02:30:00 +0800 Subject: [PATCH 221/319] Fix shared-extensions as optional {craft} extensions: curl,ast sapi: cli,micro {/craft} --- src/SPC/command/CraftCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 8d3cc2be..9a2ac441 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -49,7 +49,7 @@ class CraftCommand extends BaseCommand } $static_extensions = implode(',', $craft['extensions']); - $shared_extensions = implode(',', $craft['shared-extensions']); + $shared_extensions = implode(',', $craft['shared-extensions'] ?? []); $libs = implode(',', $craft['libs']); // init log From 6253b7a912d2fef9cc679cbea098f56dd754eb4a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 02:35:37 +0800 Subject: [PATCH 222/319] Next pr, I won't run --- docs/deps-craft-yml.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/deps-craft-yml.md b/docs/deps-craft-yml.md index 9e660be8..1b824e0b 100644 --- a/docs/deps-craft-yml.md +++ b/docs/deps-craft-yml.md @@ -42,6 +42,9 @@ build-options: # Set micro SAPI as win32 mode, without this, micro SAPI will be compiled as a console application (only for Windows, default: false) enable-micro-win32: false +# Build options for shared extensions (same as `build-shared` command options, all options are optional) +shared-extensions: [ ] + # Download options download-options: # Use custom url for specified sources, format: "{source-name}:{url}" (e.g. "php-src:https://example.com/php-8.4.0.tar.gz") From e5cd3adf97ccf74983dc925e367a3dd096553364 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 02:36:47 +0800 Subject: [PATCH 223/319] Next pr, I won't run --- .github/workflows/commit-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/commit-tests.yml b/.github/workflows/commit-tests.yml index 8878fac1..3b5dbcc7 100644 --- a/.github/workflows/commit-tests.yml +++ b/.github/workflows/commit-tests.yml @@ -10,6 +10,8 @@ env: jobs: parse-commit: runs-on: ubuntu-latest + # if the commit message does not contain {craft} or {bash} tags, then skip the craft-test and bash-test jobs + if: github.event_name == 'push' && (contains(github.event.head_commit.message, '{craft}') || contains(github.event.head_commit.message, '{bash}')) outputs: skip_craft: ${{ steps.parse_commit.outputs.skip_craft }} craft: ${{ steps.parse_commit.outputs.craft }} From 0e88cdb25876b6a274ebaa2a0ff9fe47c768b707 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 13:49:29 +0800 Subject: [PATCH 224/319] Add shared extension parser {craft} extensions: bcmath shared-extensions: xdebug,swoole sapi: cli {/craft} [spc_prefix:bin/spc-gnu-docker] --- docs/deps-craft-yml.md | 2 +- src/SPC/util/ConfigValidator.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/deps-craft-yml.md b/docs/deps-craft-yml.md index 1b824e0b..0ee0e11d 100644 --- a/docs/deps-craft-yml.md +++ b/docs/deps-craft-yml.md @@ -42,7 +42,7 @@ build-options: # Set micro SAPI as win32 mode, without this, micro SAPI will be compiled as a console application (only for Windows, default: false) enable-micro-win32: false -# Build options for shared extensions (same as `build-shared` command options, all options are optional) +# Build options for shared extensions (list or comma-separated are both accepted) shared-extensions: [ ] # Download options diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index eae2ef2b..dbc8ce23 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -164,6 +164,12 @@ class ConfigValidator if (is_string($craft['extensions'])) { $craft['extensions'] = array_filter(array_map(fn ($x) => trim($x), explode(',', $craft['extensions']))); } + if (!isset($craft['shared-extensions'])) { + $craft['shared-extensions'] = []; + } + if (is_string($craft['shared-extensions'] ?? [])) { + $craft['shared-extensions'] = array_filter(array_map(fn ($x) => trim($x), explode(',', $craft['shared-extensions']))); + } // check libs if (isset($craft['libs']) && is_string($craft['libs'])) { $craft['libs'] = array_filter(array_map(fn ($x) => trim($x), explode(',', $craft['libs']))); From 5a401a5f9265c25df538fb15a98f587b5f0c24e4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 16:09:48 +0800 Subject: [PATCH 225/319] Add source hash comparator & refactor download lock --- src/SPC/builder/LibraryBase.php | 13 ++-- src/SPC/command/DeleteDownloadCommand.php | 2 +- src/SPC/doctor/item/LinuxMuslCheck.php | 2 +- src/SPC/store/Downloader.php | 72 +++++++++++++++++++++-- src/SPC/store/FileSystem.php | 39 +++++++----- src/SPC/store/PackageManager.php | 3 +- src/SPC/store/SourceManager.php | 35 ++++++++++- src/globals/defines.php | 7 ++- tests/SPC/store/DownloaderTest.php | 4 +- tests/bootstrap.php | 2 + 10 files changed, 142 insertions(+), 37 deletions(-) diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 6780a695..f62e297b 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -51,7 +51,7 @@ abstract class LibraryBase // if source is locked as pre-built, we just tryInstall it $pre_built_name = Downloader::getPreBuiltLockName($source); if (isset($lock[$pre_built_name]) && ($lock[$pre_built_name]['lock_as'] ?? SPC_DOWNLOAD_SOURCE) === SPC_DOWNLOAD_PRE_BUILT) { - return $this->tryInstall($lock[$pre_built_name]['filename'], $force); + return $this->tryInstall($lock[$pre_built_name], $force); } return $this->tryBuild($force); } @@ -166,14 +166,15 @@ abstract class LibraryBase * @throws WrongUsageException * @throws FileSystemException */ - public function tryInstall(string $install_file, bool $force_install = false): int + public function tryInstall(array $lock, bool $force_install = false): int { + $install_file = $lock['filename']; if ($force_install) { logger()->info('Installing required library [' . static::NAME . '] from pre-built binaries'); // Extract files try { - FileSystem::extractPackage($install_file, DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH); + FileSystem::extractPackage($install_file, $lock['source_type'], DOWNLOAD_PATH . '/' . $install_file, BUILD_ROOT_PATH); $this->install(); return LIB_STATUS_OK; } catch (FileSystemException|RuntimeException $e) { @@ -183,19 +184,19 @@ abstract class LibraryBase } foreach ($this->getStaticLibs() as $name) { if (!file_exists(BUILD_LIB_PATH . "/{$name}")) { - $this->tryInstall($install_file, true); + $this->tryInstall($lock, true); return LIB_STATUS_OK; } } foreach ($this->getHeaders() as $name) { if (!file_exists(BUILD_INCLUDE_PATH . "/{$name}")) { - $this->tryInstall($install_file, true); + $this->tryInstall($lock, true); return LIB_STATUS_OK; } } // pkg-config is treated specially. If it is pkg-config, check if the pkg-config binary exists if (static::NAME === 'pkg-config' && !file_exists(BUILD_ROOT_PATH . '/bin/pkg-config')) { - $this->tryInstall($install_file, true); + $this->tryInstall($lock, true); return LIB_STATUS_OK; } return LIB_STATUS_ALREADY; diff --git a/src/SPC/command/DeleteDownloadCommand.php b/src/SPC/command/DeleteDownloadCommand.php index b68b8618..12b0b420 100644 --- a/src/SPC/command/DeleteDownloadCommand.php +++ b/src/SPC/command/DeleteDownloadCommand.php @@ -60,7 +60,7 @@ class DeleteDownloadCommand extends BaseCommand foreach ($deleted_sources as $lock_name) { // remove download file/dir if exists - if ($lock[$lock_name]['source_type'] === 'archive') { + if ($lock[$lock_name]['source_type'] === SPC_SOURCE_ARCHIVE) { if (file_exists($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock[$lock_name]['filename']))) { logger()->info('Deleting file ' . $path); unlink($path); diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index bd89c0d7..15516355 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -78,7 +78,7 @@ class LinuxMuslCheck ]; logger()->info('Downloading ' . $musl_source['url']); Downloader::downloadSource($musl_version_name, $musl_source); - FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); + FileSystem::extractSource($musl_version_name, SPC_SOURCE_ARCHIVE, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); // Apply CVE-2025-26519 patch SourcePatcher::patchFile('musl-1.2.5_CVE-2025-26519_0001.patch', SOURCE_PATH . "/{$musl_version_name}"); diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 7efcfb3b..b0c663d3 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -208,7 +208,7 @@ class Downloader if ($download_as === SPC_DOWNLOAD_PRE_BUILT) { $name = self::getPreBuiltLockName($name); } - self::lockSource($name, ['source_type' => 'archive', 'filename' => $filename, 'move_path' => $move_path, 'lock_as' => $download_as]); + self::lockSource($name, ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => $filename, 'move_path' => $move_path, 'lock_as' => $download_as]); } /** @@ -231,6 +231,9 @@ class Downloader } else { $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; } + // calculate hash + $hash = self::getLockSourceHash($data); + $data['hash'] = $hash; $lock[$name] = $data; FileSystem::writeFile(DOWNLOAD_PATH . '/.lock.json', json_encode($lock, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); } @@ -278,7 +281,7 @@ class Downloader } // Lock logger()->debug("Locking git source {$name}"); - self::lockSource($name, ['source_type' => 'dir', 'dirname' => $name, 'move_path' => $move_path, 'lock_as' => $lock_as]); + self::lockSource($name, ['source_type' => SPC_SOURCE_GIT, 'dirname' => $name, 'move_path' => $move_path, 'lock_as' => $lock_as]); /* // 复制目录过去 @@ -371,6 +374,16 @@ class Downloader SPC_DOWNLOAD_PRE_BUILT ); break; + case 'local': + // Local directory, do nothing, just lock it + logger()->debug("Locking local source {$name}"); + self::lockSource($name, [ + 'source_type' => SPC_SOURCE_LOCAL, + 'dirname' => $pkg['dirname'], + 'move_path' => $pkg['extract'] ?? null, + 'lock_as' => SPC_DOWNLOAD_PACKAGE, + ]); + break; case 'custom': // Custom download method, like API-based download or other $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\store\source'); foreach ($classes as $class) { @@ -477,6 +490,16 @@ class Downloader $download_as ); break; + case 'local': + // Local directory, do nothing, just lock it + logger()->debug("Locking local source {$name}"); + self::lockSource($name, [ + 'source_type' => SPC_SOURCE_LOCAL, + 'dirname' => $source['dirname'], + 'move_path' => $source['extract'] ?? null, + 'lock_as' => $download_as, + ]); + break; case 'custom': // Custom download method, like API-based download or other if (isset($source['func']) && is_callable($source['func'])) { $source['name'] = $name; @@ -594,6 +617,43 @@ class Downloader return "{$source}-" . PHP_OS_FAMILY . '-' . getenv('GNU_ARCH') . '-' . (getenv('SPC_LIBC') ?: 'default') . '-' . (SystemUtil::getLibcVersionIfExists() ?? 'default'); } + /** + * Get the hash of the lock source based on the lock options. + * + * @param array $lock_options Lock options + * @return string Hash of the lock source + * @throws RuntimeException + */ + public static function getLockSourceHash(array $lock_options): string + { + $result = match ($lock_options['source_type']) { + SPC_SOURCE_ARCHIVE => sha1_file(DOWNLOAD_PATH . '/' . $lock_options['filename']), + SPC_SOURCE_GIT => exec('cd ' . escapeshellarg(DOWNLOAD_PATH . '/' . $lock_options['dirname']) . ' && ' . SPC_GIT_EXEC . ' rev-parse HEAD'), + SPC_SOURCE_LOCAL => 'LOCAL HASH IS ALWAYS DIFFERENT', + default => filter_var(getenv('SPC_IGNORE_BAD_HASH'), FILTER_VALIDATE_BOOLEAN) ? '' : throw new RuntimeException("Unknown source type: {$lock_options['source_type']}"), + }; + if ($result === false && !filter_var(getenv('SPC_IGNORE_BAD_HASH'), FILTER_VALIDATE_BOOLEAN)) { + throw new RuntimeException("Failed to get hash for source: {$lock_options['source_type']}"); + } + return $result ?: ''; + } + + /** + * @param array $lock_options Lock options + * @param string $destination Target directory + * @throws FileSystemException + * @throws RuntimeException + */ + public static function putLockSourceHash(array $lock_options, string $destination): void + { + $hash = self::getLockSourceHash($lock_options); + if ($lock_options['source_type'] === SPC_SOURCE_LOCAL) { + logger()->debug("Source [{$lock_options['dirname']}] is local, no hash will be written."); + return; + } + FileSystem::writeFile("{$destination}/.spc-hash", $hash); + } + /** * Register CTRL+C event for different OS. * @@ -640,8 +700,8 @@ class Downloader // If lock file exists, skip downloading for source mode if (!$force && $download_as === SPC_DOWNLOAD_SOURCE && isset($lock[$name])) { if ( - $lock[$name]['source_type'] === 'archive' && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename']) || - $lock[$name]['source_type'] === 'dir' && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname']) + $lock[$name]['source_type'] === SPC_SOURCE_ARCHIVE && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename']) || + $lock[$name]['source_type'] === SPC_SOURCE_GIT && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname']) ) { logger()->notice("Source [{$name}] already downloaded: " . ($lock[$name]['filename'] ?? $lock[$name]['dirname'])); return true; @@ -652,8 +712,8 @@ class Downloader if (!$force && $download_as === SPC_DOWNLOAD_PRE_BUILT && isset($lock[$lock_name = self::getPreBuiltLockName($name)])) { // lock name with env if ( - $lock[$lock_name]['source_type'] === 'archive' && file_exists(DOWNLOAD_PATH . '/' . $lock[$lock_name]['filename']) || - $lock[$lock_name]['source_type'] === 'dir' && is_dir(DOWNLOAD_PATH . '/' . $lock[$lock_name]['dirname']) + $lock[$lock_name]['source_type'] === SPC_SOURCE_ARCHIVE && file_exists(DOWNLOAD_PATH . '/' . $lock[$lock_name]['filename']) || + $lock[$lock_name]['source_type'] === SPC_SOURCE_GIT && is_dir(DOWNLOAD_PATH . '/' . $lock[$lock_name]['dirname']) ) { logger()->notice("Pre-built content [{$name}] already downloaded: " . ($lock[$lock_name]['filename'] ?? $lock[$lock_name]['dirname'])); return true; diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 16047427..d67ed6cf 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -142,7 +142,7 @@ class FileSystem * @throws RuntimeException * @throws FileSystemException */ - public static function extractPackage(string $name, string $filename, ?string $extract_path = null): void + public static function extractPackage(string $name, string $source_type, string $filename, ?string $extract_path = null): void { if ($extract_path !== null) { // replace @@ -151,14 +151,15 @@ class FileSystem } else { $extract_path = PKG_ROOT_PATH . '/' . $name; } - logger()->info("extracting {$name} package to {$extract_path} ..."); + logger()->info("Extracting {$name} package to {$extract_path} ..."); $target = self::convertPath($extract_path); if (!is_dir($dir = dirname($target))) { self::createDir($dir); } try { - self::extractArchive($filename, $target); + // extract wrapper command + self::extractWithType($source_type, $filename, $extract_path); } catch (RuntimeException $e) { if (PHP_OS_FAMILY === 'Windows') { f_passthru('rmdir /s /q ' . $target); @@ -177,24 +178,23 @@ class FileSystem * @throws FileSystemException * @throws RuntimeException */ - public static function extractSource(string $name, string $filename, ?string $move_path = null): void + public static function extractSource(string $name, string $source_type, string $filename, ?string $move_path = null): void { // if source hook is empty, load it if (self::$_extract_hook === []) { SourcePatcher::init(); } - if ($move_path !== null) { - $move_path = SOURCE_PATH . '/' . $move_path; - } else { - $move_path = SOURCE_PATH . "/{$name}"; - } + $move_path = match ($move_path) { + null => SOURCE_PATH . '/' . $name, + default => self::isRelativePath($move_path) ? (SOURCE_PATH . '/' . $move_path) : $move_path, + }; $target = self::convertPath($move_path); - logger()->info("extracting {$name} source to {$target}" . ' ...'); + logger()->info("Extracting {$name} source to {$target}" . ' ...'); if (!is_dir($dir = dirname($target))) { self::createDir($dir); } try { - self::extractArchive($filename, $target); + self::extractWithType($source_type, $filename, $move_path); self::emitSourceExtractHook($name, $target); } catch (RuntimeException $e) { if (PHP_OS_FAMILY === 'Windows') { @@ -484,11 +484,6 @@ class FileSystem */ private static function extractArchive(string $filename, string $target): void { - // Git source, just move - if (is_dir(self::convertPath($filename))) { - self::copyDir(self::convertPath($filename), $target); - return; - } // Create base dir if (f_mkdir(directory: $target, recursive: true) !== true) { throw new FileSystemException('create ' . $target . ' dir failed'); @@ -553,4 +548,16 @@ class FileSystem } } } + + private static function extractWithType(string $source_type, string $filename, string $extract_path): void + { + logger()->debug('Extracting source [' . $source_type . ']: ' . $filename); + /* @phpstan-ignore-next-line */ + match ($source_type) { + SPC_SOURCE_ARCHIVE => self::extractArchive($filename, $extract_path), + SPC_SOURCE_GIT => self::copyDir(self::convertPath($filename), $extract_path), + // soft link to the local source + SPC_SOURCE_LOCAL => symlink(self::convertPath($filename), $extract_path), + }; + } } diff --git a/src/SPC/store/PackageManager.php b/src/SPC/store/PackageManager.php index 6ff2faef..ca930228 100644 --- a/src/SPC/store/PackageManager.php +++ b/src/SPC/store/PackageManager.php @@ -34,9 +34,10 @@ class PackageManager Downloader::downloadPackage($pkg_name, $config, $force); // After download, read lock file name $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); + $source_type = $lock[$pkg_name]['source_type']; $filename = DOWNLOAD_PATH . '/' . ($lock[$pkg_name]['filename'] ?? $lock[$pkg_name]['dirname']); $extract = $lock[$pkg_name]['move_path'] === null ? (PKG_ROOT_PATH . '/' . $pkg_name) : $lock[$pkg_name]['move_path']; - FileSystem::extractPackage($pkg_name, $filename, $extract); + FileSystem::extractPackage($pkg_name, $source_type, $filename, $extract); // if contains extract-files, we just move this file to destination, and remove extract dir if (is_array($config['extract-files'] ?? null) && is_assoc_array($config['extract-files'])) { diff --git a/src/SPC/store/SourceManager.php b/src/SPC/store/SourceManager.php index 4b06df34..dd419e35 100644 --- a/src/SPC/store/SourceManager.php +++ b/src/SPC/store/SourceManager.php @@ -69,10 +69,39 @@ class SourceManager $check = $lock[$lock_name]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$lock_name]['move_path']); if (!is_dir($check)) { logger()->debug('Extracting source [' . $source . '] to ' . $check . ' ...'); - FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$lock_name]['filename'] ?? $lock[$lock_name]['dirname']), $lock[$lock_name]['move_path']); - } else { - logger()->debug('Source [' . $source . '] already extracted in ' . $check . ', skip !'); + $filename = self::getSourceFullPath($lock[$lock_name]); + FileSystem::extractSource($source, $lock[$lock_name]['source_type'], $filename, $lock[$lock_name]['move_path']); + Downloader::putLockSourceHash($lock[$lock_name], $check); + continue; } + // if a lock file does not have hash, calculate with the current source (backward compatibility) + if (!isset($lock[$lock_name]['hash'])) { + $hash = Downloader::getLockSourceHash($lock[$lock_name]); + } else { + $hash = $lock[$lock_name]['hash']; + } + + // when source already extracted, detect if the extracted source hash is the same as the lock file one + if (file_exists("{$check}/.spc-hash") && FileSystem::readFile("{$check}/.spc-hash") === $hash) { + logger()->debug('Source [' . $source . '] already extracted in ' . $check . ', skip !'); + continue; + } + + // if not, remove the source dir and extract again + logger()->notice("Source [{$source}] hash mismatch, removing old source dir and extracting again ..."); + FileSystem::removeDir($check); + $filename = self::getSourceFullPath($lock[$lock_name]); + FileSystem::extractSource($source, $lock[$lock_name]['source_type'], $filename, $lock[$lock_name]['move_path']); + Downloader::putLockSourceHash($lock[$lock_name], $check); } } + + private static function getSourceFullPath(array $lock_options): string + { + return match ($lock_options['source_type']) { + SPC_SOURCE_ARCHIVE => FileSystem::isRelativePath($lock_options['filename']) ? (DOWNLOAD_PATH . '/' . $lock_options['filename']) : $lock_options['filename'], + SPC_SOURCE_GIT, SPC_SOURCE_LOCAL => FileSystem::isRelativePath($lock_options['dirname']) ? (DOWNLOAD_PATH . '/' . $lock_options['dirname']) : $lock_options['dirname'], + default => throw new WrongUsageException("Unknown source type: {$lock_options['source_type']}"), + }; + } } diff --git a/src/globals/defines.php b/src/globals/defines.php index f3d290ba..eab2fcc4 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -40,7 +40,7 @@ const SPC_EXTENSION_ALIAS = [ 'zendopcache' => 'opcache', ]; -// spc lock type +// spc download lock type const SPC_DOWNLOAD_SOURCE = 1; // lock source const SPC_DOWNLOAD_PRE_BUILT = 2; // lock pre-built const SPC_DOWNLOAD_PACKAGE = 3; // lock as package @@ -84,5 +84,10 @@ const AUTOCONF_CPPFLAGS = 4; const AUTOCONF_LDFLAGS = 8; const AUTOCONF_ALL = 15; +// spc download source type +const SPC_SOURCE_ARCHIVE = 'archive'; // download as archive +const SPC_SOURCE_GIT = 'git'; // download as git repository +const SPC_SOURCE_LOCAL = 'local'; // download as local directory + ConsoleLogger::$date_format = 'H:i:s'; ConsoleLogger::$format = '[%date%] [%level_short%] %body%'; diff --git a/tests/SPC/store/DownloaderTest.php b/tests/SPC/store/DownloaderTest.php index a9507e08..5c15d42e 100644 --- a/tests/SPC/store/DownloaderTest.php +++ b/tests/SPC/store/DownloaderTest.php @@ -57,7 +57,7 @@ class DownloaderTest extends TestCase public function testLockSource() { - Downloader::lockSource('fake-file', ['source_type' => 'archive', 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']); + Downloader::lockSource('fake-file', ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']); $this->assertFileExists(DOWNLOAD_PATH . '/.lock.json'); $json = json_decode(file_get_contents(DOWNLOAD_PATH . '/.lock.json'), true); $this->assertIsArray($json); @@ -66,7 +66,7 @@ class DownloaderTest extends TestCase $this->assertArrayHasKey('filename', $json['fake-file']); $this->assertArrayHasKey('move_path', $json['fake-file']); $this->assertArrayHasKey('lock_as', $json['fake-file']); - $this->assertEquals('archive', $json['fake-file']['source_type']); + $this->assertEquals(SPC_SOURCE_ARCHIVE, $json['fake-file']['source_type']); $this->assertEquals('fake-file-name', $json['fake-file']['filename']); $this->assertEquals('fake-path', $json['fake-file']['move_path']); $this->assertEquals('fake-lock-as', $json['fake-file']['lock_as']); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d573204b..c2fb6eee 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,5 +2,7 @@ declare(strict_types=1); +putenv('SPC_IGNORE_BAD_HASH=yes'); + require_once __DIR__ . '/../src/globals/internal-env.php'; require_once __DIR__ . '/mock/SPC_store.php'; From 0d3a80e58201a3e3c84c634e116a7113bc9fa298 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 16 Jun 2025 12:34:18 +0800 Subject: [PATCH 226/319] Define env in phpunit.xml --- phpunit.xml.dist | 5 ++++- tests/bootstrap.php | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9b045629..dc58130d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,4 +2,7 @@ - \ No newline at end of file + + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c2fb6eee..d573204b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,5 @@ declare(strict_types=1); -putenv('SPC_IGNORE_BAD_HASH=yes'); - require_once __DIR__ . '/../src/globals/internal-env.php'; require_once __DIR__ . '/mock/SPC_store.php'; From bafa67c8debbb6d2f5c3084d01b8ab173a979164 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 12:19:59 +0700 Subject: [PATCH 227/319] add patchelf to gnu docker --- bin/spc-gnu-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 36e0420e..b300d2cf 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -72,7 +72,7 @@ RUN yum update -y && \ yum install -y devtoolset-10-gcc-* RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc RUN source /etc/bashrc -RUN yum install -y which +RUN yum install -y which patchelf RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \ mkdir /cmake && \ From 7b3ea7e12ef43d605c9935de64762955c0da1777 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 12:30:11 +0700 Subject: [PATCH 228/319] fix installing patchelf --- bin/spc-gnu-docker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index b300d2cf..bc907e2a 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -72,7 +72,10 @@ RUN yum update -y && \ yum install -y devtoolset-10-gcc-* RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc RUN source /etc/bashrc -RUN yum install -y which patchelf +RUN yum install -y which + +RUN curl -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$BASE_ARCH.tar.gz && \ + tar -xzf patchelf.tgz -C /usr RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \ mkdir /cmake && \ From 9de5c621361ba2c634253a3858018e37c897a81f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 12:34:56 +0700 Subject: [PATCH 229/319] extract elsewhere temporarily --- bin/spc-gnu-docker | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index bc907e2a..b69e0710 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -74,8 +74,10 @@ RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc RUN source /etc/bashrc RUN yum install -y which -RUN curl -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$BASE_ARCH.tar.gz && \ - tar -xzf patchelf.tgz -C /usr +RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz && \ + mkdir -p /patchelf && \ + tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \ + cp /patchelf/bin/patchelf /usr/bin/ RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \ mkdir /cmake && \ From aa61a9e77b64937be70eb0a2747c19aa34881e31 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 14:01:53 +0700 Subject: [PATCH 230/319] extra info on ext load failure --- src/SPC/builder/Extension.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index d0448389..7a68ad09 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -264,9 +264,12 @@ class Extension // If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php // If check failed, throw RuntimeException $sharedExtensions = $this->getSharedExtensionLoadString(); - [$ret] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_BIN_PATH . '/php -n' . $sharedExtensions . ' --ri "' . $this->getDistName() . '"'); if ($ret !== 0) { - throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); + throw new RuntimeException( + 'extension ' . $this->getName() . ' failed runtime check: php-cli returned ' . $ret . "\n" . + join("\n", $out) + ); } if (file_exists(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php')) { From 883cc4b6fdde2d39b326adaa708256e97276fe4b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 15:53:14 +0700 Subject: [PATCH 231/319] patch on 2.17... --- src/SPC/store/SourcePatcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index d61020b8..11317314 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -454,7 +454,7 @@ class SourcePatcher public static function patchFfiCentos7FixO3strncmp(): bool { - if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() >= '2.17') { + if (PHP_OS_FAMILY !== 'Linux' || SystemUtil::getLibcVersionIfExists() > '2.17') { return false; } if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { From 3a85d96fa4fc252c4a79d6f72c3db0280ff7181f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 18:03:27 +0700 Subject: [PATCH 232/319] yet another damn centos 7 patch --- src/SPC/builder/Extension.php | 2 +- src/SPC/builder/extension/imagick.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 7a68ad09..4ea135a4 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -488,7 +488,7 @@ class Extension * * @return array [staticLibString, sharedLibString] */ - private function getStaticAndSharedLibs(): array + protected function getStaticAndSharedLibs(): array { $config = (new SPCConfigUtil($this->builder))->config([$this->getName()], with_dependencies: true); $sharedLibString = ''; diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index d78627ef..90af2c49 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -5,7 +5,9 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('imagick')] class imagick extends Extension @@ -29,4 +31,15 @@ class imagick extends Extension $disable_omp = !(getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) ? '' : ' ac_cv_func_omp_pause_resource_all=no'; return '--with-imagick=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH . $disable_omp; } + + protected function getStaticAndSharedLibs(): array + { + // on centos 7, it will use the symbol _ZTINSt6thread6_StateE, which is not defined in system libstdc++.so.6 + [$static, $shared] = parent::getStaticAndSharedLibs(); + if (getenv('SPC_LIBC') === 'glibc' && str_contains(getenv('CC'), 'devtoolset-10')) { + $static .= ' -lstdc++'; + $shared = str_replace('-lstdc++', '', $shared); + } + return [$static, $shared]; + } } From da75d2d707a82f921b60cac1ac3d28a450c51c3c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 17 Jun 2025 18:04:27 +0700 Subject: [PATCH 233/319] cs fix --- src/SPC/builder/extension/imagick.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index 90af2c49..7951ea69 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -5,9 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\store\FileSystem; use SPC\util\CustomExt; -use SPC\util\SPCConfigUtil; #[CustomExt('imagick')] class imagick extends Extension From 3a64feefd0ade9c3ce611055add2282fe3f99c48 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 11:34:51 +0800 Subject: [PATCH 234/319] Change test strategy for commit tests --- .github/pull_request_template.md | 12 ++- .github/workflows/commit-tests.yml | 137 ------------------------- .github/workflows/ext-matrix-tests.yml | 21 +++- 3 files changed, 24 insertions(+), 146 deletions(-) delete mode 100644 .github/workflows/commit-tests.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a7166ec2..07e7017b 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,7 +7,11 @@ > If your PR involves the changes mentioned below and completed the action, please tick the corresponding option. > If a modification is not involved, please skip it directly. -- [ ] If you modified `*.php`, run `composer cs-fix` at local machine. -- [ ] If it's an extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`. -- [ ] If you changed the behavior of static-php-cli, update docs in `./docs/`. -- [ ] If you updated `config/xxx.json` content, run `bin/spc dev:sort-config xxx`. +- If you modified `*.php` or `*.json`, run them locally to ensure your changes are valid: + - [ ] `PHP_CS_FIXER_IGNORE_ENV=1 composer cs-fix` + - [ ] `composer analyse` + - [ ] `composer test` + - [ ] `bin/spc dev:sort-config` +- If it's an extension or dependency update, please ensure the following: + - [ ] Add your test combination to `src/globals/test-extensions.php`. + - [ ] If adding new or fixing bugs, add commit message containing `fix` or `test` to trigger full test suite. diff --git a/.github/workflows/commit-tests.yml b/.github/workflows/commit-tests.yml deleted file mode 100644 index 3b5dbcc7..00000000 --- a/.github/workflows/commit-tests.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: Single Test -on: - push: - -permissions: read-all - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - parse-commit: - runs-on: ubuntu-latest - # if the commit message does not contain {craft} or {bash} tags, then skip the craft-test and bash-test jobs - if: github.event_name == 'push' && (contains(github.event.head_commit.message, '{craft}') || contains(github.event.head_commit.message, '{bash}')) - outputs: - skip_craft: ${{ steps.parse_commit.outputs.skip_craft }} - craft: ${{ steps.parse_commit.outputs.craft }} - skip_bash: ${{ steps.parse_commit.outputs.skip_bash }} - bash: ${{ steps.parse_commit.outputs.bash }} - build_os: ${{ steps.parse_commit.outputs.build_os }} - spc_prefix: ${{ steps.parse_commit.outputs.spc_prefix }} - steps: - - name: "Checkout" - uses: actions/checkout@v4 - - - name: "Parse commit message" - id: parse_commit - run: | - # parse the commit message, see if it has {craft} and {/craft} tags - COMMIT_MESSAGE=$(git log -1 --pretty=%B) - # judge it, it it's not exist, then skip this test - if [[ "$COMMIT_MESSAGE" != *"{craft}"* ]] || [[ "$COMMIT_MESSAGE" != *"{/craft}"* ]]; then - echo "No {craft} tags found in commit message. Skipping test." - echo "skip_craft=yes" >> $GITHUB_OUTPUT - exit 0 - else - echo -e "\e[32mCraft tags found in commit message.\e[0m" - # get the craft content - CRAFT_CONTENT=$(echo "$COMMIT_MESSAGE" | sed -nz 's/.*{craft}\(.*\){\/craft}.*/\1/p') - echo "Craft content: $CRAFT_CONTENT" - # set the output variable - echo "craft<> $GITHUB_OUTPUT - echo "$CRAFT_CONTENT" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - - # parse the bash test script from the commit message - if [[ "$COMMIT_MESSAGE" != *"{bash}"* ]] || [[ "$COMMIT_MESSAGE" != *"{/bash}"* ]]; then - echo "No {bash} tags found in commit message. Skipping bash test." - echo "skip_bash=yes" >> $GITHUB_OUTPUT - else - echo -e "\e[32mBash tags found in commit message.\e[0m" - # get the bash content - BASH_CONTENT=$(echo "$COMMIT_MESSAGE" | sed -nz 's/.*{bash}\(.*\){\/bash}.*/\1/p') - echo "Bash content: $BASH_CONTENT" - # set the output variable - echo "bash<> $GITHUB_OUTPUT - echo "$BASH_CONTENT" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - fi - - # parse spc_prefix from commit message, e.g. [spc_prefix:bin/spc-gnu-docker], default: bin/spc - if [[ "$COMMIT_MESSAGE" =~ \[spc_prefix:([^\]]+)\] ]]; then - SPC_PREFIX=${BASH_REMATCH[1]} - echo "SPC prefix found: $SPC_PREFIX" - else - SPC_PREFIX="bin/spc" - echo "No SPC prefix found, using default: $SPC_PREFIX" - fi - echo "spc_prefix=$SPC_PREFIX" >> $GITHUB_OUTPUT - - # parse build_os from commit message, e.g. [build_os:ubuntu-latest], default: ubuntu-latest - if [[ "$COMMIT_MESSAGE" =~ \[build_os:([^\]]+)\] ]]; then - BUILD_OS=${BASH_REMATCH[1]} - echo "Build OS found: $BUILD_OS" - else - BUILD_OS="ubuntu-latest" - echo "No Build OS found, using default: $BUILD_OS" - fi - echo "build_os=$BUILD_OS" >> $GITHUB_OUTPUT - - craft-test: - needs: parse-commit - if: needs.parse-commit.outputs.skip_craft != 'yes' - runs-on: ${{ needs.parse-commit.outputs.build_os }} - steps: - - name: "Checkout" - uses: actions/checkout@v4 - - - name: "Setup PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: '8.4' - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 - tools: composer - - - name: "Install Dependencies" - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - - name: "Doctor" - run: ${{ needs.parse-commit.outputs.spc_prefix }} doctor --auto-fix --debug - - - name: "Run Craft Test" - run: | - echo "Running craft test with content:" - echo "${{ needs.parse-commit.outputs.craft }}" - echo "${{ needs.parse-commit.outputs.craft }}" > craft.yml - ${{ needs.parse-commit.outputs.spc_prefix }} craft --debug - - bash-test: - needs: parse-commit - if: needs.parse-commit.outputs.skip_bash != 'yes' - runs-on: ${{ needs.parse-commit.outputs.build_os }} - steps: - - name: "Checkout" - uses: actions/checkout@v4 - - - name: "Setup PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: '8.4' - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 - tools: composer - - - name: "Install Dependencies" - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - - name: "Doctor" - run: ${{ needs.parse-commit.outputs.spc_prefix }} doctor --auto-fix --debug - - - name: "Run Bash Test" - run: | - echo "Running bash test with content:" - echo "${{ needs.parse-commit.outputs.bash }}" - echo "${{ needs.parse-commit.outputs.bash }}" | bash diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index da30d008..dc5de0d9 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -1,16 +1,27 @@ name: "Extension matrix tests" + +# Only run if: +# - the workflow is manually triggered +# - or a pull request is made to the main branch that modifies this workflow file or commit message contains "fix" or "test" on: - workflow_dispatch: - pull_request: - branches: [ "main" ] - paths: - - '.github/workflows/ext-matrix-tests.yml' + workflow_dispatch: + pull_request: + branches: [ "main" ] + paths: + - '.github/workflows/ext-matrix-tests.yml' + - 'src/**' + - 'config/**' + - 'bin/**' + - 'composer.json' + - 'box.json' + - '.php-cs-fixer.php' jobs: test: name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" runs-on: ${{ matrix.operating-system }} + if: contains(github.event.head_commit.message, 'fix') || contains(github.event.head_commit.message, 'test') strategy: fail-fast: false matrix: From 68548cf248ac2f4011c9da0fbe0afbfe3eab7dd0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 11:42:32 +0800 Subject: [PATCH 235/319] Wrap it to test test test --- .github/workflows/ext-matrix-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index dc5de0d9..ae7388a9 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -21,7 +21,7 @@ jobs: test: name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" runs-on: ${{ matrix.operating-system }} - if: contains(github.event.head_commit.message, 'fix') || contains(github.event.head_commit.message, 'test') + if: ${{ contains(github.event.head_commit.message, 'fix') || contains(github.event.head_commit.message, 'test') }} strategy: fail-fast: false matrix: From 2bfc8e92ef5a5805cadaf0e8d9109b3bb6a39235 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 11:49:42 +0800 Subject: [PATCH 236/319] Test test --- .github/workflows/ext-matrix-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index ae7388a9..7efb6e3b 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -21,7 +21,7 @@ jobs: test: name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" runs-on: ${{ matrix.operating-system }} - if: ${{ contains(github.event.head_commit.message, 'fix') || contains(github.event.head_commit.message, 'test') }} + if: github.event_name == 'push' && (contains(github.event.head_commit.message, 'fix') || contains(github.event.head_commit.message, 'test')) strategy: fail-fast: false matrix: From cb0a90d1d9b403114c2cda9243b6981faa55ea2d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 14 Jun 2025 16:09:48 +0800 Subject: [PATCH 237/319] Add source hash comparator & refactor download lock --- tests/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d573204b..c2fb6eee 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,5 +2,7 @@ declare(strict_types=1); +putenv('SPC_IGNORE_BAD_HASH=yes'); + require_once __DIR__ . '/../src/globals/internal-env.php'; require_once __DIR__ . '/mock/SPC_store.php'; From 57b22782d35b35b72ad574c4b045d966462e4287 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 16 Jun 2025 12:34:18 +0800 Subject: [PATCH 238/319] Define env in phpunit.xml --- tests/bootstrap.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c2fb6eee..d573204b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,5 @@ declare(strict_types=1); -putenv('SPC_IGNORE_BAD_HASH=yes'); - require_once __DIR__ . '/../src/globals/internal-env.php'; require_once __DIR__ . '/mock/SPC_store.php'; From 5cb107b844322de5cf1b953cf6ab230900dcdf5c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 11:53:17 +0800 Subject: [PATCH 239/319] Test test --- .github/workflows/ext-matrix-tests.yml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index 7efb6e3b..ae164094 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -1,27 +1,14 @@ name: "Extension matrix tests" - -# Only run if: -# - the workflow is manually triggered -# - or a pull request is made to the main branch that modifies this workflow file or commit message contains "fix" or "test" on: - workflow_dispatch: - pull_request: - branches: [ "main" ] - paths: - - '.github/workflows/ext-matrix-tests.yml' - - 'src/**' - - 'config/**' - - 'bin/**' - - 'composer.json' - - 'box.json' - - '.php-cs-fixer.php' + workflow_dispatch: + push: jobs: test: name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" runs-on: ${{ matrix.operating-system }} - if: github.event_name == 'push' && (contains(github.event.head_commit.message, 'fix') || contains(github.event.head_commit.message, 'test')) + if: contains(github.event.head_commit.message, 'extension test') strategy: fail-fast: false matrix: From 7057a135cf7db382b225fd2139ecb8a64912622d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 11:54:10 +0800 Subject: [PATCH 240/319] Trigger extension test --- .github/workflows/ext-matrix-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index ae164094..265c8b2e 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -1,4 +1,4 @@ -name: "Extension matrix tests" +name: "Extension Matrix Tests" on: workflow_dispatch: From 71783088c05335e58249079f23cf49d19ed90f90 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 11:55:13 +0800 Subject: [PATCH 241/319] Use new trigger test message --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 07e7017b..c1d4eb16 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -14,4 +14,4 @@ - [ ] `bin/spc dev:sort-config` - If it's an extension or dependency update, please ensure the following: - [ ] Add your test combination to `src/globals/test-extensions.php`. - - [ ] If adding new or fixing bugs, add commit message containing `fix` or `test` to trigger full test suite. + - [ ] If adding new or fixing bugs, add commit message containing `extension test` to trigger full test suite. From c1870af1b1a24be25d8f982cc7d9961aa8cce582 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 10:48:09 +0700 Subject: [PATCH 242/319] add frankenphp sapi --- config/env.ini | 3 + src/SPC/builder/linux/LinuxBuilder.php | 5 ++ src/SPC/builder/traits/UnixGoCheckTrait.php | 83 +++++++++++++++++++++ src/SPC/builder/unix/UnixBuilderBase.php | 30 ++++++++ src/SPC/command/BuildPHPCommand.php | 5 +- src/SPC/doctor/AsCheckItem.php | 3 +- src/SPC/doctor/item/BSDToolCheckList.php | 6 ++ src/SPC/doctor/item/LinuxToolCheckList.php | 8 ++ src/SPC/doctor/item/MacOSToolCheckList.php | 8 ++ src/globals/defines.php | 3 +- 10 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 src/SPC/builder/traits/UnixGoCheckTrait.php diff --git a/config/env.ini b/config/env.ini index ba8652d5..112d0187 100644 --- a/config/env.ini +++ b/config/env.ini @@ -42,6 +42,9 @@ SPC_CONCURRENCY=${CPU_COUNT} SPC_SKIP_PHP_VERSION_CHECK="no" ; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed") SPC_SKIP_DOCTOR_CHECK_ITEMS="" +; extra modules that xcaddy will include in the FrankenPHP build +SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" + ; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them ; only useful for builds targeting not pure-static linking ; default paths diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 315d7df9..fc131214 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -114,6 +114,7 @@ class LinuxBuilder extends UnixBuilderBase $enable_fpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enable_embed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $enable_frankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; // prepare build php envs @@ -175,6 +176,10 @@ class LinuxBuilder extends UnixBuilderBase } $this->buildEmbed(); } + if ($enable_frankenphp) { + logger()->info('building frankenphp'); + $this->buildFrankenphp(); + } } public function testPHP(int $build_target = BUILD_TARGET_NONE) diff --git a/src/SPC/builder/traits/UnixGoCheckTrait.php b/src/SPC/builder/traits/UnixGoCheckTrait.php new file mode 100644 index 00000000..12e3d005 --- /dev/null +++ b/src/SPC/builder/traits/UnixGoCheckTrait.php @@ -0,0 +1,83 @@ +findCommand('go', $paths) === null) { + $this->installGo(); + } + + $gobin = getenv('GOBIN') ?: (getenv('HOME') . '/go/bin'); + putenv("GOBIN={$gobin}"); + + $paths[] = $gobin; + + if ($this->findCommand('xcaddy', $paths) === null) { + shell(true)->exec('go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest'); + } + + return CheckResult::ok(); + } + + private function installGo(): bool + { + $prefix = ''; + if (get_current_user() !== 'root') { + $prefix = 'sudo '; + logger()->warning('Current user is not root, using sudo for running command'); + } + + $arch = php_uname('m'); + $go_arch = match ($arch) { + 'x86_64' => 'amd64', + 'aarch64' => 'arm64', + default => $arch + }; + $os = strtolower(PHP_OS_FAMILY); + + $go_version = '1.24.4'; + $go_filename = "go{$go_version}.{$os}-{$go_arch}.tar.gz"; + $go_url = "https://go.dev/dl/{$go_filename}"; + + logger()->info("Downloading Go {$go_version} for {$go_arch}"); + + try { + // Download Go binary + Downloader::downloadFile('go', $go_url, $go_filename); + + // Extract the tarball + FileSystem::extractSource('go', SPC_SOURCE_ARCHIVE, DOWNLOAD_PATH . "/{$go_filename}"); + + // Move to /usr/local/go + logger()->info('Installing Go to /usr/local/go'); + shell()->exec("{$prefix}rm -rf /usr/local/go"); + shell()->exec("{$prefix}mv " . SOURCE_PATH . '/go /usr/local/'); + + if (!str_contains(getenv('PATH'), '/usr/local/go/bin')) { + logger()->info('Adding Go to PATH'); + shell()->exec("{$prefix}echo 'export PATH=\$PATH:/usr/local/go/bin' >> /etc/profile"); + putenv('PATH=' . getenv('PATH') . ':/usr/local/go/bin'); + } + + logger()->info('Go has been installed successfully'); + return true; + } catch (RuntimeException $e) { + logger()->error('Failed to install Go: ' . $e->getMessage()); + return false; + } + } +} diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 0d367de1..19880bf1 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -277,4 +277,34 @@ abstract class UnixBuilderBase extends BuilderBase FileSystem::writeFile(BUILD_BIN_PATH . '/php-config', $php_config_str); } } + + protected function buildFrankenphp(): void + { + $path = getenv('PATH'); + $xcaddyPath = getenv('GOBIN') ?: (getenv('HOME') . '/go/bin'); + if (!str_contains($path, $xcaddyPath)) { + $path = $path . ':' . $xcaddyPath; + } + $path = BUILD_BIN_PATH . ':' . $path; + f_putenv("PATH={$path}"); + + $brotliLibs = $this->getLib('brotli') !== null ? '-lbrotlienc -lbrotlidec -lbrotlicommon' : ''; + $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; + $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; + + $env = [ + 'CGO_ENABLED' => '1', + 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', + 'CGO_LDFLAGS' => "$(php-config --ldflags) $(php-config --libs) {$brotliLibs} -lwatcher-c -lphp -Wl,-rpath=" . BUILD_LIB_PATH, + 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" . $nobrotli . $nowatcher, + ]; + shell()->cd(BUILD_BIN_PATH) + ->setEnv($env) + ->exec( + 'xcaddy build ' . + '--output frankenphp ' . + '--with github.com/dunglas/frankenphp/caddy ' . + getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES') + ); + } } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 353605b1..0ef9dab3 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -33,6 +33,7 @@ class BuildPHPCommand extends BuildCommand $this->addOption('build-cli', null, null, 'Build cli SAPI'); $this->addOption('build-fpm', null, null, 'Build fpm SAPI (not available on Windows)'); $this->addOption('build-embed', null, null, 'Build embed SAPI (not available on Windows)'); + $this->addOption('build-frankenphp', null, null, 'Build FrankenPHP SAPI (not available on Windows)'); $this->addOption('build-all', null, null, 'Build all SAPI'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); @@ -83,7 +84,8 @@ class BuildPHPCommand extends BuildCommand $this->output->writeln("\t--build-micro\tBuild phpmicro SAPI"); $this->output->writeln("\t--build-fpm\tBuild php-fpm SAPI"); $this->output->writeln("\t--build-embed\tBuild embed SAPI/libphp"); - $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm, embed"); + $this->output->writeln("\t--build-frankenphp\tBuild FrankenPHP SAPI/libphp"); + $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm, embed, frankenphp"); return static::FAILURE; } if ($rule === BUILD_TARGET_ALL) { @@ -304,6 +306,7 @@ class BuildPHPCommand extends BuildCommand $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-embed') || !empty($shared_extensions) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-frankenphp') || !empty($shared_extensions) ? BUILD_TARGET_FRANKENPHP : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; } diff --git a/src/SPC/doctor/AsCheckItem.php b/src/SPC/doctor/AsCheckItem.php index f64d914b..0417bcfa 100644 --- a/src/SPC/doctor/AsCheckItem.php +++ b/src/SPC/doctor/AsCheckItem.php @@ -14,5 +14,6 @@ class AsCheckItem public ?string $limit_os = null, public int $level = 100, public bool $manual = false, - ) {} + ) { + } } diff --git a/src/SPC/doctor/item/BSDToolCheckList.php b/src/SPC/doctor/item/BSDToolCheckList.php index 2505227b..97f0ccf9 100644 --- a/src/SPC/doctor/item/BSDToolCheckList.php +++ b/src/SPC/doctor/item/BSDToolCheckList.php @@ -47,6 +47,12 @@ class BSDToolCheckList return CheckResult::ok(); } + #[AsCheckItem('if xcaddy is installed', limit_os: 'BSD')] + public function checkXcaddy(): ?CheckResult + { + return $this->checkGoAndXcaddy(); + } + #[AsFixItem('build-tools-bsd')] public function fixBuildTools(array $missing): bool { diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 56235b0c..07f6b5fb 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\doctor\item; use SPC\builder\linux\SystemUtil; +use SPC\builder\traits\UnixGoCheckTrait; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; @@ -14,6 +15,7 @@ use SPC\exception\RuntimeException; class LinuxToolCheckList { use UnixSystemUtilTrait; + use UnixGoCheckTrait; public const TOOLS_ALPINE = [ 'make', 'bison', 'flex', @@ -87,6 +89,12 @@ class LinuxToolCheckList return CheckResult::ok(); } + #[AsCheckItem('if xcaddy is installed', limit_os: 'Linux')] + public function checkXcaddy(): ?CheckResult + { + return $this->checkGoAndXcaddy(); + } + #[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')] public function checkCMakeVersion(): ?CheckResult { diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index b4043a1d..57ba8157 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\doctor\item; +use SPC\builder\traits\UnixGoCheckTrait; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; @@ -13,6 +14,7 @@ use SPC\exception\RuntimeException; class MacOSToolCheckList { use UnixSystemUtilTrait; + use UnixGoCheckTrait; /** @var string[] MacOS 环境下编译依赖的命令 */ public const REQUIRED_COMMANDS = [ @@ -34,6 +36,12 @@ class MacOSToolCheckList 'glibtoolize', ]; + #[AsCheckItem('if xcaddy is installed', limit_os: 'Darwin')] + public function checkXcaddy(): ?CheckResult + { + return $this->checkGoAndXcaddy(); + } + #[AsCheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)] public function checkBrew(): ?CheckResult { diff --git a/src/globals/defines.php b/src/globals/defines.php index eab2fcc4..aebd4d5f 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -62,7 +62,8 @@ const BUILD_TARGET_CLI = 1; // build cli const BUILD_TARGET_MICRO = 2; // build micro const BUILD_TARGET_FPM = 4; // build fpm const BUILD_TARGET_EMBED = 8; // build embed -const BUILD_TARGET_ALL = 15; // build all +const BUILD_TARGET_FRANKENPHP = BUILD_TARGET_EMBED | 16; // build frankenphp +const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP; // build all // doctor error fix policy const FIX_POLICY_DIE = 1; // die directly From f64eb0dea5e3ee609de49d7127aa5c5c0297c752 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:20:05 +0700 Subject: [PATCH 243/319] build for bsd and macos too --- src/SPC/builder/freebsd/BSDBuilder.php | 5 ++++ src/SPC/builder/linux/LinuxBuilder.php | 32 +++++++++++++------------- src/SPC/builder/macos/MacOSBuilder.php | 5 ++++ src/SPC/command/BuildPHPCommand.php | 2 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 04fd43d3..65ebea57 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -96,6 +96,7 @@ class BSDBuilder extends UnixBuilderBase $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; shell()->cd(SOURCE_PATH . '/php-src') ->exec( @@ -143,6 +144,10 @@ class BSDBuilder extends UnixBuilderBase } $this->buildEmbed(); } + if ($enableFrankenphp) { + logger()->info('building frankenphp'); + $this->buildFrankenphp(); + } } public function testPHP(int $build_target = BUILD_TARGET_NONE) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index fc131214..addd2f57 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -110,11 +110,11 @@ class LinuxBuilder extends UnixBuilderBase $config_file_scan_dir = $this->getOption('with-config-file-scan-dir', false) ? ('--with-config-file-scan-dir=' . $this->getOption('with-config-file-scan-dir') . ' ') : ''; - $enable_cli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; - $enable_fpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; - $enable_micro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; - $enable_embed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; - $enable_frankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; + $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; + $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; + $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; + $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; // prepare build php envs @@ -126,7 +126,7 @@ class LinuxBuilder extends UnixBuilderBase ]); // process micro upx patch if micro sapi enabled - if ($enable_micro) { + if ($enableMicro) { if (version_compare($this->getMicroVersion(), '0.2.0') < 0) { // for phpmicro 0.1.x $this->processMicroUPXLegacy(); @@ -138,10 +138,10 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . - ($enable_cli ? '--enable-cli ' : '--disable-cli ') . - ($enable_fpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') . - ($enable_embed ? "--enable-embed={$embed_type} " : '--disable-embed ') . - ($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') . + ($enableCli ? '--enable-cli ' : '--disable-cli ') . + ($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') . + ($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') . + ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . $config_file_path . $config_file_scan_dir . $disable_jit . @@ -157,26 +157,26 @@ class LinuxBuilder extends UnixBuilderBase $this->cleanMake(); - if ($enable_cli) { + if ($enableCli) { logger()->info('building cli'); $this->buildCli(); } - if ($enable_fpm) { + if ($enableFpm) { logger()->info('building fpm'); $this->buildFpm(); } - if ($enable_micro) { + if ($enableMicro) { logger()->info('building micro'); $this->buildMicro(); } - if ($enable_embed) { + if ($enableEmbed) { logger()->info('building embed'); - if ($enable_micro) { + if ($enableMicro) { FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); } $this->buildEmbed(); } - if ($enable_frankenphp) { + if ($enableFrankenphp) { logger()->info('building frankenphp'); $this->buildFrankenphp(); } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index a0522120..153da08c 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -122,6 +122,7 @@ class MacOSBuilder extends UnixBuilderBase $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + $enableFrankenphp = ($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP; // prepare build php envs $mimallocLibs = $this->getLib('mimalloc') !== null ? BUILD_LIB_PATH . '/mimalloc.o ' : ''; @@ -180,6 +181,10 @@ class MacOSBuilder extends UnixBuilderBase } $this->buildEmbed(); } + if ($enableFrankenphp) { + logger()->info('building frankenphp'); + $this->buildFrankenphp(); + } } public function testPHP(int $build_target = BUILD_TARGET_NONE) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 0ef9dab3..96a93653 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -306,7 +306,7 @@ class BuildPHPCommand extends BuildCommand $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-embed') || !empty($shared_extensions) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); - $rule |= ($this->getOption('build-frankenphp') || !empty($shared_extensions) ? BUILD_TARGET_FRANKENPHP : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-frankenphp') ? BUILD_TARGET_FRANKENPHP : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; } From c1e68323c70e412c286650fe76d0c7e6eddd85de Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:21:50 +0700 Subject: [PATCH 244/319] cs fix --- src/SPC/doctor/AsCheckItem.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/doctor/AsCheckItem.php b/src/SPC/doctor/AsCheckItem.php index 0417bcfa..f64d914b 100644 --- a/src/SPC/doctor/AsCheckItem.php +++ b/src/SPC/doctor/AsCheckItem.php @@ -14,6 +14,5 @@ class AsCheckItem public ?string $limit_os = null, public int $level = 100, public bool $manual = false, - ) { - } + ) {} } From 92338d478e470d34d1fc63b5039513799f650b2e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:30:04 +0700 Subject: [PATCH 245/319] don't bake the rpath in, otherwise we might run into issues when loading frankenphp after compiling a different version --- src/SPC/builder/unix/UnixBuilderBase.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 19880bf1..666c09c8 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -289,14 +289,16 @@ abstract class UnixBuilderBase extends BuilderBase f_putenv("PATH={$path}"); $brotliLibs = $this->getLib('brotli') !== null ? '-lbrotlienc -lbrotlidec -lbrotlicommon' : ''; + $watcherLibs = $this->getLib('brotli') !== null ? '-lwatcher-c' : ''; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $env = [ 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', - 'CGO_LDFLAGS' => "$(php-config --ldflags) $(php-config --libs) {$brotliLibs} -lwatcher-c -lphp -Wl,-rpath=" . BUILD_LIB_PATH, + 'CGO_LDFLAGS' => "$(php-config --ldflags) $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp", 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" . $nobrotli . $nowatcher, + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; shell()->cd(BUILD_BIN_PATH) ->setEnv($env) From c46f8513dd15b8bda79ae7651417ff46dfcace73 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:34:05 +0700 Subject: [PATCH 246/319] watcher... --- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 666c09c8..4ef2502b 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -289,7 +289,7 @@ abstract class UnixBuilderBase extends BuilderBase f_putenv("PATH={$path}"); $brotliLibs = $this->getLib('brotli') !== null ? '-lbrotlienc -lbrotlidec -lbrotlicommon' : ''; - $watcherLibs = $this->getLib('brotli') !== null ? '-lwatcher-c' : ''; + $watcherLibs = $this->getLib('watcher') !== null ? '-lwatcher-c' : ''; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; From abf3bfb98e8acf1ed6b5cd8afc2d4236697ad641 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:36:58 +0700 Subject: [PATCH 247/319] suggest watcher --- config/lib.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index dc792c3b..ba76f4a9 100644 --- a/config/lib.json +++ b/config/lib.json @@ -12,8 +12,12 @@ "lib-base", "micro" ], + "lib-suggests-unix": [ + "watcher" + ], "lib-suggests-linux": [ - "libacl" + "libacl", + "watcher" ] }, "micro": { From dca43d6d8d3d7a24cc85d9f9cdded0a0590ec327 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:39:22 +0700 Subject: [PATCH 248/319] nicer escaping --- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 4ef2502b..39ea69ec 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -297,7 +297,7 @@ abstract class UnixBuilderBase extends BuilderBase 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', 'CGO_LDFLAGS' => "$(php-config --ldflags) $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp", - 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx" . $nobrotli . $nowatcher, + 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; shell()->cd(BUILD_BIN_PATH) From d635b10e248a9c6adc1ec36d70c970333ac4e807 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:47:05 +0700 Subject: [PATCH 249/319] specify system gcc to build xcaddy in spc-gnu-docker --- bin/spc-gnu-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index b69e0710..9583b4dd 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -94,7 +94,7 @@ ENV PATH="/app/bin:/cmake/bin:$PATH" ENV SPC_LIBC=glibc ADD ./config/env.ini /app/config/env.ini -RUN bin/spc doctor --auto-fix --debug +RUN CC=gcc bin/spc doctor --auto-fix --debug RUN curl -o make.tgz -fsSL https://ftp.gnu.org/gnu/make/make-4.4.tar.gz && \ tar -zxvf make.tgz && \ From d094824d76132a6de6c23a82f02416aafa63a492 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 11:54:03 +0700 Subject: [PATCH 250/319] --with github.com/dunglas/caddy-cbrotli requires brotli --- config/env.ini | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config/env.ini b/config/env.ini index 112d0187..03e07b47 100644 --- a/config/env.ini +++ b/config/env.ini @@ -43,7 +43,7 @@ SPC_SKIP_PHP_VERSION_CHECK="no" ; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed") SPC_SKIP_DOCTOR_CHECK_ITEMS="" ; extra modules that xcaddy will include in the FrankenPHP build -SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" +SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy" ; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them ; only useful for builds targeting not pure-static linking diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 39ea69ec..ac493b73 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -292,6 +292,10 @@ abstract class UnixBuilderBase extends BuilderBase $watcherLibs = $this->getLib('watcher') !== null ? '-lwatcher-c' : ''; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; + $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); + if ($this->getLib('brotli') !== null && !str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { + $xcaddyModules .= ' --with github.com/dunglas/caddy-cbrotli'; + } $env = [ 'CGO_ENABLED' => '1', @@ -302,11 +306,6 @@ abstract class UnixBuilderBase extends BuilderBase ]; shell()->cd(BUILD_BIN_PATH) ->setEnv($env) - ->exec( - 'xcaddy build ' . - '--output frankenphp ' . - '--with github.com/dunglas/frankenphp/caddy ' . - getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES') - ); + ->exec('xcaddy build --output frankenphp --with github.com/dunglas/frankenphp/caddy ' . $xcaddyModules); } } From e71f76288b21ace475673ad29313e63fabf7b335 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 12:02:37 +0700 Subject: [PATCH 251/319] support building static frankenphp --- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index ac493b73..92ee2518 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -300,7 +300,7 @@ abstract class UnixBuilderBase extends BuilderBase $env = [ 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', - 'CGO_LDFLAGS' => "$(php-config --ldflags) $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp", + 'CGO_LDFLAGS' => '$(php-config --ldflags) -L' . BUILD_LIB_PATH . " $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp -lrt", 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; From f37c863092804eb5fc57528e23fa0ca9f4948802 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 12:04:01 +0700 Subject: [PATCH 252/319] only needed on linux --- src/SPC/builder/unix/UnixBuilderBase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 92ee2518..83de392c 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -296,11 +296,12 @@ abstract class UnixBuilderBase extends BuilderBase if ($this->getLib('brotli') !== null && !str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { $xcaddyModules .= ' --with github.com/dunglas/caddy-cbrotli'; } + $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; $env = [ 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', - 'CGO_LDFLAGS' => '$(php-config --ldflags) -L' . BUILD_LIB_PATH . " $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp -lrt", + 'CGO_LDFLAGS' => '$(php-config --ldflags) -L' . BUILD_LIB_PATH . " $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp {$lrt}", 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; From d58534b07d70e4d388f39961d66ec03e470882fe Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 12:19:33 +0700 Subject: [PATCH 253/319] add support for frankenphp directory from file system, instead of pulling latest xcaddy module --- config/env.ini | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/config/env.ini b/config/env.ini index 03e07b47..7acc8730 100644 --- a/config/env.ini +++ b/config/env.ini @@ -43,7 +43,7 @@ SPC_SKIP_PHP_VERSION_CHECK="no" ; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed") SPC_SKIP_DOCTOR_CHECK_ITEMS="" ; extra modules that xcaddy will include in the FrankenPHP build -SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy" +SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" ; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them ; only useful for builds targeting not pure-static linking diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 83de392c..758efaa6 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -293,8 +293,13 @@ abstract class UnixBuilderBase extends BuilderBase $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); - if ($this->getLib('brotli') !== null && !str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { - $xcaddyModules .= ' --with github.com/dunglas/caddy-cbrotli'; + // make it possible to build from a different frankenphp directory! + if (!str_contains($xcaddyModules, '--with github.com/dunglas/frankenphp')) { + $xcaddyModules = '--with github.com/dunglas/frankenphp ' . $xcaddyModules; + } + if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { + logger()->warning('caddy-cbrotli module is enabled, but broli library is not built. Disabling caddy-cbrotli.'); + $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); } $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; @@ -307,6 +312,6 @@ abstract class UnixBuilderBase extends BuilderBase ]; shell()->cd(BUILD_BIN_PATH) ->setEnv($env) - ->exec('xcaddy build --output frankenphp --with github.com/dunglas/frankenphp/caddy ' . $xcaddyModules); + ->exec('xcaddy build --output frankenphp ' . $xcaddyModules); } } From 82ee6f0dee53815f09f258c7f4c92feaae26a428 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 12:35:48 +0700 Subject: [PATCH 254/319] allow specifying if we want to build embed shared or static --- src/SPC/command/BuildPHPCommand.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 96a93653..72d6a686 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -32,7 +32,7 @@ class BuildPHPCommand extends BuildCommand $this->addOption('build-micro', null, null, 'Build micro SAPI'); $this->addOption('build-cli', null, null, 'Build cli SAPI'); $this->addOption('build-fpm', null, null, 'Build fpm SAPI (not available on Windows)'); - $this->addOption('build-embed', null, null, 'Build embed SAPI (not available on Windows)'); + $this->addOption('build-embed', null, InputOption::VALUE_OPTIONAL, 'Build embed SAPI (not available on Windows)'); $this->addOption('build-frankenphp', null, null, 'Build FrankenPHP SAPI (not available on Windows)'); $this->addOption('build-all', null, null, 'Build all SAPI'); $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); @@ -305,7 +305,17 @@ class BuildPHPCommand extends BuildCommand $rule |= ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); - $rule |= ($this->getOption('build-embed') || !empty($shared_extensions) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); + $embed = $this->getOption('build-embed'); + if (!$embed && !empty($shared_extensions)) { + $embed = true; + } + if ($embed) { + if ($embed === true) { + $embed = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static'; + } + $rule |= BUILD_TARGET_EMBED; + f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared')); + } $rule |= ($this->getOption('build-frankenphp') ? BUILD_TARGET_FRANKENPHP : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; From a1e76d9d02e928cca769743e8e63828ca475f742 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 12:41:27 +0700 Subject: [PATCH 255/319] remove watcher suggestion --- config/lib.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/config/lib.json b/config/lib.json index ba76f4a9..dc792c3b 100644 --- a/config/lib.json +++ b/config/lib.json @@ -12,12 +12,8 @@ "lib-base", "micro" ], - "lib-suggests-unix": [ - "watcher" - ], "lib-suggests-linux": [ - "libacl", - "watcher" + "libacl" ] }, "micro": { From 8c6a708764912a7897607a82021f046b23e8725c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 12:46:05 +0700 Subject: [PATCH 256/319] ah, the infamous arm64 bug with -fpic vs -fPIC it's a bit slower, but oh well --- config/env.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/env.ini b/config/env.ini index ba8652d5..d6217f5f 100644 --- a/config/env.ini +++ b/config/env.ini @@ -68,8 +68,8 @@ CXX=${SPC_LINUX_DEFAULT_CXX} AR=${SPC_LINUX_DEFAULT_AR} LD=ld.gold ; default compiler flags, used in CMake toolchain file, openssl and pkg-config build -SPC_DEFAULT_C_FLAGS="-fpic -Os" -SPC_DEFAULT_CXX_FLAGS="-fpic -Os" +SPC_DEFAULT_C_FLAGS="-fPIC -Os" +SPC_DEFAULT_CXX_FLAGS="-fPIC -Os" ; extra libs for building php executable, used in `make` command for building php (this value may changed by extension build process, space separated) SPC_EXTRA_LIBS= ; upx executable path @@ -89,7 +89,7 @@ SPC_CMD_VAR_PHP_EMBED_TYPE="static" ; *** default build vars for building php *** ; CFLAGS for configuring php -SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fpie" +SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS="${SPC_DEFAULT_C_FLAGS} -fPIE" ; CPPFLAGS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS="-I${BUILD_INCLUDE_PATH}" ; LDFLAGS for configuring php @@ -97,7 +97,7 @@ SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS="-L${BUILD_LIB_PATH}" ; LIBS for configuring php SPC_CMD_VAR_PHP_CONFIGURE_LIBS="-ldl -lpthread -lm" ; EXTRA_CFLAGS for `make` php -SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fpie ${SPC_DEFAULT_C_FLAGS}" +SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS="-g -fstack-protector-strong -fno-ident -fPIE ${SPC_DEFAULT_C_FLAGS}" ; EXTRA_LIBS for `make` php SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm" ; EXTRA_LDFLAGS for `make` php, can use -release to set a soname for libphp.so From ba0ea5b40af810726a615dde1786c118927bb1bc Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 18 Jun 2025 14:05:43 +0800 Subject: [PATCH 257/319] Refactor lock component to a single class (#773) --- src/SPC/builder/BuilderBase.php | 11 +- src/SPC/builder/LibraryBase.php | 6 +- src/SPC/command/DeleteDownloadCommand.php | 14 +- src/SPC/command/SwitchPhpVersionCommand.php | 12 +- src/SPC/command/dev/PackLibCommand.php | 4 +- src/SPC/store/Downloader.php | 103 ++------- src/SPC/store/LockFile.php | 227 ++++++++++++++++++++ src/SPC/store/PackageManager.php | 9 +- src/SPC/store/SourceManager.php | 42 ++-- tests/SPC/store/DownloaderTest.php | 3 +- 10 files changed, 284 insertions(+), 147 deletions(-) create mode 100644 src/SPC/store/LockFile.php diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 7fc78e44..e9caabfc 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -12,6 +12,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; +use SPC\store\LockFile; use SPC\store\SourceManager; use SPC\util\CustomExt; @@ -350,15 +351,11 @@ abstract class BuilderBase public function getPHPVersionFromArchive(?string $file = null): false|string { if ($file === null) { - $lock = file_exists(DOWNLOAD_PATH . '/.lock.json') ? file_get_contents(DOWNLOAD_PATH . '/.lock.json') : false; - if ($lock === false) { - return false; - } - $lock = json_decode($lock, true); - $file = $lock['php-src']['filename'] ?? null; - if ($file === null) { + $lock = LockFile::get('php-src'); + if ($lock === null) { return false; } + $file = LockFile::getLockFullPath($lock); } if (preg_match('/php-(\d+\.\d+\.\d+(?:RC\d+)?)\.tar\.(?:gz|bz2|xz)/', $file, $match)) { return $match[1]; diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index ac2d8c5c..a130e8a8 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -10,6 +10,7 @@ use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\Downloader; use SPC\store\FileSystem; +use SPC\store\LockFile; use SPC\store\SourceManager; use SPC\util\GlobalValueTrait; @@ -46,12 +47,11 @@ abstract class LibraryBase */ public function setup(bool $force = false): int { - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; $source = Config::getLib(static::NAME, 'source'); // if source is locked as pre-built, we just tryInstall it $pre_built_name = Downloader::getPreBuiltLockName($source); - if (isset($lock[$pre_built_name]) && ($lock[$pre_built_name]['lock_as'] ?? SPC_DOWNLOAD_SOURCE) === SPC_DOWNLOAD_PRE_BUILT) { - return $this->tryInstall($lock[$pre_built_name], $force); + if (($lock = LockFile::get($pre_built_name)) && $lock['lock_as'] === SPC_DOWNLOAD_PRE_BUILT) { + return $this->tryInstall($lock, $force); } return $this->tryBuild($force); } diff --git a/src/SPC/command/DeleteDownloadCommand.php b/src/SPC/command/DeleteDownloadCommand.php index 12b0b420..0306de4c 100644 --- a/src/SPC/command/DeleteDownloadCommand.php +++ b/src/SPC/command/DeleteDownloadCommand.php @@ -9,6 +9,7 @@ use SPC\exception\FileSystemException; use SPC\exception\WrongUsageException; use SPC\store\Downloader; use SPC\store\FileSystem; +use SPC\store\LockFile; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -46,29 +47,29 @@ class DeleteDownloadCommand extends BaseCommand return static::SUCCESS; } $chosen_sources = $sources; - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; $deleted_sources = []; foreach ($chosen_sources as $source) { $source = trim($source); foreach ([$source, Downloader::getPreBuiltLockName($source)] as $name) { - if (isset($lock[$name])) { + if (LockFile::get($name)) { $deleted_sources[] = $name; } } } foreach ($deleted_sources as $lock_name) { + $lock = LockFile::get($lock_name); // remove download file/dir if exists - if ($lock[$lock_name]['source_type'] === SPC_SOURCE_ARCHIVE) { - if (file_exists($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock[$lock_name]['filename']))) { + if ($lock['source_type'] === SPC_SOURCE_ARCHIVE) { + if (file_exists($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock['filename']))) { logger()->info('Deleting file ' . $path); unlink($path); } else { logger()->warning("Source/Package [{$lock_name}] file not found, skip deleting file."); } } else { - if (is_dir($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock[$lock_name]['dirname']))) { + if (is_dir($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock['dirname']))) { logger()->info('Deleting dir ' . $path); FileSystem::removeDir($path); } else { @@ -76,9 +77,8 @@ class DeleteDownloadCommand extends BaseCommand } } // remove locked sources - unset($lock[$lock_name]); + LockFile::put($lock_name, null); } - FileSystem::writeFile(DOWNLOAD_PATH . '/.lock.json', json_encode($lock, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); logger()->info('Delete success!'); return static::SUCCESS; } catch (DownloaderException $e) { diff --git a/src/SPC/command/SwitchPhpVersionCommand.php b/src/SPC/command/SwitchPhpVersionCommand.php index ef463ef4..30ee0c79 100644 --- a/src/SPC/command/SwitchPhpVersionCommand.php +++ b/src/SPC/command/SwitchPhpVersionCommand.php @@ -7,6 +7,7 @@ namespace SPC\command; use SPC\store\Config; use SPC\store\Downloader; use SPC\store\FileSystem; +use SPC\store\LockFile; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -40,16 +41,9 @@ class SwitchPhpVersionCommand extends BaseCommand } } - // detect if downloads/.lock.json exists - $lock_file = DOWNLOAD_PATH . '/.lock.json'; - // parse php-src part of lock file - $lock_data = json_decode(file_get_contents($lock_file), true); - // get php-src downloaded file name - $php_src = $lock_data['php-src']; - $file = DOWNLOAD_PATH . '/' . ($php_src['filename'] ?? '.donot.delete.me'); - if (file_exists($file)) { + if (LockFile::isLockFileExists('php-src')) { $this->output->writeln('Removing old PHP source...'); - unlink($file); + LockFile::put('php-src', null); } // Download new PHP source diff --git a/src/SPC/command/dev/PackLibCommand.php b/src/SPC/command/dev/PackLibCommand.php index 924c3171..d0d9797e 100644 --- a/src/SPC/command/dev/PackLibCommand.php +++ b/src/SPC/command/dev/PackLibCommand.php @@ -14,6 +14,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; +use SPC\store\LockFile; use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -47,9 +48,8 @@ class PackLibCommand extends BuildCommand $lib->setup(); } else { // Get lock info - $lock = json_decode(file_get_contents(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; $source = Config::getLib($lib->getName(), 'source'); - if (!isset($lock[$source]) || ($lock[$source]['lock_as'] ?? SPC_DOWNLOAD_SOURCE) === SPC_DOWNLOAD_PRE_BUILT) { + if (($lock = LockFile::get($source)) === null || ($lock['lock_as'] === SPC_DOWNLOAD_PRE_BUILT)) { logger()->critical("The library {$lib->getName()} is downloaded as pre-built, we need to build it instead of installing pre-built."); return static::FAILURE; } diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index b0c663d3..919d1f15 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -208,34 +208,7 @@ class Downloader if ($download_as === SPC_DOWNLOAD_PRE_BUILT) { $name = self::getPreBuiltLockName($name); } - self::lockSource($name, ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => $filename, 'move_path' => $move_path, 'lock_as' => $download_as]); - } - - /** - * Try to lock source. - * - * @param string $name Source name - * @param array{ - * source_type: string, - * dirname: ?string, - * filename: ?string, - * move_path: ?string, - * lock_as: int - * } $data Source data - * @throws FileSystemException - */ - public static function lockSource(string $name, array $data): void - { - if (!file_exists(FileSystem::convertPath(DOWNLOAD_PATH . '/.lock.json'))) { - $lock = []; - } else { - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; - } - // calculate hash - $hash = self::getLockSourceHash($data); - $data['hash'] = $hash; - $lock[$name] = $data; - FileSystem::writeFile(DOWNLOAD_PATH . '/.lock.json', json_encode($lock, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); + LockFile::lockSource($name, ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => $filename, 'move_path' => $move_path, 'lock_as' => $download_as]); } /** @@ -281,7 +254,7 @@ class Downloader } // Lock logger()->debug("Locking git source {$name}"); - self::lockSource($name, ['source_type' => SPC_SOURCE_GIT, 'dirname' => $name, 'move_path' => $move_path, 'lock_as' => $lock_as]); + LockFile::lockSource($name, ['source_type' => SPC_SOURCE_GIT, 'dirname' => $name, 'move_path' => $move_path, 'lock_as' => $lock_as]); /* // 复制目录过去 @@ -377,7 +350,7 @@ class Downloader case 'local': // Local directory, do nothing, just lock it logger()->debug("Locking local source {$name}"); - self::lockSource($name, [ + LockFile::lockSource($name, [ 'source_type' => SPC_SOURCE_LOCAL, 'dirname' => $pkg['dirname'], 'move_path' => $pkg['extract'] ?? null, @@ -493,7 +466,7 @@ class Downloader case 'local': // Local directory, do nothing, just lock it logger()->debug("Locking local source {$name}"); - self::lockSource($name, [ + LockFile::lockSource($name, [ 'source_type' => SPC_SOURCE_LOCAL, 'dirname' => $source['dirname'], 'move_path' => $source['extract'] ?? null, @@ -617,43 +590,6 @@ class Downloader return "{$source}-" . PHP_OS_FAMILY . '-' . getenv('GNU_ARCH') . '-' . (getenv('SPC_LIBC') ?: 'default') . '-' . (SystemUtil::getLibcVersionIfExists() ?? 'default'); } - /** - * Get the hash of the lock source based on the lock options. - * - * @param array $lock_options Lock options - * @return string Hash of the lock source - * @throws RuntimeException - */ - public static function getLockSourceHash(array $lock_options): string - { - $result = match ($lock_options['source_type']) { - SPC_SOURCE_ARCHIVE => sha1_file(DOWNLOAD_PATH . '/' . $lock_options['filename']), - SPC_SOURCE_GIT => exec('cd ' . escapeshellarg(DOWNLOAD_PATH . '/' . $lock_options['dirname']) . ' && ' . SPC_GIT_EXEC . ' rev-parse HEAD'), - SPC_SOURCE_LOCAL => 'LOCAL HASH IS ALWAYS DIFFERENT', - default => filter_var(getenv('SPC_IGNORE_BAD_HASH'), FILTER_VALIDATE_BOOLEAN) ? '' : throw new RuntimeException("Unknown source type: {$lock_options['source_type']}"), - }; - if ($result === false && !filter_var(getenv('SPC_IGNORE_BAD_HASH'), FILTER_VALIDATE_BOOLEAN)) { - throw new RuntimeException("Failed to get hash for source: {$lock_options['source_type']}"); - } - return $result ?: ''; - } - - /** - * @param array $lock_options Lock options - * @param string $destination Target directory - * @throws FileSystemException - * @throws RuntimeException - */ - public static function putLockSourceHash(array $lock_options, string $destination): void - { - $hash = self::getLockSourceHash($lock_options); - if ($lock_options['source_type'] === SPC_SOURCE_LOCAL) { - logger()->debug("Source [{$lock_options['dirname']}] is local, no hash will be written."); - return; - } - FileSystem::writeFile("{$destination}/.spc-hash", $hash); - } - /** * Register CTRL+C event for different OS. * @@ -689,33 +625,24 @@ class Downloader /** * @throws FileSystemException + * @throws WrongUsageException */ private static function isAlreadyDownloaded(string $name, bool $force, int $download_as = SPC_DOWNLOAD_SOURCE): bool { - if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { - $lock = []; - } else { - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; - } - // If lock file exists, skip downloading for source mode - if (!$force && $download_as === SPC_DOWNLOAD_SOURCE && isset($lock[$name])) { - if ( - $lock[$name]['source_type'] === SPC_SOURCE_ARCHIVE && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename']) || - $lock[$name]['source_type'] === SPC_SOURCE_GIT && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname']) - ) { - logger()->notice("Source [{$name}] already downloaded: " . ($lock[$name]['filename'] ?? $lock[$name]['dirname'])); + // If the lock file exists, skip downloading for source mode + $lock_item = LockFile::get($name); + if (!$force && $download_as === SPC_DOWNLOAD_SOURCE && $lock_item !== null) { + if (file_exists($path = LockFile::getLockFullPath($lock_item))) { + logger()->notice("Source [{$name}] already downloaded: {$path}"); return true; } } - // If lock file exists for current arch and glibc target, skip downloading - - if (!$force && $download_as === SPC_DOWNLOAD_PRE_BUILT && isset($lock[$lock_name = self::getPreBuiltLockName($name)])) { + $lock_name = self::getPreBuiltLockName($name); + $lock_item = LockFile::get($lock_name); + if (!$force && $download_as === SPC_DOWNLOAD_PRE_BUILT && $lock_item !== null) { // lock name with env - if ( - $lock[$lock_name]['source_type'] === SPC_SOURCE_ARCHIVE && file_exists(DOWNLOAD_PATH . '/' . $lock[$lock_name]['filename']) || - $lock[$lock_name]['source_type'] === SPC_SOURCE_GIT && is_dir(DOWNLOAD_PATH . '/' . $lock[$lock_name]['dirname']) - ) { - logger()->notice("Pre-built content [{$name}] already downloaded: " . ($lock[$lock_name]['filename'] ?? $lock[$lock_name]['dirname'])); + if (file_exists($path = LockFile::getLockFullPath($lock_item))) { + logger()->notice("Pre-built content [{$name}] already downloaded: {$path}"); return true; } } diff --git a/src/SPC/store/LockFile.php b/src/SPC/store/LockFile.php new file mode 100644 index 00000000..45e3a94c --- /dev/null +++ b/src/SPC/store/LockFile.php @@ -0,0 +1,227 @@ +warning("Lock entry for '{$lock_name}' has 'source_type' set to 'dir', which is deprecated. Please re-download your dependencies."); + $result['source_type'] = SPC_SOURCE_GIT; + } + + return $result; + } + + /** + * Check if a lock file exists for a given lock name. + * + * @param string $lock_name Lock name to check + */ + public static function isLockFileExists(string $lock_name): bool + { + return match (self::get($lock_name)['source_type'] ?? null) { + SPC_SOURCE_ARCHIVE => file_exists(DOWNLOAD_PATH . '/' . (self::get($lock_name)['filename'] ?? '.never-exist-file')), + SPC_SOURCE_GIT, SPC_SOURCE_LOCAL => is_dir(DOWNLOAD_PATH . '/' . (self::get($lock_name)['dirname'] ?? '.never-exist-dir')), + default => false, + }; + } + + /** + * Put a lock entry into the lock file. + * + * @param string $lock_name Lock name to set or remove + * @param null|array $lock_content lock content to set, or null to remove the lock entry + * @throws FileSystemException + * @throws WrongUsageException + */ + public static function put(string $lock_name, ?array $lock_content): void + { + self::init(); + + $data = self::$lock_file_content; + if ($lock_content === null && isset($data[$lock_name])) { + self::removeLockFileIfExists($data[$lock_name]); + unset($data[$lock_name]); + } else { + $data[$lock_name] = $lock_content; + } + + // Write the updated lock data back to the file + file_put_contents(self::LOCK_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + } + + /** + * Get the full path of a lock file or directory based on the lock options. + * + * @param array $lock_options lock item options, must contain 'source_type', 'filename' or 'dirname' + * @return string the absolute path to the lock file or directory + * @throws WrongUsageException + */ + public static function getLockFullPath(array $lock_options): string + { + return match ($lock_options['source_type']) { + SPC_SOURCE_ARCHIVE => FileSystem::isRelativePath($lock_options['filename']) ? (DOWNLOAD_PATH . '/' . $lock_options['filename']) : $lock_options['filename'], + SPC_SOURCE_GIT, SPC_SOURCE_LOCAL => FileSystem::isRelativePath($lock_options['dirname']) ? (DOWNLOAD_PATH . '/' . $lock_options['dirname']) : $lock_options['dirname'], + default => throw new WrongUsageException("Unknown source type: {$lock_options['source_type']}"), + }; + } + + public static function getExtractPath(string $lock_name, string $default_path): ?string + { + $lock = self::get($lock_name); + if ($lock === null) { + return null; + } + + // If move_path is set, use it; otherwise, use the default extract directory + if (isset($lock['move_path'])) { + if (FileSystem::isRelativePath($lock['move_path'])) { + // If move_path is relative, prepend the default extract directory + return match ($lock['lock_as']) { + SPC_DOWNLOAD_SOURCE, SPC_DOWNLOAD_PRE_BUILT => FileSystem::convertPath(SOURCE_PATH . '/' . $lock['move_path']), + SPC_DOWNLOAD_PACKAGE => FileSystem::convertPath(PKG_ROOT_PATH . '/' . $lock['move_path']), + default => throw new WrongUsageException("Unknown lock type: {$lock['lock_as']}"), + }; + } + return FileSystem::convertPath($lock['move_path']); + } + return FileSystem::convertPath($default_path); + } + + /** + * Get the hash of the lock source based on the lock options. + * + * @param array $lock_options Lock options + * @return string Hash of the lock source + * @throws RuntimeException + */ + public static function getLockSourceHash(array $lock_options): string + { + $result = match ($lock_options['source_type']) { + SPC_SOURCE_ARCHIVE => sha1_file(DOWNLOAD_PATH . '/' . $lock_options['filename']), + SPC_SOURCE_GIT => exec('cd ' . escapeshellarg(DOWNLOAD_PATH . '/' . $lock_options['dirname']) . ' && ' . SPC_GIT_EXEC . ' rev-parse HEAD'), + SPC_SOURCE_LOCAL => 'LOCAL HASH IS ALWAYS DIFFERENT', + default => filter_var(getenv('SPC_IGNORE_BAD_HASH'), FILTER_VALIDATE_BOOLEAN) ? '' : throw new RuntimeException("Unknown source type: {$lock_options['source_type']}"), + }; + if ($result === false && !filter_var(getenv('SPC_IGNORE_BAD_HASH'), FILTER_VALIDATE_BOOLEAN)) { + throw new RuntimeException("Failed to get hash for source: {$lock_options['source_type']}"); + } + return $result ?: ''; + } + + /** + * @param array $lock_options Lock options + * @param string $destination Target directory + * @throws FileSystemException + * @throws RuntimeException + */ + public static function putLockSourceHash(array $lock_options, string $destination): void + { + $hash = LockFile::getLockSourceHash($lock_options); + if ($lock_options['source_type'] === SPC_SOURCE_LOCAL) { + logger()->debug("Source [{$lock_options['dirname']}] is local, no hash will be written."); + return; + } + FileSystem::writeFile("{$destination}/.spc-hash", $hash); + } + + /** + * Try to lock source with hash. + * + * @param string $name Source name + * @param array{ + * source_type: string, + * dirname: ?string, + * filename: ?string, + * move_path: ?string, + * lock_as: int + * } $data Source data + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public static function lockSource(string $name, array $data): void + { + // calculate hash + $hash = LockFile::getLockSourceHash($data); + $data['hash'] = $hash; + self::put($name, $data); + } + + private static function init(): void + { + if (self::$lock_file_content === null) { + // Initialize the lock file content if it hasn't been loaded yet + if (!file_exists(self::LOCK_FILE)) { + logger()->debug('Lock file does not exist: ' . self::LOCK_FILE . ', initializing empty lock file.'); + self::$lock_file_content = []; + file_put_contents(self::LOCK_FILE, json_encode(self::$lock_file_content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + } else { + $file_content = file_get_contents(self::LOCK_FILE); + self::$lock_file_content = json_decode($file_content, true); + if (self::$lock_file_content === null) { + throw new \RuntimeException('Failed to decode lock file: ' . self::LOCK_FILE); + } + } + } + } + + /** + * Remove the lock file or directory if it exists. + * + * @param array $lock_options lock item options, must contain 'source_type', 'filename' or 'dirname' + * @throws WrongUsageException + * @throws FileSystemException + */ + private static function removeLockFileIfExists(array $lock_options): void + { + if ($lock_options['source_type'] === SPC_SOURCE_ARCHIVE) { + $path = self::getLockFullPath($lock_options); + if (file_exists($path)) { + logger()->info('Removing file ' . $path); + unlink($path); + } else { + logger()->debug("Lock file [{$lock_options['filename']}] not found, skip removing file."); + } + } else { + $path = self::getLockFullPath($lock_options); + if (is_dir($path)) { + logger()->info('Removing directory ' . $path); + FileSystem::removeDir($path); + } else { + logger()->debug("Lock directory [{$lock_options['dirname']}] not found, skip removing directory."); + } + } + } +} diff --git a/src/SPC/store/PackageManager.php b/src/SPC/store/PackageManager.php index ca930228..ae2c9380 100644 --- a/src/SPC/store/PackageManager.php +++ b/src/SPC/store/PackageManager.php @@ -33,10 +33,11 @@ class PackageManager // Download package Downloader::downloadPackage($pkg_name, $config, $force); // After download, read lock file name - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); - $source_type = $lock[$pkg_name]['source_type']; - $filename = DOWNLOAD_PATH . '/' . ($lock[$pkg_name]['filename'] ?? $lock[$pkg_name]['dirname']); - $extract = $lock[$pkg_name]['move_path'] === null ? (PKG_ROOT_PATH . '/' . $pkg_name) : $lock[$pkg_name]['move_path']; + $lock = LockFile::get($pkg_name); + $source_type = $lock['source_type']; + $filename = LockFile::getLockFullPath($lock); + $extract = LockFile::getExtractPath($pkg_name, PKG_ROOT_PATH . '/' . $pkg_name); + FileSystem::extractPackage($pkg_name, $source_type, $filename, $extract); // if contains extract-files, we just move this file to destination, and remove extract dir diff --git a/src/SPC/store/SourceManager.php b/src/SPC/store/SourceManager.php index dd419e35..02d07263 100644 --- a/src/SPC/store/SourceManager.php +++ b/src/SPC/store/SourceManager.php @@ -17,11 +17,6 @@ class SourceManager */ public static function initSource(?array $sources = null, ?array $libs = null, ?array $exts = null, bool $source_only = false): void { - if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { - throw new WrongUsageException('Download lock file "downloads/.lock.json" not found, maybe you need to download sources first ?'); - } - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); - $sources_extracted = []; // source check exist if (is_array($sources)) { @@ -56,8 +51,8 @@ class SourceManager } // check source downloaded $pre_built_name = Downloader::getPreBuiltLockName($source); - if ($source_only || !isset($lock[$pre_built_name])) { - if (!isset($lock[$source])) { + if ($source_only || LockFile::get($pre_built_name) === null) { + if (LockFile::get($source) === null) { throw new WrongUsageException("Source [{$source}] not downloaded or not locked, you should download it first !"); } $lock_name = $source; @@ -65,20 +60,23 @@ class SourceManager $lock_name = $pre_built_name; } + $lock_content = LockFile::get($lock_name); + // check source dir exist - $check = $lock[$lock_name]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$lock_name]['move_path']); + $check = LockFile::getExtractPath($lock_name, SOURCE_PATH . '/' . $source); + // $check = $lock[$lock_name]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$lock_name]['move_path']); if (!is_dir($check)) { logger()->debug('Extracting source [' . $source . '] to ' . $check . ' ...'); - $filename = self::getSourceFullPath($lock[$lock_name]); - FileSystem::extractSource($source, $lock[$lock_name]['source_type'], $filename, $lock[$lock_name]['move_path']); - Downloader::putLockSourceHash($lock[$lock_name], $check); + $filename = LockFile::getLockFullPath($lock_content); + FileSystem::extractSource($source, $lock_content['source_type'], $filename, $check); + LockFile::putLockSourceHash($lock_content, $check); continue; } // if a lock file does not have hash, calculate with the current source (backward compatibility) - if (!isset($lock[$lock_name]['hash'])) { - $hash = Downloader::getLockSourceHash($lock[$lock_name]); + if (!isset($lock_content['hash'])) { + $hash = LockFile::getLockSourceHash($lock_content); } else { - $hash = $lock[$lock_name]['hash']; + $hash = $lock_content['hash']; } // when source already extracted, detect if the extracted source hash is the same as the lock file one @@ -90,18 +88,10 @@ class SourceManager // if not, remove the source dir and extract again logger()->notice("Source [{$source}] hash mismatch, removing old source dir and extracting again ..."); FileSystem::removeDir($check); - $filename = self::getSourceFullPath($lock[$lock_name]); - FileSystem::extractSource($source, $lock[$lock_name]['source_type'], $filename, $lock[$lock_name]['move_path']); - Downloader::putLockSourceHash($lock[$lock_name], $check); + $filename = LockFile::getLockFullPath($lock_content); + $move_path = LockFile::getExtractPath($lock_name, SOURCE_PATH . '/' . $source); + FileSystem::extractSource($source, $lock_content['source_type'], $filename, $move_path); + LockFile::putLockSourceHash($lock_content, $check); } } - - private static function getSourceFullPath(array $lock_options): string - { - return match ($lock_options['source_type']) { - SPC_SOURCE_ARCHIVE => FileSystem::isRelativePath($lock_options['filename']) ? (DOWNLOAD_PATH . '/' . $lock_options['filename']) : $lock_options['filename'], - SPC_SOURCE_GIT, SPC_SOURCE_LOCAL => FileSystem::isRelativePath($lock_options['dirname']) ? (DOWNLOAD_PATH . '/' . $lock_options['dirname']) : $lock_options['dirname'], - default => throw new WrongUsageException("Unknown source type: {$lock_options['source_type']}"), - }; - } } diff --git a/tests/SPC/store/DownloaderTest.php b/tests/SPC/store/DownloaderTest.php index 5c15d42e..43de396a 100644 --- a/tests/SPC/store/DownloaderTest.php +++ b/tests/SPC/store/DownloaderTest.php @@ -7,6 +7,7 @@ namespace SPC\Tests\store; use PHPUnit\Framework\TestCase; use SPC\exception\WrongUsageException; use SPC\store\Downloader; +use SPC\store\LockFile; /** * @internal @@ -57,7 +58,7 @@ class DownloaderTest extends TestCase public function testLockSource() { - Downloader::lockSource('fake-file', ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']); + LockFile::lockSource('fake-file', ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']); $this->assertFileExists(DOWNLOAD_PATH . '/.lock.json'); $json = json_decode(file_get_contents(DOWNLOAD_PATH . '/.lock.json'), true); $this->assertIsArray($json); From b4168d09b562e33138b82f3f9a5a6929b0993c27 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 14:06:36 +0800 Subject: [PATCH 258/319] Add test extensions as trigger --- .github/workflows/ext-matrix-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ext-matrix-tests.yml b/.github/workflows/ext-matrix-tests.yml index 265c8b2e..1c04f5c9 100644 --- a/.github/workflows/ext-matrix-tests.yml +++ b/.github/workflows/ext-matrix-tests.yml @@ -8,7 +8,7 @@ jobs: test: name: "${{ matrix.extension }} (PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }})" runs-on: ${{ matrix.operating-system }} - if: contains(github.event.head_commit.message, 'extension test') + if: contains(github.event.head_commit.message, 'extension test') || contains(github.event.head_commit.message, 'test extensions') strategy: fail-fast: false matrix: From f7a3f80689ce39906f50d021fce62be0260b36ee Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 14:06:59 +0800 Subject: [PATCH 259/319] Add test extensions as trigger --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index c1d4eb16..13441a81 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -14,4 +14,4 @@ - [ ] `bin/spc dev:sort-config` - If it's an extension or dependency update, please ensure the following: - [ ] Add your test combination to `src/globals/test-extensions.php`. - - [ ] If adding new or fixing bugs, add commit message containing `extension test` to trigger full test suite. + - [ ] If adding new or fixing bugs, add commit message containing `extension test` or `test extensions` to trigger full test suite. From f10ba862188ecb56885dca84a379500577616907 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 14:18:01 +0700 Subject: [PATCH 260/319] add extension test for frankenphp --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index cfde83f6..44243140 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -177,7 +177,7 @@ if ($argv[1] === 'build_cmd' || $argv[1] === 'build_embed_cmd') { $build_cmd .= $no_strip ? '--no-strip ' : ''; $build_cmd .= $upx ? '--with-upx-pack ' : ''; $build_cmd .= $final_libs === '' ? '' : ('--with-libs=' . quote2($final_libs) . ' '); - $build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm '; + $build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm --build-frankenphp'; $build_cmd .= '--debug '; } From 65b828c424b87dbc76c76a1acc24c084456ab4be Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 15:50:55 +0700 Subject: [PATCH 261/319] embed version information --- src/SPC/builder/unix/UnixBuilderBase.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 758efaa6..75e3d77d 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -12,6 +12,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\store\Downloader; use SPC\store\FileSystem; use SPC\util\DependencyUtil; use SPC\util\SPCConfigUtil; @@ -278,6 +279,10 @@ abstract class UnixBuilderBase extends BuilderBase } } + /** + * @throws WrongUsageException + * @throws RuntimeException + */ protected function buildFrankenphp(): void { $path = getenv('PATH'); @@ -302,12 +307,20 @@ abstract class UnixBuilderBase extends BuilderBase $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); } $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; + $releaseInfo = json_decode(Downloader::curlExec('https://api.github.com/repos/php/frankenphp/releases/latest'), true); + $frankenPhpVersion = $releaseInfo['tag_name']; + $libphpVersion = $this->getPHPVersion(); + $debugFlags = $this->getOption('--with-debug') ? "'-w -s' " : ''; $env = [ 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', 'CGO_LDFLAGS' => '$(php-config --ldflags) -L' . BUILD_LIB_PATH . " $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp {$lrt}", - 'XCADDY_GO_BUILD_FLAGS' => "-ldflags='-w -s' -tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", + 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . + '-ldflags \\"-linkmode=external -extldflags \'-pie\' '. $debugFlags . + '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . + "{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . + "-tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; shell()->cd(BUILD_BIN_PATH) From eee2ff6d614bdaaaccc737203de4b1937ddad626 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Wed, 18 Jun 2025 15:55:14 +0700 Subject: [PATCH 262/319] don't embed minor version when loading libphp.so --- src/SPC/builder/unix/UnixBuilderBase.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 75e3d77d..9801d47b 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -310,6 +310,9 @@ abstract class UnixBuilderBase extends BuilderBase $releaseInfo = json_decode(Downloader::curlExec('https://api.github.com/repos/php/frankenphp/releases/latest'), true); $frankenPhpVersion = $releaseInfo['tag_name']; $libphpVersion = $this->getPHPVersion(); + if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { + $libphpVersion = preg_replace('/\.\d$/', '', $libphpVersion); + } $debugFlags = $this->getOption('--with-debug') ? "'-w -s' " : ''; $env = [ From ae569316ff3234aadaa3331e9eccd8b583045120 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 20:54:01 +0800 Subject: [PATCH 263/319] Remove go download from doctor --- src/SPC/builder/traits/UnixGoCheckTrait.php | 83 --------------------- src/SPC/doctor/item/BSDToolCheckList.php | 6 -- src/SPC/doctor/item/LinuxToolCheckList.php | 8 -- src/SPC/doctor/item/MacOSToolCheckList.php | 8 -- 4 files changed, 105 deletions(-) delete mode 100644 src/SPC/builder/traits/UnixGoCheckTrait.php diff --git a/src/SPC/builder/traits/UnixGoCheckTrait.php b/src/SPC/builder/traits/UnixGoCheckTrait.php deleted file mode 100644 index 12e3d005..00000000 --- a/src/SPC/builder/traits/UnixGoCheckTrait.php +++ /dev/null @@ -1,83 +0,0 @@ -findCommand('go', $paths) === null) { - $this->installGo(); - } - - $gobin = getenv('GOBIN') ?: (getenv('HOME') . '/go/bin'); - putenv("GOBIN={$gobin}"); - - $paths[] = $gobin; - - if ($this->findCommand('xcaddy', $paths) === null) { - shell(true)->exec('go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest'); - } - - return CheckResult::ok(); - } - - private function installGo(): bool - { - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } - - $arch = php_uname('m'); - $go_arch = match ($arch) { - 'x86_64' => 'amd64', - 'aarch64' => 'arm64', - default => $arch - }; - $os = strtolower(PHP_OS_FAMILY); - - $go_version = '1.24.4'; - $go_filename = "go{$go_version}.{$os}-{$go_arch}.tar.gz"; - $go_url = "https://go.dev/dl/{$go_filename}"; - - logger()->info("Downloading Go {$go_version} for {$go_arch}"); - - try { - // Download Go binary - Downloader::downloadFile('go', $go_url, $go_filename); - - // Extract the tarball - FileSystem::extractSource('go', SPC_SOURCE_ARCHIVE, DOWNLOAD_PATH . "/{$go_filename}"); - - // Move to /usr/local/go - logger()->info('Installing Go to /usr/local/go'); - shell()->exec("{$prefix}rm -rf /usr/local/go"); - shell()->exec("{$prefix}mv " . SOURCE_PATH . '/go /usr/local/'); - - if (!str_contains(getenv('PATH'), '/usr/local/go/bin')) { - logger()->info('Adding Go to PATH'); - shell()->exec("{$prefix}echo 'export PATH=\$PATH:/usr/local/go/bin' >> /etc/profile"); - putenv('PATH=' . getenv('PATH') . ':/usr/local/go/bin'); - } - - logger()->info('Go has been installed successfully'); - return true; - } catch (RuntimeException $e) { - logger()->error('Failed to install Go: ' . $e->getMessage()); - return false; - } - } -} diff --git a/src/SPC/doctor/item/BSDToolCheckList.php b/src/SPC/doctor/item/BSDToolCheckList.php index 97f0ccf9..2505227b 100644 --- a/src/SPC/doctor/item/BSDToolCheckList.php +++ b/src/SPC/doctor/item/BSDToolCheckList.php @@ -47,12 +47,6 @@ class BSDToolCheckList return CheckResult::ok(); } - #[AsCheckItem('if xcaddy is installed', limit_os: 'BSD')] - public function checkXcaddy(): ?CheckResult - { - return $this->checkGoAndXcaddy(); - } - #[AsFixItem('build-tools-bsd')] public function fixBuildTools(array $missing): bool { diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 07f6b5fb..56235b0c 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\doctor\item; use SPC\builder\linux\SystemUtil; -use SPC\builder\traits\UnixGoCheckTrait; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; @@ -15,7 +14,6 @@ use SPC\exception\RuntimeException; class LinuxToolCheckList { use UnixSystemUtilTrait; - use UnixGoCheckTrait; public const TOOLS_ALPINE = [ 'make', 'bison', 'flex', @@ -89,12 +87,6 @@ class LinuxToolCheckList return CheckResult::ok(); } - #[AsCheckItem('if xcaddy is installed', limit_os: 'Linux')] - public function checkXcaddy(): ?CheckResult - { - return $this->checkGoAndXcaddy(); - } - #[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')] public function checkCMakeVersion(): ?CheckResult { diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index 57ba8157..b4043a1d 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\doctor\item; -use SPC\builder\traits\UnixGoCheckTrait; use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; @@ -14,7 +13,6 @@ use SPC\exception\RuntimeException; class MacOSToolCheckList { use UnixSystemUtilTrait; - use UnixGoCheckTrait; /** @var string[] MacOS 环境下编译依赖的命令 */ public const REQUIRED_COMMANDS = [ @@ -36,12 +34,6 @@ class MacOSToolCheckList 'glibtoolize', ]; - #[AsCheckItem('if xcaddy is installed', limit_os: 'Darwin')] - public function checkXcaddy(): ?CheckResult - { - return $this->checkGoAndXcaddy(); - } - #[AsCheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)] public function checkBrew(): ?CheckResult { From 8e2dffc3b5cfcf1587a77fe8136ad6b5ff2551ab Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 20:54:54 +0800 Subject: [PATCH 264/319] Add frankenphp sapi embed build at build command, not constant --- src/SPC/builder/BuilderBase.php | 23 +++++++++++++++++++++++ src/SPC/command/BuildPHPCommand.php | 5 ++++- src/globals/defines.php | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 7fc78e44..fd4788f8 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -404,6 +404,9 @@ abstract class BuilderBase if (($type & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED) { $ls[] = 'embed'; } + if (($type & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) { + $ls[] = 'frankenphp'; + } return implode(', ', $ls); } @@ -510,6 +513,26 @@ abstract class BuilderBase } } + public function checkBeforeBuildPHP(int $rule): void + { + if (($rule & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) { + // frankenphp only support linux and macOS + if (!in_array(PHP_OS_FAMILY, ['Linux', 'Darwin'])) { + throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!'); + } + // frankenphp needs package go-mod-frankenphp installed + $pkg_dir = PKG_ROOT_PATH . '/go-mod-frankenphp-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname(); + if (!file_exists("{$pkg_dir}/bin/go") || !file_exists("{$pkg_dir}/bin/xcaddy")) { + global $argv; + throw new WrongUsageException("FrankenPHP SAPI requires go-mod-frankenphp package, please install it first: {$argv[0]} install-pkg go-mod-frankenphp"); + } + // frankenphp needs libxml2 libs + if (!$this->getLib('libxml2')) { + throw new WrongUsageException('FrankenPHP SAPI requires libxml2 library, please include `xml` extension in your build.'); + } + } + } + /** * Generate micro extension test php code. */ diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 72d6a686..29cedf8f 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -196,6 +196,9 @@ class BuildPHPCommand extends BuildCommand // validate libs and extensions $builder->validateLibsAndExts(); + // check some things before building all the things + $builder->checkBeforeBuildPHP($rule); + // clean builds and sources if ($this->input->getOption('with-clean')) { logger()->info('Cleaning source and previous build dir...'); @@ -316,7 +319,7 @@ class BuildPHPCommand extends BuildCommand $rule |= BUILD_TARGET_EMBED; f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared')); } - $rule |= ($this->getOption('build-frankenphp') ? BUILD_TARGET_FRANKENPHP : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; } diff --git a/src/globals/defines.php b/src/globals/defines.php index aebd4d5f..ab37ace9 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -62,7 +62,7 @@ const BUILD_TARGET_CLI = 1; // build cli const BUILD_TARGET_MICRO = 2; // build micro const BUILD_TARGET_FPM = 4; // build fpm const BUILD_TARGET_EMBED = 8; // build embed -const BUILD_TARGET_FRANKENPHP = BUILD_TARGET_EMBED | 16; // build frankenphp +const BUILD_TARGET_FRANKENPHP = 16; // build frankenphp const BUILD_TARGET_ALL = BUILD_TARGET_CLI | BUILD_TARGET_MICRO | BUILD_TARGET_FPM | BUILD_TARGET_EMBED | BUILD_TARGET_FRANKENPHP; // build all // doctor error fix policy From f709f3bb18406b50ac102326478b99f4e8ef6dd1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 20:55:24 +0800 Subject: [PATCH 265/319] Add custom package downloader and extractor --- src/SPC/store/Downloader.php | 22 ++++++++++++++++++---- src/SPC/store/PackageManager.php | 15 +++++++++++++++ src/SPC/store/pkg/CustomPackage.php | 17 +++++++++++++++++ src/globals/functions.php | 11 +++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 src/SPC/store/pkg/CustomPackage.php diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index b0c663d3..e5cc6aae 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -9,6 +9,7 @@ use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\store\pkg\CustomPackage; use SPC\store\source\CustomSourceBase; /** @@ -385,10 +386,13 @@ class Downloader ]); break; case 'custom': // Custom download method, like API-based download or other - $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\store\source'); + $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/pkg', 'SPC\store\pkg'); foreach ($classes as $class) { - if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { - (new $class())->fetch($force); + if (is_a($class, CustomPackage::class, true) && $class !== CustomPackage::class) { + $cls = new $class(); + if (in_array($name, $cls->getSupportName())) { + (new $class())->fetch($name, $force, $pkg); + } break; } } @@ -708,7 +712,6 @@ class Downloader } } // If lock file exists for current arch and glibc target, skip downloading - if (!$force && $download_as === SPC_DOWNLOAD_PRE_BUILT && isset($lock[$lock_name = self::getPreBuiltLockName($name)])) { // lock name with env if ( @@ -719,6 +722,17 @@ class Downloader return true; } } + + // If lock file exists, skip downloading for source mode + if (!$force && $download_as === SPC_DOWNLOAD_PACKAGE && isset($lock[$name])) { + if ( + $lock[$name]['source_type'] === SPC_SOURCE_ARCHIVE && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename']) || + $lock[$name]['source_type'] === SPC_SOURCE_GIT && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname']) + ) { + logger()->notice("Package [{$name}] already downloaded: " . ($lock[$name]['filename'] ?? $lock[$name]['dirname'])); + return true; + } + } return false; } } diff --git a/src/SPC/store/PackageManager.php b/src/SPC/store/PackageManager.php index ca930228..7e8ae3fd 100644 --- a/src/SPC/store/PackageManager.php +++ b/src/SPC/store/PackageManager.php @@ -6,6 +6,7 @@ namespace SPC\store; use SPC\exception\FileSystemException; use SPC\exception\WrongUsageException; +use SPC\store\pkg\CustomPackage; class PackageManager { @@ -32,6 +33,20 @@ class PackageManager // Download package Downloader::downloadPackage($pkg_name, $config, $force); + if (Config::getPkg($pkg_name)['type'] === 'custom') { + // Custom extract function + $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/pkg', 'SPC\store\pkg'); + foreach ($classes as $class) { + if (is_a($class, CustomPackage::class, true) && $class !== CustomPackage::class) { + $cls = new $class(); + if (in_array($pkg_name, $cls->getSupportName())) { + (new $class())->extract($pkg_name); + break; + } + } + } + return; + } // After download, read lock file name $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); $source_type = $lock[$pkg_name]['source_type']; diff --git a/src/SPC/store/pkg/CustomPackage.php b/src/SPC/store/pkg/CustomPackage.php new file mode 100644 index 00000000..89edb17e --- /dev/null +++ b/src/SPC/store/pkg/CustomPackage.php @@ -0,0 +1,17 @@ + 'win', + 'Darwin' => 'macos', + 'Linux' => 'linux', + 'BSD' => 'bsd', + default => throw new WrongUsageException('Not support os: ' . PHP_OS_FAMILY), + }; +} + function shell(?bool $debug = null): UnixShell { /* @noinspection PhpUnhandledExceptionInspection */ From 92284e92c9aaf73a997e2662a02da4f9d7bb6bb6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 20:56:07 +0800 Subject: [PATCH 266/319] Refactor go and frankenphp downloads and builds --- config/pkg.json | 12 +++++ src/SPC/builder/unix/UnixBuilderBase.php | 52 +++++++++++++------ src/SPC/store/pkg/GoModFrankenphp.php | 64 ++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 15 deletions(-) create mode 100644 src/SPC/store/pkg/GoModFrankenphp.php diff --git a/config/pkg.json b/config/pkg.json index 5760c0b1..a2ec8a14 100644 --- a/config/pkg.json +++ b/config/pkg.json @@ -42,5 +42,17 @@ "extract-files": { "upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe" } + }, + "go-mod-frankenphp-x86_64-linux": { + "type": "custom" + }, + "go-mod-frankenphp-aarch64-linux": { + "type": "custom" + }, + "go-mod-frankenphp-x86_64-macos": { + "type": "custom" + }, + "go-mod-frankenphp-aarch64-macos": { + "type": "custom" } } diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 9801d47b..44756955 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -219,6 +219,19 @@ abstract class UnixBuilderBase extends BuilderBase throw new RuntimeException('embed failed sanity check: run failed. Error message: ' . implode("\n", $output)); } } + + // sanity check for frankenphp + if (($build_target & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) { + logger()->info('running frankenphp sanity check'); + $frankenphp = BUILD_BIN_PATH . '/frankenphp'; + if (!file_exists($frankenphp)) { + throw new RuntimeException('FrankenPHP binary not found: ' . $frankenphp); + } + [$ret, $output] = shell()->execWithResult($frankenphp . ' -v'); + if ($ret !== 0 || !str_contains(implode('', $output), 'FrankenPHP')) { + throw new RuntimeException('FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']'); + } + } } /** @@ -285,16 +298,19 @@ abstract class UnixBuilderBase extends BuilderBase */ protected function buildFrankenphp(): void { - $path = getenv('PATH'); - $xcaddyPath = getenv('GOBIN') ?: (getenv('HOME') . '/go/bin'); - if (!str_contains($path, $xcaddyPath)) { - $path = $path . ':' . $xcaddyPath; - } - $path = BUILD_BIN_PATH . ':' . $path; - f_putenv("PATH={$path}"); + $os = match (PHP_OS_FAMILY) { + 'Linux' => 'linux', + 'Windows' => 'win', + 'Darwin' => 'macos', + 'BSD' => 'freebsd', + default => throw new RuntimeException('Unsupported OS: ' . PHP_OS_FAMILY), + }; + $arch = arch2gnu(php_uname('m')); + + // define executables for go and xcaddy + $go_exec = PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin/go"; + $xcaddy_exec = PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin/xcaddy"; - $brotliLibs = $this->getLib('brotli') !== null ? '-lbrotlienc -lbrotlidec -lbrotlicommon' : ''; - $watcherLibs = $this->getLib('watcher') !== null ? '-lwatcher-c' : ''; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); @@ -303,7 +319,7 @@ abstract class UnixBuilderBase extends BuilderBase $xcaddyModules = '--with github.com/dunglas/frankenphp ' . $xcaddyModules; } if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { - logger()->warning('caddy-cbrotli module is enabled, but broli library is not built. Disabling caddy-cbrotli.'); + logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.'); $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); } $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; @@ -313,14 +329,20 @@ abstract class UnixBuilderBase extends BuilderBase if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { $libphpVersion = preg_replace('/\.\d$/', '', $libphpVersion); } - $debugFlags = $this->getOption('--with-debug') ? "'-w -s' " : ''; + $debugFlags = $this->getOption('--with-debug') ? "'-w -s' " : ''; + + $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true); $env = [ + 'PATH' => PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin:" . getenv('PATH'), + 'GOROOT' => PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}", + 'GOBIN' => PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin", + 'GOPATH' => PKG_ROOT_PATH . '/go', 'CGO_ENABLED' => '1', - 'CGO_CFLAGS' => '$(php-config --includes) -I$(php-config --include-dir)/..', - 'CGO_LDFLAGS' => '$(php-config --ldflags) -L' . BUILD_LIB_PATH . " $(php-config --libs) {$brotliLibs} {$watcherLibs} -lphp {$lrt}", + 'CGO_CFLAGS' => $config['cflags'], + 'CGO_LDFLAGS' => "{$config['ldflags']} {$config['libs']} {$lrt}", 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . - '-ldflags \\"-linkmode=external -extldflags \'-pie\' '. $debugFlags . + '-ldflags \"-linkmode=external -extldflags \'-pie\' ' . $debugFlags . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . "{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . "-tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", @@ -328,6 +350,6 @@ abstract class UnixBuilderBase extends BuilderBase ]; shell()->cd(BUILD_BIN_PATH) ->setEnv($env) - ->exec('xcaddy build --output frankenphp ' . $xcaddyModules); + ->exec("{$xcaddy_exec} build --output frankenphp {$xcaddyModules}"); } } diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoModFrankenphp.php new file mode 100644 index 00000000..bede5d22 --- /dev/null +++ b/src/SPC/store/pkg/GoModFrankenphp.php @@ -0,0 +1,64 @@ + 'amd64', + 'aarch64' => 'arm64', + default => throw new \InvalidArgumentException('Unsupported architecture: ' . $name), + }; + $os = match (explode('-', $name)[4]) { + 'linux' => 'linux', + 'macos' => 'darwin', + default => throw new \InvalidArgumentException('Unsupported OS: ' . $name), + }; + $go_version = '1.24.4'; + $config = [ + 'type' => 'url', + 'url' => "https://go.dev/dl/go{$go_version}.{$os}-{$arch}.tar.gz", + ]; + Downloader::downloadPackage($name, $config, $force); + } + + public function extract(string $name): void + { + $pkgroot = PKG_ROOT_PATH; + $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); + $source_type = $lock[$name]['source_type']; + $filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']); + $extract = $lock[$name]['move_path'] === null ? (PKG_ROOT_PATH . "{$pkgroot}/{$name}") : $lock[$name]['move_path']; + + FileSystem::extractPackage($name, $source_type, $filename, $extract); + + // install xcaddy + $go_exec = PKG_ROOT_PATH . "{$pkgroot}/{$name}/bin/go"; + // $xcaddy_exec = PKG_ROOT_PATH . "$pkgroot/$name/bin/xcaddy"; + shell()->appendEnv([ + 'PATH' => "{$pkgroot}/{$name}/bin:" . getenv('PATH'), + 'GOROOT' => "{$pkgroot}/{$name}", + 'GOBIN' => "{$pkgroot}/{$name}/bin", + 'GOPATH' => "{$pkgroot}/go", + ]) + ->exec("{$go_exec} install github.com/caddyserver/xcaddy/cmd/xcaddy@latest"); + // TODO: Here to download dependencies for xcaddy and frankenphp first + } +} From d6858e18df118c9160e97301fa871038593a478a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 20:57:14 +0800 Subject: [PATCH 267/319] phpstan fix --- src/globals/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/functions.php b/src/globals/functions.php index 32f0514e..998b2d1c 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -105,7 +105,7 @@ function osfamily2dir(): string function osfamily2shortname(): string { return match (PHP_OS_FAMILY) { - 'Windows', 'WINNT', 'Cygwin' => 'win', + 'Windows' => 'win', 'Darwin' => 'macos', 'Linux' => 'linux', 'BSD' => 'bsd', From 74b1dda884a447258df20c7696fa9a07872367d7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 21:06:08 +0800 Subject: [PATCH 268/319] Fix test-extensions.php --- src/globals/test-extensions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 44243140..77e0f71d 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -40,6 +40,9 @@ $no_strip = false; // compress with upx $upx = false; +// whether to test frankenphp build, only available for macos and linux +$frankenphp = false; + // prefer downloading pre-built packages to speed up the build process $prefer_pre_built = false; @@ -177,7 +180,7 @@ if ($argv[1] === 'build_cmd' || $argv[1] === 'build_embed_cmd') { $build_cmd .= $no_strip ? '--no-strip ' : ''; $build_cmd .= $upx ? '--with-upx-pack ' : ''; $build_cmd .= $final_libs === '' ? '' : ('--with-libs=' . quote2($final_libs) . ' '); - $build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm --build-frankenphp'; + $build_cmd .= str_starts_with($argv[2], 'windows-') ? '' : '--build-fpm '; $build_cmd .= '--debug '; } @@ -208,7 +211,7 @@ switch ($argv[1] ?? null) { passthru($prefix . $build_cmd . ' --build-cli --build-micro', $retcode); break; case 'build_embed_cmd': - passthru($prefix . $build_cmd . (str_starts_with($argv[2], 'windows-') ? ' --build-cli' : ' --build-embed'), $retcode); + passthru($prefix . $build_cmd . (str_starts_with($argv[2], 'windows-') ? ' --build-cli' : (' --build-embed' . ($frankenphp ? ' --build-frankenphp' : ''))), $retcode); break; case 'doctor_cmd': passthru($prefix . $doctor_cmd, $retcode); From 4ecaffd9085846091e825d300b1b29d64056b763 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 21:08:05 +0800 Subject: [PATCH 269/319] Fix test-extensions.php --- src/globals/test-extensions.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 77e0f71d..79acc984 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -41,7 +41,7 @@ $no_strip = false; $upx = false; // whether to test frankenphp build, only available for macos and linux -$frankenphp = false; +$frankenphp = true; // prefer downloading pre-built packages to speed up the build process $prefer_pre_built = false; @@ -211,6 +211,12 @@ switch ($argv[1] ?? null) { passthru($prefix . $build_cmd . ' --build-cli --build-micro', $retcode); break; case 'build_embed_cmd': + if ($frankenphp) { + passthru("{$prefix}install-pkg go-mod-frankenphp --debug", $retcode); + if ($retcode !== 0) { + break; + } + } passthru($prefix . $build_cmd . (str_starts_with($argv[2], 'windows-') ? ' --build-cli' : (' --build-embed' . ($frankenphp ? ' --build-frankenphp' : ''))), $retcode); break; case 'doctor_cmd': From becee5b42671d2b54316460bad699c8cb18aead1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 21:27:07 +0800 Subject: [PATCH 270/319] Use version instead of -v --- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 44756955..d424c594 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -227,7 +227,7 @@ abstract class UnixBuilderBase extends BuilderBase if (!file_exists($frankenphp)) { throw new RuntimeException('FrankenPHP binary not found: ' . $frankenphp); } - [$ret, $output] = shell()->execWithResult($frankenphp . ' -v'); + [$ret, $output] = shell()->execWithResult("{$frankenphp} version"); if ($ret !== 0 || !str_contains(implode('', $output), 'FrankenPHP')) { throw new RuntimeException('FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']'); } From a76f49f92739d03c683e08ed7cc6e66a9849c83d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 18 Jun 2025 21:56:36 +0800 Subject: [PATCH 271/319] Remove libxml2 requirement for linux --- src/SPC/builder/BuilderBase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index fd4788f8..daa27765 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -527,8 +527,8 @@ abstract class BuilderBase throw new WrongUsageException("FrankenPHP SAPI requires go-mod-frankenphp package, please install it first: {$argv[0]} install-pkg go-mod-frankenphp"); } // frankenphp needs libxml2 libs - if (!$this->getLib('libxml2')) { - throw new WrongUsageException('FrankenPHP SAPI requires libxml2 library, please include `xml` extension in your build.'); + if (PHP_OS_FAMILY === 'Darwin' && !$this->getLib('libxml2')) { + throw new WrongUsageException('FrankenPHP SAPI for macOS requires libxml2 library, please include `xml` extension in your build.'); } } } From 15979d4636b060f90c624900778d3858f1a034ac Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 08:59:56 +0700 Subject: [PATCH 272/319] fix double path --- src/SPC/store/pkg/GoModFrankenphp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoModFrankenphp.php index bede5d22..3b93ceac 100644 --- a/src/SPC/store/pkg/GoModFrankenphp.php +++ b/src/SPC/store/pkg/GoModFrankenphp.php @@ -45,7 +45,7 @@ class GoModFrankenphp extends CustomPackage $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); $source_type = $lock[$name]['source_type']; $filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']); - $extract = $lock[$name]['move_path'] === null ? (PKG_ROOT_PATH . "{$pkgroot}/{$name}") : $lock[$name]['move_path']; + $extract = $lock[$name]['move_path'] === null ? "{$pkgroot}/{$name}" : $lock[$name]['move_path']; FileSystem::extractPackage($name, $source_type, $filename, $extract); From cb010d81ac5f943ce8b2f344060efcb0576ee030 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:03:40 +0700 Subject: [PATCH 273/319] there's no documented functionality to download without building - xcaddy is meant to do both in one step --- src/SPC/store/pkg/GoModFrankenphp.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoModFrankenphp.php index 3b93ceac..59507b6c 100644 --- a/src/SPC/store/pkg/GoModFrankenphp.php +++ b/src/SPC/store/pkg/GoModFrankenphp.php @@ -52,13 +52,13 @@ class GoModFrankenphp extends CustomPackage // install xcaddy $go_exec = PKG_ROOT_PATH . "{$pkgroot}/{$name}/bin/go"; // $xcaddy_exec = PKG_ROOT_PATH . "$pkgroot/$name/bin/xcaddy"; - shell()->appendEnv([ - 'PATH' => "{$pkgroot}/{$name}/bin:" . getenv('PATH'), - 'GOROOT' => "{$pkgroot}/{$name}", - 'GOBIN' => "{$pkgroot}/{$name}/bin", - 'GOPATH' => "{$pkgroot}/go", - ]) + shell() + ->appendEnv([ + 'PATH' => "{$pkgroot}/{$name}/bin:" . getenv('PATH'), + 'GOROOT' => "{$pkgroot}/{$name}", + 'GOBIN' => "{$pkgroot}/{$name}/bin", + 'GOPATH' => "{$pkgroot}/go", + ]) ->exec("{$go_exec} install github.com/caddyserver/xcaddy/cmd/xcaddy@latest"); - // TODO: Here to download dependencies for xcaddy and frankenphp first } } From b42409efd183f68141865589479e00ae85e9674b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:08:42 +0700 Subject: [PATCH 274/319] LD_LIBRARY_PATH for frankenphp sanity check --- src/SPC/builder/unix/UnixBuilderBase.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index d424c594..adde474a 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -227,7 +227,9 @@ abstract class UnixBuilderBase extends BuilderBase if (!file_exists($frankenphp)) { throw new RuntimeException('FrankenPHP binary not found: ' . $frankenphp); } - [$ret, $output] = shell()->execWithResult("{$frankenphp} version"); + [$ret, $output] = shell() + ->setEnv(['LD_LIBRARY_PATH' => BUILD_LIB_PATH]) + ->execWithResult("{$frankenphp} version"); if ($ret !== 0 || !str_contains(implode('', $output), 'FrankenPHP')) { throw new RuntimeException('FrankenPHP failed sanity check: ret[' . $ret . ']. out[' . implode('', $output) . ']'); } @@ -308,7 +310,6 @@ abstract class UnixBuilderBase extends BuilderBase $arch = arch2gnu(php_uname('m')); // define executables for go and xcaddy - $go_exec = PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin/go"; $xcaddy_exec = PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin/xcaddy"; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; From 804468f7b913ce64563b3c486666fa0d443aa003 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:14:39 +0700 Subject: [PATCH 275/319] refactor common exec code out --- src/SPC/util/UnixShell.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index 0f320d50..bb4e8d5e 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -44,14 +44,7 @@ class UnixShell { /* @phpstan-ignore-next-line */ logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd)); - logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); - $env_str = $this->getEnvString(); - if (!empty($env_str)) { - $cmd = "{$env_str} {$cmd}"; - } - if ($this->cd !== null) { - $cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd; - } + $cmd = $this->getExecString($cmd); if (!$this->debug) { $cmd .= ' 1>/dev/null 2>&1'; } @@ -99,10 +92,7 @@ class UnixShell /* @phpstan-ignore-next-line */ logger()->debug(ConsoleColor::blue('[EXEC] ') . ConsoleColor::gray($cmd)); } - logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); - if ($this->cd !== null) { - $cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd; - } + $cmd = $this->getExecString($cmd); exec($cmd, $out, $code); return [$code, $out]; } @@ -126,4 +116,21 @@ class UnixShell } return trim($str); } + + /** + * @param string $cmd + * @return string + */ + private function getExecString(string $cmd): string + { + logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); + $env_str = $this->getEnvString(); + if (!empty($env_str)) { + $cmd = "{$env_str} {$cmd}"; + } + if ($this->cd !== null) { + $cmd = 'cd ' . escapeshellarg($this->cd) . ' && ' . $cmd; + } + return $cmd; + } } From a9713c3bfa5c4d5db2c0ce5394c1af88e32b8a69 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:32:55 +0700 Subject: [PATCH 276/319] polish merge --- src/SPC/store/Downloader.php | 11 ----------- src/SPC/util/UnixShell.php | 4 ---- 2 files changed, 15 deletions(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 9435202f..4c3bbf61 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -650,17 +650,6 @@ class Downloader return true; } } - - // If lock file exists, skip downloading for source mode - if (!$force && $download_as === SPC_DOWNLOAD_PACKAGE && isset($lock[$name])) { - if ( - $lock[$name]['source_type'] === SPC_SOURCE_ARCHIVE && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename']) || - $lock[$name]['source_type'] === SPC_SOURCE_GIT && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname']) - ) { - logger()->notice("Package [{$name}] already downloaded: " . ($lock[$name]['filename'] ?? $lock[$name]['dirname'])); - return true; - } - } return false; } } diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index bb4e8d5e..ffe18910 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -117,10 +117,6 @@ class UnixShell return trim($str); } - /** - * @param string $cmd - * @return string - */ private function getExecString(string $cmd): string { logger()->debug('Executed at: ' . debug_backtrace()[0]['file'] . ':' . debug_backtrace()[0]['line']); From cc09184183ec8ef7267a0519b49cd9fa5edcb2ec Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:34:44 +0700 Subject: [PATCH 277/319] fix test --- tests/SPC/builder/BuilderTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/SPC/builder/BuilderTest.php b/tests/SPC/builder/BuilderTest.php index 17f1e799..8e6cdc41 100644 --- a/tests/SPC/builder/BuilderTest.php +++ b/tests/SPC/builder/BuilderTest.php @@ -161,7 +161,8 @@ class BuilderTest extends TestCase [BUILD_TARGET_FPM, 'fpm'], [BUILD_TARGET_MICRO, 'micro'], [BUILD_TARGET_EMBED, 'embed'], - [BUILD_TARGET_ALL, 'cli, micro, fpm, embed'], + [BUILD_TARGET_FRANKENPHP, 'embed, frankenphp'], + [BUILD_TARGET_ALL, 'cli, micro, fpm, embed, frankenphp'], [BUILD_TARGET_CLI | BUILD_TARGET_EMBED, 'cli, embed'], ]; } From 497728693697c3a8fd9611ce9db6037115651734 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:43:13 +0700 Subject: [PATCH 278/319] fix test --- tests/SPC/builder/BuilderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SPC/builder/BuilderTest.php b/tests/SPC/builder/BuilderTest.php index 8e6cdc41..2bdf1109 100644 --- a/tests/SPC/builder/BuilderTest.php +++ b/tests/SPC/builder/BuilderTest.php @@ -161,7 +161,7 @@ class BuilderTest extends TestCase [BUILD_TARGET_FPM, 'fpm'], [BUILD_TARGET_MICRO, 'micro'], [BUILD_TARGET_EMBED, 'embed'], - [BUILD_TARGET_FRANKENPHP, 'embed, frankenphp'], + [BUILD_TARGET_FRANKENPHP, 'frankenphp'], [BUILD_TARGET_ALL, 'cli, micro, fpm, embed, frankenphp'], [BUILD_TARGET_CLI | BUILD_TARGET_EMBED, 'cli, embed'], ]; From c2d6b9ad2cd6e82e6460ce5d23d458f42fe295dc Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 09:50:38 +0700 Subject: [PATCH 279/319] refactor lock file constant out --- src/SPC/command/DownloadCommand.php | 3 ++- src/SPC/store/LockFile.php | 2 +- src/SPC/store/pkg/GoModFrankenphp.php | 3 ++- tests/SPC/builder/BuilderTest.php | 3 ++- tests/SPC/store/DownloaderTest.php | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 57e83cd0..d5054aa9 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -12,6 +12,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\Downloader; +use SPC\store\LockFile; use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -301,7 +302,7 @@ class DownloadCommand extends BaseCommand throw new WrongUsageException('Windows currently does not support --from-zip !'); } - if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { + if (!file_exists(LockFile::LOCK_FILE)) { throw new RuntimeException('.lock.json not exist in "downloads/"'); } } catch (RuntimeException $e) { diff --git a/src/SPC/store/LockFile.php b/src/SPC/store/LockFile.php index 45e3a94c..044b2472 100644 --- a/src/SPC/store/LockFile.php +++ b/src/SPC/store/LockFile.php @@ -10,7 +10,7 @@ use SPC\exception\WrongUsageException; class LockFile { - private const string LOCK_FILE = DOWNLOAD_PATH . '/.lock.json'; + public const string LOCK_FILE = DOWNLOAD_PATH . '/.lock.json'; private static ?array $lock_file_content = null; diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoModFrankenphp.php index 59507b6c..31195cd9 100644 --- a/src/SPC/store/pkg/GoModFrankenphp.php +++ b/src/SPC/store/pkg/GoModFrankenphp.php @@ -6,6 +6,7 @@ namespace SPC\store\pkg; use SPC\store\Downloader; use SPC\store\FileSystem; +use SPC\store\LockFile; class GoModFrankenphp extends CustomPackage { @@ -42,7 +43,7 @@ class GoModFrankenphp extends CustomPackage public function extract(string $name): void { $pkgroot = PKG_ROOT_PATH; - $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); + $lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true); $source_type = $lock[$name]['source_type']; $filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']); $extract = $lock[$name]['move_path'] === null ? "{$pkgroot}/{$name}" : $lock[$name]['move_path']; diff --git a/tests/SPC/builder/BuilderTest.php b/tests/SPC/builder/BuilderTest.php index 2bdf1109..b80f4a0d 100644 --- a/tests/SPC/builder/BuilderTest.php +++ b/tests/SPC/builder/BuilderTest.php @@ -13,6 +13,7 @@ use SPC\builder\LibraryBase; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; +use SPC\store\LockFile; use SPC\util\CustomExt; use SPC\util\DependencyUtil; use Symfony\Component\Console\Input\ArgvInput; @@ -117,7 +118,7 @@ class BuilderTest extends TestCase public function testGetPHPVersionFromArchive() { - $lock = file_exists(DOWNLOAD_PATH . '/.lock.json') ? file_get_contents(DOWNLOAD_PATH . '/.lock.json') : false; + $lock = file_exists(LockFile::LOCK_FILE) ? file_get_contents(LockFile::LOCK_FILE) : false; if ($lock === false) { $this->assertFalse($this->builder->getPHPVersionFromArchive()); } else { diff --git a/tests/SPC/store/DownloaderTest.php b/tests/SPC/store/DownloaderTest.php index 43de396a..91865bfb 100644 --- a/tests/SPC/store/DownloaderTest.php +++ b/tests/SPC/store/DownloaderTest.php @@ -59,8 +59,8 @@ class DownloaderTest extends TestCase public function testLockSource() { LockFile::lockSource('fake-file', ['source_type' => SPC_SOURCE_ARCHIVE, 'filename' => 'fake-file-name', 'move_path' => 'fake-path', 'lock_as' => 'fake-lock-as']); - $this->assertFileExists(DOWNLOAD_PATH . '/.lock.json'); - $json = json_decode(file_get_contents(DOWNLOAD_PATH . '/.lock.json'), true); + $this->assertFileExists(LockFile::LOCK_FILE); + $json = json_decode(file_get_contents(LockFile::LOCK_FILE), true); $this->assertIsArray($json); $this->assertArrayHasKey('fake-file', $json); $this->assertArrayHasKey('source_type', $json['fake-file']); From 597db25178f1022a6c98d6282706a7fd5796c199 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 10:00:56 +0700 Subject: [PATCH 280/319] frankenphp requires ZTS --- src/SPC/command/BuildPHPCommand.php | 7 +++++++ src/SPC/store/LockFile.php | 1 + 2 files changed, 8 insertions(+) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 29cedf8f..92852e41 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -319,6 +319,13 @@ class BuildPHPCommand extends BuildCommand $rule |= BUILD_TARGET_EMBED; f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared')); } + if ($this->getOption('build-frankenphp')) { + $rule |= BUILD_TARGET_FRANKENPHP; + if (!$this->getOption('enable-zts')) { + logger()->warning('FrankenPHP requires ZTS to work with multiple threads, the --enable-zts option will be enabled automatically!'); + $this->input->setOption('enable-zts', true); + } + } $rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; diff --git a/src/SPC/store/LockFile.php b/src/SPC/store/LockFile.php index 044b2472..132d3764 100644 --- a/src/SPC/store/LockFile.php +++ b/src/SPC/store/LockFile.php @@ -78,6 +78,7 @@ class LockFile } // Write the updated lock data back to the file + FileSystem::createDir(dirname(self::LOCK_FILE)); file_put_contents(self::LOCK_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } From 32dc5d3cdba1c5f61dd38f254243240ff9ff1ccd Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 10:02:22 +0700 Subject: [PATCH 281/319] leftover double path --- src/SPC/store/pkg/GoModFrankenphp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoModFrankenphp.php index 31195cd9..b45394a2 100644 --- a/src/SPC/store/pkg/GoModFrankenphp.php +++ b/src/SPC/store/pkg/GoModFrankenphp.php @@ -51,7 +51,7 @@ class GoModFrankenphp extends CustomPackage FileSystem::extractPackage($name, $source_type, $filename, $extract); // install xcaddy - $go_exec = PKG_ROOT_PATH . "{$pkgroot}/{$name}/bin/go"; + $go_exec = "{$pkgroot}/{$name}/bin/go"; // $xcaddy_exec = PKG_ROOT_PATH . "$pkgroot/$name/bin/xcaddy"; shell() ->appendEnv([ From ba6ed137c6f8ff781eed3b89bf03f9a488657db5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 10:03:35 +0700 Subject: [PATCH 282/319] remove old file deletions --- src/SPC/command/BuildPHPCommand.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 92852e41..f304a3b9 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -162,21 +162,6 @@ class BuildPHPCommand extends BuildCommand $indent_texts['UPX Pack'] = 'enabled'; } - try { - $cleanPhpSrc = $builder->getPHPVersion() !== $builder->getPHPVersionFromArchive(); - } catch (RuntimeException|WrongUsageException) { - $cleanPhpSrc = true; - } - if ($cleanPhpSrc) { - logger()->info('Cleaning previous php build due to mismatching versions...'); - FileSystem::removeDir(SOURCE_PATH . '/php-src'); - FileSystem::removeDir(BUILD_MODULES_PATH); - $binFiles = glob(BUILD_BIN_PATH . '/php*'); - $libFiles = glob(BUILD_LIB_PATH . '/libphp*'); - foreach ([...$binFiles, ...$libFiles] as $file) { - unlink($file); - } - } $ver = $builder->getPHPVersionFromArchive() ?: $builder->getPHPVersion(); $indent_texts['PHP Version'] = $ver; From aec03b2f24b8b37b44748ef67e0236d94e3eaca9 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 10:08:51 +0700 Subject: [PATCH 283/319] move enable zts check --- src/SPC/builder/BuilderBase.php | 9 ++++++--- src/SPC/command/BuildPHPCommand.php | 7 ------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 6303ffec..956aee6c 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -513,7 +513,10 @@ abstract class BuilderBase public function checkBeforeBuildPHP(int $rule): void { if (($rule & BUILD_TARGET_FRANKENPHP) === BUILD_TARGET_FRANKENPHP) { - // frankenphp only support linux and macOS + if (!$this->getOption('enable-zts')) { + throw new WrongUsageException('FrankenPHP SAPI requires ZTS enabled PHP, build with `--enable-zts`!'); + } + // frankenphp doesn't support windows, BSD is currently not supported by static-php-cli if (!in_array(PHP_OS_FAMILY, ['Linux', 'Darwin'])) { throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!'); } @@ -523,9 +526,9 @@ abstract class BuilderBase global $argv; throw new WrongUsageException("FrankenPHP SAPI requires go-mod-frankenphp package, please install it first: {$argv[0]} install-pkg go-mod-frankenphp"); } - // frankenphp needs libxml2 libs + // frankenphp needs libxml2 lib on macos, see: https://github.com/php/frankenphp/blob/main/frankenphp.go#L17 if (PHP_OS_FAMILY === 'Darwin' && !$this->getLib('libxml2')) { - throw new WrongUsageException('FrankenPHP SAPI for macOS requires libxml2 library, please include `xml` extension in your build.'); + throw new WrongUsageException('FrankenPHP SAPI for macOS requires libxml2 library, please include the `xml` extension in your build.'); } } } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index f304a3b9..13c737a7 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -304,13 +304,6 @@ class BuildPHPCommand extends BuildCommand $rule |= BUILD_TARGET_EMBED; f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared')); } - if ($this->getOption('build-frankenphp')) { - $rule |= BUILD_TARGET_FRANKENPHP; - if (!$this->getOption('enable-zts')) { - logger()->warning('FrankenPHP requires ZTS to work with multiple threads, the --enable-zts option will be enabled automatically!'); - $this->input->setOption('enable-zts', true); - } - } $rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; From 2bc9fef75839bfc314922fafb04e67ade8e4f882 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 10:09:42 +0700 Subject: [PATCH 284/319] cs fix --- src/SPC/command/BuildPHPCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 13c737a7..e40a7d83 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -6,7 +6,6 @@ namespace SPC\command; use SPC\builder\BuilderProvider; use SPC\exception\ExceptionHandler; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; From 5f3f999222060d14d25379fcc15aa598a5b6170a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 10:36:31 +0700 Subject: [PATCH 285/319] run go mod frankenphp automatically when running craft --- config/env.ini | 2 +- src/SPC/builder/linux/LinuxBuilder.php | 1 - src/SPC/builder/unix/UnixBuilderBase.php | 2 +- src/SPC/command/CraftCommand.php | 9 +++++++++ src/SPC/store/pkg/GoModFrankenphp.php | 15 +++++++++++++-- src/SPC/util/GlobalEnvManager.php | 5 ++++- 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/config/env.ini b/config/env.ini index 895a08e9..d80bc3e7 100644 --- a/config/env.ini +++ b/config/env.ini @@ -69,7 +69,7 @@ SPC_LIBC=musl CC=${SPC_LINUX_DEFAULT_CC} CXX=${SPC_LINUX_DEFAULT_CXX} AR=${SPC_LINUX_DEFAULT_AR} -LD=ld.gold +LD=${SPC_LINUX_DEFAULT_LD} ; default compiler flags, used in CMake toolchain file, openssl and pkg-config build SPC_DEFAULT_C_FLAGS="-fPIC -Os" SPC_DEFAULT_CXX_FLAGS="-fPIC -Os" diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index addd2f57..722601d1 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -33,7 +33,6 @@ class LinuxBuilder extends UnixBuilderBase if (getenv('SPC_LIBC') === 'musl' && !SystemUtil::isMuslDist()) { $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\""); $this->setOptionIfNotExist('ld_library_path', "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\""); - GlobalEnvManager::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); $configure = getenv('SPC_CMD_PREFIX_PHP_CONFIGURE'); $configure = "LD_LIBRARY_PATH=\"/usr/local/musl/{$arch}-linux-musl/lib\" " . $configure; GlobalEnvManager::putenv("SPC_CMD_PREFIX_PHP_CONFIGURE={$configure}"); diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index adde474a..4232ef91 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -324,7 +324,7 @@ abstract class UnixBuilderBase extends BuilderBase $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); } $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; - $releaseInfo = json_decode(Downloader::curlExec('https://api.github.com/repos/php/frankenphp/releases/latest'), true); + $releaseInfo = json_decode(Downloader::curlExec('https://api.github.com/repos/php/frankenphp/releases/latest', retries: 3), true); $frankenPhpVersion = $releaseInfo['tag_name']; $libphpVersion = $this->getPHPVersion(); if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 9a2ac441..744d1c57 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -66,6 +66,15 @@ class CraftCommand extends BaseCommand return static::FAILURE; } } + // install go and xcaddy for frankenphp + if (in_array('frankenphp', $craft['sapi'])) { + $retcode = $this->runCommand('install-pkg', 'go-mod-frankenphp'); + if ($retcode !== 0) { + $this->output->writeln('craft go-mod-frankenphp failed'); + $this->log("craft go-mod-frankenphp failed with code: {$retcode}", true); + return static::FAILURE; + } + } // craft download if ($craft['craft-options']['download']) { $sharedAppend = $shared_extensions ? ',' . $shared_extensions : ''; diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoModFrankenphp.php index b45394a2..e631cc8c 100644 --- a/src/SPC/store/pkg/GoModFrankenphp.php +++ b/src/SPC/store/pkg/GoModFrankenphp.php @@ -7,6 +7,7 @@ namespace SPC\store\pkg; use SPC\store\Downloader; use SPC\store\FileSystem; use SPC\store\LockFile; +use SPC\util\GlobalEnvManager; class GoModFrankenphp extends CustomPackage { @@ -22,6 +23,12 @@ class GoModFrankenphp extends CustomPackage public function fetch(string $name, bool $force = false, ?array $config = null): void { + $pkgroot = PKG_ROOT_PATH; + $go_exec = "{$pkgroot}/{$name}/bin/go"; + $xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy"; + if (file_exists($go_exec) && file_exists($xcaddy_exec)) { + return; + } $arch = match (explode('-', $name)[3]) { 'x86_64' => 'amd64', 'aarch64' => 'arm64', @@ -43,6 +50,11 @@ class GoModFrankenphp extends CustomPackage public function extract(string $name): void { $pkgroot = PKG_ROOT_PATH; + $go_exec = "{$pkgroot}/{$name}/bin/go"; + $xcaddy_exec = "{$pkgroot}/{$name}/bin/xcaddy"; + if (file_exists($go_exec) && file_exists($xcaddy_exec)) { + return; + } $lock = json_decode(FileSystem::readFile(LockFile::LOCK_FILE), true); $source_type = $lock[$name]['source_type']; $filename = DOWNLOAD_PATH . '/' . ($lock[$name]['filename'] ?? $lock[$name]['dirname']); @@ -50,9 +62,8 @@ class GoModFrankenphp extends CustomPackage FileSystem::extractPackage($name, $source_type, $filename, $extract); + GlobalEnvManager::init(); // install xcaddy - $go_exec = "{$pkgroot}/{$name}/bin/go"; - // $xcaddy_exec = PKG_ROOT_PATH . "$pkgroot/$name/bin/xcaddy"; shell() ->appendEnv([ 'PATH' => "{$pkgroot}/{$name}/bin:" . getenv('PATH'), diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 8ffd5d05..c5a0598a 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -43,16 +43,19 @@ class GlobalEnvManager } // Define env vars for linux - if (PHP_OS_FAMILY === 'Linux') { + if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') { $arch = getenv('GNU_ARCH'); if (SystemUtil::isMuslDist()) { self::putenv('SPC_LINUX_DEFAULT_CC=gcc'); self::putenv('SPC_LINUX_DEFAULT_CXX=g++'); self::putenv('SPC_LINUX_DEFAULT_AR=ar'); + self::putenv('SPC_LINUX_DEFAULT_LD=ld.gold'); } else { self::putenv("SPC_LINUX_DEFAULT_CC={$arch}-linux-musl-gcc"); self::putenv("SPC_LINUX_DEFAULT_CXX={$arch}-linux-musl-g++"); self::putenv("SPC_LINUX_DEFAULT_AR={$arch}-linux-musl-ar"); + self::putenv("SPC_LINUX_DEFAULT_LD={$arch}-linux-musl-ld"); + GlobalEnvManager::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); } } From 2f8e225abdd01b0f8bc46c1baae29855be330cef Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 11:00:07 +0700 Subject: [PATCH 286/319] remove copy of property that meant downloader would only lock one source at a time --- src/SPC/store/Downloader.php | 6 ++++++ src/SPC/store/LockFile.php | 11 +++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 4c3bbf61..ba0cd124 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -650,6 +650,12 @@ class Downloader return true; } } + if (!$force && $download_as === SPC_DOWNLOAD_PACKAGE && $lock_item !== null) { + if (file_exists($path = LockFile::getLockFullPath($lock_item))) { + logger()->notice("Source [{$name}] already downloaded: {$path}"); + return true; + } + } return false; } } diff --git a/src/SPC/store/LockFile.php b/src/SPC/store/LockFile.php index 132d3764..999f91b4 100644 --- a/src/SPC/store/LockFile.php +++ b/src/SPC/store/LockFile.php @@ -69,17 +69,16 @@ class LockFile { self::init(); - $data = self::$lock_file_content; - if ($lock_content === null && isset($data[$lock_name])) { - self::removeLockFileIfExists($data[$lock_name]); - unset($data[$lock_name]); + if ($lock_content === null && isset(self::$lock_file_content[$lock_name])) { + self::removeLockFileIfExists(self::$lock_file_content[$lock_name]); + unset(self::$lock_file_content[$lock_name]); } else { - $data[$lock_name] = $lock_content; + self::$lock_file_content[$lock_name] = $lock_content; } // Write the updated lock data back to the file FileSystem::createDir(dirname(self::LOCK_FILE)); - file_put_contents(self::LOCK_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + file_put_contents(self::LOCK_FILE, json_encode(self::$lock_file_content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); } /** From fcf2c967abe5f252c8cc5ca38f8b6e6153369a28 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 11:01:30 +0700 Subject: [PATCH 287/319] fix setting of variables --- src/SPC/util/GlobalEnvManager.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index c5a0598a..ae251223 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -43,9 +43,9 @@ class GlobalEnvManager } // Define env vars for linux - if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') { + if (PHP_OS_FAMILY === 'Linux') { $arch = getenv('GNU_ARCH'); - if (SystemUtil::isMuslDist()) { + if (SystemUtil::isMuslDist() || getenv('SPC_LIBC') !== 'musl') { self::putenv('SPC_LINUX_DEFAULT_CC=gcc'); self::putenv('SPC_LINUX_DEFAULT_CXX=g++'); self::putenv('SPC_LINUX_DEFAULT_AR=ar'); From bcea2007bd376f2a8349dfda78ec7c7ed0866d3c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 11:04:10 +0700 Subject: [PATCH 288/319] base arch instead of hardcoded x86_64 --- bin/spc-gnu-docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 9583b4dd..9327cd7e 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -74,7 +74,7 @@ RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc RUN source /etc/bashrc RUN yum install -y which -RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-x86_64.tar.gz && \ +RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$BASE_ARCH.tar.gz && \ mkdir -p /patchelf && \ tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \ cp /patchelf/bin/patchelf /usr/bin/ From 4a70f260f387ec5d60a98fc55c20181e0966ab29 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 11:12:58 +0700 Subject: [PATCH 289/319] test alpine directly too (spc-alpine-docker) --- src/SPC/util/GlobalEnvManager.php | 2 +- src/globals/test-extensions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index ae251223..17785205 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -45,7 +45,7 @@ class GlobalEnvManager // Define env vars for linux if (PHP_OS_FAMILY === 'Linux') { $arch = getenv('GNU_ARCH'); - if (SystemUtil::isMuslDist() || getenv('SPC_LIBC') !== 'musl') { + if (SystemUtil::isMuslDist() || getenv('SPC_LIBC') === 'glibc') { self::putenv('SPC_LINUX_DEFAULT_CC=gcc'); self::putenv('SPC_LINUX_DEFAULT_CXX=g++'); self::putenv('SPC_LINUX_DEFAULT_AR=ar'); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 79acc984..db51db5e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -24,7 +24,7 @@ $test_os = [ 'macos-13', // 'macos-14', 'macos-15', - // 'ubuntu-latest', + 'ubuntu-latest', 'ubuntu-22.04', 'ubuntu-24.04', 'ubuntu-22.04-arm', From 61a9264802d94bda4b531eb0f565b4ac37b99789 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 11:20:57 +0700 Subject: [PATCH 290/319] libraries must link against -lphp dynamic! --- bin/spc-alpine-docker | 3 ++- bin/spc-gnu-docker | 2 +- src/SPC/builder/Extension.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index 0733b232..cb7d7b4c 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -84,7 +84,8 @@ RUN apk update; \ wget \ xz \ gettext-dev \ - binutils-gold + binutils-gold \ + patchelf RUN curl -#fSL https://dl.static-php.dev/static-php-cli/bulk/php-8.4.4-cli-linux-\$(uname -m).tar.gz | tar -xz -C /usr/local/bin && \ chmod +x /usr/local/bin/php diff --git a/bin/spc-gnu-docker b/bin/spc-gnu-docker index 9327cd7e..92496e03 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -141,7 +141,7 @@ echo 'CC=/opt/rh/devtoolset-10/root/usr/bin/gcc' > /tmp/spc-gnu-docker.env echo 'CXX=/opt/rh/devtoolset-10/root/usr/bin/g++' >> /tmp/spc-gnu-docker.env echo 'AR=/opt/rh/devtoolset-10/root/usr/bin/ar' >> /tmp/spc-gnu-docker.env echo 'LD=/opt/rh/devtoolset-10/root/usr/bin/ld' >> /tmp/spc-gnu-docker.env -echo 'SPC_DEFAULT_C_FLAGS=-fPIE -fPIC' >> /tmp/spc-gnu-docker.env +echo 'SPC_DEFAULT_C_FLAGS=-fPIC' >> /tmp/spc-gnu-docker.env echo 'SPC_LIBC=glibc' >> /tmp/spc-gnu-docker.env echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM="-Wl,-O1 -pie"' >> /tmp/spc-gnu-docker.env echo 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS="-ldl -lpthread -lm -lresolv -lutil -lrt"' >> /tmp/spc-gnu-docker.env diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 4ea135a4..a457d82e 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -503,7 +503,7 @@ class Extension continue; } $static_lib = 'lib' . $lib . '.a'; - if (file_exists(BUILD_LIB_PATH . '/' . $static_lib)) { + if (file_exists(BUILD_LIB_PATH . '/' . $static_lib) && !str_contains($static_lib, 'libphp')) { if (!str_contains($staticLibString, '-l' . $lib . ' ')) { $staticLibString .= '-l' . $lib . ' '; } From 1357990c4cf110a69c6e5e21ac1730a7559e0908 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 19 Jun 2025 12:51:00 +0800 Subject: [PATCH 291/319] Add github token hook for curlExec --- src/SPC/builder/unix/UnixBuilderBase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 4232ef91..d88605ae 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -12,6 +12,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\store\CurlHook; use SPC\store\Downloader; use SPC\store\FileSystem; use SPC\util\DependencyUtil; @@ -324,7 +325,7 @@ abstract class UnixBuilderBase extends BuilderBase $xcaddyModules = str_replace('--with github.com/dunglas/caddy-cbrotli', '', $xcaddyModules); } $lrt = PHP_OS_FAMILY === 'Linux' ? '-lrt' : ''; - $releaseInfo = json_decode(Downloader::curlExec('https://api.github.com/repos/php/frankenphp/releases/latest', retries: 3), true); + $releaseInfo = json_decode(Downloader::curlExec('https://api.github.com/repos/php/frankenphp/releases/latest', retries: 3, hooks: [[CurlHook::class, 'setupGithubToken']]), true); $frankenPhpVersion = $releaseInfo['tag_name']; $libphpVersion = $this->getPHPVersion(); if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { From 82ec7733bafd8152ec20df7edc0341b93c224c87 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 11:59:41 +0700 Subject: [PATCH 292/319] musl: all-static! --- src/SPC/builder/unix/UnixBuilderBase.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index d88605ae..a13a8e72 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -331,7 +331,13 @@ abstract class UnixBuilderBase extends BuilderBase if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') { $libphpVersion = preg_replace('/\.\d$/', '', $libphpVersion); } - $debugFlags = $this->getOption('--with-debug') ? "'-w -s' " : ''; + $debugFlags = $this->getOption('no-strip') ? "'-w -s' " : ''; + $extLdFlags = "-extldflags '-pie'"; + $muslTags = ''; + if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') { + $extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000'"; + $muslTags = 'static_build,'; + } $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true); @@ -344,10 +350,10 @@ abstract class UnixBuilderBase extends BuilderBase 'CGO_CFLAGS' => $config['cflags'], 'CGO_LDFLAGS' => "{$config['ldflags']} {$config['libs']} {$lrt}", 'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' . - '-ldflags \"-linkmode=external -extldflags \'-pie\' ' . $debugFlags . + '-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags . '-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' . "{$frankenPhpVersion} PHP {$libphpVersion} Caddy'\\\" " . - "-tags=nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", + "-tags={$muslTags}nobadger,nomysql,nopgx{$nobrotli}{$nowatcher}", 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; shell()->cd(BUILD_BIN_PATH) From 437d6810b764db7afc572dd3a862b9c99cd46883 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 19 Jun 2025 13:01:26 +0800 Subject: [PATCH 293/319] Bump version, update docs, change owner dunglas to php --- README-zh.md | 2 +- README.md | 2 +- config/env.ini | 2 +- docs/en/guide/manual-build.md | 4 ++++ docs/zh/guide/manual-build.md | 4 ++++ src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 4 ++-- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README-zh.md b/README-zh.md index 0cbc4780..03fa7160 100755 --- a/README-zh.md +++ b/README-zh.md @@ -278,7 +278,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys 如果你知道 [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed),你应该知道如何使用它。对于有可能编译用到引入其他库的问题,你可以使用 `buildroot/bin/php-config` 来获取编译时的配置。 -另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/dunglas/frankenphp/blob/main/docs/static.md)。 +另外,有关如何使用此功能的高级示例,请查看[如何使用它构建 FrankenPHP 的静态版本](https://github.com/php/frankenphp/blob/main/docs/static.md)。 ## 贡献 diff --git a/README.md b/README.md index 301d76fd..94c10d58 100755 --- a/README.md +++ b/README.md @@ -302,7 +302,7 @@ If you know [embed SAPI](https://github.com/php/php-src/tree/master/sapi/embed), You may require the introduction of other libraries during compilation, you can use `buildroot/bin/php-config` to obtain the compile-time configuration. -For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/dunglas/frankenphp/blob/main/docs/static.md). +For an advanced example of how to use this feature, take a look at [how to use it to build a static version of FrankenPHP](https://github.com/php/frankenphp/blob/main/docs/static.md). ## Contribution diff --git a/config/env.ini b/config/env.ini index d80bc3e7..aa85751b 100644 --- a/config/env.ini +++ b/config/env.ini @@ -43,7 +43,7 @@ SPC_SKIP_PHP_VERSION_CHECK="no" ; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed") SPC_SKIP_DOCTOR_CHECK_ITEMS="" ; extra modules that xcaddy will include in the FrankenPHP build -SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" +SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/php/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" ; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them ; only useful for builds targeting not pure-static linking diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index 3c40d5eb..80c4e95b 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -167,6 +167,7 @@ If the build is successful, you will see the `buildroot/bin` directory in the cu - fpm: The build result is `buildroot/bin/php-fpm`. - micro: The build result is `buildroot/bin/micro.sfx`. If you need to further package it with PHP code, please refer to [Packaging micro binary](./manual-build#command-micro-combine). - embed: See [Using embed](./manual-build#embed-usage). +- frankenphp: The build result is `buildroot/bin/frankenphp`. If the build fails, you can use the `--debug` parameter to view detailed error information, or use the `--with-clean` to clear the old compilation results and recompile. @@ -290,6 +291,7 @@ You need to specify a compilation target, choose from the following parameters: - `--build-fpm`: Build a fpm sapi (php-fpm, used in conjunction with other traditional fpm architecture software such as nginx) - `--build-micro`: Build a micro sapi (used to build a standalone executable binary containing PHP code) - `--build-embed`: Build an embed sapi (used to embed into other C language programs) +- `--build-frankenphp`: Build a [FrankenPHP](https://github.com/php/frankenphp) executable - `--build-all`: build all above sapi ```bash @@ -509,6 +511,8 @@ When `bin/spc doctor` automatically repairs the Windows environment, tools such Here is an example of installing the tool: - Download and install UPX (Linux and Windows only): `bin/spc install-pkg upx` +- Download and install nasm (Windows only): `bin/spc install-pkg nasm` +- Download and install go-mod-frankenphp: `bin/spc install-pkg go-mod-frankenphp` ## Command - del-download diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index ca0395c8..230680ce 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -145,6 +145,7 @@ bin/spc craft --debug - fpm: 构建结果为 `buildroot/bin/php-fpm`。 - micro: 构建结果为 `buildroot/bin/micro.sfx`,如需进一步与 PHP 代码打包,请查看 [打包 micro 二进制](./manual-build#命令-micro-combine-打包-micro-二进制)。 - embed: 参见 [embed 使用](./manual-build#embed-使用)。 +- frankenphp: 构建结果为 `buildroot/bin/frankenphp`。 如果中途构建出错,你可以使用 `--debug` 参数查看详细的错误信息,或者使用 `--with-clean` 参数清除旧的编译结果,重新编译。 @@ -250,6 +251,7 @@ bin/spc doctor --auto-fix - `--build-fpm`: 构建一个 fpm sapi(php-fpm,用于和其他传统的 fpm 架构的软件如 nginx 配合使用) - `--build-micro`: 构建一个 micro sapi(用于构建一个包含 PHP 代码的独立可执行二进制) - `--build-embed`: 构建一个 embed sapi(用于嵌入到其他 C 语言程序中) +- `--build-frankenphp`: 构建一个 [frankenphp](https://github.com/php/frankenphp) 二进制 - `--build-all`: 构建以上所有 sapi ```bash @@ -457,6 +459,8 @@ bin/spc dev:sort-config ext 下面是安装工具的示例: - 下载安装 UPX(仅限 Linux 和 Windows): `bin/spc install-pkg upx` +- 下载安装 nasm(仅限 Windows): `bin/spc install-pkg nasm` +- 下载安装 go-mod-frankenphp: `bin/spc install-pkg go-mod-frankenphp` ## 命令 del-download - 删除已下载的资源 diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index c74c9bdc..b69dcf08 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -33,7 +33,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.6.0'; + public const VERSION = '2.6.1'; public function __construct() { diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index d88605ae..ef4a4f34 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -317,8 +317,8 @@ abstract class UnixBuilderBase extends BuilderBase $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); // make it possible to build from a different frankenphp directory! - if (!str_contains($xcaddyModules, '--with github.com/dunglas/frankenphp')) { - $xcaddyModules = '--with github.com/dunglas/frankenphp ' . $xcaddyModules; + if (!str_contains($xcaddyModules, '--with github.com/php/frankenphp')) { + $xcaddyModules = '--with github.com/php/frankenphp ' . $xcaddyModules; } if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.'); From fbd6360bda60536567429fb30617da85644f0325 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 12:07:22 +0700 Subject: [PATCH 294/319] rename go-mod-frankenphp to go-xcaddy --- config/pkg.json | 8 ++++---- src/SPC/builder/BuilderBase.php | 6 +++--- src/SPC/builder/unix/UnixBuilderBase.php | 8 ++++---- src/SPC/command/CraftCommand.php | 6 +++--- .../store/pkg/{GoModFrankenphp.php => GoXcaddy.php} | 10 +++++----- src/globals/test-extensions.php | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) rename src/SPC/store/pkg/{GoModFrankenphp.php => GoXcaddy.php} (91%) diff --git a/config/pkg.json b/config/pkg.json index a2ec8a14..e0762cac 100644 --- a/config/pkg.json +++ b/config/pkg.json @@ -43,16 +43,16 @@ "upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe" } }, - "go-mod-frankenphp-x86_64-linux": { + "go-xcaddy-x86_64-linux": { "type": "custom" }, - "go-mod-frankenphp-aarch64-linux": { + "go-xcaddy-aarch64-linux": { "type": "custom" }, - "go-mod-frankenphp-x86_64-macos": { + "go-xcaddy-x86_64-macos": { "type": "custom" }, - "go-mod-frankenphp-aarch64-macos": { + "go-xcaddy-aarch64-macos": { "type": "custom" } } diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 956aee6c..88e827c5 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -520,11 +520,11 @@ abstract class BuilderBase if (!in_array(PHP_OS_FAMILY, ['Linux', 'Darwin'])) { throw new WrongUsageException('FrankenPHP SAPI is only available on Linux and macOS!'); } - // frankenphp needs package go-mod-frankenphp installed - $pkg_dir = PKG_ROOT_PATH . '/go-mod-frankenphp-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname(); + // frankenphp needs package go-xcaddy installed + $pkg_dir = PKG_ROOT_PATH . '/go-xcaddy-' . arch2gnu(php_uname('m')) . '-' . osfamily2shortname(); if (!file_exists("{$pkg_dir}/bin/go") || !file_exists("{$pkg_dir}/bin/xcaddy")) { global $argv; - throw new WrongUsageException("FrankenPHP SAPI requires go-mod-frankenphp package, please install it first: {$argv[0]} install-pkg go-mod-frankenphp"); + throw new WrongUsageException("FrankenPHP SAPI requires the go-xcaddy package, please install it first: {$argv[0]} install-pkg go-xcaddy"); } // frankenphp needs libxml2 lib on macos, see: https://github.com/php/frankenphp/blob/main/frankenphp.go#L17 if (PHP_OS_FAMILY === 'Darwin' && !$this->getLib('libxml2')) { diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index df3ac3ba..e76dfa86 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -311,7 +311,7 @@ abstract class UnixBuilderBase extends BuilderBase $arch = arch2gnu(php_uname('m')); // define executables for go and xcaddy - $xcaddy_exec = PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin/xcaddy"; + $xcaddy_exec = PKG_ROOT_PATH . "/go-xcaddy-{$arch}-{$os}/bin/xcaddy"; $nobrotli = $this->getLib('brotli') === null ? ',nobrotli' : ''; $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; @@ -342,9 +342,9 @@ abstract class UnixBuilderBase extends BuilderBase $config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true); $env = [ - 'PATH' => PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin:" . getenv('PATH'), - 'GOROOT' => PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}", - 'GOBIN' => PKG_ROOT_PATH . "/go-mod-frankenphp-{$arch}-{$os}/bin", + 'PATH' => PKG_ROOT_PATH . "/go-xcaddy-{$arch}-{$os}/bin:" . getenv('PATH'), + 'GOROOT' => PKG_ROOT_PATH . "/go-xcaddy-{$arch}-{$os}", + 'GOBIN' => PKG_ROOT_PATH . "/go-xcaddy-{$arch}-{$os}/bin", 'GOPATH' => PKG_ROOT_PATH . '/go', 'CGO_ENABLED' => '1', 'CGO_CFLAGS' => $config['cflags'], diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index 744d1c57..c8003a3e 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -68,10 +68,10 @@ class CraftCommand extends BaseCommand } // install go and xcaddy for frankenphp if (in_array('frankenphp', $craft['sapi'])) { - $retcode = $this->runCommand('install-pkg', 'go-mod-frankenphp'); + $retcode = $this->runCommand('install-pkg', 'go-xcaddy'); if ($retcode !== 0) { - $this->output->writeln('craft go-mod-frankenphp failed'); - $this->log("craft go-mod-frankenphp failed with code: {$retcode}", true); + $this->output->writeln('craft go-xcaddy failed'); + $this->log("craft go-xcaddy failed with code: {$retcode}", true); return static::FAILURE; } } diff --git a/src/SPC/store/pkg/GoModFrankenphp.php b/src/SPC/store/pkg/GoXcaddy.php similarity index 91% rename from src/SPC/store/pkg/GoModFrankenphp.php rename to src/SPC/store/pkg/GoXcaddy.php index e631cc8c..81f51266 100644 --- a/src/SPC/store/pkg/GoModFrankenphp.php +++ b/src/SPC/store/pkg/GoXcaddy.php @@ -9,15 +9,15 @@ use SPC\store\FileSystem; use SPC\store\LockFile; use SPC\util\GlobalEnvManager; -class GoModFrankenphp extends CustomPackage +class GoXcaddy extends CustomPackage { public function getSupportName(): array { return [ - 'go-mod-frankenphp-x86_64-linux', - 'go-mod-frankenphp-x86_64-macos', - 'go-mod-frankenphp-aarch64-linux', - 'go-mod-frankenphp-aarch64-macos', + 'go-xcaddy-x86_64-linux', + 'go-xcaddy-x86_64-macos', + 'go-xcaddy-aarch64-linux', + 'go-xcaddy-aarch64-macos', ]; } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index db51db5e..8ec7d9ca 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -212,7 +212,7 @@ switch ($argv[1] ?? null) { break; case 'build_embed_cmd': if ($frankenphp) { - passthru("{$prefix}install-pkg go-mod-frankenphp --debug", $retcode); + passthru("{$prefix}install-pkg go-xcaddy --debug", $retcode); if ($retcode !== 0) { break; } From 40d602c82ee673a59bed8d1c31cf98264b070ac4 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 12:08:53 +0700 Subject: [PATCH 295/319] xcaddy fails with this, because the module still calls itself dunglas/frankenphp --- config/env.ini | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/env.ini b/config/env.ini index aa85751b..d80bc3e7 100644 --- a/config/env.ini +++ b/config/env.ini @@ -43,7 +43,7 @@ SPC_SKIP_PHP_VERSION_CHECK="no" ; Ignore some check item for bin/spc doctor command, comma separated (e.g. SPC_SKIP_DOCTOR_CHECK_ITEMS="if homebrew has installed") SPC_SKIP_DOCTOR_CHECK_ITEMS="" ; extra modules that xcaddy will include in the FrankenPHP build -SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/php/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" +SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES="--with github.com/dunglas/frankenphp/caddy --with github.com/dunglas/mercure/caddy --with github.com/dunglas/vulcain/caddy --with github.com/dunglas/caddy-cbrotli" ; EXTENSION_DIR where the built php will look for extension when a .ini instructs to load them ; only useful for builds targeting not pure-static linking diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index e76dfa86..27800cd8 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -318,7 +318,7 @@ abstract class UnixBuilderBase extends BuilderBase $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); // make it possible to build from a different frankenphp directory! if (!str_contains($xcaddyModules, '--with github.com/php/frankenphp')) { - $xcaddyModules = '--with github.com/php/frankenphp ' . $xcaddyModules; + $xcaddyModules = '--with github.com/dunglas/frankenphp ' . $xcaddyModules; } if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { logger()->warning('caddy-cbrotli module is enabled, but brotli library is not built. Disabling caddy-cbrotli.'); From dfac385d215ba7c48498ba991c3eff1351a2d0fc Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 12:23:33 +0700 Subject: [PATCH 296/319] suggestions --- docs/en/guide/manual-build.md | 2 +- docs/zh/guide/manual-build.md | 2 +- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index 80c4e95b..13038360 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -512,7 +512,7 @@ Here is an example of installing the tool: - Download and install UPX (Linux and Windows only): `bin/spc install-pkg upx` - Download and install nasm (Windows only): `bin/spc install-pkg nasm` -- Download and install go-mod-frankenphp: `bin/spc install-pkg go-mod-frankenphp` +- Download and install go-xcaddy: `bin/spc install-pkg go-xcaddy` ## Command - del-download diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index 230680ce..0db0bc86 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -460,7 +460,7 @@ bin/spc dev:sort-config ext - 下载安装 UPX(仅限 Linux 和 Windows): `bin/spc install-pkg upx` - 下载安装 nasm(仅限 Windows): `bin/spc install-pkg nasm` -- 下载安装 go-mod-frankenphp: `bin/spc install-pkg go-mod-frankenphp` +- 下载安装 go-xcaddy: `bin/spc install-pkg go-xcaddy` ## 命令 del-download - 删除已下载的资源 diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 27800cd8..0d56b0eb 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -317,7 +317,7 @@ abstract class UnixBuilderBase extends BuilderBase $nowatcher = $this->getLib('watcher') === null ? ',nowatcher' : ''; $xcaddyModules = getenv('SPC_CMD_VAR_FRANKENPHP_XCADDY_MODULES'); // make it possible to build from a different frankenphp directory! - if (!str_contains($xcaddyModules, '--with github.com/php/frankenphp')) { + if (!str_contains($xcaddyModules, '--with github.com/dunglas/frankenphp')) { $xcaddyModules = '--with github.com/dunglas/frankenphp ' . $xcaddyModules; } if ($this->getLib('brotli') === null && str_contains($xcaddyModules, '--with github.com/dunglas/caddy-cbrotli')) { From 608a5559ac305c6a03b4b972b8651a1894d736ea Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 12:38:05 +0700 Subject: [PATCH 297/319] fix incorrect array offset --- src/SPC/store/pkg/GoXcaddy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/store/pkg/GoXcaddy.php b/src/SPC/store/pkg/GoXcaddy.php index 81f51266..e0c7c5b9 100644 --- a/src/SPC/store/pkg/GoXcaddy.php +++ b/src/SPC/store/pkg/GoXcaddy.php @@ -29,12 +29,12 @@ class GoXcaddy extends CustomPackage if (file_exists($go_exec) && file_exists($xcaddy_exec)) { return; } - $arch = match (explode('-', $name)[3]) { + $arch = match (explode('-', $name)[2]) { 'x86_64' => 'amd64', 'aarch64' => 'arm64', default => throw new \InvalidArgumentException('Unsupported architecture: ' . $name), }; - $os = match (explode('-', $name)[4]) { + $os = match (explode('-', $name)[3]) { 'linux' => 'linux', 'macos' => 'darwin', default => throw new \InvalidArgumentException('Unsupported OS: ' . $name), From 16a4245ad7ce39213e09428b4ae82d6681e4aa1a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 12:40:42 +0700 Subject: [PATCH 298/319] common static extension tests --- src/globals/test-extensions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 8ec7d9ca..229da487 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -48,7 +48,7 @@ $prefer_pre_built = false; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'dom,mongodb', + 'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,opcache,openssl,pcntl,phar,posix,readline,session,simplexml,sockets,sodium,tokenizer,xml,xmlreader,xmlwriter,zip,zlib', 'Windows' => 'xlswriter,openssl', }; From ba26359ddeb9c5c34e802055e1808b4a4940d169 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 15:15:01 +0700 Subject: [PATCH 299/319] protobuf and grpc don't conflict when they're built shared --- src/SPC/builder/extension/protobuf.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/protobuf.php b/src/SPC/builder/extension/protobuf.php index 3393ad43..0aa6ed51 100644 --- a/src/SPC/builder/extension/protobuf.php +++ b/src/SPC/builder/extension/protobuf.php @@ -15,8 +15,9 @@ class protobuf extends Extension if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later'); } + $grpc = $this->builder->getExt('grpc'); // protobuf conflicts with grpc - if ($this->builder->getExt('grpc') !== null) { + if ($grpc?->isBuildStatic()) { throw new \RuntimeException('protobuf conflicts with grpc, please remove grpc or protobuf extension'); } } From 7f9da6478f9e344cc736b06555fa4b0968822ca9 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 18:13:00 +0700 Subject: [PATCH 300/319] remove old extension file before building new php version --- src/SPC/command/BuildPHPCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index e40a7d83..de6a2b52 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -207,6 +207,8 @@ class BuildPHPCommand extends BuildCommand // add static-php-cli.version to main.c, in order to debug php failure more easily SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); + // clean old modules that may conflict with the new php build + FileSystem::removeDir(BUILD_MODULES_PATH); // start to build $builder->buildPHP($rule); From 80687dfea3787f2729d76c10377a6c726684f440 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 19 Jun 2025 19:31:25 +0800 Subject: [PATCH 301/319] Add macOS strip option `-S`, fix macOS micro strip option (#778) * Add macOS strip option `-S`, fix macOS micro strip option * Change docs and help messages --- docs/en/faq/index.md | 14 ++++---------- docs/en/guide/manual-build.md | 2 +- docs/zh/faq/index.md | 14 ++++---------- docs/zh/guide/manual-build.md | 2 +- src/SPC/builder/macos/MacOSBuilder.php | 15 +++++++++------ src/SPC/command/BuildPHPCommand.php | 7 +------ src/globals/test-extensions.php | 22 +++++++++++----------- 7 files changed, 31 insertions(+), 45 deletions(-) diff --git a/docs/en/faq/index.md b/docs/en/faq/index.md index 1e8e0a47..a942244c 100644 --- a/docs/en/faq/index.md +++ b/docs/en/faq/index.md @@ -38,17 +38,11 @@ buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" - ``` For macOS platform, almost all binaries under macOS cannot be truly purely statically linked, and almost all binaries will link macOS system libraries: `/usr/lib/libresolv.9.dylib` and `/usr/lib/libSystem.B.dylib`. -So on macOS, you can use statically compiled PHP binaries under certain compilation conditions, and dynamically linked extensions: +So on macOS, you can **directly** use SPC to build statically compiled PHP binaries with dynamically linked extensions: -1. Using the `--no-strip` parameter will not strip information such as debugging symbols from the binary file for use with external Zend extensions such as `Xdebug`. -2. If you want to compile some Zend extensions, use Homebrew, MacPorts, source code compilation, and install a normal version of PHP on your operating system. -3. Use the `phpize && ./configure && make` command to compile the extensions you want to use. -4. Copy the extension file `xxxx.so` to the outside, use the statically compiled PHP binary, for example to use the Xdebug extension: `cd buildroot/bin/ && ./php -d "zend_extension=/path/to/xdebug.so"`. - -```bash -# build statically linked php-cli but not stripped -bin/spc build ffi --build-cli --no-strip -``` +1. Build shared extension `xxx.so` using: `--build-shared=XXX` option. e.g. `bin/spc build bcmath,zlib --build-shared=xdebug --build-cli` +2. You will get `buildroot/modules/xdebug.so` and `buildroot/bin/php`. +3. The `xdebug.so` file could be used for php that version and thread-safe are the same. ## Can it support Oracle database extension? diff --git a/docs/en/guide/manual-build.md b/docs/en/guide/manual-build.md index 13038360..e8e4510e 100644 --- a/docs/en/guide/manual-build.md +++ b/docs/en/guide/manual-build.md @@ -339,7 +339,7 @@ You can try to use the following commands: - `--cxx=XXX`: Specifies the execution command of the C++ language compiler (Linux defaults to `g++`, macOS defaults to `clang++`) - `--with-clean`: clean up old make files before compiling PHP - `--enable-zts`: Make compiled PHP thread-safe version (default is NTS version) -- `--no-strip`: Do not run `strip` after compiling the PHP library to trim the binary file to reduce its size (the macOS binary file without trim can use dynamically linked third-party extensions) +- `--no-strip`: Do not run `strip` after compiling the PHP library to trim the binary file to reduce its size - `--with-libs=XXX,YYY`: Compile the specified dependent library before compiling PHP, and activate some extended optional functions (such as libavif of the gd library, etc.) - `--with-config-file-path=XXX`: Set the path in which to look for `php.ini` (Check [here](../faq/index.html#what-is-the-path-of-php-ini) for default paths) - `--with-config-file-scan-dir=XXX`: Set the directory to scan for `.ini` files after reading `php.ini` (Check [here](../faq/index.html#what-is-the-path-of-php-ini) for default paths) diff --git a/docs/zh/faq/index.md b/docs/zh/faq/index.md index 4367b35b..4dfbade4 100644 --- a/docs/zh/faq/index.md +++ b/docs/zh/faq/index.md @@ -35,17 +35,11 @@ buildroot/bin/php -d "zend_extension=/path/to/php{PHP_VER}-{ts/nts}/xdebug.so" - ``` 对于 macOS 平台来说,macOS 下的几乎所有二进制文件都无法真正纯静态链接,几乎所有二进制文件都会链接 macOS 的系统库:`/usr/lib/libresolv.9.dylib` 和 `/usr/lib/libSystem.B.dylib`。 -所以在 macOS 系统下,在特定的编译条件下可以使用静态编译的 php 二进制文件,可使用动态链接的扩展: +因此,在 macOS 上,您可以直接构建出使用静态编译的 PHP 二进制文件和动态链接的扩展: -1. 使用 `--no-strip` 参数,将不会对二进制文件去除调试符号等信息,以供使用 `Xdebug` 等外部 Zend 扩展。 -2. 如果要编译某些 Zend 扩展,使用 Homebrew、MacPorts、源码编译的形式,在所在的操作系统安装一个普通版本的 PHP。 -3. 使用 `phpize && ./configure && make` 命令编译想要使用的扩展。 -4. 将扩展文件 `xxxx.so` 拷贝到外部,使用静态编译的 PHP 二进制,例如使用 Xdebug 扩展:`cd buildroot/bin/ && ./php -d "zend_extension=/path/to/xdebug.so"`。 - -```bash -# 构建静态 php-cli -bin/spc build ffi --build-cli --no-strip -``` +1. 使用 `--build-shared=XXX` 选项构建共享扩展 `xxx.so`。例如:`bin/spc build bcmath,zlib --build-shared=xdebug --build-cli` +2. 您将获得 `buildroot/modules/xdebug.so` 和 `buildroot/bin/php`。 +3. `xdebug.so` 文件可用于版本和线程安全相同的 php。 ## 可以支持 Oracle 数据库扩展吗 diff --git a/docs/zh/guide/manual-build.md b/docs/zh/guide/manual-build.md index 0db0bc86..5301fca1 100644 --- a/docs/zh/guide/manual-build.md +++ b/docs/zh/guide/manual-build.md @@ -296,7 +296,7 @@ bin/spc build bcmath,curl,openssl,ftp,posix,pcntl --build-cli - `--cxx=XXX`: 指定 C++ 语言编译器的执行命令(Linux 默认 `g++`,macOS 默认 `clang++`) - `--with-clean`: 编译 PHP 前先清理旧的 make 产生的文件 - `--enable-zts`: 让编译的 PHP 为线程安全版本(默认为 NTS 版本) -- `--no-strip`: 编译 PHP 库后不运行 `strip` 裁剪二进制文件缩小体积(不裁剪的 macOS 二进制文件可使用动态链接的第三方扩展) +- `--no-strip`: 编译 PHP 库后不运行 `strip` 裁剪二进制文件缩小体积 - `--with-libs=XXX,YYY`: 编译 PHP 前先编译指定的依赖库,激活部分扩展的可选功能(例如 gd 库的 libavif 等) - `--with-config-file-path=XXX`: 查找 `php.ini` 的路径(在 [这里](../faq/index.html#php-ini-的路径是什么) 查看默认路径) - `--with-config-file-scan-dir=XXX`: 读取 `php.ini` 后扫描 `.ini` 文件的目录(在 [这里](../faq/index.html#php-ini-的路径是什么) 查看默认路径) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 153da08c..d43aab4a 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -207,7 +207,7 @@ class MacOSBuilder extends UnixBuilderBase $SPC_CMD_PREFIX_PHP_MAKE = getenv('SPC_CMD_PREFIX_PHP_MAKE') ?: 'make'; $shell->exec("{$SPC_CMD_PREFIX_PHP_MAKE} {$vars} cli"); if (!$this->getOption('no-strip', false)) { - $shell->exec('dsymutil -f sapi/cli/php')->exec('strip sapi/cli/php'); + $shell->exec('dsymutil -f sapi/cli/php')->exec('strip -S sapi/cli/php'); } $this->deployBinary(BUILD_TARGET_CLI); } @@ -234,12 +234,15 @@ class MacOSBuilder extends UnixBuilderBase // patch fake cli for micro $vars['EXTRA_CFLAGS'] .= $enable_fake_cli; - if ($this->getOption('no-strip', false)) { - $vars['STRIP'] = 'dsymutil -f '; - } $vars = SystemUtil::makeEnvVarString($vars); - shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} micro"); + $shell = shell()->cd(SOURCE_PATH . '/php-src'); + // build + $shell->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} micro"); + // strip + if (!$this->getOption('no-strip', false)) { + $shell->exec('dsymutil -f sapi/micro/micro.sfx')->exec('strip -S sapi/micro/micro.sfx'); + } $this->deployBinary(BUILD_TARGET_MICRO); @@ -261,7 +264,7 @@ class MacOSBuilder extends UnixBuilderBase $shell = shell()->cd(SOURCE_PATH . '/php-src'); $shell->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} fpm"); if (!$this->getOption('no-strip', false)) { - $shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip sapi/fpm/php-fpm'); + $shell->exec('dsymutil -f sapi/fpm/php-fpm')->exec('strip -S sapi/fpm/php-fpm'); } $this->deployBinary(BUILD_TARGET_FPM); } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index e40a7d83..571c9e85 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -34,7 +34,7 @@ class BuildPHPCommand extends BuildCommand $this->addOption('build-embed', null, InputOption::VALUE_OPTIONAL, 'Build embed SAPI (not available on Windows)'); $this->addOption('build-frankenphp', null, null, 'Build FrankenPHP SAPI (not available on Windows)'); $this->addOption('build-all', null, null, 'Build all SAPI'); - $this->addOption('no-strip', null, null, 'build without strip, in order to debug and load external extensions'); + $this->addOption('no-strip', null, null, 'build without strip, keep symbols to debug'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); $this->addOption('with-config-file-path', null, InputOption::VALUE_REQUIRED, 'Set the path in which to look for php.ini', $isWindows ? null : '/usr/local/etc/php'); $this->addOption('with-config-file-scan-dir', null, InputOption::VALUE_REQUIRED, 'Set the directory to scan for .ini files after reading php.ini', $isWindows ? null : '/usr/local/etc/php/conf.d'); @@ -62,11 +62,6 @@ class BuildPHPCommand extends BuildCommand $rule = $this->parseRules($shared_extensions); // check dynamic extension build env - // macOS must use --no-strip option - if (!empty($shared_extensions) && PHP_OS_FAMILY === 'Darwin' && !$this->getOption('no-strip')) { - $this->output->writeln('MacOS does not support dynamic extension loading with stripped binary, please use --no-strip option!'); - return static::FAILURE; - } // linux must build with glibc if (!empty($shared_extensions) && PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') !== 'glibc') { $this->output->writeln('Linux does not support dynamic extension loading with musl-libc full-static build, please build with glibc!'); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 229da487..955d72cc 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,9 +13,9 @@ declare(strict_types=1); // test php version (8.1 ~ 8.4 available, multiple for matrix) $test_php_version = [ - // '8.1', - // '8.2', - // '8.3', + '8.1', + '8.2', + '8.3', '8.4', ]; @@ -24,16 +24,16 @@ $test_os = [ 'macos-13', // 'macos-14', 'macos-15', - 'ubuntu-latest', - 'ubuntu-22.04', - 'ubuntu-24.04', - 'ubuntu-22.04-arm', - 'ubuntu-24.04-arm', + // 'ubuntu-latest', + // 'ubuntu-22.04', + // 'ubuntu-24.04', + // 'ubuntu-22.04-arm', + // 'ubuntu-24.04-arm', // 'windows-latest', ]; // whether enable thread safe -$zts = true; +$zts = false; $no_strip = false; @@ -41,10 +41,10 @@ $no_strip = false; $upx = false; // whether to test frankenphp build, only available for macos and linux -$frankenphp = true; +$frankenphp = false; // prefer downloading pre-built packages to speed up the build process -$prefer_pre_built = false; +$prefer_pre_built = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { From 625ee2703d7c216bbd9a7bd33890883448a6c645 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 19 Jun 2025 22:06:11 +0700 Subject: [PATCH 302/319] uv needs to explicitly link -lpthread on aarch64, fails to pthread_atfork unresolved otherwise. It's a symbols that's in the static library, but not in the shared library --- src/SPC/builder/extension/uv.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php index af879882..67ead54e 100644 --- a/src/SPC/builder/extension/uv.php +++ b/src/SPC/builder/extension/uv.php @@ -16,4 +16,11 @@ class uv extends Extension throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later'); } } + + public function getStaticAndSharedLibs(): array + { + [$static, $shared] = parent::getStaticAndSharedLibs(); + $shared .= ' -lpthread'; + return [$static, $shared]; + } } From 8293160a01b8327f0e59a5453ba25fd2e5022cd5 Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 20 Jun 2025 00:27:02 +0700 Subject: [PATCH 303/319] fix bug with only --build-embed (#781) * passing --build-embed sets the result to NULL, not true (and not false, like for options that are not passed) * prettify * make sure embed can only contain null, static, shared or false --- src/SPC/command/BuildPHPCommand.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 8c4c7233..a6a27b34 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -74,12 +74,12 @@ class BuildPHPCommand extends BuildCommand if ($rule === BUILD_TARGET_NONE) { $this->output->writeln('Please add at least one build SAPI!'); - $this->output->writeln("\t--build-cli\tBuild php-cli SAPI"); - $this->output->writeln("\t--build-micro\tBuild phpmicro SAPI"); - $this->output->writeln("\t--build-fpm\tBuild php-fpm SAPI"); - $this->output->writeln("\t--build-embed\tBuild embed SAPI/libphp"); + $this->output->writeln("\t--build-cli\t\tBuild php-cli SAPI"); + $this->output->writeln("\t--build-micro\t\tBuild phpmicro SAPI"); + $this->output->writeln("\t--build-fpm\t\tBuild php-fpm SAPI"); + $this->output->writeln("\t--build-embed\t\tBuild embed SAPI/libphp"); $this->output->writeln("\t--build-frankenphp\tBuild FrankenPHP SAPI/libphp"); - $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm, embed, frankenphp"); + $this->output->writeln("\t--build-all\t\tBuild all SAPI: cli, micro, fpm, embed, frankenphp"); return static::FAILURE; } if ($rule === BUILD_TARGET_ALL) { @@ -290,13 +290,14 @@ class BuildPHPCommand extends BuildCommand $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); $embed = $this->getOption('build-embed'); - if (!$embed && !empty($shared_extensions)) { - $embed = true; - } + $embed = match ($embed) { + null => getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static', + 'static' => 'static', + 'shared' => 'shared', + false => false, + default => throw new WrongUsageException('Invalid --build-embed option, please use --build-embed[=static|shared]'), + }; if ($embed) { - if ($embed === true) { - $embed = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static'; - } $rule |= BUILD_TARGET_EMBED; f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared')); } From 5cd987ba3a7bc099eeb4758fe5b41219fe5c72ad Mon Sep 17 00:00:00 2001 From: Marc Date: Fri, 20 Jun 2025 00:27:33 +0700 Subject: [PATCH 304/319] since we explicitly delete module folder before building, we should reintroduce this check (#783) otherwise shared extensions that other shared extensions depend on will be built multiple times --- src/SPC/builder/Extension.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index a457d82e..22c3044c 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -342,6 +342,9 @@ class Extension return; } } + if (file_exists(BUILD_MODULES_PATH . '/' . $this->getName() . '.so')) { + logger()->info('Shared extension [' . $this->getName() . '] was already built, skipping (' . $this->getName() . '.so)'); + } logger()->info('Building extension [' . $this->getName() . '] as shared extension (' . $this->getName() . '.so)'); foreach ($this->dependencies as $dependency) { if (!$dependency instanceof Extension) { From f6837079d37176631f0856a78a26bd86bae5431b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 20 Jun 2025 01:57:45 +0800 Subject: [PATCH 305/319] Revert build-embed option as boolean --- src/SPC/command/BuildPHPCommand.php | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index a6a27b34..abe06e6a 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -31,7 +31,7 @@ class BuildPHPCommand extends BuildCommand $this->addOption('build-micro', null, null, 'Build micro SAPI'); $this->addOption('build-cli', null, null, 'Build cli SAPI'); $this->addOption('build-fpm', null, null, 'Build fpm SAPI (not available on Windows)'); - $this->addOption('build-embed', null, InputOption::VALUE_OPTIONAL, 'Build embed SAPI (not available on Windows)'); + $this->addOption('build-embed', null, null, 'Build embed SAPI (not available on Windows)'); $this->addOption('build-frankenphp', null, null, 'Build FrankenPHP SAPI (not available on Windows)'); $this->addOption('build-all', null, null, 'Build all SAPI'); $this->addOption('no-strip', null, null, 'build without strip, keep symbols to debug'); @@ -289,18 +289,7 @@ class BuildPHPCommand extends BuildCommand $rule |= ($this->getOption('build-cli') ? BUILD_TARGET_CLI : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE); - $embed = $this->getOption('build-embed'); - $embed = match ($embed) { - null => getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static', - 'static' => 'static', - 'shared' => 'shared', - false => false, - default => throw new WrongUsageException('Invalid --build-embed option, please use --build-embed[=static|shared]'), - }; - if ($embed) { - $rule |= BUILD_TARGET_EMBED; - f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared')); - } + $rule |= $this->getOption('build-embed') || !empty($shared_extensions) ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE; $rule |= ($this->getOption('build-frankenphp') ? (BUILD_TARGET_FRANKENPHP | BUILD_TARGET_EMBED) : BUILD_TARGET_NONE); $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); return $rule; From 7d454159906373025e2bbf8ae613448190390030 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 15:25:07 +0700 Subject: [PATCH 306/319] patch before make for uv --- src/SPC/builder/Extension.php | 14 ++++++++++++++ src/SPC/builder/extension/uv.php | 12 ++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index a457d82e..d6dde237 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -208,6 +208,16 @@ class Extension return false; } + /** + * Patch code before shared extension make + * If you need to patch some code, overwrite this + * return true if you patched something, false if not + */ + public function patchBeforeSharedMake(): bool + { + return false; + } + /** * @return string * returns a command line string with all required shared extensions to load @@ -408,6 +418,10 @@ class Extension '$1 ' . $staticLibString ); + if ($this->patchBeforeSharedMake()) { + logger()->info('ext [ . ' . $this->getName() . '] patching before shared make'); + } + shell()->cd($this->source_dir) ->setEnv($env) ->exec('make clean') diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php index 67ead54e..d3583fe2 100644 --- a/src/SPC/builder/extension/uv.php +++ b/src/SPC/builder/extension/uv.php @@ -5,6 +5,8 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\linux\SystemUtil; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('uv')] @@ -17,10 +19,12 @@ class uv extends Extension } } - public function getStaticAndSharedLibs(): array + public function patchBeforeSharedMake(): bool { - [$static, $shared] = parent::getStaticAndSharedLibs(); - $shared .= ' -lpthread'; - return [$static, $shared]; + if (SystemUtil::getLibcVersionIfExists() >= '2.17') { + return false; + } + FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/', '$1 -luv -ldl -lrt -pthread'); + return true; } } From be0b98c467fe80658cca5b1c9888a20e0af3bf3a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 15:27:28 +0700 Subject: [PATCH 307/319] patch before make for uv --- src/SPC/builder/extension/uv.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php index d3583fe2..d8755a89 100644 --- a/src/SPC/builder/extension/uv.php +++ b/src/SPC/builder/extension/uv.php @@ -21,7 +21,7 @@ class uv extends Extension public function patchBeforeSharedMake(): bool { - if (SystemUtil::getLibcVersionIfExists() >= '2.17') { + if (PHP_OS_FAMILY !== 'Linux' || php_uname('m') !== 'aarch64' || SystemUtil::getLibcVersionIfExists() > '2.17') { return false; } FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/', '$1 -luv -ldl -lrt -pthread'); From 3f92df0865e13504ef82209e197e4bcc4ef2fc1e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 15:57:16 +0700 Subject: [PATCH 308/319] patch before make for uv fix --- src/SPC/builder/Extension.php | 4 ++-- src/SPC/builder/extension/uv.php | 4 ++-- src/SPC/doctor/item/LinuxToolCheckList.php | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index d6dde237..f6e3508d 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -400,7 +400,7 @@ class Extension ->exec(BUILD_BIN_PATH . '/phpize'); if ($this->patchBeforeSharedConfigure()) { - logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); + logger()->info('ext [' . $this->getName() . '] patching before shared configure'); } shell()->cd($this->source_dir) @@ -419,7 +419,7 @@ class Extension ); if ($this->patchBeforeSharedMake()) { - logger()->info('ext [ . ' . $this->getName() . '] patching before shared make'); + logger()->info('ext [' . $this->getName() . '] patching before shared make'); } shell()->cd($this->source_dir) diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php index d8755a89..ffe92bcc 100644 --- a/src/SPC/builder/extension/uv.php +++ b/src/SPC/builder/extension/uv.php @@ -21,10 +21,10 @@ class uv extends Extension public function patchBeforeSharedMake(): bool { - if (PHP_OS_FAMILY !== 'Linux' || php_uname('m') !== 'aarch64' || SystemUtil::getLibcVersionIfExists() > '2.17') { + if (PHP_OS_FAMILY !== 'Linux' || GNU_ARCH !== 'aarch64') { return false; } - FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/', '$1 -luv -ldl -lrt -pthread'); + FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/m', '$1 -luv -ldl -lrt -pthread'); return true; } } diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 56235b0c..cd18c26f 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -61,8 +61,7 @@ class LinuxToolCheckList $required = match ($distro['dist']) { 'alpine' => self::TOOLS_ALPINE, - 'redhat' => self::TOOLS_RHEL, - 'centos' => array_merge(self::TOOLS_RHEL, ['perl-IPC-Cmd']), + 'redhat', 'centos' => self::TOOLS_RHEL, 'arch' => self::TOOLS_ARCH, default => self::TOOLS_DEBIAN, }; From 2abbb75f98859e02b913a2cce0d828a59f9b234c Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 15:58:42 +0700 Subject: [PATCH 309/319] phpstan doesn't like GNU_ARCH there --- src/SPC/builder/extension/uv.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php index ffe92bcc..8c54e007 100644 --- a/src/SPC/builder/extension/uv.php +++ b/src/SPC/builder/extension/uv.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\builder\linux\SystemUtil; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -21,7 +20,7 @@ class uv extends Extension public function patchBeforeSharedMake(): bool { - if (PHP_OS_FAMILY !== 'Linux' || GNU_ARCH !== 'aarch64') { + if (PHP_OS_FAMILY !== 'Linux' || arch2gnu(php_uname('m')) !== 'aarch64') { return false; } FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/^(LDFLAGS =.*)$/m', '$1 -luv -ldl -lrt -pthread'); From a0f99858e3d850ad62ef3d41b7748bd42ffb2ca3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 20 Jun 2025 17:43:25 +0800 Subject: [PATCH 310/319] Fix alpine-docker build in different arch issue (#787) * Fix alpine-docker build in different arch issue * Fix spc-gnu-docker for multi-arch build issue --- bin/spc-alpine-docker | 61 +++++++++++++++++++++++++++++-------------- bin/spc-gnu-docker | 59 ++++++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index cb7d7b4c..58c24ce7 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -1,12 +1,14 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash + +set -e # This file is using docker to run commands -SPC_DOCKER_VERSION=v3 +SPC_DOCKER_VERSION=v4 # Detect docker can run if ! which docker >/dev/null; then - echo "Docker is not installed, please install docker first !" - exit 1 + echo "Docker is not installed, please install docker first !" + exit 1 fi DOCKER_EXECUTABLE="docker" # shellcheck disable=SC2046 @@ -22,27 +24,48 @@ if [ $(id -u) -ne 0 ]; then fi fi - - -# to check if qemu-docker run -if [ "$SPC_USE_ARCH" = "" ]; then - SPC_USE_ARCH=x86_64 +# Convert uname to gnu arch +CURRENT_ARCH=$(uname -m) +if [ "$CURRENT_ARCH" = "arm64" ]; then + CURRENT_ARCH=aarch64 fi +if [ -z "$SPC_USE_ARCH" ]; then + SPC_USE_ARCH=$CURRENT_ARCH +fi +# parse SPC_USE_ARCH case $SPC_USE_ARCH in -x86_64) - ALPINE_FROM=alpine:edge +x86_64|amd64) + SPC_USE_ARCH=x86_64 + if [ "$CURRENT_ARCH" != "x86_64" ]; then + PLATFORM_ARG="--platform linux/amd64" + ALPINE_FROM=multiarch/alpine:x86_64-edge + fi ;; -aarch64) - ALPINE_FROM=multiarch/alpine:aarch64-edge - # shellcheck disable=SC2039 - echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m" - $DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null +aarch64|arm64) + SPC_USE_ARCH=aarch64 + if [ "$CURRENT_ARCH" != "aarch64" ]; then + PLATFORM_ARG="--platform linux/arm64" + ALPINE_FROM=multiarch/alpine:aarch64-edge + fi ;; *) echo "Current arch is not supported to run in docker: $SPC_USE_ARCH" exit 1 ;; esac +# if ALPINE_FROM is not set, use alpine:edge +if [ -z "$ALPINE_FROM" ]; then + ALPINE_FROM=alpine:edge +fi +if [ "$SPC_USE_ARCH" != "$CURRENT_ARCH" ]; then + echo "* Using different arch needs to setup qemu-static for docker !" + ALPINE_FROM=multiarch/alpine:$SPC_USE_ARCH-edge + if [ "$(uname -s)" = "Linux" ]; then + $DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null + fi +else + ALPINE_FROM=alpine:edge +fi if [ "$SPC_USE_MIRROR" = "yes" ]; then SPC_USE_MIRROR="RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories" @@ -53,7 +76,7 @@ fi # Detect docker env is setup if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION; then echo "Docker container does not exist. Building docker image ..." - $DOCKER_EXECUTABLE build -t cwcc-spc-$SPC_USE_ARCH-$SPC_DOCKER_VERSION -f- . </dev/null; then echo "Docker is not installed, please install docker first !" @@ -19,35 +24,47 @@ if [ $(id -u) -ne 0 ]; then fi fi - - -# to check if qemu-docker run -if [ "$SPC_USE_ARCH" = "" ]; then - SPC_USE_ARCH=current +# Convert uname to gnu arch +CURRENT_ARCH=$(uname -m) +if [ "$CURRENT_ARCH" = "arm64" ]; then + CURRENT_ARCH=aarch64 fi +if [ -z "$SPC_USE_ARCH" ]; then + SPC_USE_ARCH=$CURRENT_ARCH +fi +# parse SPC_USE_ARCH case $SPC_USE_ARCH in -current) - BASE_ARCH=$(uname -m) - if [ "$BASE_ARCH" = "arm64" ]; then - BASE_ARCH=aarch64 +x86_64|amd64) + SPC_USE_ARCH=x86_64 + SPC_USE_ARCH_DOCKER=amd64 + if [ "$CURRENT_ARCH" != "x86_64" ]; then + PLATFORM_ARG="--platform linux/amd64" fi ;; -aarch64) - BASE_ARCH=aarch64 - # shellcheck disable=SC2039 - echo -e "\e[033m* Using different arch needs to setup qemu-static for docker !\e[0m" - $DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static:register --reset > /dev/null +aarch64|arm64) + SPC_USE_ARCH=aarch64 + SPC_USE_ARCH_DOCKER=arm64 + if [ "$CURRENT_ARCH" != "aarch64" ]; then + PLATFORM_ARG="--platform linux/arm64" + fi ;; *) echo "Current arch is not supported to run in docker: $SPC_USE_ARCH" exit 1 ;; esac +# detect if we need to use qemu-static +if [ "$SPC_USE_ARCH" != "$CURRENT_ARCH" ]; then + if [ "$(uname -s)" = "Linux" ]; then + echo "* Using different arch needs to setup qemu-static for docker !" + $DOCKER_EXECUTABLE run --rm --privileged multiarch/qemu-user-static --reset -p yes > /dev/null + fi +fi # Detect docker env is setup -if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-gnu-$SPC_USE_ARCH; then +if ! $DOCKER_EXECUTABLE images | grep -q cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION; then echo "Docker container does not exist. Building docker image ..." - $DOCKER_EXECUTABLE build -t cwcc-spc-gnu-$SPC_USE_ARCH -f- . <> /etc/bashrc RUN source /etc/bashrc RUN yum install -y which -RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$BASE_ARCH.tar.gz && \ +RUN curl -fsSL -o patchelf.tgz https://github.com/NixOS/patchelf/releases/download/0.18.0/patchelf-0.18.0-$SPC_USE_ARCH.tar.gz && \ mkdir -p /patchelf && \ tar -xzf patchelf.tgz -C /patchelf --strip-components=1 && \ cp /patchelf/bin/patchelf /usr/bin/ -RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$BASE_ARCH.tar.gz && \ +RUN curl -o cmake.tgz -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-$SPC_USE_ARCH.tar.gz && \ mkdir /cmake && \ tar -xzf cmake.tgz -C /cmake --strip-components 1 @@ -173,7 +190,7 @@ if [ "$SPC_DOCKER_DEBUG" = "yes" ]; then echo "* ./pkgroot: $(pwd)/pkgroot" echo "*" set -ex - $DOCKER_EXECUTABLE run --rm -it --privileged $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH + $DOCKER_EXECUTABLE run $PLATFORM_ARG --privileged --rm -it $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION /bin/bash else - $DOCKER_EXECUTABLE run --rm $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH bin/spc $@ + $DOCKER_EXECUTABLE run $PLATFORM_ARG --rm $INTERACT $ENV_LIST --env-file /tmp/spc-gnu-docker.env $MOUNT_LIST cwcc-spc-gnu-$SPC_USE_ARCH-$SPC_DOCKER_VERSION bin/spc $@ fi From 58d979712e723d73946e78f303fc94e9e478b4fe Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 17:11:52 +0700 Subject: [PATCH 311/319] suggestion --- src/SPC/builder/Extension.php | 10 +++++++--- src/SPC/builder/extension/intl.php | 2 +- src/SPC/command/BuildPHPCommand.php | 2 -- src/SPC/store/SourcePatcher.php | 21 ++++++--------------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index f6e3508d..d1d1ebb8 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -193,7 +193,7 @@ class Extension * If you need to patch some code, overwrite this * return true if you patched something, false if not */ - public function patchBeforeSharedBuild(): bool + public function patchBeforeSharedPhpize(): bool { return false; } @@ -394,13 +394,17 @@ class Extension 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, ]; + if ($this->patchBeforeSharedPhpize()) { + logger()->info("Extension [{$this->getName()}] patched before shared phpize"); + } + // prepare configure args shell()->cd($this->source_dir) ->setEnv($env) ->exec(BUILD_BIN_PATH . '/phpize'); if ($this->patchBeforeSharedConfigure()) { - logger()->info('ext [' . $this->getName() . '] patching before shared configure'); + logger()->info("Extension [{$this->getName()}] patched before shared configure"); } shell()->cd($this->source_dir) @@ -419,7 +423,7 @@ class Extension ); if ($this->patchBeforeSharedMake()) { - logger()->info('ext [' . $this->getName() . '] patching before shared make'); + logger()->info("Extension [{$this->getName()}] patched before shared make"); } shell()->cd($this->source_dir) diff --git a/src/SPC/builder/extension/intl.php b/src/SPC/builder/extension/intl.php index 5676a489..56ce1c61 100644 --- a/src/SPC/builder/extension/intl.php +++ b/src/SPC/builder/extension/intl.php @@ -22,7 +22,7 @@ class intl extends Extension return true; } - public function patchBeforeSharedBuild(): bool + public function patchBeforeSharedPhpize(): bool { return $this->patchBeforeBuildconf(); } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 8c4c7233..2604a7b6 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -207,8 +207,6 @@ class BuildPHPCommand extends BuildCommand // start to build $builder->buildPHP($rule); - SourcePatcher::patchBeforeSharedBuild($builder); - // build dynamic extensions if needed if (!empty($shared_extensions)) { logger()->info('Building shared extensions ...'); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 11317314..1b5604c3 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -46,12 +46,12 @@ class SourcePatcher { foreach ($builder->getExts() as $ext) { if ($ext->patchBeforeBuildconf() === true) { - logger()->info('Extension [' . $ext->getName() . '] patched before buildconf'); + logger()->info("Extension [{$ext->getName()}] patched before buildconf"); } } foreach ($builder->getLibs() as $lib) { if ($lib->patchBeforeBuildconf() === true) { - logger()->info('Library [' . $lib->getName() . '] patched before buildconf'); + logger()->info("Library [{$lib->getName()}]patched before buildconf"); } } // patch windows php 8.1 bug @@ -79,15 +79,6 @@ class SourcePatcher } } - public static function patchBeforeSharedBuild(BuilderBase $builder): void - { - foreach ($builder->getExts() as $ext) { - if ($ext->patchBeforeSharedBuild() === true) { - logger()->info('Extension [' . $ext->getName() . '] patched before shared build'); - } - } - } - /** * Source patcher runner before configure * @@ -98,12 +89,12 @@ class SourcePatcher { foreach ($builder->getExts() as $ext) { if ($ext->patchBeforeConfigure() === true) { - logger()->info('Extension [' . $ext->getName() . '] patched before configure'); + logger()->info("Extension [{$ext->getName()}] patched before configure"); } } foreach ($builder->getLibs() as $lib) { if ($lib->patchBeforeConfigure() === true) { - logger()->info('Library [' . $lib->getName() . '] patched before configure'); + logger()->info("Library [{$lib->getName()}] patched before configure"); } } // patch capstone @@ -279,12 +270,12 @@ class SourcePatcher // call extension patch before make foreach ($builder->getExts(false) as $ext) { if ($ext->patchBeforeMake() === true) { - logger()->info('Extension [' . $ext->getName() . '] patched before make'); + logger()->info("Extension [{$ext->getName()}] patched before make"); } } foreach ($builder->getLibs() as $lib) { if ($lib->patchBeforeMake() === true) { - logger()->info('Library [' . $lib->getName() . '] patched before make'); + logger()->info("Library [{$lib->getName()}] patched before make"); } } } From 9bfcea6feb6b584fa2e6af970c9d90b9c368f21a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 17:13:01 +0700 Subject: [PATCH 312/319] tests --- src/globals/test-extensions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 955d72cc..990cbdd9 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -21,19 +21,19 @@ $test_php_version = [ // test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available) $test_os = [ - 'macos-13', + // 'macos-13', // 'macos-14', - 'macos-15', + // 'macos-15', // 'ubuntu-latest', // 'ubuntu-22.04', // 'ubuntu-24.04', - // 'ubuntu-22.04-arm', + 'ubuntu-22.04-arm', // 'ubuntu-24.04-arm', // 'windows-latest', ]; // whether enable thread safe -$zts = false; +$zts = true; $no_strip = false; @@ -54,13 +54,13 @@ $extensions = match (PHP_OS_FAMILY) { // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => '', + 'Linux' => 'uv', 'Darwin' => '', 'Windows' => '', }; // If you want to test lib-suggests for all extensions and libraries, set it to true. -$with_suggested_libs = true; +$with_suggested_libs = false; // If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true. $with_libs = match (PHP_OS_FAMILY) { From 1b4eb039ae9d4504ea05f57da05ef2839bbe84a8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 20 Jun 2025 18:20:58 +0800 Subject: [PATCH 313/319] Change the patch position for `-release` module suffix --- src/SPC/builder/LibraryBase.php | 13 ------------- src/SPC/store/SourcePatcher.php | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index a130e8a8..fc6adefc 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -215,19 +215,6 @@ abstract class LibraryBase */ public function tryBuild(bool $force_build = false): int { - if (str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), '-release')) { - FileSystem::replaceFileLineContainsString( - SOURCE_PATH . '/php-src/ext/standard/info.c', - '#ifdef CONFIGURE_COMMAND', - '#ifdef NO_CONFIGURE_COMMAND', - ); - } else { - FileSystem::replaceFileLineContainsString( - SOURCE_PATH . '/php-src/ext/standard/info.c', - '#ifdef NO_CONFIGURE_COMMAND', - '#ifdef CONFIGURE_COMMAND', - ); - } if (file_exists($this->source_dir . '/.spc.patched')) { $this->patched = true; } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 1b5604c3..26bd8ffc 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -278,6 +278,20 @@ class SourcePatcher logger()->info("Library [{$lib->getName()}] patched before make"); } } + + if (str_contains((string) getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS'), '-release')) { + FileSystem::replaceFileLineContainsString( + SOURCE_PATH . '/php-src/ext/standard/info.c', + '#ifdef CONFIGURE_COMMAND', + '#ifdef NO_CONFIGURE_COMMAND', + ); + } else { + FileSystem::replaceFileLineContainsString( + SOURCE_PATH . '/php-src/ext/standard/info.c', + '#ifdef NO_CONFIGURE_COMMAND', + '#ifdef CONFIGURE_COMMAND', + ); + } } /** From cd6aca832d0fefe8b155f095f4990de81d2d6f32 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 20 Jun 2025 18:43:38 +0700 Subject: [PATCH 314/319] add back perl-IPC-Cmd for spc-gnu-docker (not included in perl package on aarch64, apparently) --- src/SPC/doctor/item/LinuxToolCheckList.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index cd18c26f..56235b0c 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -61,7 +61,8 @@ class LinuxToolCheckList $required = match ($distro['dist']) { 'alpine' => self::TOOLS_ALPINE, - 'redhat', 'centos' => self::TOOLS_RHEL, + 'redhat' => self::TOOLS_RHEL, + 'centos' => array_merge(self::TOOLS_RHEL, ['perl-IPC-Cmd']), 'arch' => self::TOOLS_ARCH, default => self::TOOLS_DEBIAN, }; From 62a13f2da6da129b32f399307ea656121fe9598b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 21 Jun 2025 10:16:35 +0700 Subject: [PATCH 315/319] bring back http3 support for curl --- src/SPC/builder/unix/library/curl.php | 3 ++- src/globals/ext-tests/curl.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index 0d0b8d8d..c3dc7f2b 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -24,13 +24,14 @@ trait curl ->optionalLib('libssh2', fn ($lib) => "-DLIBSSH2_LIBRARY=\"{$lib->getStaticLibFiles(style: 'cmake')}\" -DLIBSSH2_INCLUDE_DIR={$lib->getIncludeDir()}", '-DCURL_USE_LIBSSH2=OFF') ->optionalLib('nghttp2', fn ($lib) => "-DUSE_NGHTTP2=ON -DNGHTTP2_LIBRARY=\"{$lib->getStaticLibFiles(style: 'cmake')}\" -DNGHTTP2_INCLUDE_DIR={$lib->getIncludeDir()}", '-DUSE_NGHTTP2=OFF') ->optionalLib('nghttp3', fn ($lib) => "-DUSE_NGHTTP3=ON -DNGHTTP3_LIBRARY=\"{$lib->getStaticLibFiles(style: 'cmake')}\" -DNGHTTP3_INCLUDE_DIR={$lib->getIncludeDir()}", '-DUSE_NGHTTP3=OFF') + ->optionalLib('ngtcp2', fn ($lib) => "-DUSE_NGTCP2=ON -DNGNGTCP2_LIBRARY=\"{$lib->getStaticLibFiles(style: 'cmake')}\" -DNGNGTCP2_INCLUDE_DIR={$lib->getIncludeDir()}", '-DUSE_NGTCP2=OFF') ->optionalLib('ldap', ...cmake_boolean_args('CURL_DISABLE_LDAP', true)) ->optionalLib('zstd', ...cmake_boolean_args('CURL_ZSTD')) ->optionalLib('idn2', ...cmake_boolean_args('USE_LIBIDN2')) ->optionalLib('psl', ...cmake_boolean_args('CURL_USE_LIBPSL')) ->optionalLib('libcares', '-DENABLE_ARES=ON') ->addConfigureArgs( - '-DBUILD_CURL_EXE=OFF', + '-DBUILD_CURL_EXE=ON', '-DBUILD_LIBCURL_DOCS=OFF', ) ->build(); diff --git a/src/globals/ext-tests/curl.php b/src/globals/ext-tests/curl.php index a890a8cf..2aaf1228 100644 --- a/src/globals/ext-tests/curl.php +++ b/src/globals/ext-tests/curl.php @@ -16,3 +16,6 @@ if (stripos($curl_version['ssl_version'], 'schannel') !== false) { curl_close($curl); assert($data !== false); } +if (phpversion() >= '8.2') { + assert(($curl_version['features'] & CURL_VERSION_HTTP3) === CURL_VERSION_HTTP3); +} From 8992c96014444ec64986274cfa2b5497c636b8bc Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 21 Jun 2025 10:55:06 +0700 Subject: [PATCH 316/319] remove test --- src/globals/ext-tests/curl.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/globals/ext-tests/curl.php b/src/globals/ext-tests/curl.php index 2aaf1228..a890a8cf 100644 --- a/src/globals/ext-tests/curl.php +++ b/src/globals/ext-tests/curl.php @@ -16,6 +16,3 @@ if (stripos($curl_version['ssl_version'], 'schannel') !== false) { curl_close($curl); assert($data !== false); } -if (phpversion() >= '8.2') { - assert(($curl_version['features'] & CURL_VERSION_HTTP3) === CURL_VERSION_HTTP3); -} From c464f783407e862ba5dae36986a68d31b09289db Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 21 Jun 2025 10:58:54 +0700 Subject: [PATCH 317/319] dont build exe --- src/SPC/builder/unix/library/curl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index c3dc7f2b..c38201e5 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -31,7 +31,7 @@ trait curl ->optionalLib('psl', ...cmake_boolean_args('CURL_USE_LIBPSL')) ->optionalLib('libcares', '-DENABLE_ARES=ON') ->addConfigureArgs( - '-DBUILD_CURL_EXE=ON', + '-DBUILD_CURL_EXE=OFF', '-DBUILD_LIBCURL_DOCS=OFF', ) ->build(); From 853294e1685449da018baf25145bb821c0c129c3 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 21 Jun 2025 15:47:38 +0700 Subject: [PATCH 318/319] remove disabling of asm arithmetic --- src/SPC/store/SourcePatcher.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 26bd8ffc..69d3a649 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -99,9 +99,6 @@ class SourcePatcher } // patch capstone FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/have_capstone="yes"/', 'have_capstone="no"'); - if ($builder instanceof LinuxBuilder && getenv('SPC_LIBC') === 'glibc') { - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Zend/zend_operators.h', '# define ZEND_USE_ASM_ARITHMETIC 1', '# define ZEND_USE_ASM_ARITHMETIC 0'); - } } /** From f6d25153c6cf042ee549f0c84d0836c571810cc4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 22 Jun 2025 16:04:50 +0800 Subject: [PATCH 319/319] Allow deleting pre-built or source only for del-download --- src/SPC/command/DeleteDownloadCommand.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/SPC/command/DeleteDownloadCommand.php b/src/SPC/command/DeleteDownloadCommand.php index 0306de4c..1eeddf7e 100644 --- a/src/SPC/command/DeleteDownloadCommand.php +++ b/src/SPC/command/DeleteDownloadCommand.php @@ -22,6 +22,8 @@ class DeleteDownloadCommand extends BaseCommand { $this->addArgument('sources', InputArgument::REQUIRED, 'The sources/packages will be deleted, comma separated'); $this->addOption('all', 'A', null, 'Delete all downloaded and locked sources/packages'); + $this->addOption('pre-built-only', 'W', null, 'Delete only pre-built sources/packages, not the original ones'); + $this->addOption('source-only', 'S', null, 'Delete only sources, not the pre-built packages'); } public function initialize(InputInterface $input, OutputInterface $output): void @@ -51,10 +53,11 @@ class DeleteDownloadCommand extends BaseCommand $deleted_sources = []; foreach ($chosen_sources as $source) { $source = trim($source); - foreach ([$source, Downloader::getPreBuiltLockName($source)] as $name) { - if (LockFile::get($name)) { - $deleted_sources[] = $name; - } + if (LockFile::get($source) && !$this->getOption('pre-built-only')) { + $deleted_sources[] = $source; + } + if (LockFile::get(Downloader::getPreBuiltLockName($source)) && !$this->getOption('source-only')) { + $deleted_sources[] = Downloader::getPreBuiltLockName($source); } }