From 5586f627d3f41c1b389bf8e92486c277296ffd08 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 13:51:33 +0700 Subject: [PATCH 01/21] add lerc --- config/lib.json | 10 ++++++++++ config/source.json | 10 ++++++++++ src/SPC/builder/linux/library/lerc.php | 12 ++++++++++++ src/SPC/builder/macos/library/lerc.php | 12 ++++++++++++ src/SPC/builder/unix/library/lerc.php | 22 ++++++++++++++++++++++ src/SPC/builder/unix/library/libtiff.php | 15 +++++++++------ 6 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 src/SPC/builder/linux/library/lerc.php create mode 100644 src/SPC/builder/macos/library/lerc.php create mode 100644 src/SPC/builder/unix/library/lerc.php diff --git a/config/lib.json b/config/lib.json index 1a195f66..4102756f 100644 --- a/config/lib.json +++ b/config/lib.json @@ -265,6 +265,13 @@ "libsodium" ] }, + "lerc": { + "source": "lerc", + "static-libs-unix": [ + "libLerc.a" + ], + "cpp-library": true + }, "libacl": { "source": "libacl", "static-libs-unix": [ @@ -498,6 +505,9 @@ "lib-depends": [ "zlib", "libjpeg" + ], + "lib-suggests-unix": [ + "lerc" ] }, "libuuid": { diff --git a/config/source.json b/config/source.json index b3c9cd62..7e5fae3c 100644 --- a/config/source.json +++ b/config/source.json @@ -465,6 +465,16 @@ "path": "COPYING" } }, + "lerc": { + "type": "ghtar", + "repo": "Esri/lerc", + "prefer-stable": true, + "provide-pre-built": true, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libevent": { "type": "ghrel", "repo": "libevent/libevent", diff --git a/src/SPC/builder/linux/library/lerc.php b/src/SPC/builder/linux/library/lerc.php new file mode 100644 index 00000000..6b7b658b --- /dev/null +++ b/src/SPC/builder/linux/library/lerc.php @@ -0,0 +1,12 @@ +build(); + } +} diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index f615019a..2a222670 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\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; trait libtiff @@ -16,6 +17,7 @@ trait libtiff */ protected function build(): void { + FileSystem::replaceFileStr($this->source_dir . '/configure', '-lwebp', '-lwebp -lsharpyuv'); UnixAutoconfExecutor::create($this) ->configure( // zlib deps @@ -24,17 +26,18 @@ trait libtiff "--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-old-jpeg', + '--disable-jpeg12', '--disable-libdeflate', '--disable-cxx', + '--without-x', ) + ->optionalLib('lerc', '--enable-lerc', '--disable-lerc') + ->optionalLib('zstd', '--enable-zstd', '--disable-zstd') + ->optionalLib('webp', '--enable-webp', '--disable-webp') + ->optionalLib('xz', '--enable-lzma', '--disable-lzma') ->make(); $this->patchPkgconfPrefix(['libtiff-4.pc']); } From 7c9e8e3e4042c317a61b225e6ebedab8e79cd61e Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 14:04:55 +0700 Subject: [PATCH 02/21] add jbig --- config/lib.json | 15 +++++++++++- config/source.json | 9 +++++++ src/SPC/builder/linux/library/jbig.php | 12 +++++++++ src/SPC/builder/macos/library/jbig.php | 12 +++++++++ src/SPC/builder/unix/library/jbig.php | 31 ++++++++++++++++++++++++ src/SPC/builder/unix/library/libtiff.php | 1 + 6 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/SPC/builder/linux/library/jbig.php create mode 100644 src/SPC/builder/macos/library/jbig.php create mode 100644 src/SPC/builder/unix/library/jbig.php diff --git a/config/lib.json b/config/lib.json index 4102756f..45457457 100644 --- a/config/lib.json +++ b/config/lib.json @@ -272,6 +272,18 @@ ], "cpp-library": true }, + "jbig": { + "source": "jbig", + "static-libs-unix": [ + "libjbig.a", + "libjbig85.a" + ], + "headers": [ + "jbig.h", + "jbig85.h", + "jbig_ar.h" + ] + }, "libacl": { "source": "libacl", "static-libs-unix": [ @@ -507,7 +519,8 @@ "libjpeg" ], "lib-suggests-unix": [ - "lerc" + "lerc", + "jbig" ] }, "libuuid": { diff --git a/config/source.json b/config/source.json index 7e5fae3c..34e0a2f7 100644 --- a/config/source.json +++ b/config/source.json @@ -475,6 +475,15 @@ "path": "LICENSE" } }, + "jbig": { + "type": "url", + "url": "https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz", + "provide-pre-built": true, + "license": { + "type": "file", + "path": "COPYING" + } + }, "libevent": { "type": "ghrel", "repo": "libevent/libevent", diff --git a/src/SPC/builder/linux/library/jbig.php b/src/SPC/builder/linux/library/jbig.php new file mode 100644 index 00000000..e47e21f4 --- /dev/null +++ b/src/SPC/builder/linux/library/jbig.php @@ -0,0 +1,12 @@ +source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC'); + + // Build the library + shell()->cd($this->source_dir)->initializeEnv($this) + ->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} lib") + ->exec('cp libjbig/libjbig.a ' . BUILD_LIB_PATH) + ->exec('cp libjbig/libjbig85.a ' . BUILD_LIB_PATH) + ->exec('cp libjbig/jbig.h ' . BUILD_INCLUDE_PATH) + ->exec('cp libjbig/jbig85.h ' . BUILD_INCLUDE_PATH) + ->exec('cp libjbig/jbig_ar.h ' . BUILD_INCLUDE_PATH); + } +} diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index 2a222670..31d09a0b 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -38,6 +38,7 @@ trait libtiff ->optionalLib('zstd', '--enable-zstd', '--disable-zstd') ->optionalLib('webp', '--enable-webp', '--disable-webp') ->optionalLib('xz', '--enable-lzma', '--disable-lzma') + ->optionalLib('jbig', '--enable-jbig', '--disable-jbig') ->make(); $this->patchPkgconfPrefix(['libtiff-4.pc']); } From 6b9d49eb7141020013714196d280d12c3b410f90 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 14:39:17 +0700 Subject: [PATCH 03/21] fix lerc build (needs -lstdc++) --- src/SPC/builder/unix/library/libtiff.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index 31d09a0b..b148db96 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -8,6 +8,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; use SPC\util\executor\UnixAutoconfExecutor; +use SPC\util\SPCTarget; trait libtiff { @@ -17,7 +18,9 @@ trait libtiff */ protected function build(): void { + $libcpp = SPCTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++'; FileSystem::replaceFileStr($this->source_dir . '/configure', '-lwebp', '-lwebp -lsharpyuv'); + FileSystem::replaceFileStr($this->source_dir . '/configure', '-l"$lerc_lib_name"', '-l"$lerc_lib_name" ' . $libcpp); UnixAutoconfExecutor::create($this) ->configure( // zlib deps @@ -31,6 +34,8 @@ trait libtiff '--disable-old-jpeg', '--disable-jpeg12', '--disable-libdeflate', + '--disable-tools', + '--disable-contrib', '--disable-cxx', '--without-x', ) From 7db7ed97eeb2397cebdcf2dfe2fe601553cbad83 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 14:41:10 +0700 Subject: [PATCH 04/21] sort --- config/lib.json | 42 +++++++++++++++++----------------- config/source.json | 56 +++++++++++++++++++++++----------------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/config/lib.json b/config/lib.json index 45457457..98408199 100644 --- a/config/lib.json +++ b/config/lib.json @@ -252,6 +252,18 @@ "openssl" ] }, + "jbig": { + "source": "jbig", + "static-libs-unix": [ + "libjbig.a", + "libjbig85.a" + ], + "headers": [ + "jbig.h", + "jbig85.h", + "jbig_ar.h" + ] + }, "ldap": { "source": "ldap", "static-libs-unix": [ @@ -272,18 +284,6 @@ ], "cpp-library": true }, - "jbig": { - "source": "jbig", - "static-libs-unix": [ - "libjbig.a", - "libjbig85.a" - ], - "headers": [ - "jbig.h", - "jbig85.h", - "jbig_ar.h" - ] - }, "libacl": { "source": "libacl", "static-libs-unix": [ @@ -836,6 +836,15 @@ "libiconv" ] }, + "watcher": { + "source": "watcher", + "static-libs-unix": [ + "libwatcher-c.a" + ], + "headers": [ + "wtr/watcher-c.h" + ] + }, "xz": { "source": "xz", "static-libs-unix": [ @@ -889,14 +898,5 @@ "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 34e0a2f7..31f56a8c 100644 --- a/config/source.json +++ b/config/source.json @@ -387,6 +387,15 @@ "path": "LICENSE" } }, + "jbig": { + "type": "url", + "url": "https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz", + "provide-pre-built": true, + "license": { + "type": "file", + "path": "COPYING" + } + }, "ldap": { "type": "filelist", "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", @@ -396,6 +405,16 @@ "path": "LICENSE" } }, + "lerc": { + "type": "ghtar", + "repo": "Esri/lerc", + "prefer-stable": true, + "provide-pre-built": true, + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libacl": { "alt": { "type": "url", @@ -465,25 +484,6 @@ "path": "COPYING" } }, - "lerc": { - "type": "ghtar", - "repo": "Esri/lerc", - "prefer-stable": true, - "provide-pre-built": true, - "license": { - "type": "file", - "path": "LICENSE" - } - }, - "jbig": { - "type": "url", - "url": "https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz", - "provide-pre-built": true, - "license": { - "type": "file", - "path": "COPYING" - } - }, "libevent": { "type": "ghrel", "repo": "libevent/libevent", @@ -1017,6 +1017,15 @@ "path": "COPYING" } }, + "watcher": { + "type": "ghtar", + "repo": "e-dant/watcher", + "prefer-stable": true, + "license": { + "type": "file", + "path": "license" + } + }, "xdebug": { "type": "url", "url": "https://pecl.php.net/get/xdebug", @@ -1097,14 +1106,5 @@ "type": "file", "path": "LICENSE" } - }, - "watcher": { - "type": "ghtar", - "repo": "e-dant/watcher", - "prefer-stable": true, - "license": { - "type": "file", - "path": "license" - } } } From d91a66ee8d12fed6d8e250920cfc99f8f150c12a Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 14:47:05 +0700 Subject: [PATCH 05/21] test --- config/lib.json | 5 ++++- src/globals/test-extensions.php | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/config/lib.json b/config/lib.json index 98408199..f2f71448 100644 --- a/config/lib.json +++ b/config/lib.json @@ -520,7 +520,10 @@ ], "lib-suggests-unix": [ "lerc", - "jbig" + "jbig", + "xz", + "webp", + "zstd" ] }, "libuuid": { diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ffb03701..9f802fdc 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,26 +14,26 @@ 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', // bin/spc for x86_64 + 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 - // 'macos-15', // bin/spc for arm64 + 'macos-15', // bin/spc for arm64 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 - // 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 + 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 // 'ubuntu-24.04', // bin/spc for x86_64 - // 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 + 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 // 'ubuntu-24.04-arm', // bin/spc for arm64 // 'windows-latest', // .\bin\spc.ps1 ]; // whether enable thread safe -$zts = false; +$zts = true; $no_strip = false; @@ -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' => 'imap,swoole', + 'Linux', 'Darwin' => 'imagick', 'Windows' => 'intl', }; @@ -60,7 +60,7 @@ $shared_extensions = match (PHP_OS_FAMILY) { }; // If you want to test lib-suggests for all extensions and libraries, set it to true. -$with_suggested_libs = false; +$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) { From ac7a09edd142c2c8db54c70b1fe46ccc39fe47a1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 14:52:39 +0700 Subject: [PATCH 06/21] oops --- config/lib.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index f2f71448..1ad1494f 100644 --- a/config/lib.json +++ b/config/lib.json @@ -520,9 +520,9 @@ ], "lib-suggests-unix": [ "lerc", + "libwebp", "jbig", "xz", - "webp", "zstd" ] }, From d07fadde76cc0564dbe6348933cfb3890cd1939d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 20:30:51 +0700 Subject: [PATCH 07/21] only uncomment that line temporarily --- src/SPC/builder/BuilderBase.php | 2 ++ src/SPC/builder/unix/UnixBuilderBase.php | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 184d88dc..48e72b11 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -260,6 +260,7 @@ abstract class BuilderBase } } file_put_contents(BUILD_BIN_PATH . '/php-config', implode('', $lines)); + FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', 'test "[$]$1" = "no" && $1=yes', '# test "[$]$1" = "no" && $1=yes'); FileSystem::createDir(BUILD_MODULES_PATH); try { foreach ($this->getExts() as $ext) { @@ -273,6 +274,7 @@ abstract class BuilderBase throw $e; } FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); + FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes'); } /** diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index f0e4e169..8f9da52a 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -281,7 +281,6 @@ 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 c7762a5b65909551fc7ee618edb9a3d8056190a1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 20:44:04 +0700 Subject: [PATCH 08/21] Revert "only uncomment that line temporarily" This reverts commit d07fadde76cc0564dbe6348933cfb3890cd1939d. --- src/SPC/builder/BuilderBase.php | 2 -- src/SPC/builder/unix/UnixBuilderBase.php | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 48e72b11..184d88dc 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -260,7 +260,6 @@ abstract class BuilderBase } } file_put_contents(BUILD_BIN_PATH . '/php-config', implode('', $lines)); - FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', 'test "[$]$1" = "no" && $1=yes', '# test "[$]$1" = "no" && $1=yes'); FileSystem::createDir(BUILD_MODULES_PATH); try { foreach ($this->getExts() as $ext) { @@ -274,7 +273,6 @@ abstract class BuilderBase throw $e; } FileSystem::replaceFileLineContainsString(BUILD_BIN_PATH . '/php-config', 'extension_dir=', $extension_dir_line); - FileSystem::replaceFileStr(BUILD_LIB_PATH . '/php/build/phpize.m4', '# test "[$]$1" = "no" && $1=yes', 'test "[$]$1" = "no" && $1=yes'); } /** diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 8f9da52a..f0e4e169 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -281,6 +281,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 6c109c52f6d193846ad9d1cadb9fc148f0fefb4c Mon Sep 17 00:00:00 2001 From: Marc Date: Sat, 19 Jul 2025 17:56:54 +0700 Subject: [PATCH 09/21] Update src/SPC/builder/unix/library/jbig.php Co-authored-by: Jerry Ma --- src/SPC/builder/unix/library/jbig.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/jbig.php b/src/SPC/builder/unix/library/jbig.php index d09943e2..515c72bd 100644 --- a/src/SPC/builder/unix/library/jbig.php +++ b/src/SPC/builder/unix/library/jbig.php @@ -12,13 +12,18 @@ trait jbig { /** * @throws FileSystemException + */ + public function patchBeforeBuild(): bool + { + // Patch Makefile to add -fPIC flag for position-independent code + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC'); + } + + /** * @throws RuntimeException */ protected function build(): void { - // Patch Makefile to add -fPIC flag for position-independent code - FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC'); - // Build the library shell()->cd($this->source_dir)->initializeEnv($this) ->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} lib") From 6c18862fd1742eebe111ccab7317852c50ed15a1 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sat, 19 Jul 2025 23:54:38 +0700 Subject: [PATCH 10/21] fixes --- .php-cs-fixer.php | 1 + config/lib.json | 4 +--- config/source.json | 1 - src/SPC/builder/unix/library/jbig.php | 3 +-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 47d17866..55fca81a 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -4,6 +4,7 @@ declare(strict_types=1); return (new PhpCsFixer\Config()) ->setRiskyAllowed(true) + ->setUnsupportedPhpVersionAllowed(true) ->setRules([ '@PSR12' => true, '@Symfony' => true, diff --git a/config/lib.json b/config/lib.json index 1ad1494f..964876b8 100644 --- a/config/lib.json +++ b/config/lib.json @@ -497,6 +497,7 @@ "static-libs-windows": [ "libssh2.lib" ], + "provide-pre-built": true, "headers": [ "libssh2.h", "libssh2_publickey.h", @@ -504,9 +505,6 @@ ], "lib-depends": [ "openssl" - ], - "lib-suggests": [ - "zlib" ] }, "libtiff": { diff --git a/config/source.json b/config/source.json index 81b3f074..82cc2395 100644 --- a/config/source.json +++ b/config/source.json @@ -625,7 +625,6 @@ "type": "filelist", "url": "https://download.osgeo.org/libtiff/", "regex": "/href=\"(?tiff-(?[^\"]+)\\.tar\\.xz)\"/", - "provide-pre-built": true, "license": { "type": "file", "path": "LICENSE.md" diff --git a/src/SPC/builder/unix/library/jbig.php b/src/SPC/builder/unix/library/jbig.php index 515c72bd..85e24748 100644 --- a/src/SPC/builder/unix/library/jbig.php +++ b/src/SPC/builder/unix/library/jbig.php @@ -15,8 +15,8 @@ trait jbig */ public function patchBeforeBuild(): bool { - // Patch Makefile to add -fPIC flag for position-independent code FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'CFLAGS = -O2 -W -Wno-unused-result', 'CFLAGS = -O2 -W -Wno-unused-result -fPIC'); + return true; } /** @@ -24,7 +24,6 @@ trait jbig */ protected function build(): void { - // Build the library shell()->cd($this->source_dir)->initializeEnv($this) ->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} lib") ->exec('cp libjbig/libjbig.a ' . BUILD_LIB_PATH) From 2ef64e4597c3cc59460ac18c09b4c06d89c8ca4d Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 00:10:30 +0700 Subject: [PATCH 11/21] add libjxl #755 --- config/lib.json | 17 +++++++++++++- config/source.json | 8 +++++++ src/SPC/builder/linux/library/libjxl.php | 12 ++++++++++ src/SPC/builder/macos/library/libjxl.php | 12 ++++++++++ src/SPC/builder/unix/library/imagemagick.php | 2 +- src/SPC/builder/unix/library/libjxl.php | 24 ++++++++++++++++++++ 6 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/linux/library/libjxl.php create mode 100644 src/SPC/builder/macos/library/libjxl.php create mode 100644 src/SPC/builder/unix/library/libjxl.php diff --git a/config/lib.json b/config/lib.json index 964876b8..fdffb8b3 100644 --- a/config/lib.json +++ b/config/lib.json @@ -240,7 +240,8 @@ "zstd", "xz", "libzip", - "libxml2" + "libxml2", + "libjxl" ] }, "imap": { @@ -419,6 +420,20 @@ "zlib" ] }, + "libjxl": { + "source": "libjxl", + "static-libs-unix": [ + "libjxl.a", + "libjxl_dec.a" + ], + "lib-depends": [ + "brotli", + "libgif", + "libjpeg", + "libpng", + "libwebp" + ] + }, "liblz4": { "source": "liblz4", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 82cc2395..c41b2213 100644 --- a/config/source.json +++ b/config/source.json @@ -553,6 +553,14 @@ "path": "LICENSE.md" } }, + "libjxl": { + "type": "ghtar", + "repo": "libjxl/libjxl", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "liblz4": { "type": "ghrel", "repo": "lz4/lz4", diff --git a/src/SPC/builder/linux/library/libjxl.php b/src/SPC/builder/linux/library/libjxl.php new file mode 100644 index 00000000..bc321394 --- /dev/null +++ b/src/SPC/builder/linux/library/libjxl.php @@ -0,0 +1,12 @@ +optionalLib('zstd', ...ac_with_args('zstd')) ->optionalLib('freetype', ...ac_with_args('freetype')) ->optionalLib('bzip2', ...ac_with_args('bzlib')) + ->optionalLib('libjxl', ...ac_with_args('jxl')) ->addConfigureArgs( '--disable-openmp', - '--without-jxl', '--without-x', ); diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php new file mode 100644 index 00000000..4991f6a9 --- /dev/null +++ b/src/SPC/builder/unix/library/libjxl.php @@ -0,0 +1,24 @@ +addConfigureArgs('-DJPEGXL_ENABLE_TOOLS=OFF') + ->addConfigureArgs('-DJPEGXL_ENABLE_EXAMPLES=OFF') + ->addConfigureArgs('-DJPEGXL_ENABLE_MANPAGES=OFF') + ->addConfigureArgs('-DJPEGXL_ENABLE_BENCHMARK=OFF') + ->addConfigureArgs('-DJPEGXL_ENABLE_PLUGINS=OFF') + ->addConfigureArgs('-DJPEGXL_ENABLE_SJPEG=OFF') + ->addConfigureArgs('-DJPEGXL_STATIC=ON') + ->addConfigureArgs('-DBUILD_TESTING=OFF') + ->build(); + } +} From 230879a0dbcf3f5633a308dd8791db981fbbd1a5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 01:13:51 +0700 Subject: [PATCH 12/21] fix libtiff libs being defined after configure --- config/lib.json | 11 ++++++----- config/source.json | 6 +++++- src/SPC/builder/unix/library/libjxl.php | 20 +++++++++++++++++++- src/SPC/builder/unix/library/libtiff.php | 10 +++++----- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/config/lib.json b/config/lib.json index fdffb8b3..e98c1ae5 100644 --- a/config/lib.json +++ b/config/lib.json @@ -228,8 +228,9 @@ ], "lib-depends": [ "zlib", - "libpng", "libjpeg", + "libjxl", + "libpng", "libwebp", "freetype", "libtiff", @@ -240,8 +241,7 @@ "zstd", "xz", "libzip", - "libxml2", - "libjxl" + "libxml2" ] }, "imap": { @@ -424,11 +424,12 @@ "source": "libjxl", "static-libs-unix": [ "libjxl.a", - "libjxl_dec.a" + "libjxl_dec.a", + "libjxl_threads.a", + "libhwy.a" ], "lib-depends": [ "brotli", - "libgif", "libjpeg", "libpng", "libwebp" diff --git a/config/source.json b/config/source.json index c41b2213..73982380 100644 --- a/config/source.json +++ b/config/source.json @@ -390,8 +390,12 @@ }, "jbig": { "type": "url", - "url": "https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz", + "url": "https://dl.static-php.dev/static-php-cli/deps/jbig/jbigkit-2.1.tar.gz", "provide-pre-built": true, + "alt": { + "type": "url", + "url": "https://www.cl.cam.ac.uk/~mgk25/jbigkit/download/jbigkit-2.1.tar.gz" + }, "license": { "type": "file", "path": "COPYING" diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index 4991f6a9..c7ec5a09 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -4,10 +4,28 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\store\FileSystem; use SPC\util\executor\UnixCMakeExecutor; +use SPC\util\SPCTarget; trait libjxl { + public function patchBeforeBuild(): bool + { + $depsContent = file_get_contents($this->source_dir . '/deps.sh'); + if (str_contains($depsContent, '# return 0')) { + return false; + } + FileSystem::replaceFileStr( + $this->source_dir . '/deps.sh', + 'return 0', + '# return 0', + ); + shell()->cd($this->source_dir) + ->exec('./deps.sh'); + return true; + } + protected function build(): void { UnixCMakeExecutor::create($this) @@ -17,7 +35,7 @@ trait libjxl ->addConfigureArgs('-DJPEGXL_ENABLE_BENCHMARK=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_PLUGINS=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_SJPEG=OFF') - ->addConfigureArgs('-DJPEGXL_STATIC=ON') + ->addConfigureArgs('-DJPEGXL_STATIC=' . SPCTarget::isStatic() ? 'ON' : 'OFF') ->addConfigureArgs('-DBUILD_TESTING=OFF') ->build(); } diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index b148db96..f46f32fc 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -22,6 +22,11 @@ trait libtiff FileSystem::replaceFileStr($this->source_dir . '/configure', '-lwebp', '-lwebp -lsharpyuv'); FileSystem::replaceFileStr($this->source_dir . '/configure', '-l"$lerc_lib_name"', '-l"$lerc_lib_name" ' . $libcpp); UnixAutoconfExecutor::create($this) + ->optionalLib('lerc', '--enable-lerc', '--disable-lerc') + ->optionalLib('zstd', '--enable-zstd', '--disable-zstd') + ->optionalLib('libwebp', '--enable-webp', '--disable-webp') + ->optionalLib('xz', '--enable-lzma', '--disable-lzma') + ->optionalLib('jbig', '--enable-jbig', '--disable-jbig') ->configure( // zlib deps '--enable-zlib', @@ -39,11 +44,6 @@ trait libtiff '--disable-cxx', '--without-x', ) - ->optionalLib('lerc', '--enable-lerc', '--disable-lerc') - ->optionalLib('zstd', '--enable-zstd', '--disable-zstd') - ->optionalLib('webp', '--enable-webp', '--disable-webp') - ->optionalLib('xz', '--enable-lzma', '--disable-lzma') - ->optionalLib('jbig', '--enable-jbig', '--disable-jbig') ->make(); $this->patchPkgconfPrefix(['libtiff-4.pc']); } From 0ef8b8c1759b36e0aa95ba8491c5dc2462d5da96 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 01:17:58 +0700 Subject: [PATCH 13/21] fix --- src/SPC/builder/unix/library/libjxl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index c7ec5a09..021d47dc 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -35,7 +35,7 @@ trait libjxl ->addConfigureArgs('-DJPEGXL_ENABLE_BENCHMARK=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_PLUGINS=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_SJPEG=OFF') - ->addConfigureArgs('-DJPEGXL_STATIC=' . SPCTarget::isStatic() ? 'ON' : 'OFF') + ->addConfigureArgs('-DJPEGXL_STATIC=' . (SPCTarget::isStatic() ? 'ON' : 'OFF')) ->addConfigureArgs('-DBUILD_TESTING=OFF') ->build(); } From fbd56da7ad1ad54dcf68e64747999bb4517cd556 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 01:21:33 +0700 Subject: [PATCH 14/21] add jxl to test --- src/globals/ext-tests/imagick.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/globals/ext-tests/imagick.php b/src/globals/ext-tests/imagick.php index 5fac8dcc..49f41fbe 100644 --- a/src/globals/ext-tests/imagick.php +++ b/src/globals/ext-tests/imagick.php @@ -10,3 +10,4 @@ assert(Imagick::queryFormats('WEBP') !== []); assert(Imagick::queryFormats('JPEG') !== []); assert(Imagick::queryFormats('PNG') !== []); assert(Imagick::queryFormats('TIFF') !== []); +assert(Imagick::queryFormats('JXL') !== []); From f0af17abe4a5cc0d41e66900335af0dec4657413 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 01:44:09 +0700 Subject: [PATCH 15/21] install libatomic-devel for devtoolset-10 --- 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 20a26389..1a9e7e03 100755 --- a/bin/spc-gnu-docker +++ b/bin/spc-gnu-docker @@ -86,7 +86,7 @@ RUN sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo && \ sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo RUN yum update -y && \ - yum install -y devtoolset-10-gcc-* + yum install -y devtoolset-10-gcc-* devtoolset-10-libatomic-devel RUN echo "source scl_source enable devtoolset-10" >> /etc/bashrc RUN source /etc/bashrc RUN yum install -y which From dce1065af5f4942732c43d69224f799e66add89b Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 02:06:43 +0700 Subject: [PATCH 16/21] force usage of already built brotli lib --- src/SPC/builder/unix/library/libjxl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index 021d47dc..361ece33 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -37,6 +37,7 @@ trait libjxl ->addConfigureArgs('-DJPEGXL_ENABLE_SJPEG=OFF') ->addConfigureArgs('-DJPEGXL_STATIC=' . (SPCTarget::isStatic() ? 'ON' : 'OFF')) ->addConfigureArgs('-DBUILD_TESTING=OFF') + ->addConfigureArgs('-DJPEGXL_FORCE_SYSTEM_BROTLI=ON') ->build(); } } From 26842fba27f97b5f2adf67ed75c522f523ac35b5 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 02:17:00 +0700 Subject: [PATCH 17/21] disable jni instead of sjpeg --- src/SPC/builder/unix/library/libjxl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index 361ece33..7917280a 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -34,7 +34,7 @@ trait libjxl ->addConfigureArgs('-DJPEGXL_ENABLE_MANPAGES=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_BENCHMARK=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_PLUGINS=OFF') - ->addConfigureArgs('-DJPEGXL_ENABLE_SJPEG=OFF') + ->addConfigureArgs('-DJPEGXL_ENABLE_JNI=OFF') ->addConfigureArgs('-DJPEGXL_STATIC=' . (SPCTarget::isStatic() ? 'ON' : 'OFF')) ->addConfigureArgs('-DBUILD_TESTING=OFF') ->addConfigureArgs('-DJPEGXL_FORCE_SYSTEM_BROTLI=ON') From f7080c61d5abd41ade86edb5160b3472606fb2db Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 02:49:30 +0700 Subject: [PATCH 18/21] don't download libpng, zlib, brotli, as we already build them --- src/SPC/builder/unix/library/libjxl.php | 4 ++-- src/SPC/builder/unix/library/libtiff.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index 7917280a..71848001 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -18,8 +18,8 @@ trait libjxl } FileSystem::replaceFileStr( $this->source_dir . '/deps.sh', - 'return 0', - '# return 0', + ['return 0', 'download_github third_party/brotli', 'download_github third_party/zlib', 'download_github third_party/libpng'], + ['# return 0', '# download_github third_party/brotli', '# download_github third_party/zlib', '# download_github third_party/libpng'], ); shell()->cd($this->source_dir) ->exec('./deps.sh'); diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index f46f32fc..b4afdd7f 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -18,7 +18,7 @@ trait libtiff */ protected function build(): void { - $libcpp = SPCTarget::getTargetOS() === 'Darwin' ? '-lc++' : '-lstdc++'; + $libcpp = SPCTarget::getTargetOS() === 'Linux' ? '-lstdc++' : '-lc++'; FileSystem::replaceFileStr($this->source_dir . '/configure', '-lwebp', '-lwebp -lsharpyuv'); FileSystem::replaceFileStr($this->source_dir . '/configure', '-l"$lerc_lib_name"', '-l"$lerc_lib_name" ' . $libcpp); UnixAutoconfExecutor::create($this) From d91b476f3360508e328cf9e2ecd55f80ac184b90 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 20 Jul 2025 10:37:37 +0700 Subject: [PATCH 19/21] test shared imagick.so build --- src/SPC/builder/unix/library/libjxl.php | 2 +- src/globals/test-extensions.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index 71848001..58015668 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -36,8 +36,8 @@ trait libjxl ->addConfigureArgs('-DJPEGXL_ENABLE_PLUGINS=OFF') ->addConfigureArgs('-DJPEGXL_ENABLE_JNI=OFF') ->addConfigureArgs('-DJPEGXL_STATIC=' . (SPCTarget::isStatic() ? 'ON' : 'OFF')) - ->addConfigureArgs('-DBUILD_TESTING=OFF') ->addConfigureArgs('-DJPEGXL_FORCE_SYSTEM_BROTLI=ON') + ->addConfigureArgs('-DBUILD_TESTING=OFF') ->build(); } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 9f802fdc..0358f870 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -24,7 +24,7 @@ $test_os = [ 'macos-13', // bin/spc for x86_64 // 'macos-14', // bin/spc for arm64 'macos-15', // bin/spc for arm64 - 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 + // 'ubuntu-latest', // bin/spc-alpine-docker for x86_64 'ubuntu-22.04', // bin/spc-gnu-docker for x86_64 // 'ubuntu-24.04', // bin/spc for x86_64 'ubuntu-22.04-arm', // bin/spc-gnu-docker for arm64 @@ -48,13 +48,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' => 'imagick', + 'Linux', 'Darwin' => 'bcmath', 'Windows' => 'intl', }; // If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`). $shared_extensions = match (PHP_OS_FAMILY) { - 'Linux' => '', + 'Linux' => 'imagick', 'Darwin' => '', 'Windows' => '', }; From 3c8b5883127a66d1178508fb888c1772d5ec5820 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 21 Jul 2025 19:32:44 +0700 Subject: [PATCH 20/21] suggestion 1 --- config/lib.json | 1 - config/source.json | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index e98c1ae5..6ad734ee 100644 --- a/config/lib.json +++ b/config/lib.json @@ -513,7 +513,6 @@ "static-libs-windows": [ "libssh2.lib" ], - "provide-pre-built": true, "headers": [ "libssh2.h", "libssh2_publickey.h", diff --git a/config/source.json b/config/source.json index 73982380..4698ae83 100644 --- a/config/source.json +++ b/config/source.json @@ -628,6 +628,7 @@ "repo": "libssh2/libssh2", "match": "libssh2.+\\.tar\\.gz", "prefer-stable": true, + "provide-pre-built": true, "license": { "type": "file", "path": "COPYING" From 4a0a7e0df383548303f691f68e397abc9968ccf2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 21 Jul 2025 19:34:31 +0700 Subject: [PATCH 21/21] suggestion 2 --- src/SPC/builder/unix/library/libjxl.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/SPC/builder/unix/library/libjxl.php b/src/SPC/builder/unix/library/libjxl.php index 58015668..0ff773a6 100644 --- a/src/SPC/builder/unix/library/libjxl.php +++ b/src/SPC/builder/unix/library/libjxl.php @@ -12,10 +12,6 @@ trait libjxl { public function patchBeforeBuild(): bool { - $depsContent = file_get_contents($this->source_dir . '/deps.sh'); - if (str_contains($depsContent, '# return 0')) { - return false; - } FileSystem::replaceFileStr( $this->source_dir . '/deps.sh', ['return 0', 'download_github third_party/brotli', 'download_github third_party/zlib', 'download_github third_party/libpng'],