From 4537bfb247e48292d0ffe378ce39930e1f686f9c Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 31 May 2023 10:03:40 +0200 Subject: [PATCH 001/415] Add support for libargon2 --- config/ext.json | 7 ++++++ config/lib.json | 6 +++++ config/source.json | 8 +++++++ src/SPC/builder/macos/library/libargon2.php | 12 ++++++++++ src/SPC/builder/unix/library/libargon2.php | 26 +++++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 src/SPC/builder/macos/library/libargon2.php create mode 100644 src/SPC/builder/unix/library/libargon2.php diff --git a/config/ext.json b/config/ext.json index 3c0b1960..f6d2d93c 100644 --- a/config/ext.json +++ b/config/ext.json @@ -295,6 +295,13 @@ "libsodium" ] }, + "password-argon2": { + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "libargon2" + ] + }, "sqlite3": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/lib.json b/config/lib.json index bfe6ec6c..4c2c0cae 100644 --- a/config/lib.json +++ b/config/lib.json @@ -460,5 +460,11 @@ "static-libs-unix": [ "libsodium.a" ] + }, + "libargon2": { + "source": "libargon2", + "static-libs-unix": [ + "libargon2.a" + ] } } \ No newline at end of file diff --git a/config/source.json b/config/source.json index d74fd496..d9784cba 100644 --- a/config/source.json +++ b/config/source.json @@ -419,5 +419,13 @@ "type": "file", "path": "LICENSE" } + }, + "libargon2": { + "type": "ghtar", + "repo": "P-H-C/phc-winner-argon2", + "license": { + "type": "file", + "path": "LICENSE" + } } } \ No newline at end of file diff --git a/src/SPC/builder/macos/library/libargon2.php b/src/SPC/builder/macos/library/libargon2.php new file mode 100644 index 00000000..f39afa4f --- /dev/null +++ b/src/SPC/builder/macos/library/libargon2.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec("make {$this->builder->configure_env} PREFIX='' clean") + ->exec("make -j{$this->builder->concurrency} PREFIX=''") + ->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); + + $this->patchPkgconfPrefix(['libargon2.pc']); + + foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { + if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { + unlink(BUILD_ROOT_PATH . '/lib/' . $filename); + } + } + } +} From 1b734073b023ab63003748431298dffab5ab4c25 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Fri, 2 Jun 2023 22:47:59 +0200 Subject: [PATCH 002/415] Merge refactor --- config/ext.json | 16 ++++++++-------- config/lib.json | 12 ++++++------ config/source.json | 18 ++++++++++-------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/config/ext.json b/config/ext.json index 59e07925..727907f8 100644 --- a/config/ext.json +++ b/config/ext.json @@ -195,6 +195,13 @@ "openssl" ] }, + "password-argon2": { + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "libargon2" + ] + }, "pcntl": { "type": "builtin", "unix-only": true @@ -302,13 +309,6 @@ "libsodium" ] }, - "password-argon2": { - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "libargon2" - ] - }, "sqlite3": { "type": "builtin", "arg-type": "with-prefix", @@ -435,4 +435,4 @@ "zstd" ] } -} +} \ No newline at end of file diff --git a/config/lib.json b/config/lib.json index 6f5d0682..a68fbf74 100644 --- a/config/lib.json +++ b/config/lib.json @@ -127,6 +127,12 @@ "libxml2" ] }, + "libargon2": { + "source": "libargon2", + "static-libs-unix": [ + "libargon2.a" + ] + }, "libavif": { "source": "libavif", "static-libs-unix": [ @@ -469,11 +475,5 @@ "zstd.h", "zstd_errors.h" ] - }, - "libargon2": { - "source": "libargon2", - "static-libs-unix": [ - "libargon2.a" - ] } } \ No newline at end of file diff --git a/config/source.json b/config/source.json index 977ae8ad..c61239ac 100644 --- a/config/source.json +++ b/config/source.json @@ -125,6 +125,16 @@ "path": "LICENSE" } }, + "libargon2": { + "type": "git", + "path": "", + "rev": "master", + "url": "https://github.com/mpociot/phc-winner-argon2", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libavif": { "type": "ghtar", "repo": "AOMediaCodec/libavif", @@ -427,13 +437,5 @@ "type": "file", "path": "LICENSE" } - }, - "libargon2": { - "type": "ghtar", - "repo": "P-H-C/phc-winner-argon2", - "license": { - "type": "file", - "path": "LICENSE" - } } } \ No newline at end of file From 0569c696349d75e988668132c13766c2bdfd7cd2 Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Sat, 3 Jun 2023 00:04:02 +0200 Subject: [PATCH 003/415] remove path --- config/source.json | 1 - 1 file changed, 1 deletion(-) diff --git a/config/source.json b/config/source.json index c61239ac..169143c7 100644 --- a/config/source.json +++ b/config/source.json @@ -127,7 +127,6 @@ }, "libargon2": { "type": "git", - "path": "", "rev": "master", "url": "https://github.com/mpociot/phc-winner-argon2", "license": { From 967292be5cb31e68355b6a38bdc78c105fc0a8e8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:31:17 +0800 Subject: [PATCH 004/415] Remove old configure_env --- src/SPC/builder/unix/library/libargon2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/libargon2.php b/src/SPC/builder/unix/library/libargon2.php index 4cd9a941..222e8b43 100644 --- a/src/SPC/builder/unix/library/libargon2.php +++ b/src/SPC/builder/unix/library/libargon2.php @@ -11,7 +11,7 @@ trait libargon2 protected function build() { shell()->cd($this->source_dir) - ->exec("make {$this->builder->configure_env} PREFIX='' clean") + ->exec("make PREFIX='' clean") ->exec("make -j{$this->builder->concurrency} PREFIX=''") ->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); From 3604ea6d6797d93b40341062c41711fbca0d045a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:32:29 +0800 Subject: [PATCH 005/415] Update lock --- composer.lock | 54 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/composer.lock b/composer.lock index 109c39b3..5f25211d 100644 --- a/composer.lock +++ b/composer.lock @@ -8,7 +8,7 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.29.0", + "version": "v10.30.1", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", @@ -63,7 +63,7 @@ }, { "name": "illuminate/conditionable", - "version": "v10.29.0", + "version": "v10.30.1", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,16 +109,16 @@ }, { "name": "illuminate/contracts", - "version": "v10.29.0", + "version": "v10.30.1", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "6c39fba7b2311e28f5c6ac7d729e3d49a2a98406" + "reference": "f6bf37a272fda164f6c451407c99f820eb1eb95b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/6c39fba7b2311e28f5c6ac7d729e3d49a2a98406", - "reference": "6c39fba7b2311e28f5c6ac7d729e3d49a2a98406", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/f6bf37a272fda164f6c451407c99f820eb1eb95b", + "reference": "f6bf37a272fda164f6c451407c99f820eb1eb95b", "shasum": "" }, "require": { @@ -153,11 +153,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-09-05T19:07:46+00:00" + "time": "2023-10-30T00:59:22+00:00" }, { "name": "illuminate/macroable", - "version": "v10.29.0", + "version": "v10.30.1", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.12", + "version": "v0.1.13", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "b35f249028c22016e45e48626e19e5d42fd827ff" + "reference": "e1379d8ead15edd6cc4369c22274345982edc95a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/b35f249028c22016e45e48626e19e5d42fd827ff", - "reference": "b35f249028c22016e45e48626e19e5d42fd827ff", + "url": "https://api.github.com/repos/laravel/prompts/zipball/e1379d8ead15edd6cc4369c22274345982edc95a", + "reference": "e1379d8ead15edd6cc4369c22274345982edc95a", "shasum": "" }, "require": { @@ -254,9 +254,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.12" + "source": "https://github.com/laravel/prompts/tree/v0.1.13" }, - "time": "2023-10-18T14:18:57+00:00" + "time": "2023-10-27T13:53:59+00:00" }, { "name": "psr/container", @@ -2247,16 +2247,16 @@ }, { "name": "filp/whoops", - "version": "2.15.3", + "version": "2.15.4", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "c83e88a30524f9360b11f585f71e6b17313b7187" + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/c83e88a30524f9360b11f585f71e6b17313b7187", - "reference": "c83e88a30524f9360b11f585f71e6b17313b7187", + "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", "shasum": "" }, "require": { @@ -2306,7 +2306,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.15.3" + "source": "https://github.com/filp/whoops/tree/2.15.4" }, "funding": [ { @@ -2314,7 +2314,7 @@ "type": "github" } ], - "time": "2023-07-13T12:00:00+00:00" + "time": "2023-11-03T12:00:00+00:00" }, { "name": "friendsofphp/php-cs-fixer", @@ -2521,16 +2521,16 @@ }, { "name": "humbug/php-scoper", - "version": "0.18.4", + "version": "0.18.7", "source": { "type": "git", "url": "https://github.com/humbug/php-scoper.git", - "reference": "d79c1486537280c21c907e9a8a610eceb391407f" + "reference": "9386a0af946f175d7a1ebfb68851bc2bb8ad7858" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/humbug/php-scoper/zipball/d79c1486537280c21c907e9a8a610eceb391407f", - "reference": "d79c1486537280c21c907e9a8a610eceb391407f", + "url": "https://api.github.com/repos/humbug/php-scoper/zipball/9386a0af946f175d7a1ebfb68851bc2bb8ad7858", + "reference": "9386a0af946f175d7a1ebfb68851bc2bb8ad7858", "shasum": "" }, "require": { @@ -2548,7 +2548,7 @@ "bamarni/composer-bin-plugin": "^1.1", "ergebnis/composer-normalize": "^2.28", "fidry/makefile": "^1.0", - "humbug/box": "^4.0", + "humbug/box": "^4.5.1", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.0", "symfony/yaml": "^6.1" @@ -2598,9 +2598,9 @@ "description": "Prefixes all PHP namespaces in a file or directory.", "support": { "issues": "https://github.com/humbug/php-scoper/issues", - "source": "https://github.com/humbug/php-scoper/tree/0.18.4" + "source": "https://github.com/humbug/php-scoper/tree/0.18.7" }, - "time": "2023-10-20T17:14:04+00:00" + "time": "2023-11-04T18:01:12+00:00" }, { "name": "jetbrains/phpstorm-stubs", From b1ae48a20920d13925a3062bd3c96418173422c4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 01:46:21 +0800 Subject: [PATCH 006/415] let sanity check can be overwritten --- src/SPC/builder/Extension.php | 28 +++++++++++++++++++++ src/SPC/builder/traits/UnixBuilderTrait.php | 19 +------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 922d4f3d..5d9f2e6b 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -163,6 +163,34 @@ class Extension return false; } + /** + * Run compile check if build target is cli + * If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php + * + * @throws RuntimeException + */ + public function runCheck(): void + { + [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); + } + + if (file_exists(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')) { + // Trim additional content & escape special characters to allow inline usage + $test = str_replace( + ['getName() . '.php') + ); + + [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"'); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); + } + } + } + /** * @throws RuntimeException */ diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 2d0d43d2..d698c730 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -66,24 +66,7 @@ trait UnixBuilderTrait foreach ($this->exts as $ext) { logger()->debug('testing ext: ' . $ext->getName()); - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $ext->getDistName() . '"', false); - if ($ret !== 0) { - throw new RuntimeException('extension ' . $ext->getName() . ' failed compile check'); - } - - if (file_exists(ROOT_DIR . '/src/globals/tests/' . $ext->getName() . '.php')) { - // Trim additional content & escape special characters to allow inline usage - $test = str_replace( - ['getName() . '.php') - ); - - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"'); - if ($ret !== 0) { - throw new RuntimeException('extension ' . $ext->getName() . ' failed sanity check'); - } - } + $ext->runCheck(); } } From 5db23e1db705b75ce88ae88b53bbbf1a0d5259d0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 1 Nov 2023 01:49:48 +0800 Subject: [PATCH 007/415] let sanity check can be overwritten --- src/SPC/builder/Extension.php | 3 ++- src/SPC/builder/traits/UnixBuilderTrait.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 5d9f2e6b..21f0f574 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -166,10 +166,11 @@ 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/tests/{extension_name}.php + * If check failed, throw RuntimeException * * @throws RuntimeException */ - public function runCheck(): void + public function runCliCheck(): void { [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false); if ($ret !== 0) { diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index d698c730..3fead06f 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -66,7 +66,7 @@ trait UnixBuilderTrait foreach ($this->exts as $ext) { logger()->debug('testing ext: ' . $ext->getName()); - $ext->runCheck(); + $ext->runCliCheck(); } } From dccfde9f39d43480d3f6936147a55b39e493b602 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:47:57 +0800 Subject: [PATCH 008/415] Adjust mbstring and mbregex dependencies --- config/ext.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index b18c8eb9..778afe0e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -169,14 +169,14 @@ "arg-type": "custom", "ext-depends": [ "mbstring" + ], + "lib-depends": [ + "onig" ] }, "mbstring": { "type": "builtin", - "arg-type": "custom", - "lib-depends": [ - "onig" - ] + "arg-type": "custom" }, "memcache": { "type": "external", From ff74f0cdaf9057eac343568f7b0c01f64bde22fe Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:48:20 +0800 Subject: [PATCH 009/415] overwrite mbregex cli check --- src/SPC/builder/extension/mbregex.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 6a4d1457..0301557c 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -5,18 +5,25 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\exception\RuntimeException; use SPC\util\CustomExt; #[CustomExt('mbregex')] class mbregex extends Extension { - public function getDistName(): string - { - return 'mbstring'; - } - public function getConfigureArg(): string { return ''; } + + /** + * mbregex is not an extension, we need to overwrite the default check. + */ + public function runCliCheck(): void + { + [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --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 672a4102cdce711be89ec52fb328f92dbbe5948c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:53:48 +0800 Subject: [PATCH 010/415] overwrite password-argon2 cli check --- src/SPC/builder/extension/password_argon2.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/SPC/builder/extension/password_argon2.php diff --git a/src/SPC/builder/extension/password_argon2.php b/src/SPC/builder/extension/password_argon2.php new file mode 100644 index 00000000..fb3c4b04 --- /dev/null +++ b/src/SPC/builder/extension/password_argon2.php @@ -0,0 +1,21 @@ +execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"'); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); + } + } +} From fbf5c958d085a43a7f2b7d9d084397ff55d8ae6e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:55:39 +0800 Subject: [PATCH 011/415] sort configs --- config/ext.json | 2 +- config/lib.json | 12 ++++++------ config/source.json | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/config/ext.json b/config/ext.json index 85139f1f..130e2cea 100644 --- a/config/ext.json +++ b/config/ext.json @@ -518,4 +518,4 @@ "zstd" ] } -} \ No newline at end of file +} diff --git a/config/lib.json b/config/lib.json index 13f1f1b8..2b9500fd 100644 --- a/config/lib.json +++ b/config/lib.json @@ -141,12 +141,6 @@ "libxml2" ] }, - "libargon2": { - "source": "libargon2", - "static-libs-unix": [ - "libargon2.a" - ] - }, "ldap": { "source": "ldap", "static-libs-unix": [ @@ -159,6 +153,12 @@ "libsodium" ] }, + "libargon2": { + "source": "libargon2", + "static-libs-unix": [ + "libargon2.a" + ] + }, "libavif": { "source": "libavif", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 9df19068..12015a21 100644 --- a/config/source.json +++ b/config/source.json @@ -154,19 +154,19 @@ "path": "LICENSE" } }, - "libargon2": { - "type": "git", - "rev": "master", - "url": "https://github.com/mpociot/phc-winner-argon2", + "ldap": { + "type": "filelist", + "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", + "regex": "/href=\"(?openldap-(?[^\"]+)\\.tgz)\"/", "license": { "type": "file", "path": "LICENSE" } }, - "ldap": { - "type": "filelist", - "url": "https://www.openldap.org/software/download/OpenLDAP/openldap-release/", - "regex": "/href=\"(?openldap-(?[^\"]+)\\.tgz)\"/", + "libargon2": { + "type": "git", + "rev": "master", + "url": "https://github.com/mpociot/phc-winner-argon2", "license": { "type": "file", "path": "LICENSE" From 07f943af7ebc9e2102b920df4f454d1383b085a9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 18:31:14 +0800 Subject: [PATCH 012/415] add dev:extensions command custom column display --- src/SPC/command/dev/AllExtCommand.php | 45 ++++++++++++++++++++------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 196de39f..399156c2 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -12,6 +12,7 @@ use SPC\store\Config; use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Style\SymfonyStyle; use function Laravel\Prompts\table; @@ -22,6 +23,13 @@ class AllExtCommand extends BaseCommand public function configure(): void { $this->addArgument('extensions', InputArgument::OPTIONAL, 'List of extensions that will be displayed, comma separated'); + $this->addOption( + 'columns', + null, + InputOption::VALUE_REQUIRED, + 'List of columns that will be displayed, comma separated (lib-depends, lib-suggests, ext-depends, ext-suggests, unix-only)', + 'lib-depends,lib-suggests,ext-depends,ext-suggests,unix-only' + ); } /** @@ -32,6 +40,16 @@ class AllExtCommand extends BaseCommand public function handle(): int { $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions') ?? ''))); + $columns = array_map('trim', array_filter(explode(',', $this->getOption('columns')))); + + foreach ($columns as $column) { + if (!in_array($column, ['lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only', 'type'])) { + $this->output->writeln('Column name [' . $column . '] is not valid.'); + $this->output->writeln('Available column name: lib-depends, lib-suggests, ext-depends, ext-suggests, unix-only, type'); + return static::FAILURE; + } + } + array_unshift($columns, 'name'); $style = new SymfonyStyle($this->input, $this->output); $style->writeln($extensions ? 'Available extensions:' : 'Extensions:'); @@ -51,23 +69,26 @@ class AllExtCommand extends BaseCommand $lib_suggests = Config::getExt($extension, 'lib-suggests', []); $ext_suggests = Config::getExt($extension, 'ext-suggests', []); - $data[] = [ - $extension, - implode(', ', $libraries), - implode(', ', $lib_suggests), - implode(',', $not_included), - implode(', ', $ext_suggests), - Config::getExt($extension, 'unix-only', false) ? 'true' : 'false', - ]; + $row = []; + foreach ($columns as $column) { + $row[] = match ($column) { + 'name' => $extension, + 'type' => Config::getExt($extension, 'type'), + 'lib-depends' => implode(', ', $libraries), + 'lib-suggests' => implode(', ', $lib_suggests), + 'ext-depends' => implode(',', $not_included), + 'ext-suggests' => implode(', ', $ext_suggests), + 'unix-only' => Config::getExt($extension, 'unix-only', false) ? 'true' : 'false', + default => '', + }; + } + $data[] = $row; } if ($data === []) { $style->warning('Unknown extension selected: ' . implode(',', $extensions)); } else { - table( - ['Extension', 'lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'unix-only'], - $data - ); + table($columns, $data); } return static::SUCCESS; From 7c4a991c0e59cb1fdc5283bf6d94dd30e7850828 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 31 Oct 2023 13:09:01 +0100 Subject: [PATCH 013/415] add imap support --- config/ext.json | 8 ++- config/lib.json | 9 +++ config/source.json | 9 +++ src/SPC/builder/extension/imap.php | 28 ++++++++ src/SPC/builder/linux/library/imap.php | 68 +++++++++++++++++++ src/SPC/builder/unix/library/postgresql.php | 3 +- .../patch/1006_openssl1.1_autoverify.patch | 58 ++++++++++++++++ src/globals/patch/2014_openssl1.1.1_sni.patch | 42 ++++++++++++ 8 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 src/SPC/builder/extension/imap.php create mode 100644 src/SPC/builder/linux/library/imap.php create mode 100644 src/globals/patch/1006_openssl1.1_autoverify.patch create mode 100644 src/globals/patch/2014_openssl1.1.1_sni.patch diff --git a/config/ext.json b/config/ext.json index 778afe0e..e3081154 100644 --- a/config/ext.json +++ b/config/ext.json @@ -132,12 +132,13 @@ }, "imap": { "type": "builtin", - "arg-type": "with", + "arg-type": "custom", "lib-depends": [ "imap" ], "lib-suggests": [ - "kerberos" + "kerberos", + "openssl" ] }, "inotify": { @@ -234,7 +235,8 @@ "type": "builtin", "arg-type": "custom", "lib-depends": [ - "openssl" + "openssl", + "zlib" ], "ext-depends": [ "zlib" diff --git a/config/lib.json b/config/lib.json index 6a602d16..5e6189e6 100644 --- a/config/lib.json +++ b/config/lib.json @@ -141,6 +141,15 @@ "libxml2" ] }, + "imap": { + "source": "imap", + "static-libs-unix": [ + "libc-client.a" + ], + "lib-suggests": [ + "openssl" + ] + }, "ldap": { "source": "ldap", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index cd849f86..7e1de028 100644 --- a/config/source.json +++ b/config/source.json @@ -144,6 +144,15 @@ "path": "LICENSE" } }, + "imap": { + "type": "git", + "url": "https://github.com/uw-imap/imap.git", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "inotify": { "type": "url", "url": "https://pecl.php.net/get/inotify", diff --git a/src/SPC/builder/extension/imap.php b/src/SPC/builder/extension/imap.php new file mode 100644 index 00000000..389223ec --- /dev/null +++ b/src/SPC/builder/extension/imap.php @@ -0,0 +1,28 @@ +builder->getOption('enable-zts')) { + throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds'); + } + $arg = '--with-imap=' . BUILD_ROOT_PATH; + if ($this->builder->getLib('openssl') !== null) { + $arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH; + } + return $arg; + } +} diff --git a/src/SPC/builder/linux/library/imap.php b/src/SPC/builder/linux/library/imap.php new file mode 100644 index 00000000..594a75bd --- /dev/null +++ b/src/SPC/builder/linux/library/imap.php @@ -0,0 +1,68 @@ +source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', ''); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}"); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto'); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz'); + FileSystem::replaceFileStr( + $this->source_dir . '/src/osdep/unix/ssl_unix.c', + "#include \n#include ", + "#include \n#include " + ); + SourcePatcher::patchFile('1007_openssl1.1_autoverify.patch', $this->source_dir); + SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH); + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH); + return true; + } + + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + protected function build(): void + { + if ($this->builder->getLib('openssl')) { + $ssl_options = 'SPECIALAUTHENTICATORS=ssl SSLTYPE=unix.nopwd SSLINCLUDE=' . BUILD_INCLUDE_PATH . ' SSLLIB=' . BUILD_LIB_PATH; + } else { + $ssl_options = 'SSLTYPE=none'; + } + shell()->cd($this->source_dir) + ->exec('make clean') + ->exec('touch ip6') + ->exec( + "yes | make slx {$ssl_options}" + ); + try { + shell() + ->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a') + ->exec("cp -rf {$this->source_dir}/c-client/*.c " . BUILD_LIB_PATH . '/') + ->exec("cp -rf {$this->source_dir}/c-client/*.h " . BUILD_INCLUDE_PATH . '/') + ->exec("cp -rf {$this->source_dir}/src/osdep/unix/*.h " . BUILD_INCLUDE_PATH . '/'); + } catch (\Throwable) { + // last command throws an exception, no idea why since it works + } + } +} diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 38be1bf2..5769c106 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -24,7 +24,6 @@ trait postgresql $optional_packages = [ 'zstd' => 'libzstd', 'ldap' => 'ldap', - 'libpam' => 'libpam', 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; @@ -74,12 +73,12 @@ trait postgresql '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . - ($this->builder->getLib('libpam') ? '--with-pam ' : '--without-pam ') . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . '--without-perl ' . '--without-python ' . + '--without-pam ' . '--without-bonjour ' . '--without-tcl ' ); diff --git a/src/globals/patch/1006_openssl1.1_autoverify.patch b/src/globals/patch/1006_openssl1.1_autoverify.patch new file mode 100644 index 00000000..f8629f2f --- /dev/null +++ b/src/globals/patch/1006_openssl1.1_autoverify.patch @@ -0,0 +1,58 @@ +Description: Support OpenSSL 1.1 + When building with OpenSSL 1.1 and newer, use the new built-in + hostname verification instead of code that doesn't compile due to + structs having been made opaque. +Bug-Debian: https://bugs.debian.org/828589 + +--- a/src/osdep/unix/ssl_unix.c ++++ b/src/osdep/unix/ssl_unix.c +@@ -227,8 +227,16 @@ static char *ssl_start_work (SSLSTREAM * + /* disable certificate validation? */ + if (flags & NET_NOVALIDATECERT) + SSL_CTX_set_verify (stream->context,SSL_VERIFY_NONE,NIL); +- else SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify); ++ else { ++#if OPENSSL_VERSION_NUMBER >= 0x10100000 ++ X509_VERIFY_PARAM *param = SSL_CTX_get0_param(stream->context); ++ X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); ++ X509_VERIFY_PARAM_set1_host(param, host, 0); ++#endif ++ ++ SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify); + /* set default paths to CAs... */ ++ } + SSL_CTX_set_default_verify_paths (stream->context); + /* ...unless a non-standard path desired */ + if (s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL)) +@@ -266,6 +274,7 @@ static char *ssl_start_work (SSLSTREAM * + if (SSL_write (stream->con,"",0) < 0) + return ssl_last_error ? ssl_last_error : "SSL negotiation failed"; + /* need to validate host names? */ ++#if OPENSSL_VERSION_NUMBER < 0x10100000 + if (!(flags & NET_NOVALIDATECERT) && + (err = ssl_validate_cert (cert = SSL_get_peer_certificate (stream->con), + host))) { +@@ -275,6 +284,7 @@ static char *ssl_start_work (SSLSTREAM * + sprintf (tmp,"*%.128s: %.255s",err,cert ? cert->name : "???"); + return ssl_last_error = cpystr (tmp); + } ++#endif + return NIL; + } + +@@ -313,6 +323,7 @@ static int ssl_open_verify (int ok,X509_ + * Returns: NIL if validated, else string of error message + */ + ++#if OPENSSL_VERSION_NUMBER < 0x10100000 + static char *ssl_validate_cert (X509 *cert,char *host) + { + int i,n; +@@ -342,6 +353,7 @@ static char *ssl_validate_cert (X509 *ce + else ret = "Unable to locate common name in certificate"; + return ret; + } ++#endif + + /* Case-independent wildcard pattern match + * Accepts: base string diff --git a/src/globals/patch/2014_openssl1.1.1_sni.patch b/src/globals/patch/2014_openssl1.1.1_sni.patch new file mode 100644 index 00000000..256d7d6d --- /dev/null +++ b/src/globals/patch/2014_openssl1.1.1_sni.patch @@ -0,0 +1,42 @@ +Bug-Debian: https://bugs.debian.org/916041 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1834340 +Description: + Google IMAP servers require SNI if TLSv1.3 is used, + otherwise it sends a self-signed certificate which + fails validation. + + OpenSSL support/versions: + - TLSv1.3 on 1.1.1, + - a2i_IPADDRESS() on 0.9.8'ish, + - SSL_set_tlsext_host_name() on 0.9.8'ish/1.0.0; + per 'git blame/describe' and the CHANGES file. + + So check for TLSv1.3 support / OpenSSL 1.1.1 + not to incur behavior changes on pre-TLSv1.3, + and set host_name to 'host' (ssl_open_verify() + validates this, via 'ssl_last_host' variable) + + This patch just combines these two patches: + - BTS#916041 (message #5) by Ed Spiridonov, + - LP#1834340 (comment #6) by David Zuelke. +Author: Mauricio Faria de Oliveira + +Index: uw-imap-2007f~dfsg/src/osdep/unix/ssl_unix.c +=================================================================== +--- uw-imap-2007f~dfsg.orig/src/osdep/unix/ssl_unix.c ++++ uw-imap-2007f~dfsg/src/osdep/unix/ssl_unix.c +@@ -266,6 +266,14 @@ static char *ssl_start_work (SSLSTREAM * + /* create connection */ + if (!(stream->con = (SSL *) SSL_new (stream->context))) + return "SSL connection failed"; ++#if OPENSSL_VERSION_NUMBER >= 0x10101000 ++ /* Use SNI in case server requires it with TLSv1.3. ++ * Literal IP addresses not permitted per RFC 6066. */ ++ if (!a2i_IPADDRESS(host)) { ++ ERR_clear_error(); ++ SSL_set_tlsext_host_name(stream->con,host); ++ } ++#endif + bio = BIO_new_socket (stream->tcpstream->tcpsi,BIO_NOCLOSE); + SSL_set_bio (stream->con,bio,bio); + SSL_set_connect_state (stream->con); From 31cf9bb5b7d3f5c2d988eff5cdb7147517a14544 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Tue, 31 Oct 2023 14:56:43 +0100 Subject: [PATCH 014/415] fix redhat os detection --- src/SPC/doctor/item/LinuxToolCheckList.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index ee9394f3..40d17956 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -36,7 +36,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'gcc', 'bzip2', 'cmake', 'patch', - 'xz', 'wget', // to get musl + 'xz', ]; /** @noinspection PhpUnused */ @@ -47,8 +47,7 @@ class LinuxToolCheckList $required = match ($distro['dist']) { 'alpine' => self::TOOLS_ALPINE, - 'almalinux' => self::TOOLS_RHEL, - 'rhel' => self::TOOLS_RHEL, + 'redhat' => self::TOOLS_RHEL, default => self::TOOLS_DEBIAN, }; $missing = []; @@ -61,8 +60,7 @@ class LinuxToolCheckList return match ($distro['dist']) { 'ubuntu', 'alpine', - 'rhel', - 'almalinux', + 'redhat', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'), }; @@ -74,11 +72,10 @@ class LinuxToolCheckList #[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')] public function checkSystemOSPackages(): ?CheckResult { - $distro = SystemUtil::getOSRelease(); - if ($distro['dist'] === 'alpine') { + if (SystemUtil::isMuslDist()) { // check linux-headers installation if (!file_exists('/usr/include/linux/mman.h')) { - return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [$distro, ['linux-headers']]); + return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [SystemUtil::getOSRelease(), ['linux-headers']]); } } return CheckResult::ok(); @@ -94,8 +91,7 @@ class LinuxToolCheckList $install_cmd = match ($distro['dist']) { 'ubuntu', 'debian' => 'apt-get install -y', 'alpine' => 'apk add', - 'rhel' => 'dnf install -y', - 'almalinux' => 'dnf install -y', + 'redhat' => 'dnf install -y', default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), }; $prefix = ''; @@ -104,8 +100,8 @@ class LinuxToolCheckList logger()->warning('Current user is not root, using sudo for running command'); } try { - $is_rhel = in_array($distro['dist'], ['rhel', 'almalinux']); - $to_install = $is_rhel ? $missing : str_replace('xz', 'xz-utils', $missing); + $is_debian = in_array($distro['dist'], ['debian', 'ubuntu']); + $to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing; shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install)); } catch (RuntimeException) { return false; From 3d64c6349e087055ab1fb843dde353b36b7b030f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 12 Nov 2023 16:59:16 +0800 Subject: [PATCH 015/415] remove kerberos temporarily --for-extensions is not working with it --- config/ext.json | 1 - 1 file changed, 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index e3081154..cb313ff5 100644 --- a/config/ext.json +++ b/config/ext.json @@ -137,7 +137,6 @@ "imap" ], "lib-suggests": [ - "kerberos", "openssl" ] }, From 65ef9ab20c70e5a09f50e0aa3347b4b843a1810a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 12 Nov 2023 17:00:27 +0800 Subject: [PATCH 016/415] use WrongUsageException for not supported libs --- 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 6e46886f..d214b859 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -69,7 +69,7 @@ abstract class BuilderBase foreach ($libraries as $library) { // if some libs are not supported (but in config "lib.json", throw exception) if (!isset($support_lib_list[$library])) { - throw new RuntimeException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); + throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); } $lib = new ($support_lib_list[$library])($this); $this->addLib($lib); From 347da67b714728f4f128d3c52a796373b867b0ab Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 13 Nov 2023 00:09:52 +0800 Subject: [PATCH 017/415] use static-php/imap --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index 7e1de028..a94236c3 100644 --- a/config/source.json +++ b/config/source.json @@ -146,7 +146,7 @@ }, "imap": { "type": "git", - "url": "https://github.com/uw-imap/imap.git", + "url": "https://github.com/static-php/imap.git", "rev": "master", "license": { "type": "file", From 5fdeb330313713bfe97eebd09c99f2b1f7b3f672 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 13 Nov 2023 00:10:23 +0800 Subject: [PATCH 018/415] separate linux and macos patches --- src/SPC/builder/linux/library/imap.php | 12 ++--- src/SPC/builder/macos/library/imap.php | 66 ++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 src/SPC/builder/macos/library/imap.php diff --git a/src/SPC/builder/linux/library/imap.php b/src/SPC/builder/linux/library/imap.php index 594a75bd..6a36c4ad 100644 --- a/src/SPC/builder/linux/library/imap.php +++ b/src/SPC/builder/linux/library/imap.php @@ -6,7 +6,6 @@ namespace SPC\builder\linux\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; @@ -16,31 +15,28 @@ class imap extends LinuxLibraryBase /** * @throws FileSystemException - * @throws RuntimeException */ public function patchBeforeBuild(): bool { $cc = getenv('CC') ?: 'gcc'; - FileSystem::replaceFileStr($this->source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', ''); + // FileSystem::replaceFileStr($this->source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', ''); FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}"); - FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto'); + /* FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto'); FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz'); FileSystem::replaceFileStr( $this->source_dir . '/src/osdep/unix/ssl_unix.c', "#include \n#include ", "#include \n#include " ); - SourcePatcher::patchFile('1007_openssl1.1_autoverify.patch', $this->source_dir); - SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); + // SourcePatcher::patchFile('1006_openssl1.1_autoverify.patch', $this->source_dir); + SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); */ FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH); FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH); return true; } /** - * @throws FileSystemException * @throws RuntimeException - * @throws WrongUsageException */ protected function build(): void { diff --git a/src/SPC/builder/macos/library/imap.php b/src/SPC/builder/macos/library/imap.php new file mode 100644 index 00000000..ab489ee6 --- /dev/null +++ b/src/SPC/builder/macos/library/imap.php @@ -0,0 +1,66 @@ +source_dir); + // FileSystem::replaceFileStr($this->source_dir . '/Makefile', '-DMAC_OSX_KLUDGE=1', ''); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', 'CC=cc', "CC={$cc}"); + /* FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto -lz', '-lcrypto'); + FileSystem::replaceFileStr($this->source_dir . '/src/osdep/unix/Makefile', '-lcrypto', '-lcrypto -lz'); + FileSystem::replaceFileStr( + $this->source_dir . '/src/osdep/unix/ssl_unix.c', + "#include \n#include ", + "#include \n#include " + ); + // SourcePatcher::patchFile('1006_openssl1.1_autoverify.patch', $this->source_dir); + SourcePatcher::patchFile('2014_openssl1.1.1_sni.patch', $this->source_dir); */ + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLINCLUDE=/usr/include/openssl', 'SSLINCLUDE=' . BUILD_INCLUDE_PATH); + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'SSLLIB=/usr/lib', 'SSLLIB=' . BUILD_LIB_PATH); + return true; + } + + /** + * @throws RuntimeException + */ + protected function build(): void + { + if ($this->builder->getLib('openssl')) { + $ssl_options = 'SPECIALAUTHENTICATORS=ssl SSLTYPE=unix.nopwd SSLINCLUDE=' . BUILD_INCLUDE_PATH . ' SSLLIB=' . BUILD_LIB_PATH; + } else { + $ssl_options = 'SSLTYPE=none'; + } + shell()->cd($this->source_dir) + ->exec('make clean') + ->exec('touch ip6') + ->exec( + "yes | EXTRACFLAGS='-Wimplicit-function-declaration -include $(xcrun --show-sdk-path)/usr/include/poll.h -include $(xcrun --show-sdk-path)/usr/include/time.h -include $(xcrun --show-sdk-path)/usr/include/utime.h' make osx {$ssl_options}" + ); + try { + shell() + ->exec("cp -rf {$this->source_dir}/c-client/c-client.a " . BUILD_LIB_PATH . '/libc-client.a') + ->exec("cp -rf {$this->source_dir}/c-client/*.c " . BUILD_LIB_PATH . '/') + ->exec("cp -rf {$this->source_dir}/c-client/*.h " . BUILD_INCLUDE_PATH . '/') + ->exec("cp -rf {$this->source_dir}/src/osdep/unix/*.h " . BUILD_INCLUDE_PATH . '/'); + } catch (\Throwable) { + // last command throws an exception, no idea why since it works + } + } +} From 031da802f3d24e3a095aa121f3c9dc40b5652690 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 13 Nov 2023 00:10:32 +0800 Subject: [PATCH 019/415] apply new patches --- src/globals/patch/0001_imap_macos.patch | 220 ++++++++++++++++++ .../patch/1006_openssl1.1_autoverify.patch | 58 ----- src/globals/patch/2014_openssl1.1.1_sni.patch | 42 ---- 3 files changed, 220 insertions(+), 100 deletions(-) create mode 100644 src/globals/patch/0001_imap_macos.patch delete mode 100644 src/globals/patch/1006_openssl1.1_autoverify.patch delete mode 100644 src/globals/patch/2014_openssl1.1.1_sni.patch diff --git a/src/globals/patch/0001_imap_macos.patch b/src/globals/patch/0001_imap_macos.patch new file mode 100644 index 00000000..c977de6a --- /dev/null +++ b/src/globals/patch/0001_imap_macos.patch @@ -0,0 +1,220 @@ +From 5ab3bd7fa858eec0626a9dd0117ca3b050ef4660 Mon Sep 17 00:00:00 2001 +From: crazywhalecc +Date: Mon, 13 Nov 2023 00:00:52 +0800 +Subject: [PATCH] make macOS static compile happy + +--- + src/c-client/netmsg.c | 1 + + src/c-client/nntp.c | 1 + + src/osdep/amiga/dummy.c | 1 + + src/osdep/amiga/mbx.c | 1 + + src/osdep/amiga/mh.c | 1 + + src/osdep/amiga/mtx.c | 1 + + src/osdep/amiga/unix.c | 1 + + src/osdep/unix/dummy.c | 1 + + src/osdep/unix/mbx.c | 1 + + src/osdep/unix/mh.c | 1 + + src/osdep/unix/mmdf.c | 1 + + src/osdep/unix/mtx.c | 1 + + src/osdep/unix/mx.c | 1 + + src/osdep/unix/tcp_unix.c | 1 + + src/osdep/unix/tenex.c | 2 ++ + src/osdep/unix/unix.c | 1 + + 16 files changed, 17 insertions(+) + +diff --git a/src/c-client/netmsg.c b/src/c-client/netmsg.c +index 187e4eb..f316d0b 100644 +--- a/src/c-client/netmsg.c ++++ b/src/c-client/netmsg.c +@@ -29,6 +29,7 @@ + + #include + #include ++#include + extern int errno; /* just in case */ + #include "c-client.h" + #include "netmsg.h" +diff --git a/src/c-client/nntp.c b/src/c-client/nntp.c +index fe90edb..b2f7536 100644 +--- a/src/c-client/nntp.c ++++ b/src/c-client/nntp.c +@@ -29,6 +29,7 @@ + + #include + #include ++#include + #include "c-client.h" + #include "newsrc.h" + #include "netmsg.h" +diff --git a/src/osdep/amiga/dummy.c b/src/osdep/amiga/dummy.c +index b003a0b..2c65824 100644 +--- a/src/osdep/amiga/dummy.c ++++ b/src/osdep/amiga/dummy.c +@@ -35,6 +35,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "dummy.h" + #include "misc.h" + +diff --git a/src/osdep/amiga/mbx.c b/src/osdep/amiga/mbx.c +index 1ece5d8..2495965 100644 +--- a/src/osdep/amiga/mbx.c ++++ b/src/osdep/amiga/mbx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/amiga/mh.c b/src/osdep/amiga/mh.c +index 0226b7a..e7c907a 100644 +--- a/src/osdep/amiga/mh.c ++++ b/src/osdep/amiga/mh.c +@@ -36,6 +36,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/amiga/mtx.c b/src/osdep/amiga/mtx.c +index 8e6f76e..ca7b368 100644 +--- a/src/osdep/amiga/mtx.c ++++ b/src/osdep/amiga/mtx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/amiga/unix.c b/src/osdep/amiga/unix.c +index be3c437..c755fe7 100644 +--- a/src/osdep/amiga/unix.c ++++ b/src/osdep/amiga/unix.c +@@ -46,6 +46,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "unix.h" + #include "pseudo.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/dummy.c b/src/osdep/unix/dummy.c +index b003a0b..2c65824 100644 +--- a/src/osdep/unix/dummy.c ++++ b/src/osdep/unix/dummy.c +@@ -35,6 +35,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "dummy.h" + #include "misc.h" + +diff --git a/src/osdep/unix/mbx.c b/src/osdep/unix/mbx.c +index 1ece5d8..2495965 100644 +--- a/src/osdep/unix/mbx.c ++++ b/src/osdep/unix/mbx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/mh.c b/src/osdep/unix/mh.c +index 0226b7a..e7c907a 100644 +--- a/src/osdep/unix/mh.c ++++ b/src/osdep/unix/mh.c +@@ -36,6 +36,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/mmdf.c b/src/osdep/unix/mmdf.c +index e962434..8cc9fae 100644 +--- a/src/osdep/unix/mmdf.c ++++ b/src/osdep/unix/mmdf.c +@@ -34,6 +34,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "pseudo.h" + #include "fdstring.h" + #include "misc.h" +diff --git a/src/osdep/unix/mtx.c b/src/osdep/unix/mtx.c +index 8e6f76e..ca7b368 100644 +--- a/src/osdep/unix/mtx.c ++++ b/src/osdep/unix/mtx.c +@@ -43,6 +43,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/mx.c b/src/osdep/unix/mx.c +index 4549527..9d444c9 100644 +--- a/src/osdep/unix/mx.c ++++ b/src/osdep/unix/mx.c +@@ -36,6 +36,7 @@ extern int errno; /* just in case */ + #include + #include + #include ++#include + #include "misc.h" + #include "dummy.h" + #include "fdstring.h" +diff --git a/src/osdep/unix/tcp_unix.c b/src/osdep/unix/tcp_unix.c +index 5bad706..5d6cd03 100644 +--- a/src/osdep/unix/tcp_unix.c ++++ b/src/osdep/unix/tcp_unix.c +@@ -27,6 +27,7 @@ + */ + + #include "ip_unix.c" ++#include + + #undef write /* don't use redefined write() */ + +diff --git a/src/osdep/unix/tenex.c b/src/osdep/unix/tenex.c +index eee61fb..61760f0 100644 +--- a/src/osdep/unix/tenex.c ++++ b/src/osdep/unix/tenex.c +@@ -46,6 +46,8 @@ extern int errno; /* just in case */ + #include "mail.h" + #include "osdep.h" + #include ++#include ++#include + #include "misc.h" + #include "dummy.h" + +diff --git a/src/osdep/unix/unix.c b/src/osdep/unix/unix.c +index be3c437..c755fe7 100644 +--- a/src/osdep/unix/unix.c ++++ b/src/osdep/unix/unix.c +@@ -46,6 +46,7 @@ extern int errno; /* just in case */ + #include "osdep.h" + #include + #include ++#include + #include "unix.h" + #include "pseudo.h" + #include "fdstring.h" +-- +2.39.3 (Apple Git-145) + diff --git a/src/globals/patch/1006_openssl1.1_autoverify.patch b/src/globals/patch/1006_openssl1.1_autoverify.patch deleted file mode 100644 index f8629f2f..00000000 --- a/src/globals/patch/1006_openssl1.1_autoverify.patch +++ /dev/null @@ -1,58 +0,0 @@ -Description: Support OpenSSL 1.1 - When building with OpenSSL 1.1 and newer, use the new built-in - hostname verification instead of code that doesn't compile due to - structs having been made opaque. -Bug-Debian: https://bugs.debian.org/828589 - ---- a/src/osdep/unix/ssl_unix.c -+++ b/src/osdep/unix/ssl_unix.c -@@ -227,8 +227,16 @@ static char *ssl_start_work (SSLSTREAM * - /* disable certificate validation? */ - if (flags & NET_NOVALIDATECERT) - SSL_CTX_set_verify (stream->context,SSL_VERIFY_NONE,NIL); -- else SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify); -+ else { -+#if OPENSSL_VERSION_NUMBER >= 0x10100000 -+ X509_VERIFY_PARAM *param = SSL_CTX_get0_param(stream->context); -+ X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); -+ X509_VERIFY_PARAM_set1_host(param, host, 0); -+#endif -+ -+ SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify); - /* set default paths to CAs... */ -+ } - SSL_CTX_set_default_verify_paths (stream->context); - /* ...unless a non-standard path desired */ - if (s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL)) -@@ -266,6 +274,7 @@ static char *ssl_start_work (SSLSTREAM * - if (SSL_write (stream->con,"",0) < 0) - return ssl_last_error ? ssl_last_error : "SSL negotiation failed"; - /* need to validate host names? */ -+#if OPENSSL_VERSION_NUMBER < 0x10100000 - if (!(flags & NET_NOVALIDATECERT) && - (err = ssl_validate_cert (cert = SSL_get_peer_certificate (stream->con), - host))) { -@@ -275,6 +284,7 @@ static char *ssl_start_work (SSLSTREAM * - sprintf (tmp,"*%.128s: %.255s",err,cert ? cert->name : "???"); - return ssl_last_error = cpystr (tmp); - } -+#endif - return NIL; - } - -@@ -313,6 +323,7 @@ static int ssl_open_verify (int ok,X509_ - * Returns: NIL if validated, else string of error message - */ - -+#if OPENSSL_VERSION_NUMBER < 0x10100000 - static char *ssl_validate_cert (X509 *cert,char *host) - { - int i,n; -@@ -342,6 +353,7 @@ static char *ssl_validate_cert (X509 *ce - else ret = "Unable to locate common name in certificate"; - return ret; - } -+#endif - - /* Case-independent wildcard pattern match - * Accepts: base string diff --git a/src/globals/patch/2014_openssl1.1.1_sni.patch b/src/globals/patch/2014_openssl1.1.1_sni.patch deleted file mode 100644 index 256d7d6d..00000000 --- a/src/globals/patch/2014_openssl1.1.1_sni.patch +++ /dev/null @@ -1,42 +0,0 @@ -Bug-Debian: https://bugs.debian.org/916041 -Bug-Ubuntu: https://bugs.launchpad.net/bugs/1834340 -Description: - Google IMAP servers require SNI if TLSv1.3 is used, - otherwise it sends a self-signed certificate which - fails validation. - - OpenSSL support/versions: - - TLSv1.3 on 1.1.1, - - a2i_IPADDRESS() on 0.9.8'ish, - - SSL_set_tlsext_host_name() on 0.9.8'ish/1.0.0; - per 'git blame/describe' and the CHANGES file. - - So check for TLSv1.3 support / OpenSSL 1.1.1 - not to incur behavior changes on pre-TLSv1.3, - and set host_name to 'host' (ssl_open_verify() - validates this, via 'ssl_last_host' variable) - - This patch just combines these two patches: - - BTS#916041 (message #5) by Ed Spiridonov, - - LP#1834340 (comment #6) by David Zuelke. -Author: Mauricio Faria de Oliveira - -Index: uw-imap-2007f~dfsg/src/osdep/unix/ssl_unix.c -=================================================================== ---- uw-imap-2007f~dfsg.orig/src/osdep/unix/ssl_unix.c -+++ uw-imap-2007f~dfsg/src/osdep/unix/ssl_unix.c -@@ -266,6 +266,14 @@ static char *ssl_start_work (SSLSTREAM * - /* create connection */ - if (!(stream->con = (SSL *) SSL_new (stream->context))) - return "SSL connection failed"; -+#if OPENSSL_VERSION_NUMBER >= 0x10101000 -+ /* Use SNI in case server requires it with TLSv1.3. -+ * Literal IP addresses not permitted per RFC 6066. */ -+ if (!a2i_IPADDRESS(host)) { -+ ERR_clear_error(); -+ SSL_set_tlsext_host_name(stream->con,host); -+ } -+#endif - bio = BIO_new_socket (stream->tcpstream->tcpsi,BIO_NOCLOSE); - SSL_set_bio (stream->con,bio,bio); - SSL_set_connect_state (stream->con); From 2d192fc3908088e2faea14bc50ceb2822a5e171e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 13 Nov 2023 00:17:46 +0800 Subject: [PATCH 020/415] replace libpng to github --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index a94236c3..d0e8e3b3 100644 --- a/config/source.json +++ b/config/source.json @@ -234,7 +234,7 @@ }, "libpng": { "type": "git", - "url": "https://git.code.sf.net/p/libpng/code", + "url": "https://github.com/glennrp/libpng.git", "rev": "libpng16", "license": { "type": "file", From a8f2b0096b6362e90a9bbf21b126d70495073a14 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 13 Nov 2023 00:32:59 +0800 Subject: [PATCH 021/415] cs fix --- src/SPC/builder/linux/library/imap.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/builder/linux/library/imap.php b/src/SPC/builder/linux/library/imap.php index 6a36c4ad..60b02203 100644 --- a/src/SPC/builder/linux/library/imap.php +++ b/src/SPC/builder/linux/library/imap.php @@ -7,7 +7,6 @@ namespace SPC\builder\linux\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; -use SPC\store\SourcePatcher; class imap extends LinuxLibraryBase { From 74536bd2e1be3dc530e9cd2de16b23c694f3e674 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 13 Nov 2023 17:59:03 +0800 Subject: [PATCH 022/415] Change CI download all to --for-extensions (#262) * Change download all to --for-extensions * Update build-linux-x86_64.yml * Update build-linux-arm.yml * Update build-linux-x86_64.yml * Update build-macos-x86_64.yml --- .github/workflows/build-linux-arm.yml | 4 ++-- .github/workflows/build-linux-x86_64.yml | 4 ++-- .github/workflows/build-macos-x86_64.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-linux-arm.yml b/.github/workflows/build-linux-arm.yml index d36321e4..3fc6d5e5 100644 --- a/.github/workflows/build-linux-arm.yml +++ b/.github/workflows/build-linux-arm.yml @@ -51,7 +51,7 @@ jobs: uses: actions/cache@v3 with: path: downloads - key: php-${{ inputs.version }}-dependencies + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} # With or without debug - if: inputs.debug == true @@ -67,7 +67,7 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} # Run build command - run: SPC_USE_ARCH=${{ inputs.operating-system }} ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 90705f33..4251f9e2 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -56,7 +56,7 @@ jobs: uses: actions/cache@v3 with: path: downloads - key: php-${{ inputs.version }}-dependencies + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} # With or without debug - if: inputs.debug == true @@ -72,7 +72,7 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: CACHE_API_EXEC=yes ./bin/spc-alpine-docker download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} # Run build command - run: ./bin/spc-alpine-docker build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index 6727fcbd..7ef31bb7 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -61,7 +61,7 @@ jobs: uses: actions/cache@v3 with: path: downloads - key: php-${{ inputs.version }}-dependencies + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} # With or without debug - if: inputs.debug == true @@ -77,7 +77,7 @@ jobs: # If there's no dependencies cache, fetch sources, with or without debug - if: steps.cache-download.outputs.cache-hit != 'true' - run: ./bin/spc download --with-php=${{ inputs.version }} --all ${{ env.SPC_BUILD_DEBUG }} + run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} # Run build command - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} From f7c73c00afcb6e166c0d86eecb7f7eaa79196179 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 14 Nov 2023 20:24:32 +0800 Subject: [PATCH 023/415] Fix iconv not depends on libiconv in linux --- config/ext.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index cb313ff5..21aedf67 100644 --- a/config/ext.json +++ b/config/ext.json @@ -118,7 +118,7 @@ "iconv": { "type": "builtin", "arg-type": "with-prefix", - "lib-depends-windows": [ + "lib-depends": [ "libiconv" ] }, From e3671387fc3b2f09c11ba800e7b11236a3e46a53 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 15 Nov 2023 18:00:06 +0800 Subject: [PATCH 024/415] temporarily use fixed url for freetype --- config/source.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index d0e8e3b3..32ca61f3 100644 --- a/config/source.json +++ b/config/source.json @@ -111,9 +111,8 @@ } }, "freetype": { - "type": "filelist", - "url": "https://download-mirror.savannah.gnu.org/releases/freetype/", - "regex": "/href=\"(?freetype-(?[^\"]+)\\.tar\\.xz)\"/", + "type": "url", + "url": "https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz", "license": { "type": "file", "path": "LICENSE.TXT" From 66cebb5fe4191d05e9cd6173ccaf628a9962d5d8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 15 Nov 2023 18:29:59 +0800 Subject: [PATCH 025/415] disable brotli if not enabled --- src/SPC/builder/extension/swoole.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 987a0cab..a9c1199f 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -16,7 +16,7 @@ class swoole extends Extension // pgsql hook is buggy for static php $arg .= ' --disable-swoole-pgsql'; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; - $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; + $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; $arg .= $this->builder->getExt('curl') ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; return $arg; } From a6fbcc954e7d611bfddc71b972bab1288cda830d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 15 Nov 2023 15:28:38 +0100 Subject: [PATCH 026/415] fix pthreads4w URL --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index 32ca61f3..3595223d 100644 --- a/config/source.json +++ b/config/source.json @@ -404,7 +404,7 @@ "pthreads4w": { "type": "git", "rev": "master", - "url": "https://git.code.sf.net/p/pthreads4w/code", + "url": "https://github.com/jwinarske/pthreads4w", "license": { "type": "file", "path": "LICENSE" From 3bd5a0572504846678fcab0e2c69ec0ab9bc5034 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 16 Nov 2023 00:11:52 +0800 Subject: [PATCH 027/415] remove pthreads4w --- config/lib.json | 15 +-------------- config/source.json | 9 --------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/config/lib.json b/config/lib.json index 5e6189e6..a36afebd 100644 --- a/config/lib.json +++ b/config/lib.json @@ -311,8 +311,7 @@ ], "lib-suggests-windows": [ "icu", - "xz", - "pthreads4w" + "xz" ] }, "libxslt": { @@ -450,18 +449,6 @@ "zstd" ] }, - "pthreads4w": { - "source": "pthreads4w", - "static-libs-windows": [ - "libpthreadVC3.lib" - ], - "headers-windows": [ - "_ptw32.h", - "pthread.h", - "sched.h", - "semaphore.h" - ] - }, "readline": { "source": "readline", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 3595223d..99264f06 100644 --- a/config/source.json +++ b/config/source.json @@ -401,15 +401,6 @@ "path": "LICENSE" } }, - "pthreads4w": { - "type": "git", - "rev": "master", - "url": "https://github.com/jwinarske/pthreads4w", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "readline": { "type": "filelist", "url": "https://ftp.gnu.org/pub/gnu/readline/", From 2a6441a500dc406a2662d563c409bcc56c639c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Nov 2023 11:09:06 +0100 Subject: [PATCH 028/415] switch to git --- config/source.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/source.json b/config/source.json index 99264f06..9f9124cb 100644 --- a/config/source.json +++ b/config/source.json @@ -111,8 +111,9 @@ } }, "freetype": { - "type": "url", - "url": "https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz", + "type": "git", + "rev": "VER-2-13-2", + "url": "https://github.com/freetype/freetype", "license": { "type": "file", "path": "LICENSE.TXT" @@ -216,7 +217,7 @@ }, "libmcrypt": { "type": "url", - "url": "https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz", + "url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz", "license": { "type": "file", "path": "COPYING" @@ -302,7 +303,7 @@ }, "mcrypt": { "type": "url", - "url": "https://jaist.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz", + "url": "https://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz", "license": { "type": "file", "path": "COPYING" From edaa82b8c522d48ed14779c00df95a2cbf2ea5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Nov 2023 11:17:36 +0100 Subject: [PATCH 029/415] autogen --- src/SPC/builder/unix/library/freetype.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 8ef3368f..3158d828 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -26,6 +26,7 @@ trait freetype $suggested .= ' '; shell()->cd($this->source_dir) + ->exec('sh autogen.sh') ->exec( './configure ' . '--enable-static --disable-shared --without-harfbuzz --prefix= ' . From 5736964b2e6c26b1fa96d39c10ff8cbd028d8fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Nov 2023 11:37:58 +0100 Subject: [PATCH 030/415] fix --- config/source.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index 9f9124cb..61db9e3c 100644 --- a/config/source.json +++ b/config/source.json @@ -111,9 +111,8 @@ } }, "freetype": { - "type": "git", - "rev": "VER-2-13-2", - "url": "https://github.com/freetype/freetype", + "type": "url", + "url": "https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz", "license": { "type": "file", "path": "LICENSE.TXT" From d09a3074ad4913e41fb4d5a86dfbf2d321e03426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 16 Nov 2023 11:54:31 +0100 Subject: [PATCH 031/415] include git metadata --- config/source.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/source.json b/config/source.json index 61db9e3c..9f9124cb 100644 --- a/config/source.json +++ b/config/source.json @@ -111,8 +111,9 @@ } }, "freetype": { - "type": "url", - "url": "https://github.com/freetype/freetype/archive/refs/tags/VER-2-13-2.tar.gz", + "type": "git", + "rev": "VER-2-13-2", + "url": "https://github.com/freetype/freetype", "license": { "type": "file", "path": "LICENSE.TXT" From a2c687599f6d44876fc9291d3a50c1a08bbdbdd0 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 19 Nov 2023 13:38:09 +0800 Subject: [PATCH 032/415] Create pull_request_template.md --- .github/pull_request_template.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..6a441788 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,12 @@ +## What does this PR do? + + + +## Checklist before merging + +> 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 it's a extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`. +- [ ] If you changed the behavior of static-php-cli, add docs in [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) . +- [ ] If you updated `config/xxxx.json` content, run `bin/spc dev:sort-config xxx`. From 2e637524fce5dca2bee1893671d94a9c49a765e8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 19 Nov 2023 13:38:55 +0800 Subject: [PATCH 033/415] Add test build things --- .github/workflows/tests.yml | 203 ++++++++++++++++++++------------ src/globals/test-extensions.php | 8 ++ 2 files changed, 133 insertions(+), 78 deletions(-) create mode 100644 src/globals/test-extensions.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d7223f64..8370a0c3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,98 +1,145 @@ name: Tests on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] permissions: - contents: read + contents: read jobs: - php-cs-fixer: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Checkout - uses: actions/checkout@v4 + php-cs-fixer: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 - tools: pecl, composer, php-cs-fixer + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: pecl, composer, php-cs-fixer - - name: Run PHP-CS-Fixer fix - run: php-cs-fixer fix --dry-run --diff --ansi + - name: Run PHP-CS-Fixer fix + run: php-cs-fixer fix --dry-run --diff --ansi - phpstan: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Checkout - uses: actions/checkout@v4 + phpstan: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 - tools: composer + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + tools: composer - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-phpstan- + - name: "Cache Composer packages" + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-phpstan- - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Run phpstan - run: vendor/bin/phpstan analyse + - name: "Run phpstan" + run: vendor/bin/phpstan analyse - phpunit: - name: PHPUnit (PHP ${{ matrix.php }}) - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - matrix: - include: - - php: '8.1' - - php: '8.2' - fail-fast: false + phpunit: + name: "PHPUnit (PHP ${{ matrix.php }})" + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + matrix: + include: + - php: '8.1' + - php: '8.2' + fail-fast: false - steps: - - name: Checkout - uses: actions/checkout@v4 + steps: + - name: "Checkout" + uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: pecl, composer - extensions: curl, openssl, mbstring - ini-values: memory_limit=-1 + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 - - name: Cache Composer packages - id: composer-cache - uses: actions/cache@v3 - with: - path: vendor - key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-php- + - name: "Cache Composer packages" + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Run PHPUnit tests - run: | - vendor/bin/phpunit tests/ --no-coverage + - name: "Run PHPUnit Tests" + run: | + vendor/bin/phpunit tests/ --no-coverage + + build: + name: "Build PHP Test (PHP ${{ matrix.php }})" + runs-on: ${{ matrix.os }} + timeout-minutes: 120 + strategy: + matrix: + php: + - 8.0 + - 8.1 + - 8.2 + os: + - ubuntu-latest + - macos-latest + fail-fast: false + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: pecl, composer + extensions: curl, openssl, mbstring + ini-values: memory_limit=-1 + + - name: "Cache Composer packages" + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: "Install Dependencies" + run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: "Run Build Tests (doctor)" + run: bin/spc doctor --auto-fix + + - name: "Run Build Tests (download)" + run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug + + - name: "Run Build Tests (build)" + run: bin/spc build "$(php src/globals/test-extensions.php)" --build-cli --build-micro --build-fpm --debug diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php new file mode 100644 index 00000000..3a2548d3 --- /dev/null +++ b/src/globals/test-extensions.php @@ -0,0 +1,8 @@ + Date: Sun, 19 Nov 2023 13:41:09 +0800 Subject: [PATCH 034/415] Add test build things --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8370a0c3..3e23e8f2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -133,7 +133,7 @@ jobs: ${{ runner.os }}-php- - name: "Install Dependencies" - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: "Run Build Tests (doctor)" run: bin/spc doctor --auto-fix From c0e88bf4bd21150311d7311ababb8b3396b2c509 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 19 Nov 2023 13:42:40 +0800 Subject: [PATCH 035/415] prevent setup php from using 8.0 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e23e8f2..517dc25f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -118,7 +118,7 @@ jobs: - name: "Setup PHP" uses: shivammathur/setup-php@v2 with: - php-version: "${{ matrix.php }}" + php-version: 8.2 tools: pecl, composer extensions: curl, openssl, mbstring ini-values: memory_limit=-1 From 859182abff39fc3c4d228861fdfbaf1daa107102 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 19 Nov 2023 13:44:12 +0800 Subject: [PATCH 036/415] remove fail fast --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 517dc25f..0fc951b7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -67,7 +67,6 @@ jobs: include: - php: '8.1' - php: '8.2' - fail-fast: false steps: - name: "Checkout" @@ -98,7 +97,7 @@ jobs: vendor/bin/phpunit tests/ --no-coverage build: - name: "Build PHP Test (PHP ${{ matrix.php }})" + name: "Build PHP Test (PHP ${{ matrix.php }} ${{ matrix.os }})" runs-on: ${{ matrix.os }} timeout-minutes: 120 strategy: From 9c904409cdc1c58b837698ef3f1c292423c3d260 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 19 Nov 2023 13:47:48 +0800 Subject: [PATCH 037/415] use string --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0fc951b7..f90631dd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -103,9 +103,9 @@ jobs: strategy: matrix: php: - - 8.0 - - 8.1 - - 8.2 + - "8.0" + - "8.1" + - "8.2" os: - ubuntu-latest - macos-latest From b3d41ef969efa83543a9f2ae4beae16c631d1803 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 9 Nov 2023 00:35:01 +0800 Subject: [PATCH 038/415] add extension rar --- config/ext.json | 5 +++++ config/source.json | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/config/ext.json b/config/ext.json index 21aedf67..19125296 100644 --- a/config/ext.json +++ b/config/ext.json @@ -278,6 +278,11 @@ "sqlite" ] }, + "rar": { + "type": "external", + "source": "rar", + "cpp-extension": true + }, "pgsql": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/source.json b/config/source.json index 9f9124cb..cca1284f 100644 --- a/config/source.json +++ b/config/source.json @@ -51,6 +51,16 @@ "path": "LICENSE" } }, + "rar": { + "type": "git", + "url": "https://github.com/static-php/php-rar.git", + "path": "php-src/ext/rar", + "rev": "issue-php82", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-glfw": { "type": "git", "url": "https://github.com/mario-deluna/php-glfw", From 2bb08af89bac1ac4d277d3d4d454f05e7f66aad1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 19 Nov 2023 14:04:51 +0800 Subject: [PATCH 039/415] add rar 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 3a2548d3..b3bd4572 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; +$extensions = 'rar,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; echo $extensions; From 869130572f8c206864792ff0f5e8d68237280b50 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 19 Nov 2023 14:46:30 +0800 Subject: [PATCH 040/415] change 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 b3bd4572..83783a27 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'rar,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; +$extensions = 'rar,zlib,zip'; echo $extensions; From 36a30cc23b83e3511f158437c2efc235a7b81da9 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 21 Nov 2023 23:35:34 +0800 Subject: [PATCH 041/415] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c89abc91..0fe5acef 100755 --- a/README.md +++ b/README.md @@ -272,11 +272,13 @@ You can sponsor my project on [this page](https://github.com/crazywhalecc/crazyw ## Open-Source License This project itself is based on MIT License, -some newly added extensions and dependencies may originate from the following projects (including but not limited to), -and the headers of these code files will also be given additional instructions LICENSE and AUTHOR: +some newly added extensions and dependencies may originate from the the other projects, +and the headers of these code files will also be given additional instructions LICENSE and AUTHOR. -- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) (Mulun Permissive License) -- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) (Apache 2.0 LICENSE+SWOOLE-CLI LICENSE) +These are similar projects: + +- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) +- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) Due to the special nature of this project, many other open source projects such as curl and protobuf will be used during the project compilation process, From 2e24976b71bcb678f713b86efbe505165f8c7b96 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 22 Nov 2023 11:05:57 +0800 Subject: [PATCH 042/415] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0fe5acef..356f812b 100755 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ Please first select the extension you want to compile based on the extension lis > If an extension you need is missing, you can submit an issue. +Here is the current planned roadmap for extension support: [#152](https://github.com/crazywhalecc/static-php-cli/issues/152) . + ### GitHub Actions Build Use GitHub Action to easily build a statically compiled PHP, From 04f100da8bf308a3a006cede42455aa2f2576851 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 21 Nov 2023 23:12:00 +0800 Subject: [PATCH 043/415] add tidy support --- config/ext.json | 12 +++++----- config/lib.json | 6 +++++ config/source.json | 29 +++++++++++++++-------- src/SPC/builder/macos/library/tidy.php | 12 ++++++++++ src/SPC/builder/unix/library/tidy.php | 32 ++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 src/SPC/builder/macos/library/tidy.php create mode 100644 src/SPC/builder/unix/library/tidy.php diff --git a/config/ext.json b/config/ext.json index 19125296..e38bacb6 100644 --- a/config/ext.json +++ b/config/ext.json @@ -278,11 +278,6 @@ "sqlite" ] }, - "rar": { - "type": "external", - "source": "rar", - "cpp-extension": true - }, "pgsql": { "type": "builtin", "arg-type": "with-prefix", @@ -311,6 +306,11 @@ "aspell" ] }, + "rar": { + "type": "external", + "source": "rar", + "cpp-extension": true + }, "readline": { "type": "builtin", "arg-type": "with-prefix", @@ -435,7 +435,7 @@ }, "tidy": { "type": "builtin", - "arg-type": "with", + "arg-type": "with-prefix", "lib-depends": [ "tidy" ] diff --git a/config/lib.json b/config/lib.json index a36afebd..7abff12c 100644 --- a/config/lib.json +++ b/config/lib.json @@ -483,6 +483,12 @@ "sqlite3ext.h" ] }, + "tidy": { + "source": "tidy", + "static-libs-unix": [ + "libtidy.a" + ] + }, "xz": { "source": "xz", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index cca1284f..143e1874 100644 --- a/config/source.json +++ b/config/source.json @@ -51,16 +51,6 @@ "path": "LICENSE" } }, - "rar": { - "type": "git", - "url": "https://github.com/static-php/php-rar.git", - "path": "php-src/ext/rar", - "rev": "issue-php82", - "license": { - "type": "file", - "path": "LICENSE" - } - }, "ext-glfw": { "type": "git", "url": "https://github.com/mario-deluna/php-glfw", @@ -412,6 +402,16 @@ "path": "LICENSE" } }, + "rar": { + "type": "git", + "url": "https://github.com/static-php/php-rar.git", + "path": "php-src/ext/rar", + "rev": "issue-php82", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "readline": { "type": "filelist", "url": "https://ftp.gnu.org/pub/gnu/readline/", @@ -469,6 +469,15 @@ "path": "LICENSE" } }, + "tidy": { + "type": "url", + "url": "https://github.com/htacg/tidy-html5/archive/refs/tags/5.8.0.tar.gz", + "filename": "tidy-html5.tgz", + "license": { + "type": "file", + "path": "README/LICENSE.md" + } + }, "xlswriter": { "type": "url", "url": "https://pecl.php.net/get/xlswriter", diff --git a/src/SPC/builder/macos/library/tidy.php b/src/SPC/builder/macos/library/tidy.php new file mode 100644 index 00000000..733e7644 --- /dev/null +++ b/src/SPC/builder/macos/library/tidy.php @@ -0,0 +1,12 @@ +source_dir . '/build-dir'); + shell()->cd($this->source_dir . '/build-dir') + ->exec( + 'cmake ' . + "{$this->builder->makeCmakeArgs()} " . + '-DBUILD_SHARED_LIB=OFF ' . + '-DSUPPORT_CONSOLE_APP=OFF ' . + '..' + ) + ->exec("cmake --build . -j {$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $this->patchPkgconfPrefix(['tidy.pc']); + } +} From 89afd44344933d752424c61abf0bf74fa4d94e57 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 21 Nov 2023 23:12:40 +0800 Subject: [PATCH 044/415] add tidy support for linux --- src/SPC/builder/linux/library/tidy.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/SPC/builder/linux/library/tidy.php diff --git a/src/SPC/builder/linux/library/tidy.php b/src/SPC/builder/linux/library/tidy.php new file mode 100644 index 00000000..0cfcd27e --- /dev/null +++ b/src/SPC/builder/linux/library/tidy.php @@ -0,0 +1,12 @@ + Date: Tue, 21 Nov 2023 23:13:09 +0800 Subject: [PATCH 045/415] add 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 83783a27..fbdbf3bd 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'rar,zlib,zip'; +$extensions = 'tidy,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; echo $extensions; From 7a2e237069b15aad1f22eb4b33e731bb89116e95 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 22 Nov 2023 00:29:44 +0800 Subject: [PATCH 046/415] add php 8.3 support --- .github/workflows/build-linux-arm.yml | 1 + .github/workflows/build-linux-x86_64.yml | 1 + .github/workflows/build-macos-x86_64.yml | 1 + .github/workflows/download-cache.yml | 2 +- .github/workflows/tests.yml | 4 +++- README-zh.md | 2 +- README.md | 2 +- bin/setup-runtime | 4 ++-- 8 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-linux-arm.yml b/.github/workflows/build-linux-arm.yml index 3fc6d5e5..1a062727 100644 --- a/.github/workflows/build-linux-arm.yml +++ b/.github/workflows/build-linux-arm.yml @@ -15,6 +15,7 @@ on: default: '8.2' type: choice options: + - '8.3' - '8.2' - '8.1' - '8.0' diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 4251f9e2..91803677 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -9,6 +9,7 @@ on: default: '8.2' type: choice options: + - '8.3' - '8.2' - '8.1' - '8.0' diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index 7ef31bb7..a942a39f 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -9,6 +9,7 @@ on: default: '8.2' type: choice options: + - '8.3' - '8.2' - '8.1' - '8.0' diff --git a/.github/workflows/download-cache.yml b/.github/workflows/download-cache.yml index 86b4322e..1d0a5f52 100644 --- a/.github/workflows/download-cache.yml +++ b/.github/workflows/download-cache.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: [ "8.0", "8.1", "8.2" ] + php-version: [ "8.0", "8.1", "8.2", "8.3" ] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f90631dd..d5b9d041 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -67,6 +67,7 @@ jobs: include: - php: '8.1' - php: '8.2' + - php: '8.3' steps: - name: "Checkout" @@ -106,6 +107,7 @@ jobs: - "8.0" - "8.1" - "8.2" + - "8.3" os: - ubuntu-latest - macos-latest @@ -117,7 +119,7 @@ jobs: - name: "Setup PHP" uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: 8.3 tools: pecl, composer extensions: curl, openssl, mbstring ini-values: memory_limit=-1 diff --git a/README-zh.md b/README-zh.md index 33cb1d64..e8aac2c3 100755 --- a/README-zh.md +++ b/README-zh.md @@ -130,7 +130,7 @@ chmod +x bin/spc ./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro ``` -你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.2: +你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.3: ```bash # 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建 diff --git a/README.md b/README.md index 356f812b..2f5f5ccf 100755 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ Basic usage for building php and micro with some extensions: ./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro ``` -You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.2: +You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.3: ```bash # Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro diff --git a/bin/setup-runtime b/bin/setup-runtime index bd7144b7..b344bab5 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd) __PROJECT__=$(cd "${__DIR__}"/../ && pwd) # set download dir -__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" +__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" __COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar" # use china mirror @@ -46,7 +46,7 @@ done case "$mirror" in china) - __PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.10-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" + __PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" __COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar" ;; From 93e64e1d5a8ebd05d29a516541f0bf541c1dd978 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 24 Nov 2023 01:20:13 +0800 Subject: [PATCH 047/415] use php 8.2 to setup php runtime --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d5b9d041..9b9e64a8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -119,7 +119,7 @@ jobs: - name: "Setup PHP" uses: shivammathur/setup-php@v2 with: - php-version: 8.3 + php-version: 8.2 tools: pecl, composer extensions: curl, openssl, mbstring ini-values: memory_limit=-1 From 5449e0589802ec6c66d6a1bbb6bd434665baec1b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 24 Nov 2023 10:28:35 +0800 Subject: [PATCH 048/415] Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2f5f5ccf..cd714f70 100755 --- a/README.md +++ b/README.md @@ -90,13 +90,12 @@ Currently, the platforms supported by `spc` binary are Linux and macOS. Here's how to download from GitHub Actions: -1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml). -2. Select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform. -3. Unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`. +1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml) or [self-hosted nightly builds](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/). +2. If you download from GHA, select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform. +3. If you download from GHA, unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`. +4. If you download from self-hosted server, download `spc-$os-$arch` file and just use it (don't forget `chmod +x`). -You can also download binaries from a self-hosted server: [enter](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/). - -> SPC single-file binary is built by phpmicro and box. +> SPC single-file binary is built by phpmicro and box, and it doesn't need to install PHP. Just treat `spc` as a standalone executable. ### Manual build (using source code) From 0589690eaa6aea204abb15975ad1f739d0a7168e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 27 Nov 2023 21:21:31 +0800 Subject: [PATCH 049/415] add libtool installation for debian --- 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 40d17956..7755f838 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -28,7 +28,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', - 'xz', + 'xz', 'libtool', ]; public const TOOLS_RHEL = [ From 4400c6271e267a16da108f63020b9d7d512848d6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 27 Nov 2023 21:21:45 +0800 Subject: [PATCH 050/415] update composer lock --- composer.lock | 236 +++++++++++++++++++++++++------------------------- 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/composer.lock b/composer.lock index 109c39b3..1be1f401 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.29.0", + "version": "v10.33.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "bb8784ce913bd46f944b4bd67cd857f40d9cfe68" + "reference": "766a3b6c3e5c8011b037a147266dcf7f93b21223" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/bb8784ce913bd46f944b4bd67cd857f40d9cfe68", - "reference": "bb8784ce913bd46f944b4bd67cd857f40d9cfe68", + "url": "https://api.github.com/repos/illuminate/collections/zipball/766a3b6c3e5c8011b037a147266dcf7f93b21223", + "reference": "766a3b6c3e5c8011b037a147266dcf7f93b21223", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-10-10T12:55:25+00:00" + "time": "2023-11-20T15:45:45+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.29.0", + "version": "v10.33.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,16 +109,16 @@ }, { "name": "illuminate/contracts", - "version": "v10.29.0", + "version": "v10.33.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "6c39fba7b2311e28f5c6ac7d729e3d49a2a98406" + "reference": "f6bf37a272fda164f6c451407c99f820eb1eb95b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/6c39fba7b2311e28f5c6ac7d729e3d49a2a98406", - "reference": "6c39fba7b2311e28f5c6ac7d729e3d49a2a98406", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/f6bf37a272fda164f6c451407c99f820eb1eb95b", + "reference": "f6bf37a272fda164f6c451407c99f820eb1eb95b", "shasum": "" }, "require": { @@ -153,11 +153,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-09-05T19:07:46+00:00" + "time": "2023-10-30T00:59:22+00:00" }, { "name": "illuminate/macroable", - "version": "v10.29.0", + "version": "v10.33.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.12", + "version": "v0.1.13", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "b35f249028c22016e45e48626e19e5d42fd827ff" + "reference": "e1379d8ead15edd6cc4369c22274345982edc95a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/b35f249028c22016e45e48626e19e5d42fd827ff", - "reference": "b35f249028c22016e45e48626e19e5d42fd827ff", + "url": "https://api.github.com/repos/laravel/prompts/zipball/e1379d8ead15edd6cc4369c22274345982edc95a", + "reference": "e1379d8ead15edd6cc4369c22274345982edc95a", "shasum": "" }, "require": { @@ -254,9 +254,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.12" + "source": "https://github.com/laravel/prompts/tree/v0.1.13" }, - "time": "2023-10-18T14:18:57+00:00" + "time": "2023-10-27T13:53:59+00:00" }, { "name": "psr/container", @@ -414,16 +414,16 @@ }, { "name": "symfony/console", - "version": "v6.3.4", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6" + "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6", - "reference": "eca495f2ee845130855ddf1cf18460c38966c8b6", + "url": "https://api.github.com/repos/symfony/console/zipball/0d14a9f6d04d4ac38a8cea1171f4554e325dae92", + "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92", "shasum": "" }, "require": { @@ -484,7 +484,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.3.4" + "source": "https://github.com/symfony/console/tree/v6.3.8" }, "funding": [ { @@ -500,11 +500,11 @@ "type": "tidelift" } ], - "time": "2023-08-16T10:10:12+00:00" + "time": "2023-10-31T08:09:35+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", @@ -551,7 +551,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" }, "funding": [ { @@ -901,16 +901,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4" + "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", - "reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838", + "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838", "shasum": "" }, "require": { @@ -963,7 +963,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.0" }, "funding": [ { @@ -979,20 +979,20 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2023-07-30T20:28:31+00:00" }, { "name": "symfony/string", - "version": "v6.3.5", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339" + "reference": "13880a87790c76ef994c91e87efb96134522577a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339", - "reference": "13d76d0fb049051ed12a04bef4f9de8715bea339", + "url": "https://api.github.com/repos/symfony/string/zipball/13880a87790c76ef994c91e87efb96134522577a", + "reference": "13880a87790c76ef994c91e87efb96134522577a", "shasum": "" }, "require": { @@ -1049,7 +1049,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.5" + "source": "https://github.com/symfony/string/tree/v6.3.8" }, "funding": [ { @@ -1065,7 +1065,7 @@ "type": "tidelift" } ], - "time": "2023-09-18T10:38:32+00:00" + "time": "2023-11-09T08:28:21+00:00" }, { "name": "zhamao/logger", @@ -1691,16 +1691,16 @@ }, { "name": "captainhook/captainhook", - "version": "5.18.2", + "version": "5.18.3", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook.git", - "reference": "61c24442f71ea216e9e172861d48d7676439dd18" + "reference": "b7bc503a40ccfe80ea9638e4921b4697669d725f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/61c24442f71ea216e9e172861d48d7676439dd18", - "reference": "61c24442f71ea216e9e172861d48d7676439dd18", + "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/b7bc503a40ccfe80ea9638e4921b4697669d725f", + "reference": "b7bc503a40ccfe80ea9638e4921b4697669d725f", "shasum": "" }, "require": { @@ -1762,7 +1762,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook/tree/5.18.2" + "source": "https://github.com/captainhookphp/captainhook/tree/5.18.3" }, "funding": [ { @@ -1770,7 +1770,7 @@ "type": "github" } ], - "time": "2023-10-16T15:13:42+00:00" + "time": "2023-11-05T13:56:19+00:00" }, { "name": "captainhook/plugin-composer", @@ -2247,16 +2247,16 @@ }, { "name": "filp/whoops", - "version": "2.15.3", + "version": "2.15.4", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "c83e88a30524f9360b11f585f71e6b17313b7187" + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/c83e88a30524f9360b11f585f71e6b17313b7187", - "reference": "c83e88a30524f9360b11f585f71e6b17313b7187", + "url": "https://api.github.com/repos/filp/whoops/zipball/a139776fa3f5985a50b509f2a02ff0f709d2a546", + "reference": "a139776fa3f5985a50b509f2a02ff0f709d2a546", "shasum": "" }, "require": { @@ -2306,7 +2306,7 @@ ], "support": { "issues": "https://github.com/filp/whoops/issues", - "source": "https://github.com/filp/whoops/tree/2.15.3" + "source": "https://github.com/filp/whoops/tree/2.15.4" }, "funding": [ { @@ -2314,54 +2314,54 @@ "type": "github" } ], - "time": "2023-07-13T12:00:00+00:00" + "time": "2023-11-03T12:00:00+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.37.1", + "version": "v3.40.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "c3fe76976081ab871aa654e872da588077e19679" + "reference": "27d2b3265b5d550ec411b4319967ae7cfddfb2e0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c3fe76976081ab871aa654e872da588077e19679", - "reference": "c3fe76976081ab871aa654e872da588077e19679", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/27d2b3265b5d550ec411b4319967ae7cfddfb2e0", + "reference": "27d2b3265b5d550ec411b4319967ae7cfddfb2e0", "shasum": "" }, "require": { - "composer/semver": "^3.3", + "composer/semver": "^3.4", "composer/xdebug-handler": "^3.0.3", "ext-json": "*", "ext-tokenizer": "*", "php": "^7.4 || ^8.0", "sebastian/diff": "^4.0 || ^5.0", - "symfony/console": "^5.4 || ^6.0", - "symfony/event-dispatcher": "^5.4 || ^6.0", - "symfony/filesystem": "^5.4 || ^6.0", - "symfony/finder": "^5.4 || ^6.0", - "symfony/options-resolver": "^5.4 || ^6.0", - "symfony/polyfill-mbstring": "^1.27", - "symfony/polyfill-php80": "^1.27", - "symfony/polyfill-php81": "^1.27", - "symfony/process": "^5.4 || ^6.0", - "symfony/stopwatch": "^5.4 || ^6.0" + "symfony/console": "^5.4 || ^6.0 || ^7.0", + "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", + "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", + "symfony/finder": "^5.4 || ^6.0 || ^7.0", + "symfony/options-resolver": "^5.4 || ^6.0 || ^7.0", + "symfony/polyfill-mbstring": "^1.28", + "symfony/polyfill-php80": "^1.28", + "symfony/polyfill-php81": "^1.28", + "symfony/process": "^5.4 || ^6.0 || ^7.0", + "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { "facile-it/paraunit": "^1.3 || ^2.0", "justinrainbow/json-schema": "^5.2", - "keradus/cli-executor": "^2.0", + "keradus/cli-executor": "^2.1", "mikey179/vfsstream": "^1.6.11", - "php-coveralls/php-coveralls": "^2.5.3", + "php-coveralls/php-coveralls": "^2.7", "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", - "phpspec/prophecy": "^1.16", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", + "phpspec/prophecy": "^1.17", "phpspec/prophecy-phpunit": "^2.0", - "phpunit/phpunit": "^9.5", - "symfony/phpunit-bridge": "^6.2.3", - "symfony/yaml": "^5.4 || ^6.0" + "phpunit/phpunit": "^9.6", + "symfony/phpunit-bridge": "^6.3.8 || ^7.0", + "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { "ext-dom": "For handling output formats in XML", @@ -2399,7 +2399,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.40.0" }, "funding": [ { @@ -2407,7 +2407,7 @@ "type": "github" } ], - "time": "2023-10-29T20:51:23+00:00" + "time": "2023-11-26T09:25:53+00:00" }, { "name": "humbug/box", @@ -2521,16 +2521,16 @@ }, { "name": "humbug/php-scoper", - "version": "0.18.4", + "version": "0.18.7", "source": { "type": "git", "url": "https://github.com/humbug/php-scoper.git", - "reference": "d79c1486537280c21c907e9a8a610eceb391407f" + "reference": "9386a0af946f175d7a1ebfb68851bc2bb8ad7858" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/humbug/php-scoper/zipball/d79c1486537280c21c907e9a8a610eceb391407f", - "reference": "d79c1486537280c21c907e9a8a610eceb391407f", + "url": "https://api.github.com/repos/humbug/php-scoper/zipball/9386a0af946f175d7a1ebfb68851bc2bb8ad7858", + "reference": "9386a0af946f175d7a1ebfb68851bc2bb8ad7858", "shasum": "" }, "require": { @@ -2548,7 +2548,7 @@ "bamarni/composer-bin-plugin": "^1.1", "ergebnis/composer-normalize": "^2.28", "fidry/makefile": "^1.0", - "humbug/box": "^4.0", + "humbug/box": "^4.5.1", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.0", "symfony/yaml": "^6.1" @@ -2598,9 +2598,9 @@ "description": "Prefixes all PHP namespaces in a file or directory.", "support": { "issues": "https://github.com/humbug/php-scoper/issues", - "source": "https://github.com/humbug/php-scoper/tree/0.18.4" + "source": "https://github.com/humbug/php-scoper/tree/0.18.7" }, - "time": "2023-10-20T17:14:04+00:00" + "time": "2023-11-04T18:01:12+00:00" }, { "name": "jetbrains/phpstorm-stubs", @@ -2722,16 +2722,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.3.2", + "version": "v1.3.3", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c" + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/076fe2cf128bd54b4341cdc6d49b95b34e101e4c", - "reference": "076fe2cf128bd54b4341cdc6d49b95b34e101e4c", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/3dbf8a8e914634c48d389c1234552666b3d43754", + "reference": "3dbf8a8e914634c48d389c1234552666b3d43754", "shasum": "" }, "require": { @@ -2778,7 +2778,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2023-10-17T13:38:16+00:00" + "time": "2023-11-08T14:08:06+00:00" }, { "name": "myclabs/deep-copy", @@ -3477,16 +3477,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.2", + "version": "1.24.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bcad8d995980440892759db0c32acae7c8e79442" + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442", - "reference": "bcad8d995980440892759db0c32acae7c8e79442", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", "shasum": "" }, "require": { @@ -3518,22 +3518,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" }, - "time": "2023-09-26T12:28:12+00:00" + "time": "2023-11-26T18:29:22+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.40", + "version": "1.10.44", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d" + "reference": "bf84367c53a23f759513985c54ffe0d0c249825b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/93c84b5bf7669920d823631e39904d69b9c7dc5d", - "reference": "93c84b5bf7669920d823631e39904d69b9c7dc5d", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bf84367c53a23f759513985c54ffe0d0c249825b", + "reference": "bf84367c53a23f759513985c54ffe0d0c249825b", "shasum": "" }, "require": { @@ -3582,20 +3582,20 @@ "type": "tidelift" } ], - "time": "2023-10-30T14:48:31+00:00" + "time": "2023-11-21T16:30:46+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.7", + "version": "10.1.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "355324ca4980b8916c18b9db29f3ef484078f26e" + "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/355324ca4980b8916c18b9db29f3ef484078f26e", - "reference": "355324ca4980b8916c18b9db29f3ef484078f26e", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a56a9ab2f680246adcf3db43f38ddf1765774735", + "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735", "shasum": "" }, "require": { @@ -3652,7 +3652,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.7" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.9" }, "funding": [ { @@ -3660,7 +3660,7 @@ "type": "github" } ], - "time": "2023-10-04T15:34:17+00:00" + "time": "2023-11-23T12:23:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -5292,7 +5292,7 @@ }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", @@ -5348,7 +5348,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0" }, "funding": [ { @@ -5685,16 +5685,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.3.6", + "version": "v6.3.8", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97" + "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/999ede244507c32b8e43aebaa10e9fce20de7c97", - "reference": "999ede244507c32b8e43aebaa10e9fce20de7c97", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/81acabba9046550e89634876ca64bfcd3c06aa0a", + "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a", "shasum": "" }, "require": { @@ -5749,7 +5749,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.3.6" + "source": "https://github.com/symfony/var-dumper/tree/v6.3.8" }, "funding": [ { @@ -5765,7 +5765,7 @@ "type": "tidelift" } ], - "time": "2023-10-12T18:45:56+00:00" + "time": "2023-11-08T10:42:36+00:00" }, { "name": "thecodingmachine/safe", @@ -5908,16 +5908,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.2", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", "shasum": "" }, "require": { @@ -5946,7 +5946,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + "source": "https://github.com/theseer/tokenizer/tree/1.2.2" }, "funding": [ { @@ -5954,7 +5954,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2023-11-20T00:12:19+00:00" }, { "name": "webmozart/assert", From 9dcda873f3ed7dd6a40fa52157c23236d778925e Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 27 Nov 2023 22:35:40 +0800 Subject: [PATCH 051/415] Fix debian libtool bug (#276) * add libtool installation for debian * update composer lock * re-fix libtool check * re-fix libtool check --- 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 7755f838..33aa0639 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -28,7 +28,7 @@ class LinuxToolCheckList 'git', 'autoconf', 'automake', 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'patch', - 'xz', 'libtool', + 'xz', 'libtoolize', ]; public const TOOLS_RHEL = [ @@ -102,6 +102,7 @@ class LinuxToolCheckList try { $is_debian = in_array($distro['dist'], ['debian', 'ubuntu']); $to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing; + $to_install = $is_debian ? str_replace('libtoolize', 'libtool', $to_install) : $to_install; shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install)); } catch (RuntimeException) { return false; From 1c307d0d594a0b3139446d0bcd5e1a28c805ddaa Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 13:30:12 +0800 Subject: [PATCH 052/415] upgrade libpq to v16.1 --- config/source.json | 2 +- src/SPC/builder/unix/library/postgresql.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/config/source.json b/config/source.json index 143e1874..fb29e410 100644 --- a/config/source.json +++ b/config/source.json @@ -386,7 +386,7 @@ }, "postgresql": { "type": "url", - "url": "https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz", + "url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz", "license": { "type": "file", "path": "COPYRIGHT" diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 5769c106..b3630f57 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -57,9 +57,7 @@ trait postgresql # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile shell()->cd($this->source_dir . '/build') - ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') - ->exec('sed -i.backup "293 s/^/#$/" ../src/Makefile.shlib') - ->exec('sed -i.backup "441 s/^/#$/" ../src/Makefile.shlib'); + ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile'); // configure shell()->cd($this->source_dir . '/build') @@ -88,9 +86,7 @@ trait postgresql ->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/backend/port install') ->exec($envs . ' make -C src/port install') - ->exec($envs . ' make -C src/backend/libpq install') ->exec($envs . ' make -C src/interfaces/libpq install'); // remove dynamic libs From 41cd319d4e7147d0c07573d02fbcf529ee7b4837 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 29 Nov 2023 14:28:39 +0800 Subject: [PATCH 053/415] 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 fbdbf3bd..b1c96f55 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'tidy,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; +$extensions = 'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,imap,ldap,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; echo $extensions; From c7b3275a72ec37302e22d9cc63c23d440814e899 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 15:06:17 +0800 Subject: [PATCH 054/415] update libpq build config --- src/SPC/builder/unix/library/postgresql.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index b3630f57..339664ae 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -57,7 +57,9 @@ trait postgresql # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile shell()->cd($this->source_dir . '/build') - ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile'); + ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') + ->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib') + ->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib'); // configure shell()->cd($this->source_dir . '/build') From 5db084ba0e3f63b0a005c0ced6005ee56dea5678 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 29 Nov 2023 15:17:21 +0800 Subject: [PATCH 055/415] reduce test extensions --- 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 b1c96f55..a06374df 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,imap,ldap,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; +$extensions = 'pgsql,openssl,posix,pcntl,phar,zip,pdo_pgsql'; echo $extensions; From ed22945ae2c786aa1758fc78bfa9bd4c085d0805 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 15:44:04 +0800 Subject: [PATCH 056/415] test --- src/SPC/builder/unix/library/postgresql.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 339664ae..b1187a5b 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -27,9 +27,13 @@ trait postgresql 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; + logger()->info(shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}")[1][0]); foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; + logger()->info(shell()->execWithResult("pkg-config --cflags-only-I --static {$pkg}")[1][0]); + logger()->info(shell()->execWithResult("pkg-config --libs-only-L --static {$pkg}")[1][0]); + logger()->info(shell()->execWithResult("pkg-config --libs-only-l --static {$pkg}")[1][0]); } } @@ -96,5 +100,7 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so.*") ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); + + logger()->info(shell()->execWithResult('pkg-config --cflags-only-I --static libpq')[1][0]); } } From 400007c206a5e085410b9dee9a0a0f141c7483fd Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 15:56:52 +0800 Subject: [PATCH 057/415] test change test-extensions --- 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 a06374df..075c1f8d 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'pgsql,openssl,posix,pcntl,phar,zip,pdo_pgsql'; - +$extensions = +'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,imap,ldap,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; echo $extensions; From cee1346bec042fcd7a8f096eee2130b8bf7924a3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 29 Nov 2023 00:51:05 +0800 Subject: [PATCH 058/415] fix imagemagick linking issue --- src/SPC/builder/extension/imagick.php | 5 ++++- src/SPC/builder/unix/library/imagemagick.php | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index ef965d58..d7721a24 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\linux\LinuxBuilder; use SPC\util\CustomExt; #[CustomExt('imagick')] @@ -14,7 +15,9 @@ class imagick extends Extension { // imagick may call omp_pause_all which requires -lgomp $extra_libs = $this->builder->getOption('extra-libs', ''); - $extra_libs .= ' -lgomp '; + if ($this->builder instanceof LinuxBuilder) { + $extra_libs .= ' -lgomp '; + } $this->builder->setOption('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 bd4d0424..a75969ac 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\builder\linux\library\LinuxLibraryBase; +use SPC\builder\macos\library\MacOSLibraryBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\store\FileSystem; @@ -39,8 +40,12 @@ trait imagemagick } $ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : ''; + + // libxml iconv patch + $required_libs .= $this instanceof MacOSLibraryBase ? (' -liconv') : ''; shell()->cd($this->source_dir) ->exec( + 'PKG_CONFIG="$PKG_CONFIG --static" ' . $ldflags . "LIBS='{$required_libs}' " . './configure ' . From 8ed95602e2c69c22075c4cb78ebb7f851de1b571 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 29 Nov 2023 00:55:04 +0800 Subject: [PATCH 059/415] add 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 fbdbf3bd..b1c96f55 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'tidy,bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; +$extensions = 'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,imap,ldap,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; echo $extensions; From edfd371973be54bf28fdf7b84c1d00c2d75058cd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 29 Nov 2023 01:01:19 +0800 Subject: [PATCH 060/415] bypass error: unknown warning option '-Wno-logical-op' for macOS --- src/SPC/builder/extension/sodium.php | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/SPC/builder/extension/sodium.php diff --git a/src/SPC/builder/extension/sodium.php b/src/SPC/builder/extension/sodium.php new file mode 100644 index 00000000..18059774 --- /dev/null +++ b/src/SPC/builder/extension/sodium.php @@ -0,0 +1,35 @@ +removeLineContainingString(); + } + + private function removeLineContainingString(): bool + { + $path = SOURCE_PATH . '/php-src/ext/sodium/config.m4'; + $search = '-Wno-logical-op'; + if (!file_exists($path)) { + return false; + } + $content = file_get_contents($path); + $lines = preg_split('/\r\n|\n/', $content); + $filteredLines = array_filter($lines, function ($line) use ($search) { + return strpos($line, $search) === false; + }); + $newContent = implode("\n", $filteredLines); + file_put_contents($path, $newContent); + return true; + } +} From 6b23c90bba480d8643f8a2a8bdb101be8bfd68af Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 16:52:53 +0800 Subject: [PATCH 061/415] test build libpq --- src/SPC/builder/unix/library/postgresql.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index b1187a5b..580cbe4e 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -27,13 +27,13 @@ trait postgresql 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; - logger()->info(shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}")[1][0]); + foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; - logger()->info(shell()->execWithResult("pkg-config --cflags-only-I --static {$pkg}")[1][0]); - logger()->info(shell()->execWithResult("pkg-config --libs-only-L --static {$pkg}")[1][0]); - logger()->info(shell()->execWithResult("pkg-config --libs-only-l --static {$pkg}")[1][0]); + logger()->debug(shell()->execWithResult("pkg-config --cflags-only-I --static {$pkg}")[1][0]); + logger()->debug(shell()->execWithResult("pkg-config --libs-only-L --static {$pkg}")[1][0]); + logger()->debug(shell()->execWithResult("pkg-config --libs-only-l --static {$pkg}")[1][0]); } } @@ -101,6 +101,8 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); - logger()->info(shell()->execWithResult('pkg-config --cflags-only-I --static libpq')[1][0]); + logger()->debug(shell()->execWithResult('pkg-config --cflags-only-I --static libpq')[1][0]); + logger()->debug(shell()->execWithResult('pkg-config --libs-only-L --static libpq')[1][0]); + logger()->debug(shell()->execWithResult('pkg-config --libs-only-l --static libpq')[1][0]); } } From 82e3a86f17ef1fc50c741a48cacc5daf7bb898c7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 29 Nov 2023 20:31:53 +0800 Subject: [PATCH 062/415] bypass error: swoole curl hook is buggy for php 8.0 --- src/SPC/builder/extension/swoole.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index a9c1199f..3dd570a1 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -17,7 +17,8 @@ class swoole extends Extension $arg .= ' --disable-swoole-pgsql'; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; - $arg .= $this->builder->getExt('curl') ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; + // swoole curl hook is buggy for php 8.0 + $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; return $arg; } } From 266108b25f1f4e26c9ca29485610f23389ea3a80 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 22:06:30 +0800 Subject: [PATCH 063/415] test libpq build config --- src/SPC/builder/unix/library/postgresql.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 580cbe4e..4c50f783 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -31,9 +31,11 @@ trait postgresql foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; - logger()->debug(shell()->execWithResult("pkg-config --cflags-only-I --static {$pkg}")[1][0]); - logger()->debug(shell()->execWithResult("pkg-config --libs-only-L --static {$pkg}")[1][0]); - logger()->debug(shell()->execWithResult("pkg-config --libs-only-l --static {$pkg}")[1][0]); + + $output = shell()->execWithResult("pkg-config --cflags --libs --static {$pkg}")[1][0]; + if (!empty($output[1][0])) { + logger()->info($output[1][0]); + } } } @@ -100,9 +102,5 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so.*") ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); - - logger()->debug(shell()->execWithResult('pkg-config --cflags-only-I --static libpq')[1][0]); - logger()->debug(shell()->execWithResult('pkg-config --libs-only-L --static libpq')[1][0]); - logger()->debug(shell()->execWithResult('pkg-config --libs-only-l --static libpq')[1][0]); } } From 7c866cb0e3f47ff7cc02d8afbffd6e9e242e13aa Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 22:19:20 +0800 Subject: [PATCH 064/415] swoole enable pgsql --- src/SPC/builder/extension/swoole.php | 19 +++++-- src/SPC/builder/linux/LinuxBuilder.php | 59 ++++++++++++++++----- src/SPC/builder/unix/library/postgresql.php | 1 - 3 files changed, 62 insertions(+), 17 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 3dd570a1..b98e74f8 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -13,12 +13,23 @@ class swoole extends Extension public function getUnixConfigureArg(): string { $arg = '--enable-swoole'; - // pgsql hook is buggy for static php - $arg .= ' --disable-swoole-pgsql'; + + $options = ''; + if ($this->builder->getLib('postgresql')) { + if (!$this->builder->getExt('pdo_pgsql')) { + $options .= '--enable-swoole-pgsql'; + } + } else { + $options .= '--disable-swoole-pgsql'; + } + $arg .= $options; $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; - $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; + $arg .= $this->builder->getLib( + 'brotli' + ) ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; // swoole curl hook is buggy for php 8.0 - $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; + $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID( + ) >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; return $arg; } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index da7f793d..758a561d 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -46,15 +46,23 @@ class LinuxBuilder extends BuilderBase f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}"); f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}"); f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); - f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + f_putenv( + "PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv( + 'PATH' + ) + ); // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) $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"); // check musl-cross make installed if we use musl-cross-make - if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { - throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists( + "/usr/local/musl/bin/{$arch}-linux-musl-gcc" + )) { + throw new WrongUsageException( + 'musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)' + ); } } @@ -72,7 +80,10 @@ class LinuxBuilder extends BuilderBase // cflags $this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch')); $this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch')); - $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC')); + $this->tune_c_flags = SystemUtil::checkCCFlags( + SystemUtil::getTuneCFlags($this->getOption('arch')), + getenv('CC') + ); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile( 'Linux', @@ -133,7 +144,10 @@ class LinuxBuilder extends BuilderBase if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { - $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode( + ' ', + array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles())) + ); } // add libstdc++, some extensions or libraries need it $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : ''); @@ -212,7 +226,11 @@ class LinuxBuilder extends BuilderBase if ($enableEmbed) { logger()->info('building embed'); if ($enableMicro) { - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/Makefile', + 'OVERALL_TARGET =', + 'OVERALL_TARGET = libphp.la' + ); } $this->buildEmbed(); } @@ -259,9 +277,11 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchMicro(['phar']); } - $vars = SystemUtil::makeEnvVarString($this->getBuildVars([ - 'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '', - ])); + $vars = SystemUtil::makeEnvVarString( + $this->getBuildVars([ + 'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '', + ]) + ); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} micro"); @@ -322,10 +342,25 @@ class LinuxBuilder extends BuilderBase $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; $ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : ''; - return [ - 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags, + + $export_variables = []; + if ($this->getLib('postgresql') && $this->getExt('swoole')) { + $output = shell()->execWithResult('pkg-config --cflags --static libpq'); + if (!empty($output[1][0])) { + $export_variables['LIBPQ_CFLAGS'] = $output[1][0]; + } + $output = shell()->execWithResult('pkg-config --libs --static libpq'); + if (!empty($output[1][0])) { + $export_variables['LIBPQ_LIBS'] = $output[1][0]; + } + } + return array_merge($export_variables, [ + 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode( + ' ', + array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags) + ) . $cflags, 'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs, 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags, - ]; + ]); } } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 4c50f783..0e52224b 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -31,7 +31,6 @@ trait postgresql foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; - $output = shell()->execWithResult("pkg-config --cflags --libs --static {$pkg}")[1][0]; if (!empty($output[1][0])) { logger()->info($output[1][0]); From 7ee431725cc652d716ffa8e1d65cf70351dbdede Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 22:22:36 +0800 Subject: [PATCH 065/415] test swoole enable pgsql --- src/SPC/builder/extension/swoole.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index b98e74f8..eaa7e783 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -12,24 +12,24 @@ class swoole extends Extension { public function getUnixConfigureArg(): string { - $arg = '--enable-swoole'; + $arg = ' --enable-swoole '; $options = ''; if ($this->builder->getLib('postgresql')) { if (!$this->builder->getExt('pdo_pgsql')) { - $options .= '--enable-swoole-pgsql'; + $options .= ' --enable-swoole-pgsql '; } } else { - $options .= '--disable-swoole-pgsql'; + $options .= ' --disable-swoole-pgsql '; } $arg .= $options; - $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; + $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl ' : ' --disable-openssl --without-openssl '; $arg .= $this->builder->getLib( 'brotli' - ) ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; + ) ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli '; // swoole curl hook is buggy for php 8.0 $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID( - ) >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; + ) >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl '; return $arg; } } From 930849758c74fb7e57c851bbf2eb133275cb91f4 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 22:28:20 +0800 Subject: [PATCH 066/415] swoole.php and LinuxBuilder.php revert --- src/SPC/builder/extension/swoole.php | 23 +++------- src/SPC/builder/linux/LinuxBuilder.php | 59 ++++++-------------------- 2 files changed, 18 insertions(+), 64 deletions(-) diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index eaa7e783..3dd570a1 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -12,24 +12,13 @@ class swoole extends Extension { public function getUnixConfigureArg(): string { - $arg = ' --enable-swoole '; - - $options = ''; - if ($this->builder->getLib('postgresql')) { - if (!$this->builder->getExt('pdo_pgsql')) { - $options .= ' --enable-swoole-pgsql '; - } - } else { - $options .= ' --disable-swoole-pgsql '; - } - $arg .= $options; - $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl ' : ' --disable-openssl --without-openssl '; - $arg .= $this->builder->getLib( - 'brotli' - ) ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli '; + $arg = '--enable-swoole'; + // pgsql hook is buggy for static php + $arg .= ' --disable-swoole-pgsql'; + $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; + $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; // swoole curl hook is buggy for php 8.0 - $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID( - ) >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl '; + $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; return $arg; } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 758a561d..da7f793d 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -46,23 +46,15 @@ class LinuxBuilder extends BuilderBase f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}"); f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}"); f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); - f_putenv( - "PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv( - 'PATH' - ) - ); + f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) $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"); // check musl-cross make installed if we use musl-cross-make - if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists( - "/usr/local/musl/bin/{$arch}-linux-musl-gcc" - )) { - throw new WrongUsageException( - 'musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)' - ); + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { + throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); } } @@ -80,10 +72,7 @@ class LinuxBuilder extends BuilderBase // cflags $this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch')); $this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch')); - $this->tune_c_flags = SystemUtil::checkCCFlags( - SystemUtil::getTuneCFlags($this->getOption('arch')), - getenv('CC') - ); + $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC')); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile( 'Linux', @@ -144,10 +133,7 @@ class LinuxBuilder extends BuilderBase if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { - $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode( - ' ', - array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles())) - ); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", array_filter($this->getAllStaticLibFiles()))); } // add libstdc++, some extensions or libraries need it $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : ''); @@ -226,11 +212,7 @@ class LinuxBuilder extends BuilderBase if ($enableEmbed) { logger()->info('building embed'); if ($enableMicro) { - FileSystem::replaceFileStr( - SOURCE_PATH . '/php-src/Makefile', - 'OVERALL_TARGET =', - 'OVERALL_TARGET = libphp.la' - ); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); } $this->buildEmbed(); } @@ -277,11 +259,9 @@ class LinuxBuilder extends BuilderBase SourcePatcher::patchMicro(['phar']); } - $vars = SystemUtil::makeEnvVarString( - $this->getBuildVars([ - 'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '', - ]) - ); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars([ + 'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '', + ])); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} micro"); @@ -342,25 +322,10 @@ class LinuxBuilder extends BuilderBase $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; $ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : ''; - - $export_variables = []; - if ($this->getLib('postgresql') && $this->getExt('swoole')) { - $output = shell()->execWithResult('pkg-config --cflags --static libpq'); - if (!empty($output[1][0])) { - $export_variables['LIBPQ_CFLAGS'] = $output[1][0]; - } - $output = shell()->execWithResult('pkg-config --libs --static libpq'); - if (!empty($output[1][0])) { - $export_variables['LIBPQ_LIBS'] = $output[1][0]; - } - } - return array_merge($export_variables, [ - 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode( - ' ', - array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags) - ) . $cflags, + return [ + 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags, 'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs, 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags, - ]); + ]; } } From b1958ea0c4a9e8ec1f9ca50b3f2e2216280b58f7 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 12:37:20 +0800 Subject: [PATCH 067/415] test libpq build --- src/SPC/builder/unix/library/postgresql.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 0e52224b..6b7478ef 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -28,13 +28,14 @@ trait postgresql 'icu' => 'icu-i18n', ]; + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); + foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; - $output = shell()->execWithResult("pkg-config --cflags --libs --static {$pkg}")[1][0]; - if (!empty($output[1][0])) { - logger()->info($output[1][0]); - } + $output = shell()->execWithResult("pkg-config --static {$pkg}"); + logger()->info($output[1][0]); } } From b1bf8bb848c3bb2be1fd8418d9fe1a6bfd1148ff Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 12:53:19 +0800 Subject: [PATCH 068/415] test libpq build --- 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 6b7478ef..0eb46643 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -35,7 +35,7 @@ trait postgresql if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; $output = shell()->execWithResult("pkg-config --static {$pkg}"); - logger()->info($output[1][0]); + logger()->info(var_export($output[1], true)); } } From e603e441e7248ddec80e157b16ce3e627e858a96 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 12:56:47 +0800 Subject: [PATCH 069/415] test libpq build --- src/SPC/builder/unix/library/postgresql.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 0eb46643..03d8eb5f 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -23,7 +23,7 @@ trait postgresql $packages = 'openssl zlib readline libxml-2.0 zlib'; $optional_packages = [ 'zstd' => 'libzstd', - 'ldap' => 'ldap', + // 'ldap' => 'ldap', 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; @@ -78,7 +78,7 @@ trait postgresql '--with-readline ' . '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . + ($this->builder->getLib('ldap') && 0 ? '--with-ldap ' : '--without-ldap ') . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . From 3185d98b1a9ba383cf97b7e8b0e6f6656dd683ae Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 13:00:04 +0800 Subject: [PATCH 070/415] test libpq build --- 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 03d8eb5f..bd3530de 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -78,7 +78,7 @@ trait postgresql '--with-readline ' . '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - ($this->builder->getLib('ldap') && 0 ? '--with-ldap ' : '--without-ldap ') . + (($this->builder->getLib('ldap') && 0) ? '--with-ldap ' : '--without-ldap ') . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . From 433c91b68d429afea805b73af71c337b9d3922f7 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 13:01:15 +0800 Subject: [PATCH 071/415] test libpq build --- src/SPC/builder/unix/library/postgresql.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index bd3530de..393c85a9 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -78,7 +78,7 @@ trait postgresql '--with-readline ' . '--with-libxml ' . ($this->builder->getLib('icu') ? '--with-icu ' : '--without-icu ') . - (($this->builder->getLib('ldap') && 0) ? '--with-ldap ' : '--without-ldap ') . + '--without-ldap ' . ($this->builder->getLib('libxslt') ? '--with-libxslt ' : '--without-libxslt ') . ($this->builder->getLib('zstd') ? '--with-zstd ' : '--without-zstd ') . '--without-lz4 ' . @@ -88,6 +88,7 @@ trait postgresql '--without-bonjour ' . '--without-tcl ' ); + // ($this->builder->getLib('ldap') ? '--with-ldap ' : '--without-ldap ') . // build shell()->cd($this->source_dir . '/build') From d3e4470e1fc01b1b1b422e46df57bb49c3135a2d Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 13:06:36 +0800 Subject: [PATCH 072/415] test libpq build --- src/SPC/builder/unix/library/ldap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 9b4080df..a557eb8e 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -15,6 +15,8 @@ trait ldap $alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : ''; // libsodium support $alt .= $this->builder->getLib('libsodium') ? '--with-argon2=libsodium ' : ''; + f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); + f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); shell()->cd($this->source_dir) ->exec( $this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) . From 98b7164de3ac393a0f4b553895e87bdc659be298 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 13:09:02 +0800 Subject: [PATCH 073/415] test libpq build --- config/lib.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/lib.json b/config/lib.json index 7abff12c..63ca1967 100644 --- a/config/lib.json +++ b/config/lib.json @@ -156,8 +156,10 @@ "liblber.a", "libldap.a" ], + "lib-depends": [ + "openssl" + ], "lib-suggests": [ - "openssl", "gmp", "libsodium" ] From 00689b951b03e64f9785802e09e660e95d46c20a Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 14:19:20 +0800 Subject: [PATCH 074/415] update ldap depends --- config/lib.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/lib.json b/config/lib.json index 63ca1967..318afe16 100644 --- a/config/lib.json +++ b/config/lib.json @@ -157,9 +157,8 @@ "libldap.a" ], "lib-depends": [ - "openssl" - ], - "lib-suggests": [ + "openssl", + "zlib", "gmp", "libsodium" ] From bba2d0dbf736b7a7462f05ca7ce73e085de93b55 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 30 Nov 2023 21:29:57 +0800 Subject: [PATCH 075/415] test remove imap ldap extension --- 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 b1c96f55..07fedb5f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,imap,ldap,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; +$extensions = 'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; echo $extensions; From c1758bd75466a36a0c86d8efc72f4002003e5787 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 7 Dec 2023 16:01:12 +0800 Subject: [PATCH 076/415] Update README.md --- README.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index cd714f70..1edbc56a 100755 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ You can also use the micro binary file to combine php binary and php source code [![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() -## Docs +## Documentation The current README contains basic usage. For all the features of static-php-cli, see . @@ -135,7 +135,7 @@ Basic usage for building php and micro with some extensions: > If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands. ```bash -# Check system tool dependencies, fix them automatically +# Check system tool dependencies, fix them if possible ./bin/spc doctor # fetch all libraries ./bin/spc download --all @@ -167,7 +167,7 @@ If anything goes wrong, use `--debug` option to display full terminal output: ./bin/spc fetch --all --debug ``` -In addition, we build NTS by default. If you are going to build ZTS version, just add `--enable-zts` option. +In addition, we build NTS (non-thread-safe) by default. If you are going to build ZTS version, just add `--enable-zts` option. ```bash ./bin/spc build openssl,pcntl --build-all --enable-zts @@ -236,7 +236,7 @@ When using the parameter `--build-all` or `--build-fpm`, the final compilation result will output a file named `./php-fpm`, This file will be located in the path `buildroot/bin/`, simply copy it out for use. -In normal Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm. +In common Linux distributions and macOS systems, the package manager will automatically generate a default fpm configuration file after installing php-fpm. Because php-fpm must specify a configuration file before running, the php-fpm compiled by this project will not have any configuration files, so you need to write `php-fpm.conf` and `pool.conf` configuration files yourself. Specifying `php-fpm.conf` can use the command parameter `-y`, for example: `./php-fpm -y php-fpm.conf`. @@ -262,10 +262,6 @@ If you want to contribute documentation, please go to [static-php/static-php-cli Now there is a [static-php](https://github.com/static-php) organization, which is used to store the repo related to the project. -Part of the English document is written by me, and part is translated by Google, -and there may be inaccurate descriptions, strange or offensive expressions. -If you are a native English speaker, some corrections to the documentation are welcome. - ## Sponsor this project You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). @@ -288,8 +284,3 @@ and they all have their own open source licenses. Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation, and comply with the corresponding project's LICENSE. -## Advanced - -The refactoring branch of this project is written modularly. -If you are interested in this project and want to join the development, -you can refer to the [Contribution Guide](https://static-php.dev) of the documentation to contribute code or documentation. From c7e929490828b204584af3271423600397e09e67 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Dec 2023 18:27:19 +0800 Subject: [PATCH 077/415] fix libtool missing bug for freetype --- bin/spc-alpine-docker | 1 + src/SPC/doctor/item/LinuxToolCheckList.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/spc-alpine-docker b/bin/spc-alpine-docker index e807a2df..87e52968 100755 --- a/bin/spc-alpine-docker +++ b/bin/spc-alpine-docker @@ -73,6 +73,7 @@ RUN apk update; \ git \ jq \ libgcc \ + libtool \ libstdc++ \ linux-headers \ m4 \ diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 33aa0639..01df03d6 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -21,6 +21,7 @@ class LinuxToolCheckList 'tar', 'unzip', 'gzip', 'bzip2', 'cmake', 'gcc', 'g++', 'patch', 'binutils-gold', + 'libtoolize', ]; public const TOOLS_DEBIAN = [ @@ -102,7 +103,8 @@ class LinuxToolCheckList try { $is_debian = in_array($distro['dist'], ['debian', 'ubuntu']); $to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing; - $to_install = $is_debian ? str_replace('libtoolize', 'libtool', $to_install) : $to_install; + // debian, alpine libtool -> libtoolize + $to_install = str_replace('libtoolize', 'libtool', $to_install); shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install)); } catch (RuntimeException) { return false; From f0319de93e7c7720c1dae3f5e03d64ab5a44e328 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Dec 2023 18:27:52 +0800 Subject: [PATCH 078/415] opcache limit php version --- config/ext.json | 3 ++- src/SPC/builder/extension/opcache.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index e38bacb6..2df51239 100644 --- a/config/ext.json +++ b/config/ext.json @@ -228,7 +228,8 @@ ] }, "opcache": { - "type": "builtin" + "type": "builtin", + "arg-type": "custom" }, "openssl": { "type": "builtin", diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index f592303a..82efc853 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -5,11 +5,25 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\util\CustomExt; #[CustomExt('opcache')] class opcache extends Extension { + /** + * @throws WrongUsageException + * @throws RuntimeException + */ + public function getUnixConfigureArg(): string + { + if ($this->builder->getPHPVersionID() < 80000) { + throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !'); + } + return '--enable-opcache'; + } + public function getDistName(): string { return 'Zend Opcache'; From 42f448cf1799d064894b36d1dbcb6f28d94a3daf Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Dec 2023 18:28:15 +0800 Subject: [PATCH 079/415] reformat build log --- src/SPC/command/BuildCliCommand.php | 77 +++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 72235847..5bd0bba3 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use ZM\Logger\ConsoleColor; -#[AsCommand('build', 'build CLI binary')] +#[AsCommand('build', 'build PHP')] class BuildCliCommand extends BuildCommand { public function configure(): void @@ -33,6 +33,8 @@ class BuildCliCommand extends BuildCommand $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); $this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli'); + $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); + $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); } public function handle(): int @@ -42,12 +44,9 @@ class BuildCliCommand extends BuildCommand // transform string to array $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); - $rule = BUILD_TARGET_NONE; - $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') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); - $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); + // parse rule with options + $rule = $this->parseRules(); + if ($rule === BUILD_TARGET_NONE) { $this->output->writeln('Please add at least one build target!'); $this->output->writeln("\t--build-cli\tBuild php-cli SAPI"); @@ -62,16 +61,27 @@ class BuildCliCommand extends BuildCommand $builder = BuilderProvider::makeBuilderByInput($this->input); // calculate dependencies [$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions, $libraries); - /* @phpstan-ignore-next-line */ - logger()->info('Build target: ' . ConsoleColor::yellow($builder->getBuildTypeName($rule))); - /* @phpstan-ignore-next-line */ - logger()->info('Enabled extensions: ' . ConsoleColor::yellow(implode(', ', $extensions))); - /* @phpstan-ignore-next-line */ - logger()->info('Required libraries: ' . ConsoleColor::yellow(implode(', ', $libraries))); - if (!empty($not_included)) { - logger()->warning('some extensions will be enabled due to dependencies: ' . implode(',', $not_included)); + + // print info + $indent_texts = [ + 'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')', + 'Build SAPI' => $builder->getBuildTypeName($rule), + 'Extensions (' . count($extensions) . ')' => implode(', ', $extensions), + 'Libraries (' . count($libraries) . ')' => implode(', ', $libraries), + 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', + 'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no', + ]; + if (!empty($this->input->getOption('with-hardcoded-ini'))) { + $indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini'); } + $this->printFormatInfo($indent_texts); + + if (!empty($not_included)) { + logger()->warning('Some extensions will be enabled due to dependencies: ' . implode(',', $not_included)); + } + logger()->info('Build will start after 2s ...'); sleep(2); + if ($this->input->getOption('with-clean')) { logger()->info('Cleaning source dir...'); FileSystem::removeDir(SOURCE_PATH); @@ -140,4 +150,41 @@ class BuildCliCommand extends BuildCommand return static::FAILURE; } } + + /** + * Parse build options to rule int. + */ + private function parseRules(): int + { + $rule = BUILD_TARGET_NONE; + $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') ? BUILD_TARGET_EMBED : BUILD_TARGET_NONE); + $rule |= ($this->getOption('build-all') ? BUILD_TARGET_ALL : BUILD_TARGET_NONE); + return $rule; + } + + private function printFormatInfo(array $indent_texts): void + { + // calculate space count for every line + $maxlen = 0; + foreach ($indent_texts as $k => $v) { + $maxlen = max(strlen($k), $maxlen); + } + foreach ($indent_texts as $k => $v) { + if (is_string($v)) { + /* @phpstan-ignore-next-line */ + logger()->info($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($v)); + } elseif (is_array($v) && !is_assoc_array($v)) { + $first = array_shift($v); + /* @phpstan-ignore-next-line */ + logger()->info($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($first)); + foreach ($v as $vs) { + /* @phpstan-ignore-next-line */ + logger()->info(str_pad('', $maxlen + 2) . ConsoleColor::yellow($vs)); + } + } + } + } } From 3e9ddc8e0122822c5d7ed137ed2e46c994fcfb61 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Dec 2023 20:43:52 +0800 Subject: [PATCH 080/415] update to rc9 --- 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 2de132e0..73b354be 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0.0-rc8'; + public const VERSION = '2.0.0-rc9'; public function __construct() { From 0cfac49560734c4f6e92fa3ee89b9c808c011cef Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Dec 2023 00:34:22 +0800 Subject: [PATCH 081/415] adjust package order --- 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 393c85a9..2448f656 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -20,7 +20,7 @@ trait postgresql { $builddir = BUILD_ROOT_PATH; $envs = ''; - $packages = 'openssl zlib readline libxml-2.0 zlib'; + $packages = 'zlib openssl readline libxml-2.0'; $optional_packages = [ 'zstd' => 'libzstd', // 'ldap' => 'ldap', From d8ce5f69f41b2357c92a6a5a7e36548372ca4ad1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Dec 2023 01:31:01 +0800 Subject: [PATCH 082/415] fix mongodb support for Linux (mac still broken) --- src/SPC/builder/BuilderBase.php | 13 +++++++++++++ src/SPC/builder/extension/mongodb.php | 9 +++++++++ src/globals/test-extensions.php | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index d214b859..72db5961 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -259,6 +259,19 @@ abstract class BuilderBase throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } + public function getPHPVersion(): string + { + if (!file_exists(SOURCE_PATH . '/php-src/main/php_version.h')) { + throw new WrongUsageException('PHP source files are not available, you need to download them first'); + } + $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); + if (preg_match('/PHP_VERSION "(.*)"/', $file, $match) !== 0) { + return $match[1]; + } + + throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); + } + /** * Get build type name string to display. * diff --git a/src/SPC/builder/extension/mongodb.php b/src/SPC/builder/extension/mongodb.php index 2096de05..e6f12d54 100644 --- a/src/SPC/builder/extension/mongodb.php +++ b/src/SPC/builder/extension/mongodb.php @@ -5,11 +5,20 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('mongodb')] class mongodb extends Extension { + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'if test -z "$PHP_CONFIG"; then', 'if false; then'); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION=`${PHP_CONFIG} --version`', 'PHP_MONGODB_PHP_VERSION=' . $this->builder->getPHPVersion()); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION_ID=`${PHP_CONFIG} --vernum`', 'PHP_MONGODB_PHP_VERSION_ID=' . $this->builder->getPHPVersionID()); + return true; + } + public function getUnixConfigureArg(): string { $arg = ' --enable-mongodb '; diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 07fedb5f..a80c9a78 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,calendar,ctype,curl,dba,dom,exif,filter,fileinfo,gd,iconv,intl,mbstring,mbregex,mysqli,mysqlnd,openssl,opcache,pcntl,pdo,pdo_mysql,pdo_sqlite,pdo_pgsql,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,bz2,event,gmp,imagick,protobuf,shmop,snappy,soap,swoole,sysvmsg,sysvsem,sysvshm,tidy,zstd'; +$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; echo $extensions; From 9266a4c504701de4a13e70fefe2e4753f8f65d0f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Dec 2023 23:36:12 +0800 Subject: [PATCH 083/415] remove ldap 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 a80c9a78..73b57056 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; echo $extensions; From ed8b60676152658d0ed7af833b7080e0db3ddc72 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 16 Dec 2023 15:07:04 +0800 Subject: [PATCH 084/415] add libtool for macos doctor --- src/SPC/doctor/item/MacOSToolCheckList.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index df1e6ed4..9f43e8fb 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -25,6 +25,7 @@ class MacOSToolCheckList 'autoconf', 'automake', 'tar', + 'libtool', 'unzip', 'xz', 'gzip', From ea64e50ce5762077dc990be1d08504c3c59d5add Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 16 Dec 2023 18:49:38 +0800 Subject: [PATCH 085/415] fix SourcePatcher::patchFile not working with spc binary --- src/SPC/store/SourcePatcher.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index b0edc303..426f978a 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -134,6 +134,12 @@ class SourcePatcher $patch_file = ROOT_DIR . "/src/globals/patch/{$patch_name}"; $patch_str = str_replace('/', DIRECTORY_SEPARATOR, $patch_file); + // copy patch from phar + if (\Phar::running() !== '') { + file_put_contents(SOURCE_PATH . '/' . $patch_name, file_get_contents($patch_file)); + $patch_str = str_replace('/', DIRECTORY_SEPARATOR, SOURCE_PATH . '/' . $patch_name); + } + f_passthru( 'cd ' . $cwd . ' && ' . (PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patch_str . ' | patch -p1 ' . ($reverse ? '-R' : '') From 1f7bdb94fb9f0cff322936a69d4047ffd62a4270 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 17 Dec 2023 01:02:02 +0800 Subject: [PATCH 086/415] update README --- README-zh.md | 5 +++-- README.md | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README-zh.md b/README-zh.md index e8aac2c3..3e31ae79 100755 --- a/README-zh.md +++ b/README-zh.md @@ -28,9 +28,10 @@ Build single static PHP binary, with PHP project together, with popular extensio ## 自托管直接下载 -如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载:[进入](https://dl.static-php.dev/static-php-cli/common/) +如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载。 -> 自托管的服务器默认包含的扩展有:`bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` +- [扩展组合 - common](https://dl.static-php.dev/static-php-cli/common/):common 组合包含了约 [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) 个常用扩展,体积为 22MB 左右。 +- [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。 ## 使用 static-php-cli 构建 PHP diff --git a/README.md b/README.md index 1edbc56a..61dd9f2f 100755 --- a/README.md +++ b/README.md @@ -31,9 +31,13 @@ see . ## Direct Download -If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from [self-hosted server](https://dl.static-php.dev/static-php-cli/common/). +If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from self-hosted server. -> self-hosted server contains extensions: `bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip` +Below are several precompiled static-php binaries with different extension combinations, +which can be downloaded directly according to your needs. + +- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): The common combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. +- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): The bulk package contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. ## Use static-php-cli to build PHP From bc15de0dfb925249b95f725769cfea7e99b1838d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 17 Dec 2023 01:03:32 +0800 Subject: [PATCH 087/415] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 61dd9f2f..40c28991 100755 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ If you don't want to compile yourself, you can download example pre-compiled art Below are several precompiled static-php binaries with different extension combinations, which can be downloaded directly according to your needs. -- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): The common combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. -- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): The bulk package contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. +- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. +- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` combination contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. ## Use static-php-cli to build PHP From a5fa46b82dfc92d48a2b21405ca4b4eb34ba9f67 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 17 Dec 2023 01:35:28 +0800 Subject: [PATCH 088/415] update README --- README-zh.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README-zh.md b/README-zh.md index 3e31ae79..da571330 100755 --- a/README-zh.md +++ b/README-zh.md @@ -32,6 +32,7 @@ Build single static PHP binary, with PHP project together, with popular extensio - [扩展组合 - common](https://dl.static-php.dev/static-php-cli/common/):common 组合包含了约 [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) 个常用扩展,体积为 22MB 左右。 - [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。 +- [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/):minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 6MB 左右。 ## 使用 static-php-cli 构建 PHP diff --git a/README.md b/README.md index 40c28991..cc626e40 100755 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ which can be downloaded directly according to your needs. - [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. - [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` combination contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. +- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` combination contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size. ## Use static-php-cli to build PHP From d72ee53cb42d720a6a96695eebfa13da48d02168 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 17 Dec 2023 02:02:00 +0800 Subject: [PATCH 089/415] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc626e40..0926ea29 100755 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ cat buildroot/bin/micro.sfx my-app.phar > my-app && chmod +x my-app bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=system" --output my-app-2 ``` -> In some cases, PHAR files may not run in a micro environment. +> In some cases, PHAR files may not run in a micro environment. Overall, micro is not production ready. ### Use fpm From 33e1759caa0b8192eeaf8f7baa0b150e76cdb5de Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 17 Dec 2023 12:16:54 +0800 Subject: [PATCH 090/415] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0926ea29..faedaf13 100755 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ If you don't want to compile yourself, you can download example pre-compiled art Below are several precompiled static-php binaries with different extension combinations, which can be downloaded directly according to your needs. -- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` combination contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. -- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` combination contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. -- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` combination contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size. +- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. +- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. +- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size. ## Use static-php-cli to build PHP From b961c34d9a8b85e296fff5f8b3ac7c2cfb316940 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 18 Dec 2023 00:14:14 +0800 Subject: [PATCH 091/415] add ldap 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 73b57056..a80c9a78 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; echo $extensions; From 93a55e87d5fe2e6e259b456955a9f498709c6b82 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 19 Dec 2023 19:03:16 +0800 Subject: [PATCH 092/415] temporarily use pkg-config mirror (freedesktop.org down) --- config/source.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index 23b4ab1b..09cd2064 100644 --- a/config/source.json +++ b/config/source.json @@ -385,9 +385,8 @@ } }, "pkg-config": { - "type": "filelist", - "url": "https://pkgconfig.freedesktop.org/releases/", - "regex": "/href=\"(?pkg-config-(?[^\"]+)\\.tar\\.gz)\"/", + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz", "license": { "type": "file", "path": "COPYING" From e0550b4a4520931c2fba3aa7ecefa7173d57fd14 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 19 Dec 2023 19:04:49 +0800 Subject: [PATCH 093/415] add argon2 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 a80c9a78..06eaf68e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,6 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; echo $extensions; From 48551cc602dbda7e5688f1f60882a60896429162 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 19 Dec 2023 19:13:19 +0800 Subject: [PATCH 094/415] add linux support for libargon2 --- src/SPC/builder/linux/library/libargon2.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/SPC/builder/linux/library/libargon2.php diff --git a/src/SPC/builder/linux/library/libargon2.php b/src/SPC/builder/linux/library/libargon2.php new file mode 100644 index 00000000..59e85112 --- /dev/null +++ b/src/SPC/builder/linux/library/libargon2.php @@ -0,0 +1,12 @@ + Date: Tue, 19 Dec 2023 19:31:56 +0800 Subject: [PATCH 095/415] fix linux build (dont know why linux failed) --- src/SPC/builder/linux/library/libargon2.php | 13 +++++++++++++ src/globals/test-extensions.php | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/linux/library/libargon2.php b/src/SPC/builder/linux/library/libargon2.php index 59e85112..ca4a72ac 100644 --- a/src/SPC/builder/linux/library/libargon2.php +++ b/src/SPC/builder/linux/library/libargon2.php @@ -4,9 +4,22 @@ declare(strict_types=1); namespace SPC\builder\linux\library; +use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; + class libargon2 extends LinuxLibraryBase { use \SPC\builder\unix\library\libargon2; public const NAME = 'libargon2'; + + public function patchBeforeBuild(): bool + { + // detect libsodium (The libargon2 conflicts with the libsodium library.) + if ($this->builder->getLib('libsodium') !== null) { + throw new WrongUsageException('libargon2 (required by password-argon2) conflicts with the libsodium library !'); + } + FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib'); + return true; + } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 06eaf68e..fd55f0c4 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,6 +3,10 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; + +if (PHP_OS_FAMILY === 'Darwin') { + $extensions .= ',sodium'; +} echo $extensions; From c4cfc01b88a88585f23358409b78585b162cdbe3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 19 Dec 2023 19:37:19 +0800 Subject: [PATCH 096/415] fix linux build (dont know why linux failed) --- 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 fd55f0c4..6de2bdf8 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,10 +3,10 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; if (PHP_OS_FAMILY === 'Darwin') { - $extensions .= ',sodium'; + $extensions .= ',ldap,sodium'; } echo $extensions; From 248918e4580fd3b52b0a8459daca53b1014f5232 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 19 Dec 2023 20:04:13 +0800 Subject: [PATCH 097/415] remove ldap test for known reason --- 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 6de2bdf8..f047e249 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -6,7 +6,7 @@ declare(strict_types=1); $extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; if (PHP_OS_FAMILY === 'Darwin') { - $extensions .= ',ldap,sodium'; + $extensions .= ',sodium'; } echo $extensions; From 7e5b0d6f436a41ad2f28d13366999d5b57d2304c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 21 Dec 2023 01:43:49 +0800 Subject: [PATCH 098/415] use bulk combination for setup-runtime --- bin/setup-runtime | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/setup-runtime b/bin/setup-runtime index b344bab5..b914c1ba 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -25,7 +25,7 @@ __DIR__=$(cd "$(dirname "$0")" && pwd) __PROJECT__=$(cd "${__DIR__}"/../ && pwd) # set download dir -__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" +__PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" __COMPOSER_URL__="https://getcomposer.org/download/latest-stable/composer.phar" # use china mirror @@ -46,7 +46,7 @@ done case "$mirror" in china) - __PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/common/php-8.2.12-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" + __PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" __COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar" ;; From 2d437952f28d8d64260f57df13dfe213250ffdbf Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 21 Dec 2023 12:54:43 +0800 Subject: [PATCH 099/415] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index faedaf13..a860aeb7 100755 --- a/README.md +++ b/README.md @@ -18,10 +18,9 @@ You can also use the micro binary file to combine php binary and php source code [![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-linux-x86_64.yml?branch=refactor&label=Linux%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/build-macos-x86_64.yml?branch=refactor&label=macOS%20Build&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/build.yml) +[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=refactor&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) -[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() ## Documentation From a39cd9a23890188ecb7b26400e54a8841d0681d3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 21 Dec 2023 12:55:20 +0800 Subject: [PATCH 100/415] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a860aeb7..970be43e 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ You can also use the micro binary file to combine php binary and php source code [![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=refactor&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() From 1e0265e67391d2fe6975f237d53fb36d0a999cf3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 21 Dec 2023 14:02:32 +0800 Subject: [PATCH 101/415] add sqlsrv support --- config/ext.json | 11 +++++++ config/lib.json | 11 +++++++ config/source.json | 18 ++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 1 + src/SPC/builder/linux/library/unixodbc.php | 12 ++++++++ src/SPC/builder/macos/MacOSBuilder.php | 1 + src/SPC/builder/macos/library/unixodbc.php | 12 ++++++++ src/SPC/builder/unix/library/unixodbc.php | 34 ++++++++++++++++++++++ 8 files changed, 100 insertions(+) create mode 100644 src/SPC/builder/linux/library/unixodbc.php create mode 100644 src/SPC/builder/macos/library/unixodbc.php create mode 100644 src/SPC/builder/unix/library/unixodbc.php diff --git a/config/ext.json b/config/ext.json index 8a75b502..26bb9e94 100644 --- a/config/ext.json +++ b/config/ext.json @@ -391,6 +391,17 @@ "sqlite" ] }, + "sqlsrv": { + "type": "external", + "source": "sqlsrv", + "lib-depends": [ + "unixodbc" + ], + "cpp-extension": true, + "ext-depends-linux": [ + "pcntl" + ] + }, "ssh2": { "type": "external", "source": "ext-ssh2", diff --git a/config/lib.json b/config/lib.json index 14d66130..73c5aee2 100644 --- a/config/lib.json +++ b/config/lib.json @@ -496,6 +496,17 @@ "libtidy.a" ] }, + "unixodbc": { + "source": "unixodbc", + "static-libs-unix": [ + "libodbc.a", + "libodbccr.a", + "libodbcinst.a" + ], + "lib-depends": [ + "libiconv" + ] + }, "xz": { "source": "xz", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 09cd2064..d9cd69dd 100644 --- a/config/source.json +++ b/config/source.json @@ -457,6 +457,16 @@ "text": "The author disclaims copyright to this source code. In place of\na legal notice, here is a blessing:\n\n * May you do good and not evil.\n * May you find forgiveness for yourself and forgive others.\n * May you share freely, never taking more than you give." } }, + "sqlsrv": { + "type": "url", + "url": "https://pecl.php.net/get/sqlsrv", + "path": "php-src/ext/sqlsrv", + "filename": "sqlsrv.tgz", + "license": { + "type": "text", + "text": "TODO" + } + }, "swoole": { "type": "ghtar", "path": "php-src/ext/swoole", @@ -486,6 +496,14 @@ "path": "README/LICENSE.md" } }, + "unixodbc": { + "type": "url", + "url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz", + "license": { + "type": "text", + "text": "TODO" + } + }, "xlswriter": { "type": "url", "url": "https://pecl.php.net/get/xlswriter", diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index da7f793d..a757c661 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -144,6 +144,7 @@ class LinuxBuilder extends BuilderBase // prepare build php envs $envs_build_php = SystemUtil::makeEnvVarString([ 'CFLAGS' => $cflags, + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, 'LIBS' => '-ldl -lpthread', ]); diff --git a/src/SPC/builder/linux/library/unixodbc.php b/src/SPC/builder/linux/library/unixodbc.php new file mode 100644 index 00000000..0741d264 --- /dev/null +++ b/src/SPC/builder/linux/library/unixodbc.php @@ -0,0 +1,12 @@ +arch_c_flags} -Werror=unknown-warning-option' " . + "CPPFLAGS='-I" . BUILD_INCLUDE_PATH . "' " . '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . diff --git a/src/SPC/builder/macos/library/unixodbc.php b/src/SPC/builder/macos/library/unixodbc.php new file mode 100644 index 00000000..35ac965e --- /dev/null +++ b/src/SPC/builder/macos/library/unixodbc.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static --disable-shared ' . + '--disable-debug ' . + '--disable-dependency-tracking ' . + '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . + '--enable-gui=no ' . + '--prefix=' + ) + ->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(); + } +} From a632caed54de3e92f97f8496cfd88edb0eda62c8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 21 Dec 2023 14:03:33 +0800 Subject: [PATCH 102/415] add sqlsrv support 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 f047e249..ce05d33e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -3,7 +3,7 @@ declare(strict_types=1); # If you want to test new extensions here, just modify it. -$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +$extensions = 'sqlsrv,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; if (PHP_OS_FAMILY === 'Darwin') { $extensions .= ',sodium'; From 3828ba7c7747014e8d45f89c5448d8a913e90bc0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 21 Dec 2023 15:02:21 +0800 Subject: [PATCH 103/415] fix x86_64 build --- config/source.json | 8 ++++---- src/SPC/builder/unix/library/unixodbc.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/config/source.json b/config/source.json index d9cd69dd..276cb4bd 100644 --- a/config/source.json +++ b/config/source.json @@ -463,8 +463,8 @@ "path": "php-src/ext/sqlsrv", "filename": "sqlsrv.tgz", "license": { - "type": "text", - "text": "TODO" + "type": "file", + "path": "LICENSE" } }, "swoole": { @@ -500,8 +500,8 @@ "type": "url", "url": "https://www.unixodbc.org/unixODBC-2.3.12.tar.gz", "license": { - "type": "text", - "text": "TODO" + "type": "file", + "path": "COPYING" } }, "xlswriter": { diff --git a/src/SPC/builder/unix/library/unixodbc.php b/src/SPC/builder/unix/library/unixodbc.php index 48c403e0..f89eb0a4 100644 --- a/src/SPC/builder/unix/library/unixodbc.php +++ b/src/SPC/builder/unix/library/unixodbc.php @@ -22,6 +22,7 @@ trait unixodbc '--disable-debug ' . '--disable-dependency-tracking ' . '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . + '--with-included-ltdl ' . '--enable-gui=no ' . '--prefix=' ) From 6bcda6a5a040a9781999002639445bacc3f0c9c2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Dec 2023 13:53:22 +0800 Subject: [PATCH 104/415] add lz4, igbinary support for redis --- .github/workflows/tests.yml | 2 +- config/ext.json | 10 +++++++- config/lib.json | 18 +++++-------- config/source.json | 32 +++++++++++++----------- src/SPC/builder/extension/redis.php | 10 ++++---- src/SPC/builder/linux/library/liblz4.php | 12 +++++++++ src/SPC/builder/macos/library/liblz4.php | 12 +++++++++ src/SPC/builder/unix/library/liblz4.php | 26 +++++++++++++++++++ src/globals/test-extensions.php | 3 +++ 9 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 src/SPC/builder/linux/library/liblz4.php create mode 100644 src/SPC/builder/macos/library/liblz4.php create mode 100644 src/SPC/builder/unix/library/liblz4.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b9e64a8..9176fcf0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -143,4 +143,4 @@ jobs: run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" - run: bin/spc build "$(php src/globals/test-extensions.php)" --build-cli --build-micro --build-fpm --debug + run: bin/spc build $(php src/globals/test-extensions.php) --build-cli --build-micro --build-fpm --debug diff --git a/config/ext.json b/config/ext.json index 26bb9e94..1dde5bc6 100644 --- a/config/ext.json +++ b/config/ext.json @@ -150,6 +150,10 @@ "icu" ] }, + "igbinary": { + "type": "external", + "source": "igbinary" + }, "ldap": { "type": "builtin", "arg-type": "with-prefix", @@ -331,7 +335,11 @@ "source": "redis", "arg-type": "custom", "ext-suggests": [ - "session" + "session", + "igbinary" + ], + "lib-suggests": [ + "zstd" ] }, "session": { diff --git a/config/lib.json b/config/lib.json index 73c5aee2..7116a115 100644 --- a/config/lib.json +++ b/config/lib.json @@ -224,12 +224,6 @@ "libturbojpeg.a" ] }, - "libmcrypt": { - "source": "libmcrypt", - "static-libs-unix": [ - "libmcrypt.a" - ] - }, "libmemcached": { "source": "libmemcached", "static-libs-unix": [ @@ -368,12 +362,6 @@ "openssl" ] }, - "mcrypt": { - "source": "mcrypt", - "static-libs-unix": [ - "libmcrypt.a" - ] - }, "ncurses": { "source": "ncurses", "static-libs-unix": [ @@ -507,6 +495,12 @@ "libiconv" ] }, + "liblz4": { + "source": "liblz4", + "static-libs-unix": [ + "liblz4.a" + ] + }, "xz": { "source": "xz", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 276cb4bd..7738d6b4 100644 --- a/config/source.json +++ b/config/source.json @@ -224,12 +224,13 @@ "path": "LICENSE.md" } }, - "libmcrypt": { - "type": "url", - "url": "https://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz", + "liblz4": { + "type": "ghrel", + "repo": "lz4/lz4", + "match": "lz4-.+\\.tar\\.gz", "license": { "type": "file", - "path": "COPYING" + "path": "LICENSE" } }, "libmemcached": { @@ -251,8 +252,9 @@ } }, "libsodium": { - "type": "url", - "url": "https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz", + "type": "ghrel", + "repo": "jedisct1/libsodium", + "match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz", "license": { "type": "file", "path": "LICENSE" @@ -310,14 +312,6 @@ "path": "LICENSE" } }, - "mcrypt": { - "type": "url", - "url": "https://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz", - "license": { - "type": "file", - "path": "COPYING" - } - }, "memcached": { "type": "url", "url": "https://pecl.php.net/get/memcached", @@ -366,6 +360,16 @@ "path": "COPYING" } }, + "igbinary": { + "type": "url", + "url": "https://pecl.php.net/get/igbinary", + "path": "php-src/ext/igbinary", + "filename": "igbinary.tgz", + "license": { + "type": "file", + "path": "COPYING" + } + }, "onig": { "type": "ghrel", "repo": "kkos/oniguruma", diff --git a/src/SPC/builder/extension/redis.php b/src/SPC/builder/extension/redis.php index ffe50d1d..259a22c4 100644 --- a/src/SPC/builder/extension/redis.php +++ b/src/SPC/builder/extension/redis.php @@ -13,14 +13,14 @@ class redis extends Extension public function getUnixConfigureArg(): string { $arg = '--enable-redis'; - if (!$this->builder->getExt('session')) { - $arg .= ' --disable-redis-session'; - } else { - $arg .= ' --enable-redis-session'; - } + $arg .= $this->builder->getExt('session') ? ' --enable-redis-session' : ' --disable-redis-session'; + $arg .= $this->builder->getExt('igbinary') ? ' --enable-redis-igbinary' : ' --disable-redis-igbinary'; if ($this->builder->getLib('zstd')) { $arg .= ' --enable-redis-zstd --with-libzstd="' . BUILD_ROOT_PATH . '"'; } + if ($this->builder->getLib('liblz4')) { + $arg .= ' --enable-redis-lz4 --with-liblz4="' . BUILD_ROOT_PATH . '"'; + } return $arg; } } diff --git a/src/SPC/builder/linux/library/liblz4.php b/src/SPC/builder/linux/library/liblz4.php new file mode 100644 index 00000000..8015b4e3 --- /dev/null +++ b/src/SPC/builder/linux/library/liblz4.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec("make PREFIX='' clean") + ->exec("make -j{$this->builder->concurrency} PREFIX=''") + ->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); + + $this->patchPkgconfPrefix(['liblz4.pc']); + + foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { + if (str_starts_with($filename, 'liblz4') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) { + unlink(BUILD_ROOT_PATH . '/lib/' . $filename); + } + } + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ce05d33e..0ee0701d 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -9,4 +9,7 @@ if (PHP_OS_FAMILY === 'Darwin') { $extensions .= ',sodium'; } +// test redis lz4, igbinary +$extensions .= ',igbinary,zstd --with-libs=liblz4'; + echo $extensions; From d3ff6fd8c0baf7cc2d8ecaca767ae7151ee2061b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Dec 2023 13:54:11 +0800 Subject: [PATCH 105/415] sort config --- config/ext.json | 8 ++++---- config/lib.json | 12 ++++++------ config/source.json | 20 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/config/ext.json b/config/ext.json index 1dde5bc6..2d0bac9f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -122,6 +122,10 @@ "libiconv" ] }, + "igbinary": { + "type": "external", + "source": "igbinary" + }, "imagick": { "type": "external", "source": "ext-imagick", @@ -150,10 +154,6 @@ "icu" ] }, - "igbinary": { - "type": "external", - "source": "igbinary" - }, "ldap": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/lib.json b/config/lib.json index 7116a115..e6d0f729 100644 --- a/config/lib.json +++ b/config/lib.json @@ -224,6 +224,12 @@ "libturbojpeg.a" ] }, + "liblz4": { + "source": "liblz4", + "static-libs-unix": [ + "liblz4.a" + ] + }, "libmemcached": { "source": "libmemcached", "static-libs-unix": [ @@ -495,12 +501,6 @@ "libiconv" ] }, - "liblz4": { - "source": "liblz4", - "static-libs-unix": [ - "liblz4.a" - ] - }, "xz": { "source": "xz", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 7738d6b4..04d29227 100644 --- a/config/source.json +++ b/config/source.json @@ -136,6 +136,16 @@ "path": "LICENSE" } }, + "igbinary": { + "type": "url", + "url": "https://pecl.php.net/get/igbinary", + "path": "php-src/ext/igbinary", + "filename": "igbinary.tgz", + "license": { + "type": "file", + "path": "COPYING" + } + }, "imagemagick": { "type": "ghtar", "repo": "ImageMagick/ImageMagick", @@ -360,16 +370,6 @@ "path": "COPYING" } }, - "igbinary": { - "type": "url", - "url": "https://pecl.php.net/get/igbinary", - "path": "php-src/ext/igbinary", - "filename": "igbinary.tgz", - "license": { - "type": "file", - "path": "COPYING" - } - }, "onig": { "type": "ghrel", "repo": "kkos/oniguruma", From e1e5515694ef3521999cfa4c15eae6b684e4dfa4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Dec 2023 14:48:59 +0800 Subject: [PATCH 106/415] fix tests --- .github/workflows/tests.yml | 4 ++-- src/globals/test-extensions.php | 28 +++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9176fcf0..2db76bc4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -140,7 +140,7 @@ jobs: run: bin/spc doctor --auto-fix - name: "Run Build Tests (download)" - run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php)" --with-php=${{ matrix.php }} --debug + run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" - run: bin/spc build $(php src/globals/test-extensions.php) --build-cli --build-micro --build-fpm --debug + run: bin/spc build $(php src/globals/test-extensions.php cmd) --build-cli --build-micro --build-fpm --debug diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 0ee0701d..505eabba 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -2,14 +2,24 @@ declare(strict_types=1); -# If you want to test new extensions here, just modify it. -$extensions = 'sqlsrv,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib'; +# Normal test, contains `common` extension. +$extensions = 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; -if (PHP_OS_FAMILY === 'Darwin') { - $extensions .= ',sodium'; +# Normal test, contains gd extra libraries. +$additional_libs = 'libwebp,libavif,libjpeg,freetype'; + +# If you want to test additional extensions, add them below. (comma start) +$extensions .= ',igbinary'; + +# If you want to test additional features for extensions, add libs below. (comma start like extensions) +$additional_libs .= ',liblz4'; + +if (!isset($argv[1])) { + exit("Please use 'extensions', 'cmd' or 'libs' as output type"); } - -// test redis lz4, igbinary -$extensions .= ',igbinary,zstd --with-libs=liblz4'; - -echo $extensions; +echo match ($argv[1]) { + 'extensions' => $extensions, + 'libs' => $additional_libs, + 'cmd' => $extensions . ' --with-libs=' . $additional_libs, + default => '', +}; From 584f96484c282c22c809115921d68f05c10c475b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 23 Dec 2023 14:53:39 +0800 Subject: [PATCH 107/415] add liblz4 suggest --- config/ext.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index 2d0bac9f..8bb79743 100644 --- a/config/ext.json +++ b/config/ext.json @@ -339,7 +339,8 @@ "igbinary" ], "lib-suggests": [ - "zstd" + "zstd", + "liblz4" ] }, "session": { From 6b8df9728249fe1b25d2139bf8d9e149277b074e Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 23 Dec 2023 16:23:37 +0800 Subject: [PATCH 108/415] Add uv/libuv support (#296) * add uv/libuv support * sort config --- config/ext.json | 8 +++++++ config/lib.json | 6 +++++ config/source.json | 24 ++++++++++++++++++++ src/SPC/builder/linux/library/libuv.php | 12 ++++++++++ src/SPC/builder/macos/library/libuv.php | 12 ++++++++++ src/SPC/builder/unix/library/libuv.php | 29 +++++++++++++++++++++++++ src/globals/test-extensions.php | 4 ++-- 7 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/linux/library/libuv.php create mode 100644 src/SPC/builder/macos/library/libuv.php create mode 100644 src/SPC/builder/unix/library/libuv.php diff --git a/config/ext.json b/config/ext.json index 8bb79743..b36d4204 100644 --- a/config/ext.json +++ b/config/ext.json @@ -471,6 +471,14 @@ "tokenizer": { "type": "builtin" }, + "uv": { + "type": "external", + "source": "ext-uv", + "arg-type": "with-prefix", + "lib-depends": [ + "libuv" + ] + }, "xlswriter": { "type": "external", "source": "xlswriter", diff --git a/config/lib.json b/config/lib.json index e6d0f729..45329c04 100644 --- a/config/lib.json +++ b/config/lib.json @@ -284,6 +284,12 @@ "zlib" ] }, + "libuv": { + "source": "libuv", + "static-libs-unix": [ + "libuv.a" + ] + }, "libwebp": { "source": "libwebp", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 04d29227..56435a0a 100644 --- a/config/source.json +++ b/config/source.json @@ -100,6 +100,16 @@ "path": "LICENSE" } }, + "ext-uv": { + "type": "url", + "url": "https://pecl.php.net/get/uv", + "path": "php-src/ext/uv", + "filename": "uv.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-zstd": { "type": "git", "path": "php-src/ext/zstd", @@ -279,6 +289,20 @@ "path": "COPYING" } }, + "libuv": { + "type": "ghtar", + "repo": "libuv/libuv", + "license": [ + { + "type": "file", + "path": "LICENSE" + }, + { + "type": "file", + "path": "LICENSE-extra" + } + ] + }, "libwebp": { "type": "url", "url": "https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz", diff --git a/src/SPC/builder/linux/library/libuv.php b/src/SPC/builder/linux/library/libuv.php new file mode 100644 index 00000000..406bd205 --- /dev/null +++ b/src/SPC/builder/linux/library/libuv.php @@ -0,0 +1,12 @@ +source_dir . '/build'); + // Start build + shell()->cd($this->source_dir . '/build') + ->exec("cmake {$this->builder->makeCmakeArgs()} -DLIBUV_BUILD_SHARED=OFF ..") + ->exec("cmake --build . -j {$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + // patch pkgconfig + $this->patchPkgconfPrefix(['libuv-static.pc']); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 505eabba..3af820f7 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -9,10 +9,10 @@ $extensions = 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gm $additional_libs = 'libwebp,libavif,libjpeg,freetype'; # If you want to test additional extensions, add them below. (comma start) -$extensions .= ',igbinary'; +$extensions .= ',uv'; # If you want to test additional features for extensions, add libs below. (comma start like extensions) -$additional_libs .= ',liblz4'; +$additional_libs .= ''; if (!isset($argv[1])) { exit("Please use 'extensions', 'cmd' or 'libs' as output type"); From db7532cad3807d907f9fcc8f9d8086f4913af725 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 Dec 2023 14:43:47 +0800 Subject: [PATCH 109/415] add composer library mode --- bin/spc | 8 +++++++- src/globals/defines.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/spc b/bin/spc index 58749f61..a8571b1b 100755 --- a/bin/spc +++ b/bin/spc @@ -4,7 +4,13 @@ use SPC\ConsoleApplication; use SPC\exception\ExceptionHandler; -require_once __DIR__ . '/../vendor/autoload.php'; +if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) { + // Current: ./bin (git/project mode) + require_once dirname(__DIR__) . '/vendor/autoload.php'; +} else { + // Current: ./vendor/crazywhalecc/static-php-cli/bin (composer library mode) + require_once dirname(__DIR__, 3) . '/autoload.php'; +} // 防止 Micro 打包状态下不支持中文的显示(虽然这个项目目前好像没输出过中文?) if (PHP_OS_FAMILY === 'Windows' && Phar::running()) { diff --git a/src/globals/defines.php b/src/globals/defines.php index 3415f5c6..79b85406 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -5,7 +5,7 @@ declare(strict_types=1); use ZM\Logger\ConsoleLogger; define('WORKING_DIR', getcwd()); -const ROOT_DIR = __DIR__ . '/../..'; +define('ROOT_DIR', dirname(__DIR__, 2)); // CLI start time define('START_TIME', microtime(true)); From cbfbec41b47d4e315e4bd7d3a29f5931833afb6e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 24 Dec 2023 15:27:17 +0800 Subject: [PATCH 110/415] add extension xhprof --- config/ext.json | 7 ++++++ config/source.json | 10 +++++++++ src/SPC/builder/extension/xhprof.php | 33 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/SPC/builder/extension/xhprof.php diff --git a/config/ext.json b/config/ext.json index b36d4204..e549724f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -479,6 +479,13 @@ "libuv" ] }, + "xhprof": { + "type": "external", + "source": "xhprof", + "ext-depends": [ + "ctype" + ] + }, "xlswriter": { "type": "external", "source": "xlswriter", diff --git a/config/source.json b/config/source.json index 56435a0a..b6cb0441 100644 --- a/config/source.json +++ b/config/source.json @@ -532,6 +532,16 @@ "path": "COPYING" } }, + "xhprof": { + "type": "url", + "url": "https://pecl.php.net/get/xhprof", + "path": "php-src/ext/xhprof-src", + "filename": "xhprof.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "xlswriter": { "type": "url", "url": "https://pecl.php.net/get/xlswriter", diff --git a/src/SPC/builder/extension/xhprof.php b/src/SPC/builder/extension/xhprof.php new file mode 100644 index 00000000..c3d98aac --- /dev/null +++ b/src/SPC/builder/extension/xhprof.php @@ -0,0 +1,33 @@ + Date: Sun, 24 Dec 2023 15:28:12 +0800 Subject: [PATCH 111/415] add extension xhprof 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 3af820f7..e5ef1de2 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -9,7 +9,7 @@ $extensions = 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gm $additional_libs = 'libwebp,libavif,libjpeg,freetype'; # If you want to test additional extensions, add them below. (comma start) -$extensions .= ',uv'; +$extensions .= ',xhprof'; # If you want to test additional features for extensions, add libs below. (comma start like extensions) $additional_libs .= ''; From 539aaefd72f3dff822c684eb6e049ae0016d0ec4 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 24 Dec 2023 20:17:06 +0800 Subject: [PATCH 112/415] Add initial windows runtime setup (#292) * add initial windows runtime setup * add cool console output * doctor support windows base * add `add-path` and `remove-path` for bin/setup-runtime * fix composer.ps1 path * add windows system util * add windows cmd and doctor base check * add windows fallback for laravel/prompts * cd fix [skip ci] * dir separator and typo fix [skip ci] --- .gitignore | 7 +- bin/setup-runtime.ps1 | 115 ++++++ bin/spc.ps1 | 12 + composer.json | 1 - composer.lock | 403 +++++++++++-------- src/SPC/builder/windows/SystemUtil.php | 26 ++ src/SPC/command/BaseCommand.php | 13 + src/SPC/command/DoctorCommand.php | 5 +- src/SPC/doctor/CheckListHandler.php | 19 +- src/SPC/doctor/item/OSCheckList.php | 4 +- src/SPC/doctor/item/WindowsToolCheckList.php | 44 ++ src/SPC/util/UnixShell.php | 3 + src/SPC/util/WindowsCmd.php | 90 +++++ src/globals/defines.php | 4 + src/globals/functions.php | 6 + 15 files changed, 568 insertions(+), 184 deletions(-) create mode 100644 bin/setup-runtime.ps1 create mode 100644 bin/spc.ps1 create mode 100644 src/SPC/builder/windows/SystemUtil.php create mode 100644 src/SPC/doctor/item/WindowsToolCheckList.php create mode 100644 src/SPC/util/WindowsCmd.php diff --git a/.gitignore b/.gitignore index 1f749916..776dbffd 100644 --- a/.gitignore +++ b/.gitignore @@ -22,9 +22,12 @@ docker/source/ # exclude self-runtime /bin/* -!/bin/spc -!/bin/setup-runtime +!/bin/spc* +!/bin/setup-runtime* !/bin/spc-alpine-docker +# exclude windows build tools +/php-sdk-binary-tools/ + # default test directory /tests/var/ diff --git a/bin/setup-runtime.ps1 b/bin/setup-runtime.ps1 new file mode 100644 index 00000000..b04c3b58 --- /dev/null +++ b/bin/setup-runtime.ps1 @@ -0,0 +1,115 @@ +param ( + [string] ${action} +) + +function AddToPath { + param ( + [string]$pathToAdd + ) + + $currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User') + + if ($currentPath -notlike "*$pathToAdd*") { + $newPath = $currentPath + ";$pathToAdd" + [System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User') + Write-Host "Added '$pathToAdd' to Path." + Write-Host "To remove path, use: " -NoNewline + Write-Host "bin/setup-runtime remove-path" -ForegroundColor Cyan + } else { + Write-Host "Path already exists." + } +} + +function RemoveFromPath { + param ( + [string]$pathToRemove + ) + + $currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User') + + if ($currentPath -like "*$pathToRemove*") { + $newPath = $currentPath -replace [regex]::Escape($pathToRemove), '' + [System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User') + Write-Host "Removed Path '$pathToRemove'" + } else { + Write-Host "Path '$pathToRemove' not in Path" + } +} + +# working dir +$WorkingDir = (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Definition)) + +if ($action -eq 'add-path') { + AddToPath ($WorkingDir + '\runtime') + exit 0 +} elseif ($action -eq 'remove-path') { + RemoveFromPath ($WorkingDir + '\runtime') + exit 0 +} elseif (-not($action -eq '')) { + Write-Host ("Invalid action: " + $action) -ForegroundColor Red + exit 1 +} + +# get php 8.1 specific version +$API = (Invoke-WebRequest -Uri "https://www.php.net/releases/index.php?json&version=8.1") | ConvertFrom-Json + +# php windows download +$PHPRuntimeUrl = "https://windows.php.net/downloads/releases/php-" + $API.version + "-Win32-vs16-x64.zip" +$ComposerUrl = "https://getcomposer.org/download/latest-stable/composer.phar" + +# create dir +New-Item -Path "downloads" -ItemType Directory -Force | Out-Null + +# download php +if (-not(Test-Path "downloads\php.zip")) +{ + Write-Host "Downloading PHP ..." + Invoke-WebRequest $PHPRuntimeUrl -OutFile "downloads\php.zip" +} + +# extract php +New-Item -Path "runtime" -ItemType Directory -Force | Out-Null +Write-Host "Extracting php.zip ..." +Expand-Archive -Path "downloads/php.zip" -DestinationPath "runtime" -Force +# make php.ini +Move-Item -Path "runtime\php.ini-production" -Destination "runtime\php.ini" -Force +$OriginINI = Get-Content -Path "runtime\php.ini" -Raw +$OriginINI = $OriginINI -replace ';extension=openssl', 'extension=openssl' +$OriginINI = $OriginINI -replace ';extension=curl', 'extension=curl' +$OriginINI = $OriginINI -replace ';extension=mbstring', 'extension=mbstring' +$OriginINI = $OriginINI -replace ';extension=sodium', 'extension=sodium' +$OriginINI = $OriginINI -replace ';extension_dir = "./"', ('extension_dir = "' + (Split-Path -Parent $MyInvocation.MyCommand.Definition) + '\..\runtime\ext"') +$OriginINI | Set-Content -Path "runtime\php.ini" + +# download composer +if (-not(Test-Path "runtime\composer.phar")) +{ + Write-Host "Downloading composer ..." + Invoke-WebRequest $ComposerUrl -OutFile "downloads\composer.phar" + Move-Item -Path "downloads\composer.phar" -Destination "runtime\composer.phar" -Force +} + +# create runtime\composer.ps1 +$ComposerContent = ' +$WorkingDir = (Split-Path -Parent $MyInvocation.MyCommand.Definition) +Start-Process ($WorkingDir + "\php.exe") ($WorkingDir + "\composer.phar " + $args) -NoNewWindow -Wait +' +$ComposerContent | Set-Content -Path 'runtime\composer.ps1' -Encoding UTF8 + +Write-Host "Successfully downloaded PHP and Composer !" -ForegroundColor Green +Write-Host "Use static-php-cli: " -NoNewline +Write-Host "bin/spc" -ForegroundColor Cyan +Write-Host "Use php: " -NoNewline +Write-Host "runtime/php" -ForegroundColor Cyan +Write-Host "Use composer: " -NoNewline +Write-Host "runtime/composer" -ForegroundColor Cyan +Write-Host "" +Write-Host "Don't forget installing composer dependencies '" -NoNewline +Write-Host "runtime/composer install" -ForegroundColor Cyan -NoNewline +Write-Host "' before using static-php-cli !" +Write-Host "" +Write-Host "If you want to use this PHP for quality tools (like phpstan, php-cs-fixer) or other project," +Write-Host "or use PHP, Composer as system executable," +Write-Host "use '" -NoNewline +Write-Host "bin/setup-runtime add-path" -ForegroundColor Cyan -NoNewline +Write-Host "' to add runtime dir in Path." diff --git a/bin/spc.ps1 b/bin/spc.ps1 new file mode 100644 index 00000000..7123a880 --- /dev/null +++ b/bin/spc.ps1 @@ -0,0 +1,12 @@ +$PHP_Exec = "runtime\php.exe" + +if (-not(Test-Path $PHP_Exec)) { + $PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition + if (-not $PHP_Exec) { + Write-Host "Error: PHP not found, you need to install PHP on your system or use 'bin/setup-runtime'." -ForegroundColor Red + exit 1 + } +} + +$phpArgs = "bin\spc " + $args +Start-Process $PHP_Exec -ArgumentList $phpArgs -NoNewWindow -Wait diff --git a/composer.json b/composer.json index 2a8b4c96..a827184c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,6 @@ "require": { "php": ">= 8.1", "ext-mbstring": "*", - "ext-pcntl": "*", "laravel/prompts": "^0.1.12", "symfony/console": "^5.4 || ^6 || ^7", "zhamao/logger": "^1.0" diff --git a/composer.lock b/composer.lock index 1be1f401..53557ee8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "198b6207aabb33778c51282cb7aa0c52", + "content-hash": "30d9cdb68b65870a63338606f68130f8", "packages": [ { "name": "illuminate/collections", - "version": "v10.33.0", + "version": "v10.38.1", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "766a3b6c3e5c8011b037a147266dcf7f93b21223" + "reference": "2677b3962a88640f92dba8a1f4ed38dcaaf13dad" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/766a3b6c3e5c8011b037a147266dcf7f93b21223", - "reference": "766a3b6c3e5c8011b037a147266dcf7f93b21223", + "url": "https://api.github.com/repos/illuminate/collections/zipball/2677b3962a88640f92dba8a1f4ed38dcaaf13dad", + "reference": "2677b3962a88640f92dba8a1f4ed38dcaaf13dad", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-11-20T15:45:45+00:00" + "time": "2023-12-15T18:25:00+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.33.0", + "version": "v10.38.1", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.33.0", + "version": "v10.38.1", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.33.0", + "version": "v10.38.1", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -414,16 +414,16 @@ }, { "name": "symfony/console", - "version": "v6.3.8", + "version": "v6.4.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92" + "reference": "a550a7c99daeedef3f9d23fb82e3531525ff11fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0d14a9f6d04d4ac38a8cea1171f4554e325dae92", - "reference": "0d14a9f6d04d4ac38a8cea1171f4554e325dae92", + "url": "https://api.github.com/repos/symfony/console/zipball/a550a7c99daeedef3f9d23fb82e3531525ff11fd", + "reference": "a550a7c99daeedef3f9d23fb82e3531525ff11fd", "shasum": "" }, "require": { @@ -431,7 +431,7 @@ "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^5.4|^6.0" + "symfony/string": "^5.4|^6.0|^7.0" }, "conflict": { "symfony/dependency-injection": "<5.4", @@ -445,12 +445,16 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/lock": "^5.4|^6.0", - "symfony/process": "^5.4|^6.0", - "symfony/var-dumper": "^5.4|^6.0" + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/lock": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/stopwatch": "^5.4|^6.0|^7.0", + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -484,7 +488,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.3.8" + "source": "https://github.com/symfony/console/tree/v6.4.1" }, "funding": [ { @@ -500,7 +504,7 @@ "type": "tidelift" } ], - "time": "2023-10-31T08:09:35+00:00" + "time": "2023-11-30T10:54:28+00:00" }, { "name": "symfony/deprecation-contracts", @@ -983,16 +987,16 @@ }, { "name": "symfony/string", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "13880a87790c76ef994c91e87efb96134522577a" + "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/13880a87790c76ef994c91e87efb96134522577a", - "reference": "13880a87790c76ef994c91e87efb96134522577a", + "url": "https://api.github.com/repos/symfony/string/zipball/b45fcf399ea9c3af543a92edf7172ba21174d809", + "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809", "shasum": "" }, "require": { @@ -1006,11 +1010,11 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/error-handler": "^5.4|^6.0", - "symfony/http-client": "^5.4|^6.0", - "symfony/intl": "^6.2", + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^5.4|^6.0" + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -1049,7 +1053,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.3.8" + "source": "https://github.com/symfony/string/tree/v6.4.0" }, "funding": [ { @@ -1065,7 +1069,7 @@ "type": "tidelift" } ], - "time": "2023-11-09T08:28:21+00:00" + "time": "2023-11-28T20:41:49+00:00" }, { "name": "zhamao/logger", @@ -1691,29 +1695,30 @@ }, { "name": "captainhook/captainhook", - "version": "5.18.3", + "version": "5.19.2", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook.git", - "reference": "b7bc503a40ccfe80ea9638e4921b4697669d725f" + "reference": "604bfc55fa40d6fe8c0275ca707ee80920b3b3f1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/b7bc503a40ccfe80ea9638e4921b4697669d725f", - "reference": "b7bc503a40ccfe80ea9638e4921b4697669d725f", + "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/604bfc55fa40d6fe8c0275ca707ee80920b3b3f1", + "reference": "604bfc55fa40d6fe8c0275ca707ee80920b3b3f1", "shasum": "" }, "require": { + "captainhook/secrets": "^0.9.4", "ext-json": "*", "ext-spl": "*", "ext-xml": "*", - "php": ">=7.4", + "php": ">=8.0", "sebastianfeldmann/camino": "^0.9.2", "sebastianfeldmann/cli": "^3.3", "sebastianfeldmann/git": "^3.9", - "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0", - "symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", + "symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "replace": { "sebastianfeldmann/captainhook": "*" @@ -1750,7 +1755,7 @@ } ], "description": "PHP git hook manager", - "homepage": "https://github.com/captainhookphp/captainhook", + "homepage": "http://php.captainhook.info/", "keywords": [ "commit-msg", "git", @@ -1762,7 +1767,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook/tree/5.18.3" + "source": "https://github.com/captainhookphp/captainhook/tree/5.19.2" }, "funding": [ { @@ -1770,7 +1775,7 @@ "type": "github" } ], - "time": "2023-11-05T13:56:19+00:00" + "time": "2023-12-18T14:06:12+00:00" }, { "name": "captainhook/plugin-composer", @@ -1827,6 +1832,62 @@ }, "time": "2022-01-28T04:35:22+00:00" }, + { + "name": "captainhook/secrets", + "version": "0.9.5", + "source": { + "type": "git", + "url": "https://github.com/captainhookphp/secrets.git", + "reference": "8aa90d5b9b7892abd11b9da2fc172a7b32b90cbe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/captainhookphp/secrets/zipball/8aa90d5b9b7892abd11b9da2fc172a7b32b90cbe", + "reference": "8aa90d5b9b7892abd11b9da2fc172a7b32b90cbe", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "CaptainHook\\Secrets\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info" + } + ], + "description": "Utility classes to detect secrets", + "keywords": [ + "commit-msg", + "keys", + "passwords", + "post-merge", + "prepare-commit-msg", + "secrets", + "tokens" + ], + "support": { + "issues": "https://github.com/captainhookphp/secrets/issues", + "source": "https://github.com/captainhookphp/secrets/tree/0.9.5" + }, + "funding": [ + { + "url": "https://github.com/sponsors/sebastianfeldmann", + "type": "github" + } + ], + "time": "2023-11-30T18:10:18+00:00" + }, { "name": "composer/pcre", "version": "3.1.1", @@ -2178,31 +2239,29 @@ }, { "name": "fidry/filesystem", - "version": "1.1.0", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/theofidry/filesystem.git", - "reference": "1dd372ab3eb8b84ffe9578bff576b00c9a44ee46" + "reference": "8303225d289da1c434f6009743fbe9aad852de0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theofidry/filesystem/zipball/1dd372ab3eb8b84ffe9578bff576b00c9a44ee46", - "reference": "1dd372ab3eb8b84ffe9578bff576b00c9a44ee46", + "url": "https://api.github.com/repos/theofidry/filesystem/zipball/8303225d289da1c434f6009743fbe9aad852de0c", + "reference": "8303225d289da1c434f6009743fbe9aad852de0c", "shasum": "" }, "require": { "php": "^8.1", - "symfony/filesystem": "^6.3", + "symfony/filesystem": "^6.4 || ^7.0", "thecodingmachine/safe": "^2.0" }, "require-dev": { "bamarni/composer-bin-plugin": "^1.4", "ergebnis/composer-normalize": "^2.28", - "infection/infection": "^0.26", - "phpspec/prophecy-phpunit": "^2.0", + "infection/infection": ">=0.26", "phpunit/phpunit": "^10.3", - "symfony/finder": "^6.3", - "symfony/phpunit-bridge": "^6.2" + "symfony/finder": "^6.4 || ^7.0" }, "type": "library", "extra": { @@ -2235,7 +2294,7 @@ ], "support": { "issues": "https://github.com/theofidry/filesystem/issues", - "source": "https://github.com/theofidry/filesystem/tree/1.1.0" + "source": "https://github.com/theofidry/filesystem/tree/1.2.1" }, "funding": [ { @@ -2243,7 +2302,7 @@ "type": "github" } ], - "time": "2023-10-07T07:32:54+00:00" + "time": "2023-12-10T13:29:09+00:00" }, { "name": "filp/whoops", @@ -2318,16 +2377,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.40.0", + "version": "v3.41.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "27d2b3265b5d550ec411b4319967ae7cfddfb2e0" + "reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/27d2b3265b5d550ec411b4319967ae7cfddfb2e0", - "reference": "27d2b3265b5d550ec411b4319967ae7cfddfb2e0", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8b6ae8dcbaf23f09680643ab832a4a3a260265f6", + "reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6", "shasum": "" }, "require": { @@ -2357,8 +2416,6 @@ "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", - "phpspec/prophecy": "^1.17", - "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.6", "symfony/phpunit-bridge": "^6.3.8 || ^7.0", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" @@ -2399,7 +2456,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.40.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.1" }, "funding": [ { @@ -2407,7 +2464,7 @@ "type": "github" } ], - "time": "2023-11-26T09:25:53+00:00" + "time": "2023-12-10T19:59:27+00:00" }, { "name": "humbug/box", @@ -2841,16 +2898,16 @@ }, { "name": "nikic/iter", - "version": "v2.3.0", + "version": "v2.4.0", "source": { "type": "git", "url": "https://github.com/nikic/iter.git", - "reference": "d9f88bc04b5b453914373e70c041353d8e67c3f5" + "reference": "09cd930fa9ff55747f34c7184532a5a1bd2385b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/iter/zipball/d9f88bc04b5b453914373e70c041353d8e67c3f5", - "reference": "d9f88bc04b5b453914373e70c041353d8e67c3f5", + "url": "https://api.github.com/repos/nikic/iter/zipball/09cd930fa9ff55747f34c7184532a5a1bd2385b1", + "reference": "09cd930fa9ff55747f34c7184532a5a1bd2385b1", "shasum": "" }, "require": { @@ -2887,22 +2944,22 @@ ], "support": { "issues": "https://github.com/nikic/iter/issues", - "source": "https://github.com/nikic/iter/tree/v2.3.0" + "source": "https://github.com/nikic/iter/tree/v2.4.0" }, - "time": "2023-07-25T19:55:40+00:00" + "time": "2023-12-10T20:43:19+00:00" }, { "name": "nikic/php-parser", - "version": "v4.17.1", + "version": "v4.18.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", - "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", "shasum": "" }, "require": { @@ -2943,9 +3000,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" }, - "time": "2023-08-13T19:53:39+00:00" + "time": "2023-12-10T21:03:43+00:00" }, { "name": "nunomaduro/collision", @@ -3477,16 +3534,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.4", + "version": "1.24.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496" + "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6bd0c26f3786cd9b7c359675cb789e35a8e07496", - "reference": "6bd0c26f3786cd9b7c359675cb789e35a8e07496", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", "shasum": "" }, "require": { @@ -3518,22 +3575,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.4" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" }, - "time": "2023-11-26T18:29:22+00:00" + "time": "2023-12-16T09:33:33+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.44", + "version": "1.10.50", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "bf84367c53a23f759513985c54ffe0d0c249825b" + "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/bf84367c53a23f759513985c54ffe0d0c249825b", - "reference": "bf84367c53a23f759513985c54ffe0d0c249825b", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/06a98513ac72c03e8366b5a0cb00750b487032e4", + "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4", "shasum": "" }, "require": { @@ -3582,27 +3639,27 @@ "type": "tidelift" } ], - "time": "2023-11-21T16:30:46+00:00" + "time": "2023-12-13T10:59:42+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.9", + "version": "10.1.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735" + "reference": "78c3b7625965c2513ee96569a4dbb62601784145" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/a56a9ab2f680246adcf3db43f38ddf1765774735", - "reference": "a56a9ab2f680246adcf3db43f38ddf1765774735", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/78c3b7625965c2513ee96569a4dbb62601784145", + "reference": "78c3b7625965c2513ee96569a4dbb62601784145", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1", "phpunit/php-file-iterator": "^4.0", "phpunit/php-text-template": "^3.0", @@ -3652,7 +3709,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.9" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.11" }, "funding": [ { @@ -3660,7 +3717,7 @@ "type": "github" } ], - "time": "2023-11-23T12:23:20+00:00" + "time": "2023-12-21T15:38:30+00:00" }, { "name": "phpunit/php-file-iterator", @@ -3907,16 +3964,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.4.2", + "version": "10.5.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1" + "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/cacd8b9dd224efa8eb28beb69004126c7ca1a1a1", - "reference": "cacd8b9dd224efa8eb28beb69004126c7ca1a1a1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6fce887c71076a73f32fd3e0774a6833fc5c7f19", + "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19", "shasum": "" }, "require": { @@ -3956,7 +4013,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.4-dev" + "dev-main": "10.5-dev" } }, "autoload": { @@ -3988,7 +4045,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.4.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.3" }, "funding": [ { @@ -4004,7 +4061,7 @@ "type": "tidelift" } ], - "time": "2023-10-26T07:21:45+00:00" + "time": "2023-12-13T07:25:23+00:00" }, { "name": "psr/event-dispatcher", @@ -4302,20 +4359,20 @@ }, { "name": "sebastian/complexity", - "version": "3.1.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68cfb347a44871f01e33ab0ef8215966432f6957", - "reference": "68cfb347a44871f01e33ab0ef8215966432f6957", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -4324,7 +4381,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.1-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -4348,7 +4405,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.1.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -4356,7 +4413,7 @@ "type": "github" } ], - "time": "2023-09-28T11:50:59+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", @@ -4631,20 +4688,20 @@ }, { "name": "sebastian/lines-of-code", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/649e40d279e243d985aa8fb6e74dd5bb28dc185d", - "reference": "649e40d279e243d985aa8fb6e74dd5bb28dc185d", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -4677,7 +4734,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.1" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -4685,7 +4742,7 @@ "type": "github" } ], - "time": "2023-08-31T09:25:50+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", @@ -5148,16 +5205,16 @@ }, { "name": "seld/jsonlint", - "version": "1.10.0", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/Seldaek/jsonlint.git", - "reference": "594fd6462aad8ecee0b45ca5045acea4776667f1" + "reference": "76d449a358ece77d6f1d6331c68453e657172202" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/594fd6462aad8ecee0b45ca5045acea4776667f1", - "reference": "594fd6462aad8ecee0b45ca5045acea4776667f1", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/76d449a358ece77d6f1d6331c68453e657172202", + "reference": "76d449a358ece77d6f1d6331c68453e657172202", "shasum": "" }, "require": { @@ -5184,7 +5241,7 @@ { "name": "Jordi Boggiano", "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" + "homepage": "https://seld.be" } ], "description": "JSON Linter", @@ -5196,7 +5253,7 @@ ], "support": { "issues": "https://github.com/Seldaek/jsonlint/issues", - "source": "https://github.com/Seldaek/jsonlint/tree/1.10.0" + "source": "https://github.com/Seldaek/jsonlint/tree/1.10.1" }, "funding": [ { @@ -5208,20 +5265,20 @@ "type": "tidelift" } ], - "time": "2023-05-11T13:16:46+00:00" + "time": "2023-12-18T13:03:25+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.3.2", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e" + "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e", - "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d76d2632cfc2206eecb5ad2b26cd5934082941b6", + "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6", "shasum": "" }, "require": { @@ -5238,13 +5295,13 @@ }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0", - "symfony/dependency-injection": "^5.4|^6.0", - "symfony/error-handler": "^5.4|^6.0", - "symfony/expression-language": "^5.4|^6.0", - "symfony/http-foundation": "^5.4|^6.0", + "symfony/config": "^5.4|^6.0|^7.0", + "symfony/dependency-injection": "^5.4|^6.0|^7.0", + "symfony/error-handler": "^5.4|^6.0|^7.0", + "symfony/expression-language": "^5.4|^6.0|^7.0", + "symfony/http-foundation": "^5.4|^6.0|^7.0", "symfony/service-contracts": "^2.5|^3", - "symfony/stopwatch": "^5.4|^6.0" + "symfony/stopwatch": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -5272,7 +5329,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.0" }, "funding": [ { @@ -5288,7 +5345,7 @@ "type": "tidelift" } ], - "time": "2023-07-06T06:56:43+00:00" + "time": "2023-07-27T06:52:43+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -5368,16 +5425,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.3.1", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" + "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", - "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/952a8cb588c3bc6ce76f6023000fb932f16a6e59", + "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59", "shasum": "" }, "require": { @@ -5411,7 +5468,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.3.1" + "source": "https://github.com/symfony/filesystem/tree/v6.4.0" }, "funding": [ { @@ -5427,27 +5484,27 @@ "type": "tidelift" } ], - "time": "2023-06-01T08:30:39+00:00" + "time": "2023-07-26T17:27:13+00:00" }, { "name": "symfony/finder", - "version": "v6.3.5", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4" + "reference": "11d736e97f116ac375a81f96e662911a34cd50ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4", - "reference": "a1b31d88c0e998168ca7792f222cbecee47428c4", + "url": "https://api.github.com/repos/symfony/finder/zipball/11d736e97f116ac375a81f96e662911a34cd50ce", + "reference": "11d736e97f116ac375a81f96e662911a34cd50ce", "shasum": "" }, "require": { "php": ">=8.1" }, "require-dev": { - "symfony/filesystem": "^6.0" + "symfony/filesystem": "^6.0|^7.0" }, "type": "library", "autoload": { @@ -5475,7 +5532,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.3.5" + "source": "https://github.com/symfony/finder/tree/v6.4.0" }, "funding": [ { @@ -5491,20 +5548,20 @@ "type": "tidelift" } ], - "time": "2023-09-26T12:56:25+00:00" + "time": "2023-10-31T17:30:12+00:00" }, { "name": "symfony/options-resolver", - "version": "v6.3.0", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd" + "reference": "22301f0e7fdeaacc14318928612dee79be99860e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd", - "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/22301f0e7fdeaacc14318928612dee79be99860e", + "reference": "22301f0e7fdeaacc14318928612dee79be99860e", "shasum": "" }, "require": { @@ -5542,7 +5599,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v6.3.0" + "source": "https://github.com/symfony/options-resolver/tree/v6.4.0" }, "funding": [ { @@ -5558,20 +5615,20 @@ "type": "tidelift" } ], - "time": "2023-05-12T14:21:09+00:00" + "time": "2023-08-08T10:16:24+00:00" }, { "name": "symfony/process", - "version": "v6.3.4", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54" + "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54", - "reference": "0b5c29118f2e980d455d2e34a5659f4579847c54", + "url": "https://api.github.com/repos/symfony/process/zipball/191703b1566d97a5425dc969e4350d32b8ef17aa", + "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa", "shasum": "" }, "require": { @@ -5603,7 +5660,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.3.4" + "source": "https://github.com/symfony/process/tree/v6.4.0" }, "funding": [ { @@ -5619,11 +5676,11 @@ "type": "tidelift" } ], - "time": "2023-08-07T10:39:22+00:00" + "time": "2023-11-17T21:06:49+00:00" }, { "name": "symfony/stopwatch", - "version": "v6.3.0", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -5665,7 +5722,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v6.3.0" + "source": "https://github.com/symfony/stopwatch/tree/v6.4.0" }, "funding": [ { @@ -5685,16 +5742,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.3.8", + "version": "v6.4.0", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a" + "reference": "c40f7d17e91d8b407582ed51a2bbf83c52c367f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/81acabba9046550e89634876ca64bfcd3c06aa0a", - "reference": "81acabba9046550e89634876ca64bfcd3c06aa0a", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/c40f7d17e91d8b407582ed51a2bbf83c52c367f6", + "reference": "c40f7d17e91d8b407582ed51a2bbf83c52c367f6", "shasum": "" }, "require": { @@ -5707,10 +5764,11 @@ }, "require-dev": { "ext-iconv": "*", - "symfony/console": "^5.4|^6.0", - "symfony/http-kernel": "^5.4|^6.0", - "symfony/process": "^5.4|^6.0", - "symfony/uid": "^5.4|^6.0", + "symfony/console": "^5.4|^6.0|^7.0", + "symfony/error-handler": "^6.3|^7.0", + "symfony/http-kernel": "^5.4|^6.0|^7.0", + "symfony/process": "^5.4|^6.0|^7.0", + "symfony/uid": "^5.4|^6.0|^7.0", "twig/twig": "^2.13|^3.0.4" }, "bin": [ @@ -5749,7 +5807,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.3.8" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.0" }, "funding": [ { @@ -5765,7 +5823,7 @@ "type": "tidelift" } ], - "time": "2023-11-08T10:42:36+00:00" + "time": "2023-11-09T08:28:32+00:00" }, { "name": "thecodingmachine/safe", @@ -6022,9 +6080,8 @@ "prefer-lowest": false, "platform": { "php": ">= 8.1", - "ext-mbstring": "*", - "ext-pcntl": "*" + "ext-mbstring": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/src/SPC/builder/windows/SystemUtil.php b/src/SPC/builder/windows/SystemUtil.php new file mode 100644 index 00000000..b1ec35af --- /dev/null +++ b/src/SPC/builder/windows/SystemUtil.php @@ -0,0 +1,26 @@ +input = $input; $this->output = $output; + + // windows fallback + Prompt::fallbackWhen(PHP_OS_FAMILY === 'Windows'); + ConfirmPrompt::fallbackUsing(function (ConfirmPrompt $prompt) use ($input, $output) { + $helper = new QuestionHelper(); + $case = $prompt->default ? ' [Y/n] ' : ' [y/N] '; + $question = new ConfirmationQuestion($prompt->label . $case, $prompt->default); + return $helper->ask($input, $output, $question); + }); if ($this->shouldExecute()) { try { return $this->handle(); diff --git a/src/SPC/command/DoctorCommand.php b/src/SPC/command/DoctorCommand.php index 9aabdeca..bc77511a 100644 --- a/src/SPC/command/DoctorCommand.php +++ b/src/SPC/command/DoctorCommand.php @@ -75,8 +75,9 @@ class DoctorCommand extends BaseCommand } catch (\Throwable $e) { $this->output->writeln('' . $e->getMessage() . ''); - pcntl_signal(SIGINT, SIG_IGN); - + if (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, SIG_IGN); + } return static::FAILURE; } diff --git a/src/SPC/doctor/CheckListHandler.php b/src/SPC/doctor/CheckListHandler.php index bfeb39c4..de5733df 100644 --- a/src/SPC/doctor/CheckListHandler.php +++ b/src/SPC/doctor/CheckListHandler.php @@ -34,12 +34,23 @@ final class CheckListHandler */ public function emitFix(OutputInterface $output, CheckResult $result): void { - pcntl_signal(SIGINT, function () use ($output) { - $output->writeln('You cancelled fix'); - }); + if (PHP_OS_FAMILY === 'Windows') { + sapi_windows_set_ctrl_handler(function () use ($output) { + $output->writeln('You cancelled fix'); + }); + } elseif (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, function () use ($output) { + $output->writeln('You cancelled fix'); + }); + } $fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams()); - pcntl_signal(SIGINT, SIG_IGN); + + if (PHP_OS_FAMILY === 'Windows') { + sapi_windows_set_ctrl_handler(null); + } elseif (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, SIG_IGN); + } if ($fix_result) { $output->writeln('Fix done'); diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index ad6b2551..8c7aa762 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -16,8 +16,8 @@ class OSCheckList #[AsCheckItem('if current OS are supported', level: 999)] public function checkOS(): ?CheckResult { - if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { - return CheckResult::fail('Current OS is not supported'); + if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD', 'Windows'])) { + return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY); } $distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : ''; return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported'); diff --git a/src/SPC/doctor/item/WindowsToolCheckList.php b/src/SPC/doctor/item/WindowsToolCheckList.php new file mode 100644 index 00000000..73092233 --- /dev/null +++ b/src/SPC/doctor/item/WindowsToolCheckList.php @@ -0,0 +1,44 @@ +exec('git clone https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH); + } catch (RuntimeException) { + return false; + } + return true; + } +} diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index 5fd730f9..2c0ba5d1 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -17,6 +17,9 @@ class UnixShell public function __construct(?bool $debug = null) { + if (PHP_OS_FAMILY === 'Windows') { + throw new RuntimeException('Windows cannot use UnixShell'); + } $this->debug = $debug ?? defined('DEBUG_MODE'); } diff --git a/src/SPC/util/WindowsCmd.php b/src/SPC/util/WindowsCmd.php new file mode 100644 index 00000000..cf461725 --- /dev/null +++ b/src/SPC/util/WindowsCmd.php @@ -0,0 +1,90 @@ +debug = $debug ?? defined('DEBUG_MODE'); + } + + public function cd(string $dir): WindowsCmd + { + logger()->info('Entering dir: ' . $dir); + $c = clone $this; + $c->cd = $dir; + return $c; + } + + /** + * @throws RuntimeException + */ + public function exec(string $cmd): WindowsCmd + { + /* @phpstan-ignore-next-line */ + logger()->info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd)); + if ($this->cd !== null) { + $cmd = 'cd /d ' . escapeshellarg($this->cd) . ' && ' . $cmd; + } + if (!$this->debug) { + $cmd .= ' >nul 2>&1'; + } + echo $cmd . PHP_EOL; + + f_passthru($cmd); + return $this; + } + + public function execWithResult(string $cmd, bool $with_log = true): array + { + if ($with_log) { + /* @phpstan-ignore-next-line */ + logger()->info(ConsoleColor::blue('[EXEC] ') . ConsoleColor::green($cmd)); + } else { + logger()->debug('Running command with result: ' . $cmd); + } + exec($cmd, $out, $code); + return [$code, $out]; + } + + public function setEnv(array $env): 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; + } +} diff --git a/src/globals/defines.php b/src/globals/defines.php index 79b85406..26d2f6d7 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -22,6 +22,10 @@ define('SEPARATED_PATH', [ BUILD_ROOT_PATH, ]); +if (PHP_OS_FAMILY === 'Windows') { + define('PHP_SDK_PATH', is_string($a = getenv('PHP_SDK_PATH')) ? $a : (WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools')); +} + // dangerous command const DANGER_CMD = [ 'rm', diff --git a/src/globals/functions.php b/src/globals/functions.php index d63f3350..afadf3a4 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -5,6 +5,7 @@ declare(strict_types=1); use Psr\Log\LoggerInterface; use SPC\exception\WrongUsageException; use SPC\util\UnixShell; +use SPC\util\WindowsCmd; use ZM\Logger\ConsoleLogger; /** @@ -120,3 +121,8 @@ function shell(?bool $debug = null): UnixShell { return new UnixShell($debug); } + +function cmd(?bool $debug = null): WindowsCmd +{ + return new WindowsCmd($debug); +} From fa1bd340f1336f3bdab57c989e75b5443ca5f00a Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 26 Dec 2023 01:42:52 +0800 Subject: [PATCH 113/415] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 970be43e..7470d6bd 100755 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Build single static PHP binary, with PHP project together, with popular extensio 🌐 **[中文](README-zh.md)** | **[English](README.md)** +> 2.0 Release is coming soon, windows support will be published in v2.1. + The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) From 5c7552f8260cbba98a75dab8117a3ecfdd2d990c Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 26 Dec 2023 01:47:33 +0800 Subject: [PATCH 114/415] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7470d6bd..6014d943 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build single static PHP binary, with PHP project together, with popular extensio 🌐 **[中文](README-zh.md)** | **[English](README.md)** -> 2.0 Release is coming soon, windows support will be published in v2.1. +> 2.0 Release is coming soon, windows support will be added in v2.1. The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 From 31c71f180b659a276c2e1bc9ab0f411bfdd3bc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=90=A7=EF=BC=8C=E4=BD=A0=E6=83=B3=E8=AF=B4?= =?UTF-8?q?=E5=95=A5?= Date: Wed, 3 Jan 2024 10:31:21 +0800 Subject: [PATCH 115/415] Feature perfect swoole extension config (#297) * improve swoole static build config * improve swoole static build config * improve swoole static build config * improve swoole static build config * improve swoole static build config * add cares config * update swoole depend config * update swoole depend config * update cares build config * update workflow tests.yaml config * fix setup-runtime * test with clang build * test with clang build * update cares build config * test * test * test * test * test * test * test * test * test * test * test * test * test * test * update cares license * test build * test build * test build * test build * test add enable libpq * test add enable libpq * test add enable libpq * test add enable libpq * test add enable libpq * test add enable libpq * test add enable libpq * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * update * update * update * update * update * update * update * update * update * compatible old * fix code format * fix code format * add swoole test case * add swoole test case * add phpstan ignore error * add phpstan ignore error * add phpstan ignore error * add phpstan ignore error * add phpstan ignore error * update phpstan.neon * update swoole extension test case * update swoole test case * adjust config order and depends * revert LinuxBuilder * remove swoole.phpt * re-adjust swoole args * update test-extensions and some PHPDoc * revert: debian and alpine clang doctor install * revert: MacOSBuilder * fix: extract hook for archive not working * revert: build tests * use addon mode to swoole database hook * add hook tests * test minimal * test minimal * sort config --------- Co-authored-by: crazywhalecc --- bin/setup-runtime | 3 +- config/ext.json | 43 +++++++++++-- config/lib.json | 12 ++++ config/source.json | 9 +++ phpstan.neon | 7 +- src/SPC/builder/BuilderBase.php | 2 +- src/SPC/builder/extension/swoole.php | 30 +++++++-- .../builder/extension/swoole_hook_mysql.php | 36 +++++++++++ .../builder/extension/swoole_hook_pgsql.php | 40 ++++++++++++ .../builder/extension/swoole_hook_sqlite.php | 40 ++++++++++++ src/SPC/builder/linux/LinuxBuilder.php | 14 ++-- src/SPC/builder/linux/library/libcares.php | 12 ++++ src/SPC/builder/linux/library/nghttp2.php | 64 +------------------ src/SPC/builder/macos/MacOSBuilder.php | 49 +++++++++----- src/SPC/builder/macos/library/libcares.php | 12 ++++ src/SPC/builder/macos/library/nghttp2.php | 46 +------------ src/SPC/builder/unix/library/brotli.php | 6 +- src/SPC/builder/unix/library/libcares.php | 21 ++++++ src/SPC/builder/unix/library/nghttp2.php | 53 +++++++++++++++ src/SPC/builder/unix/library/postgresql.php | 3 - src/SPC/store/FileSystem.php | 1 + src/SPC/store/SourcePatcher.php | 12 ++++ src/globals/functions.php | 5 +- src/globals/test-extensions.php | 53 +++++++++++---- src/globals/tests/swoole.php | 12 ++++ 25 files changed, 421 insertions(+), 164 deletions(-) create mode 100644 src/SPC/builder/extension/swoole_hook_mysql.php create mode 100644 src/SPC/builder/extension/swoole_hook_pgsql.php create mode 100644 src/SPC/builder/extension/swoole_hook_sqlite.php create mode 100644 src/SPC/builder/linux/library/libcares.php create mode 100644 src/SPC/builder/macos/library/libcares.php create mode 100644 src/SPC/builder/unix/library/libcares.php create mode 100644 src/SPC/builder/unix/library/nghttp2.php create mode 100644 src/globals/tests/swoole.php diff --git a/bin/setup-runtime b/bin/setup-runtime index b914c1ba..86c29c2d 100755 --- a/bin/setup-runtime +++ b/bin/setup-runtime @@ -35,7 +35,6 @@ while [ $# -gt 0 ]; do case "$1" in --mirror) mirror="$2" - shift ;; --*) echo "Illegal option $1" @@ -47,7 +46,7 @@ done case "$mirror" in china) __PHP_RUNTIME_URL__="https://dl.static-php.dev/static-php-cli/bulk/php-8.2.13-cli-${__OS_FIXED__}-${__ARCH__}.tar.gz" - __COMPOSER_URL__="https://mirrors.aliyun.com/composer/composer.phar" + __COMPOSER_URL__="https://mirrors.tencent.com/composer/composer.phar" ;; esac diff --git a/config/ext.json b/config/ext.json index e549724f..c15e162c 100644 --- a/config/ext.json +++ b/config/ext.json @@ -424,17 +424,50 @@ "source": "swoole", "arg-type": "custom", "cpp-extension": true, + "unix-only": true, "lib-depends": [ - "openssl" + "libcares", + "brotli", + "nghttp2", + "zlib" ], "ext-depends": [ - "openssl" + "openssl", + "curl" ], "ext-suggests": [ - "curl", - "pgsql" + "swoole-hook-pgsql", + "swoole-hook-mysql", + "swoole-hook-sqlite" + ] + }, + "swoole-hook-mysql": { + "type": "addon", + "arg-type": "custom", + "ext-depends": [ + "mysqlnd", + "pdo", + "pdo_mysql" ], - "unix-only": true + "ext-suggests": [ + "mysqli" + ] + }, + "swoole-hook-pgsql": { + "type": "addon", + "arg-type": "custom", + "ext-depends": [ + "pgsql", + "pdo" + ] + }, + "swoole-hook-sqlite": { + "type": "addon", + "arg-type": "custom", + "ext-depends": [ + "sqlite3", + "pdo" + ] }, "swow": { "type": "external", diff --git a/config/lib.json b/config/lib.json index 45329c04..25c2c6df 100644 --- a/config/lib.json +++ b/config/lib.json @@ -175,6 +175,18 @@ "libavif.a" ] }, + "libcares": { + "source": "libcares", + "static-libs-unix": [ + "libcares.a" + ], + "headers-unix": [ + "ares.h", + "ares_dns.h", + "ares_nameser.h", + "ares_rules.h" + ] + }, "libevent": { "source": "libevent", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index b6cb0441..13a196b7 100644 --- a/config/source.json +++ b/config/source.json @@ -209,6 +209,15 @@ "path": "LICENSE" } }, + "libcares": { + "type": "filelist", + "url": "https://c-ares.org/download/", + "regex": "/href=\"\\/download\\/(?c-ares-(?[^\"]+)\\.tar\\.gz)\"/", + "license": { + "type": "file", + "path": "LICENSE.md" + } + }, "libevent": { "type": "ghrel", "repo": "libevent/libevent", diff --git a/phpstan.neon b/phpstan.neon index 3f0ab052..1bdf9125 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,5 +8,10 @@ parameters: - '#Unsafe usage of new static#' - '#class Fiber#' - '#Attribute class JetBrains\\PhpStorm\\ArrayShape does not exist#' + - '#Function Swoole\\Coroutine\\run not found.#' dynamicConstantNames: - - PHP_OS_FAMILY \ No newline at end of file + - PHP_OS_FAMILY + excludePaths: + analyseAndScan: + - ./src/globals/tests/swoole.php + - ./src/globals/tests/swoole.phpt \ No newline at end of file diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 72db5961..86254869 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -227,7 +227,7 @@ abstract class BuilderBase foreach ($this->exts as $ext) { $ret[] = trim($ext->getConfigureArg()); } - logger()->info('Using configure: ' . implode(' ', $ret)); + logger()->debug('Using configure: ' . implode(' ', $ret)); return implode(' ', $ret); } diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 3dd570a1..f9da2005 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -12,13 +12,31 @@ class swoole extends Extension { public function getUnixConfigureArg(): string { + // enable swoole $arg = '--enable-swoole'; - // pgsql hook is buggy for static php - $arg .= ' --disable-swoole-pgsql'; - $arg .= $this->builder->getLib('openssl') ? ' --enable-openssl' : ' --disable-openssl --without-openssl'; - $arg .= $this->builder->getLib('brotli') ? (' --enable-brotli --with-brotli-dir=' . BUILD_ROOT_PATH) : ' --disable-brotli'; - // swoole curl hook is buggy for php 8.0 - $arg .= $this->builder->getExt('curl') && $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; + + // commonly-used feature: coroutine-time, thread-context + $arg .= ' --enable-swoole-coro-time --enable-thread-context'; + + // required feature: curl, openssl (but curl hook is buggy for php 8.0) + $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; + $arg .= ' --enable-openssl'; + + // additional feature: c-ares, brotli, nghttp2 (can be disabled, but we enable it by default in config to support full network feature) + $arg .= $this->builder->getLib('libcares') ? ' --enable-cares' : ''; + $arg .= $this->builder->getLib('brotli') ? (' --with-brotli-dir=' . BUILD_ROOT_PATH) : ''; + $arg .= $this->builder->getLib('nghttp2') ? (' --with-nghttp2-dir=' . BUILD_ROOT_PATH) : ''; + + // additional feature: swoole-pgsql, it should depend on lib [postgresql], but it will lack of CFLAGS etc. + // so this is a tricky way (enable ext [pgsql,pdo] to add postgresql hook and pdo_pgsql support) + $arg .= $this->builder->getExt('swoole-hook-pgsql') ? '' : ' --disable-swoole-pgsql'; + + // enable this feature , need remove pdo_sqlite + // more info : https://wenda.swoole.com/detail/109023 + $arg .= $this->builder->getExt('swoole-hook-sqlite') ? '' : ' --disable-swoole-sqlite'; + + // enable this feature , need stop pdo_* + // $arg .= $this->builder->getLib('unixodbc') ? ' --with-swoole-odbc=unixODBC,' : ' '; return $arg; } } diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php new file mode 100644 index 00000000..6a239976 --- /dev/null +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -0,0 +1,36 @@ +builder->getExt('swoole') === null) { + return; + } + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false); + $out = implode('', $out); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); + } + if (!str_contains($out, 'mysqlnd')) { + throw new RuntimeException('swoole mysql hook is not enabled correctly.'); + } + } +} diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php new file mode 100644 index 00000000..93e6172c --- /dev/null +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -0,0 +1,40 @@ +builder->getExt('pdo_pgsql') !== null) { + throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.'); + } + // enable swoole pgsql hook + return '--enable-swoole-pgsql'; + } + + public function runCliCheck(): void + { + // skip if not enable swoole + if ($this->builder->getExt('swoole') === null) { + return; + } + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false); + $out = implode('', $out); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); + } + if (!str_contains($out, 'coroutine_pgsql')) { + throw new RuntimeException('swoole pgsql hook is not enabled correctly.'); + } + } +} diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php new file mode 100644 index 00000000..714c83b6 --- /dev/null +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -0,0 +1,40 @@ +builder->getExt('pdo_sqlite') !== null) { + throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.'); + } + // enable swoole pgsql hook + return '--enable-swoole-sqlite'; + } + + public function runCliCheck(): void + { + // skip if not enable swoole + if ($this->builder->getExt('swoole') === null) { + return; + } + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "swoole"', false); + $out = implode('', $out); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); + } + if (!str_contains($out, 'coroutine_sqlite')) { + throw new RuntimeException('swoole sqlite hook is not enabled correctly.'); + } + } +} diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index a757c661..8fe8010c 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -138,16 +138,15 @@ class LinuxBuilder extends BuilderBase // add libstdc++, some extensions or libraries need it $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : ''); $this->setOption('extra-libs', $extra_libs); - $cflags = $this->arch_c_flags; // prepare build php envs $envs_build_php = SystemUtil::makeEnvVarString([ 'CFLAGS' => $cflags, 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, + 'LDFLAGS' => '-L' . BUILD_LIB_PATH, 'LIBS' => '-ldl -lpthread', ]); - SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); @@ -190,8 +189,8 @@ class LinuxBuilder extends BuilderBase $json_74 . $zts . $maxExecutionTimers . - $this->makeExtensionArgs() . ' ' . - $envs_build_php + $this->makeExtensionArgs() . + ' ' . $envs_build_php . ' ' ); SourcePatcher::patchBeforeMake($this); @@ -323,10 +322,11 @@ class LinuxBuilder extends BuilderBase $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; $ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : ''; + $tune_c_flags = implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)); return [ - 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE " . implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)) . $cflags, - 'EXTRA_LIBS' => $this->getOption('extra-libs', '') . $libs, - 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static" . $ldflags, + 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE {$tune_c_flags}{$cflags}", + 'EXTRA_LIBS' => "{$this->getOption('extra-libs', '')} {$libs}", + 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static{$ldflags}", ]; } } diff --git a/src/SPC/builder/linux/library/libcares.php b/src/SPC/builder/linux/library/libcares.php new file mode 100644 index 00000000..ef3801da --- /dev/null +++ b/src/SPC/builder/linux/library/libcares.php @@ -0,0 +1,12 @@ + - * - * lwmbs is licensed under Mulan PSL v2. You can use this - * software according to the terms and conditions of the - * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, - * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; -use SPC\exception\WrongUsageException; - class nghttp2 extends LinuxLibraryBase { + use \SPC\builder\unix\library\nghttp2; + public const NAME = 'nghttp2'; - - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ - public 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, - 'cunit' => null, - ]); - - [,,$destdir] = SEPARATED_PATH; - - shell()->cd($this->source_dir) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . - '--enable-lib-only ' . - '--with-boost=no ' . - $args . ' ' . - '--prefix=' - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); - $this->patchPkgconfPrefix(['libnghttp2.pc']); - } } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 5330e8a2..6a60b33d 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -155,6 +155,21 @@ class MacOSBuilder extends BuilderBase $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + // prepare build php envs + $envs_build_php = SystemUtil::makeEnvVarString([ + 'CFLAGS' => " {$this->arch_c_flags} -Werror=unknown-warning-option ", + 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, + 'LDFLAGS' => '-L' . BUILD_LIB_PATH, + ]); + + if ($this->getLib('postgresql')) { + shell() + ->cd(SOURCE_PATH . '/php-src') + ->exec( + 'sed -i.backup "s/ac_cv_func_explicit_bzero\" = xyes/ac_cv_func_explicit_bzero\" = x_fake_yes/" ./configure' + ); + } + shell()->cd(SOURCE_PATH . '/php-src') ->exec( './configure ' . @@ -162,8 +177,6 @@ class MacOSBuilder extends BuilderBase '--with-valgrind=no ' . // Not detect memory leak '--enable-shared=no ' . '--enable-static=yes ' . - "CFLAGS='{$this->arch_c_flags} -Werror=unknown-warning-option' " . - "CPPFLAGS='-I" . BUILD_INCLUDE_PATH . "' " . '--disable-all ' . '--disable-cgi ' . '--disable-phpdbg ' . @@ -173,7 +186,8 @@ class MacOSBuilder extends BuilderBase ($enableMicro ? '--enable-micro ' : '--disable-micro ') . $json_74 . $zts . - $this->makeExtensionArgs() + $this->makeExtensionArgs() . ' ' . + $envs_build_php ); SourcePatcher::patchBeforeMake($this); @@ -213,10 +227,7 @@ class MacOSBuilder extends BuilderBase */ public function buildCli(): void { - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it) - ]); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); $shell = shell()->cd(SOURCE_PATH . '/php-src'); $shell->exec("make -j{$this->concurrency} {$vars} cli"); @@ -247,9 +258,8 @@ class MacOSBuilder extends BuilderBase $vars = [ // with debug information, optimize for size, remove identifiers, patch fake cli for micro 'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli, - // link resolv library (macOS needs it) - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", ]; + $vars = $this->getBuildVars($vars); if (!$this->getOption('no-strip', false)) { $vars['STRIP'] = 'dsymutil -f '; } @@ -272,10 +282,7 @@ class MacOSBuilder extends BuilderBase */ public function buildFpm(): void { - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it) - ]); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); $shell = shell()->cd(SOURCE_PATH . '/php-src'); $shell->exec("make -j{$this->concurrency} {$vars} fpm"); @@ -292,10 +299,7 @@ class MacOSBuilder extends BuilderBase */ public function buildEmbed(): void { - $vars = SystemUtil::makeEnvVarString([ - 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv", // link resolv library (macOS needs it) - ]); + $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); shell() ->cd(SOURCE_PATH . '/php-src') @@ -309,4 +313,15 @@ class MacOSBuilder extends BuilderBase ->exec('ar rcs ' . BUILD_ROOT_PATH . '/lib/libphp.a *.o') ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); } + + private function getBuildVars($input = []): array + { + $optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os'; + $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; + $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; + return [ + 'EXTRA_CFLAGS' => "{$optimization} {$cflags} " . $this->getOption('x-extra-cflags'), + 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv {$libs} " . $this->getOption('x-extra-libs'), + ]; + } } diff --git a/src/SPC/builder/macos/library/libcares.php b/src/SPC/builder/macos/library/libcares.php new file mode 100644 index 00000000..6eb92ec0 --- /dev/null +++ b/src/SPC/builder/macos/library/libcares.php @@ -0,0 +1,12 @@ +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, - 'cunit' => null, - ]); - - [,,$destdir] = SEPARATED_PATH; - - shell()->cd($this->source_dir) - ->exec( - './configure ' . - '--enable-static ' . - '--disable-shared ' . - "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . - '--enable-lib-only ' . - '--with-boost=no ' . - $args . ' ' . - '--prefix=' - ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec("make install DESTDIR={$destdir}"); - $this->patchPkgconfPrefix(['libnghttp2.pc']); - } } diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 92c04de4..1b783ad0 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -28,9 +28,9 @@ trait brotli ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); shell()->cd(BUILD_ROOT_PATH . '/lib') - ->exec('ln -s libbrotlicommon.a libbrotlicommon-static.a') - ->exec('ln -s libbrotlidec.a libbrotlidec-static.a') - ->exec('ln -s libbrotlienc.a libbrotlienc-static.a'); + ->exec('ln -sf libbrotlicommon.a libbrotlicommon-static.a') + ->exec('ln -sf libbrotlidec.a libbrotlidec-static.a') + ->exec('ln -sf libbrotlienc.a libbrotlienc-static.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'))) { unlink(BUILD_ROOT_PATH . '/lib/' . $filename); diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php new file mode 100644 index 00000000..6d570174 --- /dev/null +++ b/src/SPC/builder/unix/library/libcares.php @@ -0,0 +1,21 @@ +cd($this->source_dir) + ->exec('./configure --prefix=' . BUILD_ROOT_PATH . ' --enable-static --disable-shared --disable-tests') + ->exec("make -j {$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/builder/unix/library/nghttp2.php b/src/SPC/builder/unix/library/nghttp2.php new file mode 100644 index 00000000..0334beba --- /dev/null +++ b/src/SPC/builder/unix/library/nghttp2.php @@ -0,0 +1,53 @@ +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, + 'cunit' => null, + ]); + + [,,$destdir] = SEPARATED_PATH; + + shell()->cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static ' . + '--disable-shared ' . + '--enable-lib-only ' . + '--with-boost=no ' . + $args . ' ' . + '--prefix=' + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec("make install DESTDIR={$destdir}"); + $this->patchPkgconfPrefix(['libnghttp2.pc']); + } +} diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 2448f656..4061f13e 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -28,9 +28,6 @@ trait postgresql 'icu' => 'icu-i18n', ]; - f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); - f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); - foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 0480ff14..c08a09bb 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -233,6 +233,7 @@ class FileSystem throw new FileSystemException("unknown archive format: {$filename}"); } } + self::emitSourceExtractHook($name); } catch (RuntimeException $e) { if (PHP_OS_FAMILY === 'Windows') { f_passthru('rmdir /s /q ' . SOURCE_PATH . "/{$name}"); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 426f978a..fc3e69d4 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -16,6 +16,7 @@ class SourcePatcher // FileSystem::addSourceExtractHook('swow', [SourcePatcher::class, 'patchSwow']); FileSystem::addSourceExtractHook('micro', [SourcePatcher::class, 'patchMicro']); FileSystem::addSourceExtractHook('openssl', [SourcePatcher::class, 'patchOpenssl11Darwin']); + FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']); } /** @@ -159,6 +160,17 @@ class SourcePatcher return false; } + public static function patchSwoole(): bool + { + // swoole hook needs pdo/pdo.h + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/swoole/config.m4', + 'PHP_ADD_INCLUDE([$ext_srcdir])', + "PHP_ADD_INCLUDE( [\$ext_srcdir] )\n PHP_ADD_INCLUDE([\$abs_srcdir/ext])" + ); + return true; + } + /** * @throws FileSystemException */ diff --git a/src/globals/functions.php b/src/globals/functions.php index afadf3a4..e48eaeeb 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -3,6 +3,7 @@ declare(strict_types=1); use Psr\Log\LoggerInterface; +use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\util\UnixShell; use SPC\util\WindowsCmd; @@ -69,7 +70,7 @@ function osfamily2dir(): string /** * Execute the shell command, and the output will be directly printed in the terminal. If there is an error, an exception will be thrown * - * @throws \SPC\exception\RuntimeException + * @throws RuntimeException */ function f_passthru(string $cmd): ?bool { @@ -87,7 +88,7 @@ function f_passthru(string $cmd): ?bool } $ret = passthru($cmd, $code); if ($code !== 0) { - throw new \SPC\exception\RuntimeException('Command run failed with code[' . $code . ']: ' . $cmd, $code); + throw new RuntimeException('Command run failed with code[' . $code . ']: ' . $cmd, $code); } return $ret; } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index e5ef1de2..00d69c0a 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -2,24 +2,55 @@ declare(strict_types=1); -# Normal test, contains `common` extension. -$extensions = 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip'; +/** + * This is GitHub Actions automatic test extension args generator. + * You can edit $extensions, $with_libs and $base_combination. + */ -# Normal test, contains gd extra libraries. -$additional_libs = 'libwebp,libavif,libjpeg,freetype'; +// --------------------------------- edit area --------------------------------- -# If you want to test additional extensions, add them below. (comma start) -$extensions .= ',xhprof'; +// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). +$extensions = 'swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite'; -# If you want to test additional features for extensions, add libs below. (comma start like extensions) -$additional_libs .= ''; +// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). +$with_libs = ''; + +// Please change your test base combination. We recommend testing with `common`. +// You can use `common`, `bulk`, `minimal` or `none`. +$base_combination = 'minimal'; + +// -------------------------- code area, do not modify -------------------------- + +/** + * get combination for tests, do not modify it if not necessary. + */ +function _getCombination(string $type = 'common'): string +{ + return match ($type) { + 'common' => 'bcmath,bz2,calendar,ctype,curl,dom,exif,fileinfo,filter,ftp,gd,gmp,iconv,xml,mbstring,mbregex,' . + 'mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,redis,session,simplexml,soap,sockets,' . + 'sqlite3,tokenizer,xmlwriter,xmlreader,zlib,zip', + 'bulk' => 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,' . + 'intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,' . + 'posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,' . + 'sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib', + 'minimal' => 'pcntl,posix,mbstring,tokenizer,phar', + default => '', // none + }; +} if (!isset($argv[1])) { exit("Please use 'extensions', 'cmd' or 'libs' as output type"); } + +$trim_value = "\r\n \t,"; + +$final_extensions = trim(trim($extensions, $trim_value) . ',' . _getCombination($base_combination), $trim_value); +$final_libs = trim($with_libs, $trim_value); + echo match ($argv[1]) { - 'extensions' => $extensions, - 'libs' => $additional_libs, - 'cmd' => $extensions . ' --with-libs=' . $additional_libs, + 'extensions' => $final_extensions, + 'libs' => $final_libs, + 'cmd' => $final_extensions . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), default => '', }; diff --git a/src/globals/tests/swoole.php b/src/globals/tests/swoole.php new file mode 100644 index 00000000..9e5752f0 --- /dev/null +++ b/src/globals/tests/swoole.php @@ -0,0 +1,12 @@ + Date: Wed, 3 Jan 2024 10:36:04 +0800 Subject: [PATCH 116/415] Update to 2.0.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 73b354be..5ab014fa 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0.0-rc9'; + public const VERSION = '2.0.0'; public function __construct() { From eac4763d822eb3733d34b0dbb0815d21489c12f3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 3 Jan 2024 13:40:48 +0800 Subject: [PATCH 117/415] fix libxml2 with icu finding issue (#304) * fix libxml2 with icu finding issue * add test --- config/lib.json | 4 ---- src/SPC/builder/linux/library/libxml2.php | 6 ++++-- src/SPC/builder/macos/library/libxml2.php | 6 ++++-- src/globals/test-extensions.php | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/lib.json b/config/lib.json index 25c2c6df..8ccb8091 100644 --- a/config/lib.json +++ b/config/lib.json @@ -333,10 +333,6 @@ "lib-suggests": [ "xz", "icu" - ], - "lib-suggests-windows": [ - "icu", - "xz" ] }, "libxslt": { diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index 82327c58..e6131224 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -26,7 +26,9 @@ class libxml2 extends LinuxLibraryBase shell()->cd($this->source_dir . '/build') ->exec( 'cmake ' . - "{$this->builder->makeCmakeArgs()} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DIconv_IS_BUILT_IN=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . @@ -39,7 +41,7 @@ class libxml2 extends LinuxLibraryBase '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make install'); FileSystem::replaceFileStr( BUILD_LIB_PATH . '/pkgconfig/libxml-2.0.pc', diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 50cb3a5a..4b22bc4a 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -27,7 +27,9 @@ class libxml2 extends MacOSLibraryBase ->exec( 'cmake ' . // '--debug-find ' . - "{$this->builder->makeCmakeArgs()} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DBUILD_SHARED_LIBS=OFF ' . '-DLIBXML2_WITH_ICONV=ON ' . "-DLIBXML2_WITH_ZLIB={$enable_zlib} " . @@ -39,6 +41,6 @@ class libxml2 extends MacOSLibraryBase '..' ) ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->exec('make install'); } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 00d69c0a..512eecbd 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -10,7 +10,7 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). -$extensions = 'swoole,swoole-hook-pgsql,swoole-hook-mysql,swoole-hook-sqlite'; +$extensions = 'xml,intl'; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = ''; From dabdb518cecbd55bcde4fa5ff713aa83c8b531ee Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 3 Jan 2024 14:56:39 +0800 Subject: [PATCH 118/415] xz use github --- config/source.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index 13a196b7..ba9480df 100644 --- a/config/source.json +++ b/config/source.json @@ -562,9 +562,9 @@ } }, "xz": { - "type": "filelist", - "url": "https://tukaani.org/xz/", - "regex": "/href=\"(?xz-(?[^\"]+)\\.tar\\.xz)\"/", + "type": "ghrel", + "repo": "tukaani-project/xz", + "match": "xz-.+\\.tar\\.gz", "license": { "type": "file", "path": "COPYING" From 269e95e0fe2016e87c990857d2bdf0720ebdab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=B8=E6=B0=94=E5=8D=83=E7=A7=8B?= Date: Fri, 5 Jan 2024 19:21:07 +0800 Subject: [PATCH 119/415] fix #307 (#308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #307 uv 和 swoole 同时启用的时候会提示 uv 找不到 * Update test-extensions.php * update cs-fixer config for newer version * revert composer.lock to fit 8.1 --------- Co-authored-by: Jerry Ma --- .php-cs-fixer.php | 1 + composer.lock | 170 ++++++++++++------------ config/ext.json | 3 + src/SPC/builder/unix/library/brotli.php | 1 + src/globals/test-extensions.php | 2 +- 5 files changed, 91 insertions(+), 86 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 143407b8..428cf277 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -63,6 +63,7 @@ return (new PhpCsFixer\Config()) 'phpdoc_summary' => false, 'php_unit_test_class_requires_covers' => false, 'phpdoc_var_without_name' => false, + 'fully_qualified_strict_types' => false, ]) ->setFinder( PhpCsFixer\Finder::create()->in([__DIR__ . '/src', __DIR__ . '/tests/SPC']) diff --git a/composer.lock b/composer.lock index 53557ee8..01014a05 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.38.1", + "version": "v10.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "2677b3962a88640f92dba8a1f4ed38dcaaf13dad" + "reference": "63fc240a047788fbc2ebe153de85cb72fce88440" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/2677b3962a88640f92dba8a1f4ed38dcaaf13dad", - "reference": "2677b3962a88640f92dba8a1f4ed38dcaaf13dad", + "url": "https://api.github.com/repos/illuminate/collections/zipball/63fc240a047788fbc2ebe153de85cb72fce88440", + "reference": "63fc240a047788fbc2ebe153de85cb72fce88440", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-15T18:25:00+00:00" + "time": "2023-12-21T14:17:35+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.38.1", + "version": "v10.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.38.1", + "version": "v10.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.38.1", + "version": "v10.39.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.13", + "version": "v0.1.14", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "e1379d8ead15edd6cc4369c22274345982edc95a" + "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/e1379d8ead15edd6cc4369c22274345982edc95a", - "reference": "e1379d8ead15edd6cc4369c22274345982edc95a", + "url": "https://api.github.com/repos/laravel/prompts/zipball/2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", + "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", "shasum": "" }, "require": { @@ -228,7 +228,7 @@ "require-dev": { "mockery/mockery": "^1.5", "pestphp/pest": "^2.3", - "phpstan/phpstan": "^1.10", + "phpstan/phpstan": "^1.11", "phpstan/phpstan-mockery": "^1.1" }, "suggest": { @@ -254,9 +254,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.13" + "source": "https://github.com/laravel/prompts/tree/v0.1.14" }, - "time": "2023-10-27T13:53:59+00:00" + "time": "2023-12-27T04:18:09+00:00" }, { "name": "psr/container", @@ -414,16 +414,16 @@ }, { "name": "symfony/console", - "version": "v6.4.1", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "a550a7c99daeedef3f9d23fb82e3531525ff11fd" + "reference": "0254811a143e6bc6c8deea08b589a7e68a37f625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/a550a7c99daeedef3f9d23fb82e3531525ff11fd", - "reference": "a550a7c99daeedef3f9d23fb82e3531525ff11fd", + "url": "https://api.github.com/repos/symfony/console/zipball/0254811a143e6bc6c8deea08b589a7e68a37f625", + "reference": "0254811a143e6bc6c8deea08b589a7e68a37f625", "shasum": "" }, "require": { @@ -488,7 +488,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.1" + "source": "https://github.com/symfony/console/tree/v6.4.2" }, "funding": [ { @@ -504,7 +504,7 @@ "type": "tidelift" } ], - "time": "2023-11-30T10:54:28+00:00" + "time": "2023-12-10T16:15:48+00:00" }, { "name": "symfony/deprecation-contracts", @@ -905,21 +905,21 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.0", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838" + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838", - "reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^2.0" + "psr/container": "^1.1|^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -967,7 +967,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" }, "funding": [ { @@ -983,20 +983,20 @@ "type": "tidelift" } ], - "time": "2023-07-30T20:28:31+00:00" + "time": "2023-12-26T14:02:43+00:00" }, { "name": "symfony/string", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809" + "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/b45fcf399ea9c3af543a92edf7172ba21174d809", - "reference": "b45fcf399ea9c3af543a92edf7172ba21174d809", + "url": "https://api.github.com/repos/symfony/string/zipball/7cb80bc10bfcdf6b5492741c0b9357dac66940bc", + "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc", "shasum": "" }, "require": { @@ -1053,7 +1053,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.0" + "source": "https://github.com/symfony/string/tree/v6.4.2" }, "funding": [ { @@ -1069,7 +1069,7 @@ "type": "tidelift" } ], - "time": "2023-11-28T20:41:49+00:00" + "time": "2023-12-10T16:15:48+00:00" }, { "name": "zhamao/logger", @@ -2377,21 +2377,22 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.41.1", + "version": "v3.46.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6" + "reference": "be6831c9af1740470d2a773119b9273f8ac1c3d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8b6ae8dcbaf23f09680643ab832a4a3a260265f6", - "reference": "8b6ae8dcbaf23f09680643ab832a4a3a260265f6", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/be6831c9af1740470d2a773119b9273f8ac1c3d2", + "reference": "be6831c9af1740470d2a773119b9273f8ac1c3d2", "shasum": "" }, "require": { "composer/semver": "^3.4", "composer/xdebug-handler": "^3.0.3", + "ext-filter": "*", "ext-json": "*", "ext-tokenizer": "*", "php": "^7.4 || ^8.0", @@ -2416,8 +2417,7 @@ "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", - "phpunit/phpunit": "^9.6", - "symfony/phpunit-bridge": "^6.3.8 || ^7.0", + "phpunit/phpunit": "^9.6 || ^10.5.5", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { @@ -2456,7 +2456,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.46.0" }, "funding": [ { @@ -2464,7 +2464,7 @@ "type": "github" } ], - "time": "2023-12-10T19:59:27+00:00" + "time": "2024-01-03T21:38:46+00:00" }, { "name": "humbug/box", @@ -3534,16 +3534,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.5", + "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc" + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fedf211ff14ec8381c9bf5714e33a7a552dd1acc", - "reference": "fedf211ff14ec8381c9bf5714e33a7a552dd1acc", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", "shasum": "" }, "require": { @@ -3575,22 +3575,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.5" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" }, - "time": "2023-12-16T09:33:33+00:00" + "time": "2024-01-04T17:06:16+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.50", + "version": "1.10.52", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4" + "reference": "0cd0c330081d4f1e1d630701fe4f342c3b659685" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/06a98513ac72c03e8366b5a0cb00750b487032e4", - "reference": "06a98513ac72c03e8366b5a0cb00750b487032e4", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0cd0c330081d4f1e1d630701fe4f342c3b659685", + "reference": "0cd0c330081d4f1e1d630701fe4f342c3b659685", "shasum": "" }, "require": { @@ -3639,7 +3639,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T10:59:42+00:00" + "time": "2024-01-05T09:51:32+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3964,16 +3964,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.3", + "version": "10.5.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19" + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6fce887c71076a73f32fd3e0774a6833fc5c7f19", - "reference": "6fce887c71076a73f32fd3e0774a6833fc5c7f19", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", "shasum": "" }, "require": { @@ -4045,7 +4045,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.3" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" }, "funding": [ { @@ -4061,7 +4061,7 @@ "type": "tidelift" } ], - "time": "2023-12-13T07:25:23+00:00" + "time": "2023-12-27T15:13:52+00:00" }, { "name": "psr/event-dispatcher", @@ -4417,16 +4417,16 @@ }, { "name": "sebastian/diff", - "version": "5.0.3", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b" + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b", - "reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f", "shasum": "" }, "require": { @@ -4439,7 +4439,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -4472,7 +4472,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.0.3" + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.0" }, "funding": [ { @@ -4480,7 +4480,7 @@ "type": "github" } ], - "time": "2023-05-01T07:48:21+00:00" + "time": "2023-12-22T10:55:06+00:00" }, { "name": "sebastian/environment", @@ -5269,16 +5269,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6" + "reference": "e95216850555cd55e71b857eb9d6c2674124603a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d76d2632cfc2206eecb5ad2b26cd5934082941b6", - "reference": "d76d2632cfc2206eecb5ad2b26cd5934082941b6", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e95216850555cd55e71b857eb9d6c2674124603a", + "reference": "e95216850555cd55e71b857eb9d6c2674124603a", "shasum": "" }, "require": { @@ -5329,7 +5329,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.0" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.2" }, "funding": [ { @@ -5345,7 +5345,7 @@ "type": "tidelift" } ], - "time": "2023-07-27T06:52:43+00:00" + "time": "2023-12-27T22:16:42+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -5619,16 +5619,16 @@ }, { "name": "symfony/process", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa" + "reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/191703b1566d97a5425dc969e4350d32b8ef17aa", - "reference": "191703b1566d97a5425dc969e4350d32b8ef17aa", + "url": "https://api.github.com/repos/symfony/process/zipball/c4b1ef0bc80533d87a2e969806172f1c2a980241", + "reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241", "shasum": "" }, "require": { @@ -5660,7 +5660,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.0" + "source": "https://github.com/symfony/process/tree/v6.4.2" }, "funding": [ { @@ -5676,7 +5676,7 @@ "type": "tidelift" } ], - "time": "2023-11-17T21:06:49+00:00" + "time": "2023-12-22T16:42:54+00:00" }, { "name": "symfony/stopwatch", @@ -5742,16 +5742,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.4.0", + "version": "v6.4.2", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "c40f7d17e91d8b407582ed51a2bbf83c52c367f6" + "reference": "68d6573ec98715ddcae5a0a85bee3c1c27a4c33f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/c40f7d17e91d8b407582ed51a2bbf83c52c367f6", - "reference": "c40f7d17e91d8b407582ed51a2bbf83c52c367f6", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/68d6573ec98715ddcae5a0a85bee3c1c27a4c33f", + "reference": "68d6573ec98715ddcae5a0a85bee3c1c27a4c33f", "shasum": "" }, "require": { @@ -5807,7 +5807,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.0" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.2" }, "funding": [ { @@ -5823,7 +5823,7 @@ "type": "tidelift" } ], - "time": "2023-11-09T08:28:32+00:00" + "time": "2023-12-28T19:16:56+00:00" }, { "name": "thecodingmachine/safe", @@ -6083,5 +6083,5 @@ "ext-mbstring": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/config/ext.json b/config/ext.json index c15e162c..64c859cd 100644 --- a/config/ext.json +++ b/config/ext.json @@ -510,6 +510,9 @@ "arg-type": "with-prefix", "lib-depends": [ "libuv" + ], + "ext-depends": [ + "sockets" ] }, "xhprof": { diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 1b783ad0..e4ed1221 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -29,6 +29,7 @@ trait brotli $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); shell()->cd(BUILD_ROOT_PATH . '/lib') ->exec('ln -sf libbrotlicommon.a libbrotlicommon-static.a') + ->exec('ln -sf libbrotlicommon.a libbrotli.a') ->exec('ln -sf libbrotlidec.a libbrotlidec-static.a') ->exec('ln -sf libbrotlienc.a libbrotlienc-static.a'); foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 512eecbd..f1e82490 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -10,7 +10,7 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). -$extensions = 'xml,intl'; +$extensions = 'swoole,uv'; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = ''; From cb5e13e39a966e48215adac01deb522feb4eca36 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 00:36:58 +0800 Subject: [PATCH 120/415] update release-build (Build SPC Binary) workflow --- .github/workflows/release-build.yml | 73 +++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index cb08ba23..66d5bc06 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -1,6 +1,8 @@ -name: Upload SPC Binary (Release) +name: Build SPC Binary on: + push: + branches: [ "main" ] release: types: - published @@ -8,10 +10,14 @@ on: jobs: build-release-artifacts: - name: "Upload SPC Binary (Release)" + name: "Build SPC Binary" runs-on: ubuntu-latest strategy: matrix: + php-version: + - "8.1" + micro-version: + - "8.1.26" operating-system: - "linux-x86_64" - "macos-x86_64" @@ -21,18 +27,57 @@ jobs: - name: "Checkout" uses: "actions/checkout@v4" - - name: Reuse static-php-cli-hosted artifacts - uses: dawidd6/action-download-artifact@v2 + - if: inputs.debug == true + run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV + + - name: "Install PHP for official runners" + uses: "shivammathur/setup-php@v2" with: - repo: static-php/static-php-cli-hosted - branch: master - workflow: build-spc-release.yml - name: "spc-${{ matrix.operating-system }}" + coverage: none + tools: composer:v2 + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + + - name: "Get Composer Cache Directory" + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: "actions/cache@v3" + with: + path: "${{ steps.composer-cache.outputs.dir }}" + key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" + restore-keys: | + php-${{ matrix.php-version }}-locked-composer + + - name: "Install Locked Dependencies" + run: "composer install --no-interaction --no-progress" + + - name: "Build PHAR File" + run: "composer build:phar" + + - name: "Download minimal combination" + run: | + curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz + tar -zxvf tmp.tgz + + - name: "Generate Executable" + run: | + cat micro.sfx spc.phar > spc + chmod +x spc - name: "Archive Executable" run: | tar -czf spc-${{ matrix.operating-system }}.tar.gz spc echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV + echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV + if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then + ./spc dev:extensions + fi + + - name: "Copy file" + run: "mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS" - name: upload binaries to release uses: softprops/action-gh-release@v1 @@ -40,6 +85,18 @@ jobs: with: files: ${{ env.filename }} + - name: "Deploy to Self-Hosted Server" + if: secrets.DEPLOY_SERVER_HOST != '' + uses: easingthemes/ssh-deploy@main + env: + SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} + ARGS: "-rltgoDzvO" + SOURCE: "dist/" + REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }} + REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }} + REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }} + TARGET: ${{ secrets.DEPLOY_SERVER_TARGET_SPC_NIGHTLY }} + - name: "Upload Artifact" uses: actions/upload-artifact@v3 with: From 54ba41d1b3b1bc7fee4ed4ffd8451f613b8c0934 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 00:37:21 +0800 Subject: [PATCH 121/415] fix imap executable permission --- src/SPC/builder/linux/library/imap.php | 4 ++++ src/SPC/builder/macos/library/imap.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/SPC/builder/linux/library/imap.php b/src/SPC/builder/linux/library/imap.php index 60b02203..96380501 100644 --- a/src/SPC/builder/linux/library/imap.php +++ b/src/SPC/builder/linux/library/imap.php @@ -47,6 +47,10 @@ class imap extends LinuxLibraryBase shell()->cd($this->source_dir) ->exec('make clean') ->exec('touch ip6') + ->exec('chmod +x tools/an') + ->exec('chmod +x tools/ua') + ->exec('chmod +x src/osdep/unix/drivers') + ->exec('chmod +x src/osdep/unix/mkauths') ->exec( "yes | make slx {$ssl_options}" ); diff --git a/src/SPC/builder/macos/library/imap.php b/src/SPC/builder/macos/library/imap.php index ab489ee6..2deb17ab 100644 --- a/src/SPC/builder/macos/library/imap.php +++ b/src/SPC/builder/macos/library/imap.php @@ -50,6 +50,10 @@ class imap extends MacOSLibraryBase shell()->cd($this->source_dir) ->exec('make clean') ->exec('touch ip6') + ->exec('chmod +x tools/an') + ->exec('chmod +x tools/ua') + ->exec('chmod +x src/osdep/unix/drivers') + ->exec('chmod +x src/osdep/unix/mkauths') ->exec( "yes | EXTRACFLAGS='-Wimplicit-function-declaration -include $(xcrun --show-sdk-path)/usr/include/poll.h -include $(xcrun --show-sdk-path)/usr/include/time.h -include $(xcrun --show-sdk-path)/usr/include/utime.h' make osx {$ssl_options}" ); From bff1a6168f810c2ec92c427b3980a25e5aafb70b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 00:38:16 +0800 Subject: [PATCH 122/415] fix imagemagick with curl,brotli errors symlink breaks imagemagick build --- src/SPC/builder/unix/library/brotli.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index e4ed1221..15568ef3 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -28,10 +28,10 @@ trait brotli ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); shell()->cd(BUILD_ROOT_PATH . '/lib') - ->exec('ln -sf libbrotlicommon.a libbrotlicommon-static.a') + ->exec('cp libbrotlicommon.a libbrotlicommon-static.a') ->exec('ln -sf libbrotlicommon.a libbrotli.a') - ->exec('ln -sf libbrotlidec.a libbrotlidec-static.a') - ->exec('ln -sf libbrotlienc.a libbrotlienc-static.a'); + ->exec('cp libbrotlidec.a libbrotlidec-static.a') + ->exec('cp libbrotlienc.a libbrotlienc-static.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'))) { unlink(BUILD_ROOT_PATH . '/lib/' . $filename); From daf0d2eb329cf90a0fd3d577ddf585bdba0e4fb8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 00:39:36 +0800 Subject: [PATCH 123/415] fix dependency sort --- config/lib.json | 6 +++--- src/SPC/builder/BuilderBase.php | 18 ++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/config/lib.json b/config/lib.json index 8ccb8091..da330f9b 100644 --- a/config/lib.json +++ b/config/lib.json @@ -327,12 +327,12 @@ "libxml2" ], "lib-depends": [ - "libiconv", - "zlib" + "libiconv" ], "lib-suggests": [ "xz", - "icu" + "icu", + "zlib" ] }, "libxslt": { diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 86254869..3c77c610 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -33,12 +33,12 @@ abstract class BuilderBase /** * Build libraries * - * @param array $libraries Libraries to build + * @param array $sorted_libraries Libraries to build (if not empty, must sort first) * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException */ - public function buildLibs(array $libraries): void + public function buildLibs(array $sorted_libraries): void { // search all supported libs $support_lib_list = []; @@ -53,20 +53,18 @@ abstract class BuilderBase } // if no libs specified, compile all supported libs - if ($libraries === [] && $this->isLibsOnly()) { + if ($sorted_libraries === [] && $this->isLibsOnly()) { $libraries = array_keys($support_lib_list); + $sorted_libraries = DependencyUtil::getLibsByDeps($libraries); } // pkg-config must be compiled first, whether it is specified or not - if (!in_array('pkg-config', $libraries)) { - array_unshift($libraries, 'pkg-config'); + if (!in_array('pkg-config', $sorted_libraries)) { + array_unshift($sorted_libraries, 'pkg-config'); } - // append dependencies - $libraries = DependencyUtil::getLibsByDeps($libraries); - // add lib object for builder - foreach ($libraries as $library) { + foreach ($sorted_libraries as $library) { // if some libs are not supported (but in config "lib.json", throw exception) if (!isset($support_lib_list[$library])) { throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); @@ -81,7 +79,7 @@ abstract class BuilderBase } // extract sources - SourceExtractor::initSource(libs: $libraries); + SourceExtractor::initSource(libs: $sorted_libraries); // build all libs foreach ($this->libs as $lib) { From 5549068275c2fd19290f93f6d187c43c72c11572 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 00:53:03 +0800 Subject: [PATCH 124/415] add download cache for tests --- .github/workflows/tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2db76bc4..18c5fd7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -133,6 +133,13 @@ jobs: restore-keys: | ${{ runner.os }}-php- + # Cache downloaded source + - id: cache-download + uses: actions/cache@v3 + with: + path: downloads + key: php-${{ matrix.php }}-dependencies + - name: "Install Dependencies" run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist From 5b581a54aa10cff9ccb43da17cf4e51af5de0d39 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 01:57:55 +0800 Subject: [PATCH 125/415] add docs config actions --- .github/workflows/update-docs-config.yml | 42 ++++++++++++++++++++++++ config/ext.json | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update-docs-config.yml diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml new file mode 100644 index 00000000..c8ef76f7 --- /dev/null +++ b/.github/workflows/update-docs-config.yml @@ -0,0 +1,42 @@ +name: Update Docs Config + +on: + push: + branches: + - main + paths: + - 'config/**.json' + +jobs: + update-docs-config: + name: "Update Docs Config" + runs-on: ubuntu-latest + if: secrets.DOCS_REPO_TOKEN != '' + steps: + - name: "Checkout static-php-cli" + uses: actions/checkout@v4 + with: + ref: main + path: static-php-cli + + - name: "Checkout static-php-cli-docs" + uses: actions/checkout@v4 + with: + repository: static-php/static-php-cli-docs + ref: master + path: static-php-cli-docs + + - name: "Set up Git" + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + + - name: "Copy Config Files" + run: cp -r static-php-cli/config/ static-php-cli-docs/docs/.vitepress/config/ + + - name: "Commit and Push Changes" + run: | + cd static-php-cli-docs + git add -A + git commit -m "Sync config files from main" + git push origin master diff --git a/config/ext.json b/config/ext.json index 64c859cd..b92e1798 100644 --- a/config/ext.json +++ b/config/ext.json @@ -403,10 +403,10 @@ "sqlsrv": { "type": "external", "source": "sqlsrv", + "cpp-extension": true, "lib-depends": [ "unixodbc" ], - "cpp-extension": true, "ext-depends-linux": [ "pcntl" ] From eda3a9b4865a38d83137ed3160f71fcaa654de7c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 01:58:31 +0800 Subject: [PATCH 126/415] add docs config actions --- .github/workflows/update-docs-config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml index c8ef76f7..01da56c7 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/update-docs-config.yml @@ -24,6 +24,7 @@ jobs: with: repository: static-php/static-php-cli-docs ref: master + token: ${{ secrets.DOCS_REPO_TOKEN }} path: static-php-cli-docs - name: "Set up Git" From 8d4a375400f511c34402123fce3ec9e8c83130bd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:03:04 +0800 Subject: [PATCH 127/415] fix if statement for workflow --- .github/workflows/release-build.yml | 2 +- .github/workflows/update-docs-config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 66d5bc06..57f5dc60 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -86,7 +86,7 @@ jobs: files: ${{ env.filename }} - name: "Deploy to Self-Hosted Server" - if: secrets.DEPLOY_SERVER_HOST != '' + if: ${{ secrets.DEPLOY_SERVER_HOST != '' }} uses: easingthemes/ssh-deploy@main env: SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml index 01da56c7..ca9329d8 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/update-docs-config.yml @@ -11,7 +11,7 @@ jobs: update-docs-config: name: "Update Docs Config" runs-on: ubuntu-latest - if: secrets.DOCS_REPO_TOKEN != '' + if: ${{ secrets.DOCS_REPO_TOKEN != '' }} steps: - name: "Checkout static-php-cli" uses: actions/checkout@v4 From 7b2c3ac12de833b115eb74f77ab4a4e2174d1b68 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:10:14 +0800 Subject: [PATCH 128/415] fix if statement for workflow --- .github/workflows/release-build.yml | 2 +- .github/workflows/update-docs-config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 57f5dc60..78b91a4c 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -86,7 +86,7 @@ jobs: files: ${{ env.filename }} - name: "Deploy to Self-Hosted Server" - if: ${{ secrets.DEPLOY_SERVER_HOST != '' }} + if: github.repository == 'crazywhalecc/static-php-cli' uses: easingthemes/ssh-deploy@main env: SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }} diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml index ca9329d8..a6fd90a3 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/update-docs-config.yml @@ -11,7 +11,7 @@ jobs: update-docs-config: name: "Update Docs Config" runs-on: ubuntu-latest - if: ${{ secrets.DOCS_REPO_TOKEN != '' }} + if: github.repository == 'crazywhalecc/static-php-cli' steps: - name: "Checkout static-php-cli" uses: actions/checkout@v4 From 450ec21c906b5e1491275de2b5548e2f7357715a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:11:46 +0800 Subject: [PATCH 129/415] remove main push test --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 18c5fd7c..fd93a719 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,8 +1,6 @@ name: Tests on: - push: - branches: [ "main" ] pull_request: branches: [ "main" ] From a0a0b01cc3f61341563fc868ebb3eafa0624dde2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:14:45 +0800 Subject: [PATCH 130/415] update config to test actions --- config/ext.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index b92e1798..2dfc67d6 100644 --- a/config/ext.json +++ b/config/ext.json @@ -403,13 +403,13 @@ "sqlsrv": { "type": "external", "source": "sqlsrv", - "cpp-extension": true, "lib-depends": [ "unixodbc" ], "ext-depends-linux": [ "pcntl" - ] + ], + "cpp-extension": true }, "ssh2": { "type": "external", From fce0c2f896e94eacc99e7b863ea452c57b6742d1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:16:17 +0800 Subject: [PATCH 131/415] update config to test actions --- .github/workflows/update-docs-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml index a6fd90a3..d29b7960 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/update-docs-config.yml @@ -33,7 +33,7 @@ jobs: git config --global user.name "GitHub Actions" - name: "Copy Config Files" - run: cp -r static-php-cli/config/ static-php-cli-docs/docs/.vitepress/config/ + run: cp -r static-php-cli/config/* static-php-cli-docs/docs/.vitepress/config/ - name: "Commit and Push Changes" run: | From ac005d1e0f956f469616070f49f9e27f141675d6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:16:50 +0800 Subject: [PATCH 132/415] update config to test actions --- config/source.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/source.json b/config/source.json index ba9480df..b62ac334 100644 --- a/config/source.json +++ b/config/source.json @@ -30,7 +30,7 @@ "regex": "/href=\"(?bzip2-(?[^\"]+)\\.tar\\.gz)\"/", "license": { "type": "text", - "text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement." + "text": "This program, \"bzip2\", the associated library \"libbzip2\", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved. \n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nJulian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010\n\nPATENTS: To the best of my knowledge, bzip2 and libbzip2 do not use any patented algorithms. However, I do not have the resources to carry out a patent search. Therefore I cannot give any guarantee of the above statement." } }, "curl": { From 0c2de9f936eb1fd563ccc3695d56c1b9a9fbdc27 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:22:35 +0800 Subject: [PATCH 133/415] run build test when changing test-extensions.php --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd93a719..f7138d01 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,6 +1,11 @@ name: Tests on: + push: + branches: + - main + paths: + - 'src/globals/test-extensions.php' pull_request: branches: [ "main" ] From a45f2f357d1539b313955678b3d1bed7ef851ded Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:28:44 +0800 Subject: [PATCH 134/415] test ldap --- 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 f1e82490..95573416 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -10,14 +10,14 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). -$extensions = 'swoole,uv'; +$extensions = 'ldap'; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = ''; // Please change your test base combination. We recommend testing with `common`. // You can use `common`, `bulk`, `minimal` or `none`. -$base_combination = 'minimal'; +$base_combination = 'common'; // -------------------------- code area, do not modify -------------------------- From 6efcb75224e0a39bcc38b7f4681b8f9dd6b004d8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 02:50:52 +0800 Subject: [PATCH 135/415] test ldap --- 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 95573416..93156f5f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -17,7 +17,7 @@ $with_libs = ''; // Please change your test base combination. We recommend testing with `common`. // You can use `common`, `bulk`, `minimal` or `none`. -$base_combination = 'common'; +$base_combination = 'minimal'; // -------------------------- code area, do not modify -------------------------- From ceed1005ccb5174f46e7000d6d00066332c59f4c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 03:01:09 +0800 Subject: [PATCH 136/415] remove unused download-cache workflow --- .github/workflows/download-cache.yml | 40 ---------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/download-cache.yml diff --git a/.github/workflows/download-cache.yml b/.github/workflows/download-cache.yml deleted file mode 100644 index 1d0a5f52..00000000 --- a/.github/workflows/download-cache.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: archive download sources weekly - -on: - workflow_dispatch: - schedule: - - cron: "* 14 * * 5" - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - download: - name: cache download sources - runs-on: ubuntu-latest - strategy: - matrix: - php-version: [ "8.0", "8.1", "8.2", "8.3" ] - steps: - - uses: actions/checkout@v3 - - # Cache composer dependencies - - id: cache-composer-deps - uses: actions/cache@v3 - with: - path: vendor - key: composer-dependencies - - # If there's no Composer cache, install dependencies - - if: steps.cache-composer-deps.outputs.cache-hit != 'true' - run: composer update --no-dev - - # If there's no dependencies cache, fetch sources, with or without debug - - if: steps.cache-download.outputs.cache-hit != 'true' - run: ./bin/spc download --with-php=${{ matrix.php-version }} --all --debug - - # Upload downloaded files - - uses: actions/upload-artifact@v3 - with: - name: download-files-${{ matrix.php-version }} - path: downloads/ From 0b322f494b0c66755854347c6f371b314a76195b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 03:08:17 +0800 Subject: [PATCH 137/415] test --- src/SPC/command/BuildCliCommand.php | 2 ++ src/SPC/command/BuildLibsCommand.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 5bd0bba3..412520c9 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -102,6 +102,8 @@ class BuildCliCommand extends BuildCommand SourcePatcher::patchHardcodedINI($custom_ini); } + shell(true)->cd(BUILD_LIB_PATH)->exec('cat pkgconfig/ldap.pc'); + logger()->info('TEST BREAKPOINT'); // start to build $builder->buildPHP($rule); diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index be49f86a..f3fb8897 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -7,6 +7,7 @@ namespace SPC\command; use SPC\builder\BuilderProvider; use SPC\exception\ExceptionHandler; use SPC\exception\RuntimeException; +use SPC\util\DependencyUtil; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -59,6 +60,7 @@ class BuildLibsCommand extends BuildCommand // 只编译 library 的情况下,标记 $builder->setLibsOnly(); // 编译和检查库完整 + $libraries = DependencyUtil::getLibsByDeps($libraries); $builder->buildLibs($libraries); $time = round(microtime(true) - START_TIME, 3); From 6562bc200c4771b77e103adc2ab40a8946cf8fca Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 10:38:08 +0800 Subject: [PATCH 138/415] fix ldap for macos x86_64 --- src/SPC/builder/unix/library/ldap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index a557eb8e..fd6f7105 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -10,7 +10,7 @@ trait ldap { $alt = ''; // openssl support - $alt .= $this->builder->getLib('openssl') && $this->builder->getExt('zlib') ? '--with-tls=openssl ' : ''; + $alt .= ($this->builder->getLib('openssl') && $this->builder->getExt('zlib')) ? '--with-tls=openssl ' : ''; // gmp support $alt .= $this->builder->getLib('gmp') ? '--with-mp=gmp ' : ''; // libsodium support From d4eb199504183a2c4fe640d298aedbb94405fd27 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 10:54:49 +0800 Subject: [PATCH 139/415] use non-static suffix for brotli --- config/lib.json | 12 ++++++------ src/SPC/builder/unix/library/brotli.php | 6 +----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/config/lib.json b/config/lib.json index da330f9b..a56d8772 100644 --- a/config/lib.json +++ b/config/lib.json @@ -2,14 +2,14 @@ "brotli": { "source": "brotli", "static-libs-unix": [ - "libbrotlidec-static.a", - "libbrotlienc-static.a", - "libbrotlicommon-static.a" + "libbrotlidec.a", + "libbrotlienc.a", + "libbrotlicommon.a" ], "static-libs-windows": [ - "brotlicommon-static.lib", - "brotlienc-static.lib", - "brotlidec-static.lib" + "brotlicommon.lib", + "brotlienc.lib", + "brotlidec.lib" ], "headers": [ "brotli" diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 15568ef3..08eae3a1 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -27,11 +27,7 @@ trait brotli ->exec("cmake --build . -j {$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); - shell()->cd(BUILD_ROOT_PATH . '/lib') - ->exec('cp libbrotlicommon.a libbrotlicommon-static.a') - ->exec('ln -sf libbrotlicommon.a libbrotli.a') - ->exec('cp libbrotlidec.a libbrotlidec-static.a') - ->exec('cp libbrotlienc.a libbrotlienc-static.a'); + 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'))) { unlink(BUILD_ROOT_PATH . '/lib/' . $filename); From d3d8230a0921e68aa4dde8f6b21e83c57b91e186 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 11:09:26 +0800 Subject: [PATCH 140/415] add openssl patch --- src/SPC/builder/unix/library/ldap.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index fd6f7105..807abc2b 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -4,17 +4,25 @@ declare(strict_types=1); namespace SPC\builder\unix\library; +use SPC\store\FileSystem; + trait ldap { + public function patchBeforeBuild(): bool + { + FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lz -lssl -lcrypto'); + return true; + } + protected function build(): void { $alt = ''; // openssl support - $alt .= ($this->builder->getLib('openssl') && $this->builder->getExt('zlib')) ? '--with-tls=openssl ' : ''; + $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 ' : ''; + $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) @@ -24,7 +32,6 @@ trait ldap '--enable-static ' . '--disable-shared ' . '--disable-slapd ' . - '--disable-slurpd ' . '--without-systemd ' . '--without-cyrus-sasl ' . $alt . From 81df124b42fcd378d18685c59d8a009fd096cd32 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 11:17:25 +0800 Subject: [PATCH 141/415] update README badge [skip ci] --- README-zh.md | 6 +++--- README.md | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README-zh.md b/README-zh.md index da571330..68602e84 100755 --- a/README-zh.md +++ b/README-zh.md @@ -14,10 +14,10 @@ Build single static PHP binary, with PHP project together, with popular extensio > 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/static-php/phpmicro)。 -[![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0.0-green.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/static-php/static-php-cli-hosted/build-php-common.yml?branch=refactor&label=Build%20Common%20Extensions&style=flat-square)](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml) -[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]() +[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]() [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() > 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 diff --git a/README.md b/README.md index 6014d943..541b8349 100755 --- a/README.md +++ b/README.md @@ -18,11 +18,10 @@ You can also use the micro binary file to combine php binary and php source code > This SAPI feature is from the [Fork](https://github.com/static-php/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). -[![Version](https://img.shields.io/badge/Version-2.0--rc8-pink.svg?style=flat-square)]() +[![Version](https://img.shields.io/badge/Version-2.0.0-green.svg?style=flat-square)]() [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) - -[![](https://img.shields.io/badge/Extension%20Counter-65+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) +[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) [![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() ## Documentation From 13e0e12181d9f2d1f67616a180e7a7a07c445084 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 11:37:06 +0800 Subject: [PATCH 142/415] update patch order --- src/SPC/builder/unix/library/ldap.php | 2 +- src/SPC/command/BuildCliCommand.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index 807abc2b..d1807d89 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -10,7 +10,7 @@ trait ldap { public function patchBeforeBuild(): bool { - FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lz -lssl -lcrypto'); + FileSystem::replaceFileStr($this->source_dir . '/configure', '"-lssl -lcrypto', '"-lssl -lcrypto -lz'); return true; } diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 412520c9..5bd0bba3 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -102,8 +102,6 @@ class BuildCliCommand extends BuildCommand SourcePatcher::patchHardcodedINI($custom_ini); } - shell(true)->cd(BUILD_LIB_PATH)->exec('cat pkgconfig/ldap.pc'); - logger()->info('TEST BREAKPOINT'); // start to build $builder->buildPHP($rule); From 25a2684e5ae2cb032d032b6a9785e08f081cf59a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Jan 2024 12:07:00 +0800 Subject: [PATCH 143/415] add ldap patches (why ext-ldap doesn't use pkg-config to find ldap?) --- src/SPC/builder/extension/ldap.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/SPC/builder/extension/ldap.php diff --git a/src/SPC/builder/extension/ldap.php b/src/SPC/builder/extension/ldap.php new file mode 100644 index 00000000..4616bea8 --- /dev/null +++ b/src/SPC/builder/extension/ldap.php @@ -0,0 +1,23 @@ +execWithResult('$PKG_CONFIG --libs-only-l --static ldap'); + if (!empty($output[1][0])) { + $libs = $output[1][0]; + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lldap ', $libs . ' '); + } + return true; + } +} From 8d2f6baaa27ff9510770a36ab4693e2eb6e9c16b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 7 Jan 2024 12:54:48 +0800 Subject: [PATCH 144/415] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 541b8349..aa7f1043 100755 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Build single static PHP binary, with PHP project together, with popular extensio 🌐 **[中文](README-zh.md)** | **[English](README.md)** -> 2.0 Release is coming soon, windows support will be added in v2.1. +> Windows support will be added in v2.1. The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 From f9e7af1c9a8c9e715614d15c87bf9aaf3162da15 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 8 Jan 2024 23:34:17 +0800 Subject: [PATCH 145/415] add deepin support for doctor --- src/SPC/builder/linux/SystemUtil.php | 17 +++++++++++++++++ src/SPC/doctor/item/LinuxToolCheckList.php | 7 ++++--- src/SPC/doctor/item/OSCheckList.php | 5 +++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index 34b9cdef..e04c8e10 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -209,4 +209,21 @@ class SystemUtil } return $ret; } + + /** + * Get fully-supported linux distros. + * + * @return string[] List of supported Linux distro name for doctor + */ + public static function getSupportedDistros(): array + { + return [ + // debian-like + 'debian', 'ubuntu', 'Deepin', + // rhel-like + 'redhat', + // alpine + 'alpine', + ]; + } } diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index 01df03d6..f57f01ce 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -62,6 +62,7 @@ class LinuxToolCheckList 'ubuntu', 'alpine', 'redhat', + 'Deepin', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'), }; @@ -70,7 +71,7 @@ class LinuxToolCheckList } /** @noinspection PhpUnused */ - #[AsCheckItem('if necessary packages are installed', limit_os: 'Linux')] + #[AsCheckItem('if necessary linux headers are installed', limit_os: 'Linux')] public function checkSystemOSPackages(): ?CheckResult { if (SystemUtil::isMuslDist()) { @@ -90,7 +91,7 @@ class LinuxToolCheckList public function fixBuildTools(array $distro, array $missing): bool { $install_cmd = match ($distro['dist']) { - 'ubuntu', 'debian' => 'apt-get install -y', + 'ubuntu', 'debian', 'Deepin' => 'apt-get install -y', 'alpine' => 'apk add', 'redhat' => 'dnf install -y', default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), @@ -101,7 +102,7 @@ class LinuxToolCheckList logger()->warning('Current user is not root, using sudo for running command'); } try { - $is_debian = in_array($distro['dist'], ['debian', 'ubuntu']); + $is_debian = in_array($distro['dist'], ['debian', 'ubuntu', 'Deepin']); $to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing; // debian, alpine libtool -> libtoolize $to_install = str_replace('libtoolize', 'libtool', $to_install); diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index 8c7aa762..eef30f60 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -13,13 +13,14 @@ class OSCheckList { use UnixSystemUtilTrait; - #[AsCheckItem('if current OS are supported', level: 999)] + #[AsCheckItem('if current OS are supported', level: 1000)] public function checkOS(): ?CheckResult { if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD', 'Windows'])) { return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY); } $distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : ''; - return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported'); + $known_distro = PHP_OS_FAMILY === 'Linux' && in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros()); + return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)')); } } From 12ea3218e89409b368fc8a9b2aa86230727408d6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 8 Jan 2024 23:32:04 +0800 Subject: [PATCH 146/415] fix --from-zip not working bug --- src/SPC/command/DownloadCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 15d55e88..5bb6e79d 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -188,7 +188,8 @@ class DownloadCommand extends BaseCommand // create downloads try { if (PHP_OS_FAMILY !== 'Windows') { - f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($path)); + $abs_path = realpath($path); + f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($abs_path)); } // Windows TODO From 149e844d59c7c276415063503a6bae8b88df865e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 3 Jan 2024 15:57:05 +0800 Subject: [PATCH 147/415] add `--with-added-patch` command --- src/SPC/builder/BuilderBase.php | 48 ++++++++++++++++++++++++++ src/SPC/builder/LibraryBase.php | 2 ++ src/SPC/builder/freebsd/BSDBuilder.php | 4 +++ src/SPC/builder/linux/LinuxBuilder.php | 5 +++ src/SPC/builder/macos/MacOSBuilder.php | 4 +++ src/SPC/command/BuildCliCommand.php | 2 ++ 6 files changed, 65 insertions(+) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 3c77c610..175aaf41 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 SPC\exception\ExceptionHandler; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; @@ -30,6 +31,9 @@ abstract class BuilderBase /** @var array compile options */ protected array $options = []; + /** @var string patch point name */ + protected string $patch_point = ''; + /** * Build libraries * @@ -78,9 +82,14 @@ abstract class BuilderBase $lib->calcDependency(); } + // patch point + $this->emitPatchPoint('before-libs-extract'); + // extract sources SourceExtractor::initSource(libs: $sorted_libraries); + $this->emitPatchPoint('after-libs-extract'); + // build all libs foreach ($this->libs as $lib) { match ($lib->tryBuild($this->getOption('rebuild', false))) { @@ -189,11 +198,17 @@ abstract class BuilderBase public function proveExts(array $extensions): void { CustomExt::loadCustomExt(); + $this->emitPatchPoint('before-php-extract'); SourceExtractor::initSource(sources: ['php-src']); + $this->emitPatchPoint('after-php-extract'); if ($this->getPHPVersionID() >= 80000) { + $this->emitPatchPoint('before-micro-extract'); SourceExtractor::initSource(sources: ['micro']); + $this->emitPatchPoint('after-micro-extract'); } + $this->emitPatchPoint('before-exts-extract'); SourceExtractor::initSource(exts: $extensions); + $this->emitPatchPoint('after-exts-extract'); foreach ($extensions as $extension) { $class = CustomExt::getExtClass($extension); $ext = new $class($extension, $this); @@ -342,6 +357,39 @@ abstract class BuilderBase return implode(' ', $env); } + /** + * Get builder patch point name. + */ + public function getPatchPoint(): string + { + return $this->patch_point; + } + + public function emitPatchPoint(string $point_name): void + { + $this->patch_point = $point_name; + if (($patches = $this->getOption('with-added-patch', [])) === []) { + return; + } + + foreach ($patches as $patch) { + try { + if (!file_exists($patch)) { + throw new RuntimeException("Additional patch script file {$patch} not found!"); + } + logger()->debug('Running additional patch script: ' . $patch); + require $patch; + } catch (\Throwable $e) { + logger()->critical('Patch script ' . $patch . ' failed to run.'); + if ($this->getOption('debug')) { + ExceptionHandler::getInstance()->handle($e); + } else { + logger()->critical('Please check with --debug option to see more details.'); + } + } + } + } + /** * Check if all libs are downloaded. * If not, throw exception. diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index bd7752ac..51ab7e30 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -140,7 +140,9 @@ abstract class LibraryBase if (!$this->patched && $this->patchBeforeBuild()) { file_put_contents($this->source_dir . '/.spc.patched', 'PATCHED!!!'); } + $this->getBuilder()->emitPatchPoint('before-library[ ' . static::NAME . ']-build'); $this->build(); + $this->getBuilder()->emitPatchPoint('after-library[ ' . static::NAME . ']-build'); return BUILD_STATUS_OK; } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 469c7534..ddad0ca9 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -81,10 +81,12 @@ class BSDBuilder extends BuilderBase } $this->setOption('extra-libs', $extra_libs); + $this->emitPatchPoint('before-php-buildconf'); SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); + $this->emitPatchPoint('before-php-configure'); SourcePatcher::patchBeforeConfigure($this); $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; @@ -115,6 +117,7 @@ class BSDBuilder extends BuilderBase $this->makeExtensionArgs() ); + $this->emitPatchPoint('before-php-make'); SourcePatcher::patchBeforeMake($this); $this->cleanMake(); @@ -140,6 +143,7 @@ class BSDBuilder extends BuilderBase } 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 8fe8010c..e01028be 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -147,10 +147,13 @@ class LinuxBuilder extends BuilderBase 'LDFLAGS' => '-L' . BUILD_LIB_PATH, 'LIBS' => '-ldl -lpthread', ]); + + $this->emitPatchPoint('before-php-buildconf'); SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); + $this->emitPatchPoint('before-php-configure'); SourcePatcher::patchBeforeConfigure($this); $phpVersionID = $this->getPHPVersionID(); @@ -193,6 +196,7 @@ class LinuxBuilder extends BuilderBase ' ' . $envs_build_php . ' ' ); + $this->emitPatchPoint('before-php-make'); SourcePatcher::patchBeforeMake($this); $this->cleanMake(); @@ -218,6 +222,7 @@ class LinuxBuilder extends BuilderBase } if (php_uname('m') === $this->getOption('arch')) { + $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 6a60b33d..c7ac7107 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -141,10 +141,12 @@ class MacOSBuilder extends BuilderBase } $this->setOption('extra-libs', $extra_libs); + $this->emitPatchPoint('before-php-buildconf'); SourcePatcher::patchBeforeBuildconf($this); shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); + $this->emitPatchPoint('before-php-configure'); SourcePatcher::patchBeforeConfigure($this); $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; @@ -190,6 +192,7 @@ class MacOSBuilder extends BuilderBase $envs_build_php ); + $this->emitPatchPoint('before-php-make'); SourcePatcher::patchBeforeMake($this); $this->cleanMake(); @@ -215,6 +218,7 @@ class MacOSBuilder extends BuilderBase } if (php_uname('m') === $this->getOption('arch')) { + $this->emitPatchPoint('before-sanity-check'); $this->sanityCheck($build_target); } } diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 5bd0bba3..82f6b78a 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -35,6 +35,8 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli'); $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); + $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); + } public function handle(): int From e973fe743e503db2fca99e1e689ab1b80620738d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 3 Jan 2024 16:02:12 +0800 Subject: [PATCH 148/415] add BuilderProvider::getBuilder() function --- src/SPC/builder/BuilderProvider.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index 552af229..23bcf6c5 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -17,6 +17,8 @@ use Symfony\Component\Console\Input\InputInterface; */ class BuilderProvider { + private static ?BuilderBase $builder = null; + /** * @throws FileSystemException * @throws RuntimeException @@ -24,7 +26,7 @@ class BuilderProvider */ public static function makeBuilderByInput(InputInterface $input): BuilderBase { - return match (PHP_OS_FAMILY) { + self::$builder = match (PHP_OS_FAMILY) { // 'Windows' => new WindowsBuilder( // binary_sdk_dir: $input->getOption('with-sdk-binary-dir'), // vs_ver: $input->getOption('vs-ver'), @@ -35,5 +37,17 @@ class BuilderProvider 'BSD' => new BSDBuilder($input->getOptions()), default => throw new WrongUsageException('Current OS "' . PHP_OS_FAMILY . '" is not supported yet'), }; + return self::$builder; + } + + /** + * @throws WrongUsageException + */ + public function getBuilder(): BuilderBase + { + if (self::$builder === null) { + throw new WrongUsageException('Builder has not been initialized'); + } + return self::$builder; } } From 7620d5900ecb59ec1b6fc3ac6bd29d8b898a2a8b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 3 Jan 2024 16:06:44 +0800 Subject: [PATCH 149/415] cs fix --- src/SPC/command/BuildCliCommand.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 82f6b78a..4913751c 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -36,7 +36,6 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); - } public function handle(): int From fdc00301c09db97856773f048c71d5888156ff8f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 9 Jan 2024 10:35:14 +0800 Subject: [PATCH 150/415] add builder() and patch_point() global functions --- src/SPC/builder/BuilderProvider.php | 2 +- src/globals/functions.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index 23bcf6c5..d1e0cd77 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -43,7 +43,7 @@ class BuilderProvider /** * @throws WrongUsageException */ - public function getBuilder(): BuilderBase + public static function getBuilder(): BuilderBase { if (self::$builder === null) { throw new WrongUsageException('Builder has not been initialized'); diff --git a/src/globals/functions.php b/src/globals/functions.php index e48eaeeb..7b7540b3 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -3,6 +3,8 @@ declare(strict_types=1); use Psr\Log\LoggerInterface; +use SPC\builder\BuilderBase; +use SPC\builder\BuilderProvider; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\util\UnixShell; @@ -127,3 +129,23 @@ function cmd(?bool $debug = null): WindowsCmd { return new WindowsCmd($debug); } + +/** + * Get current builder. + * + * @throws WrongUsageException + */ +function builder(): BuilderBase +{ + return BuilderProvider::getBuilder(); +} + +/** + * Get current patch point. + * + * @throws WrongUsageException + */ +function patch_point(): string +{ + return BuilderProvider::getBuilder()->getPatchPoint(); +} From a7d5a48b489d4dcdcf1b3a240d550c7e95fb90e8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 9 Jan 2024 10:40:30 +0800 Subject: [PATCH 151/415] bump version to 2.0.1 --- 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 5ab014fa..a067e88d 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0.0'; + public const VERSION = '2.0.1'; public function __construct() { From 8de942c27464546a67e24a6664e8e47e2c8d9e7d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 10 Jan 2024 11:10:40 +0800 Subject: [PATCH 152/415] Adjust function to protected (#315) * add `--with-added-patch` command * add BuilderProvider::getBuilder() function * cs fix * add builder() and patch_point() global functions * bump version to 2.0.1 * adjust function prefix * adjust function prefix --- src/SPC/builder/BuilderBase.php | 4 ++ src/SPC/builder/freebsd/BSDBuilder.php | 8 +-- src/SPC/builder/linux/LinuxBuilder.php | 8 +-- src/SPC/builder/macos/MacOSBuilder.php | 8 +-- src/SPC/builder/traits/UnixBuilderTrait.php | 80 ++++++++++----------- 5 files changed, 56 insertions(+), 52 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 175aaf41..729a46c5 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -41,6 +41,7 @@ abstract class BuilderBase * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException + * @internal */ public function buildLibs(array $sorted_libraries): void { @@ -181,6 +182,8 @@ abstract class BuilderBase /** * Set libs only mode. + * + * @internal */ public function setLibsOnly(bool $status = true): void { @@ -194,6 +197,7 @@ abstract class BuilderBase * @throws RuntimeException * @throws \ReflectionException * @throws WrongUsageException + * @internal */ public function proveExts(array $extensions): void { diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index ddad0ca9..b1fa8851 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -154,7 +154,7 @@ class BSDBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildCli(): void + protected function buildCli(): void { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size @@ -177,7 +177,7 @@ class BSDBuilder extends BuilderBase * @throws RuntimeException * @throws WrongUsageException */ - public function buildMicro(): void + protected function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); @@ -215,7 +215,7 @@ class BSDBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildFpm(): void + protected function buildFpm(): void { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size @@ -235,7 +235,7 @@ class BSDBuilder extends BuilderBase * * @throws RuntimeException */ - public function buildEmbed(): void + protected function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString([ 'EXTRA_CFLAGS' => '-g -Os', // with debug information, but optimize for size diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index e01028be..f99c9bca 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -233,7 +233,7 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildCli(): void + protected function buildCli(): void { $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); shell()->cd(SOURCE_PATH . '/php-src') @@ -254,7 +254,7 @@ class LinuxBuilder extends BuilderBase * @throws RuntimeException * @throws WrongUsageException */ - public function buildMicro(): void + protected function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); @@ -288,7 +288,7 @@ class LinuxBuilder extends BuilderBase * @throws FileSystemException * @throws RuntimeException */ - public function buildFpm(): void + protected function buildFpm(): void { $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); shell()->cd(SOURCE_PATH . '/php-src') @@ -307,7 +307,7 @@ class LinuxBuilder extends BuilderBase * * @throws RuntimeException */ - public function buildEmbed(): void + protected function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index c7ac7107..b74aaa60 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -229,7 +229,7 @@ class MacOSBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildCli(): void + protected function buildCli(): void { $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); @@ -248,7 +248,7 @@ class MacOSBuilder extends BuilderBase * @throws RuntimeException * @throws WrongUsageException */ - public function buildMicro(): void + protected function buildMicro(): void { if ($this->getPHPVersionID() < 80000) { throw new WrongUsageException('phpmicro only support PHP >= 8.0!'); @@ -284,7 +284,7 @@ class MacOSBuilder extends BuilderBase * @throws RuntimeException * @throws FileSystemException */ - public function buildFpm(): void + protected function buildFpm(): void { $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); @@ -301,7 +301,7 @@ class MacOSBuilder extends BuilderBase * * @throws RuntimeException */ - public function buildEmbed(): void + protected function buildEmbed(): void { $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); diff --git a/src/SPC/builder/traits/UnixBuilderTrait.php b/src/SPC/builder/traits/UnixBuilderTrait.php index 3fead06f..e369fb04 100644 --- a/src/SPC/builder/traits/UnixBuilderTrait.php +++ b/src/SPC/builder/traits/UnixBuilderTrait.php @@ -49,12 +49,49 @@ trait UnixBuilderTrait return array_map(fn ($x) => realpath(BUILD_LIB_PATH . "/{$x}"), $libFiles); } + /** + * Return generic cmake options when configuring cmake projects + */ + public function makeCmakeArgs(): string + { + $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : ''; + return $extra . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DCMAKE_INSTALL_PREFIX=/ ' . + '-DCMAKE_INSTALL_BINDIR=/bin ' . + '-DCMAKE_INSTALL_LIBDIR=/lib ' . + '-DCMAKE_INSTALL_INCLUDEDIR=/include ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}"; + } + + /** + * Generate configure flags + */ + public function makeAutoconfFlags(int $flag = AUTOCONF_ALL): string + { + $extra = ''; + // TODO: add auto pkg-config support + if (($flag & AUTOCONF_LIBS) === AUTOCONF_LIBS) { + $extra .= 'LIBS="' . BUILD_LIB_PATH . '" '; + } + if (($flag & AUTOCONF_CFLAGS) === AUTOCONF_CFLAGS) { + $extra .= 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" '; + } + if (($flag & AUTOCONF_CPPFLAGS) === AUTOCONF_CPPFLAGS) { + $extra .= 'CPPFLAGS="-I' . BUILD_INCLUDE_PATH . '" '; + } + if (($flag & AUTOCONF_LDFLAGS) === AUTOCONF_LDFLAGS) { + $extra .= 'LDFLAGS="-L' . BUILD_LIB_PATH . '" '; + } + return $extra; + } + /** * Sanity check after build complete * * @throws RuntimeException */ - public function sanityCheck(int $build_target): void + protected function sanityCheck(int $build_target): void { // sanity check for php-cli if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { @@ -95,7 +132,7 @@ trait UnixBuilderTrait * @throws RuntimeException * @throws FileSystemException */ - public function deployBinary(int $type): bool + protected function deployBinary(int $type): bool { $src = match ($type) { BUILD_TARGET_CLI => SOURCE_PATH . '/php-src/sapi/cli/php', @@ -114,46 +151,9 @@ trait UnixBuilderTrait * * @throws RuntimeException */ - public function cleanMake(): void + protected function cleanMake(): void { logger()->info('cleaning up'); shell()->cd(SOURCE_PATH . '/php-src')->exec('make clean'); } - - /** - * Return generic cmake options when configuring cmake projects - */ - public function makeCmakeArgs(): string - { - $extra = $this instanceof LinuxBuilder ? '-DCMAKE_C_COMPILER=' . getenv('CC') . ' ' : ''; - return $extra . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DCMAKE_INSTALL_PREFIX=/ ' . - '-DCMAKE_INSTALL_BINDIR=/bin ' . - '-DCMAKE_INSTALL_LIBDIR=/lib ' . - '-DCMAKE_INSTALL_INCLUDEDIR=/include ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->cmake_toolchain_file}"; - } - - /** - * Generate configure flags - */ - public function makeAutoconfFlags(int $flag = AUTOCONF_ALL): string - { - $extra = ''; - // TODO: add auto pkg-config support - if (($flag & AUTOCONF_LIBS) === AUTOCONF_LIBS) { - $extra .= 'LIBS="' . BUILD_LIB_PATH . '" '; - } - if (($flag & AUTOCONF_CFLAGS) === AUTOCONF_CFLAGS) { - $extra .= 'CFLAGS="-I' . BUILD_INCLUDE_PATH . '" '; - } - if (($flag & AUTOCONF_CPPFLAGS) === AUTOCONF_CPPFLAGS) { - $extra .= 'CPPFLAGS="-I' . BUILD_INCLUDE_PATH . '" '; - } - if (($flag & AUTOCONF_LDFLAGS) === AUTOCONF_LDFLAGS) { - $extra .= 'LDFLAGS="-L' . BUILD_LIB_PATH . '" '; - } - return $extra; - } } From 17b69ec1e93e4e976b16f5e278503c6a467d262e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 11:11:45 +0800 Subject: [PATCH 153/415] update README --- README-zh.md | 161 +++++++++++++++++++++++++---------------------- README.md | 172 ++++++++++++++++++++++++++------------------------- 2 files changed, 173 insertions(+), 160 deletions(-) diff --git a/README-zh.md b/README-zh.md index 68602e84..9791335a 100755 --- a/README-zh.md +++ b/README-zh.md @@ -1,32 +1,44 @@ # static-php-cli -Build single static PHP binary, with PHP project together, with popular extensions included. - -🌐 **[中文](README-zh.md)** | **[English](README.md)** - -编译纯静态的 PHP Binary 二进制文件,带有各种扩展,让 PHP-cli 应用变得更便携!(cli SAPI) - -截屏2023-05-02 15 53 13 - -同时可以使用 micro 二进制文件,将 PHP 源码和 PHP 二进制构建为一个文件分发!(micro SAPI) - -截屏2023-05-02 15 52 33 - -> 该 SAPI 源自 [dixyes/phpmicro](https://github.com/dixyes/phpmicro) 的 [Fork 仓库](https://github.com/static-php/phpmicro)。 - -[![Version](https://img.shields.io/badge/Version-2.0.0-green.svg?style=flat-square)]() -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() +[![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) -[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]() -[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() +[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) +[![](https://dcbadge.vercel.app/api/server/RNpegEYW?style=flat-square&compact=true&theme=default-inverted)](https://discord.gg/RNpegEYW) -> 项目名称是 static-php-cli,但其实支持 cli、fpm、micro 和 embed SAPI 😎 +**static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。 + +目前 static-php-cli 支持 `cli`、`fpm`、`embed` 和 `micro` SAPI。 + +**static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。 + +- [README - English](./README.md) +- [README - 中文](./README-zh.md) + +## 特性 + +static-php-cli(简称 `spc`)有许多特性: + +- :handbag: 构建独立的单文件 PHP 解释器,无需任何依赖 +- :hamburger: 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自执行二进制(将 PHP 代码和 PHP 解释器打包为一个文件) +- :pill: 提供一键检查和修复编译环境的 Doctor 模块 +- :zap: 支持多个系统:`Linux`、`macOS`、`FreeBSD`、[`Windows (WIP)`](https://github.com/crazywhalecc/static-php-cli/pull/301) +- :wrench: 高度自定义的代码 patch 功能 +- :books: 自带编译依赖管理 +- 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建) +- :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html) + +**静态 php-cli:** +out1 + +**使用 phpmicro 打包 PHP 代码:** +out2 ## 文档 目前 README 编写了基本用法。有关 static-php-cli 所有的功能,请点击这里查看文档:。 -## 自托管直接下载 +## 直接下载 如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载。 @@ -38,6 +50,10 @@ Build single static PHP binary, with PHP project together, with popular extensio ### 编译环境需求 +- PHP >= 8.1(spc 自身是用 PHP 写的) +- 扩展:`mbstring,pcntl,posix,tokenizer,phar` +- 系统安装了 `curl` 和 `git` + 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 @@ -50,11 +66,9 @@ Build single static PHP binary, with PHP project together, with popular extensio | Windows | | | | FreeBSD | :computer: | :computer: | -> macOS-arm64 因 GitHub 暂未提供 arm runner,如果要构建 arm 二进制,可以使用手动构建。 - 目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 -### 支持的扩展情况 +### 支持的扩展 请先根据下方扩展列表选择你要编译的扩展。 @@ -63,7 +77,7 @@ Build single static PHP binary, with PHP project together, with popular extensio > 如果这里没有你需要的扩展,可以提交 Issue。 -### 使用 Actions 构建 +### 在线构建(使用 GitHub Actions) 使用 GitHub Action 可以方便地构建一个静态编译的 PHP,同时可以自行定义要编译的扩展。 @@ -74,72 +88,77 @@ Build single static PHP binary, with PHP project together, with popular extensio 如果你选择了 `debug`,则会在构建时输出所有日志,包括编译的日志,以供排查错误。 -### 手动构建(使用 SPC 二进制) +### 本地构建(使用 spc 二进制) -本项目提供了一个 static-php-cli 的二进制文件,你可以直接下载对应平台的二进制文件,然后使用它来构建静态的 PHP。目前 `spc` 二进制支持的平台有 Linux 和 macOS。 +该项目提供了 static-php-cli 的二进制文件:`spc`。 +您可以使用 `spc` 二进制文件,无需安装任何运行时(用起来就像 golang 程序)。 +目前,`spc` 二进制文件提供的平台有 Linux 和 macOS。 -下面是从 GitHub Action 下载的方法: - -1. 进入 [GitHub Action](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。 -2. 选择一个最新的构建任务,进入后选择 `Artifacts`,下载对应平台的二进制文件。 -3. 解压 `.zip` 文件。解压后,为其添加执行权限:`chmod +x ./spc`。 - -你也可以从自托管的服务器下载二进制文件:[进入](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/)。 - -### 手动构建(使用源码) - -先克隆本项目: +使用以下命令从自托管服务器下载: ```bash +# Download from self-hosted nightly builds (sync with main branch) +# For Linux x86_64 +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64 +# For Linux aarch64 +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64 +# macOS x86_64 (Intel) +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64 +# macOS aarch64 (Apple) +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64 + +# add x perm +chmod +x ./spc +./spc --version +``` + +自托管 `spc` 由 GitHub Actions 构建,你也可以从 Actions 直接下载:[此处](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。 + +### 本地构建(使用 git 源码) + +```bash +# clone 仓库即可 git clone https://github.com/crazywhalecc/static-php-cli.git ``` -如果你本机没有安装 PHP,你需要先使用包管理(例如 brew、apt、yum、apk 等)安装 php。 - -你也可以通过 `bin/setup-runtime` 命令下载静态编译好的 php-cli 和 Composer。下载的 php 和 Composer 将保存为 `bin/php` 和 `bin/composer`。 +如果您的系统上尚未安装 php,我们建议你使用内置的 setup-runtime 自动安装 PHP 和 Composer。 ```bash cd static-php-cli chmod +x bin/setup-runtime -./bin/setup-runtime - -# 使用独立的 php 运行 static-php-cli -./bin/php bin/spc - -# 使用 composer -./bin/php bin/composer - -# 初始化本项目 -cd static-php-cli -composer update +# it will download static php (from self-hosted server) and composer (from getcomposer) +bin/setup-runtime +# initialize composer deps +bin/composer install +# chmod chmod +x bin/spc +bin/spc --version ``` -### 使用 static-php-cli 命令行程序 +### 开始构建 PHP -下面是使用 static-php-cli 编译静态 php 和 micro 的基础用法: +下面是使用 static-php-cli 的基础用法: -> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `bin/spc` 替换为 `./spc`。 +> 如果你使用的是打包好的 `spc` 二进制,你需要将下列命令的 `./bin/spc` 替换为 `./spc`。 ```bash -# 检查环境依赖,并根据提示的命令安装缺失的编译工具 -./bin/spc doctor +# 检查环境依赖,并根据尝试自动安装缺失的编译工具 +./bin/spc doctor --auto-fix + # 拉取所有依赖库 -./bin/spc fetch --all -# 只拉取编译指定扩展需要的所有依赖 +./bin/spc download --all +# 只拉取编译指定扩展需要的所有依赖(推荐) ./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite +# 下载编译不同版本的 PHP (--with-php=x.y,推荐 7.3 ~ 8.3) +./bin/spc download --for-extensions=openssl,curl,mbstring --with-php=8.1 + # 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx ./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro +# 编译线程安全版本 (--enable-zts) +./bin/spc build curl,phar --enable-zts --build-cli ``` -你也可以使用参数 `--with-php=x.y` 来指定下载的 PHP 版本,目前支持 7.3 ~ 8.3: - -```bash -# 优先考虑使用 >= 8.0 的 PHP 版本,因为 phpmicro 不支持在 PHP7 中构建 -./bin/spc download --with-php=8.2 --all -``` - -其中,目前支持构建 cli,micro,fpm 三种静态二进制,使用以下参数的一个或多个来指定编译的 SAPI: +其中,目前支持构建 cli,micro,fpm 和 embed,使用以下参数的一个或多个来指定编译的 SAPI: - `--build-cli`:构建 cli 二进制 - `--build-micro`:构建 phpmicro 自执行二进制 @@ -151,17 +170,9 @@ chmod +x bin/spc ```bash ./bin/spc build openssl,pcntl,mbstring --debug --build-all -./bin/spc fetch --all --debug +./bin/spc download --all --debug ``` -此外,默认编译的 PHP 为 NTS 版本。如需编译线程安全版本(ZTS),只需添加参数 `--enable-zts` 即可。 - -```bash -./bin/spc build openssl,pcntl --build-all --enable-zts -``` - -同时,你也可以使用参数 `--no-strip` 来关闭裁剪,关闭裁剪后可以使用 gdb 等工具调试,但这样会让静态二进制体积变大。 - ## 不同 SAPI 的使用 ### 使用 cli diff --git a/README.md b/README.md index aa7f1043..157e589f 100755 --- a/README.md +++ b/README.md @@ -1,28 +1,40 @@ # static-php-cli -Build single static PHP binary, with PHP project together, with popular extensions included. - -🌐 **[中文](README-zh.md)** | **[English](README.md)** - -> Windows support will be added in v2.1. - -The project name is static-php-cli, but it actually supports cli, fpm, micro and embed SAPI 😎 - -Compile a purely static php-cli binary file with various extensions to make PHP applications more portable! (cli SAPI) - -2023-05-02 15 53 13 - -You can also use the micro binary file to combine php binary and php source code into one for distribution! (micro SAPI) - -2023-05-02 15 52 33 - -> This SAPI feature is from the [Fork](https://github.com/static-php/phpmicro) of [dixyes/phpmicro](https://github.com/dixyes/phpmicro). - -[![Version](https://img.shields.io/badge/Version-2.0.0-green.svg?style=flat-square)]() -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() +[![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() [![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) -[![](https://img.shields.io/github/search/crazywhalecc/static-php-cli/TODO?label=TODO%20Counter&style=flat-square)]() +[![](https://dcbadge.vercel.app/api/server/RNpegEYW?style=flat-square&compact=true&theme=default-inverted)](https://discord.gg/RNpegEYW) + +**static-php-cli** is a powerful tool designed for building static, standalone PHP runtime +with popular extensions. + +Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed` and `micro` SAPI. + +**static-php-cli** also has the ability to package PHP projects +along with the PHP interpreter into one single executable file. + +- [README - English](./README.md) +- [README - 中文](./README-zh.md) + +## Features + +static-php-cli (you can call it `spc`) has a lot of features: + +- :handbag: Build single-file php executable, without any dependencies +- :hamburger: Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracted executable (glue php binary and php source code into one file) +- :pill: Automatic build environment checker (Doctor module) +- :zap: `Linux`, `macOS`, `FreeBSD`, [`Windows (WIP)`](https://github.com/crazywhalecc/static-php-cli/pull/301) support +- :wrench: Configurable source code patches +- :books: Build dependency management +- 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box)) +- :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html) + +**Single-file standalone php-cli:** +out1 + +**Combine PHP code with PHP interpreter using phpmicro:** +out2 ## Documentation @@ -31,7 +43,7 @@ see . ## Direct Download -If you don't want to compile yourself, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-common.yml), or from self-hosted server. +If you don't want to build or want to test first, you can download example pre-compiled artifact from [Actions](https://github.com/static-php/static-php-cli-hosted/actions/workflows/build-php-bulk.yml), or from self-hosted server. Below are several precompiled static-php binaries with different extension combinations, which can be downloaded directly according to your needs. @@ -40,14 +52,18 @@ which can be downloaded directly according to your needs. - [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. - [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size. -## Use static-php-cli to build PHP +## Build ### Compilation Requirements -Yes, this project is written in PHP, pretty funny. +- PHP >= 8.1 (static-php-cli is written in PHP) +- Extension: `mbstring,pcntl,posix,tokenizer,phar` +- Supported OS with `curl` and `git` installed + +You can say I made a PHP builder written in PHP, pretty funny. But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. -Here is the architecture support status, where :octocat: represents support for GitHub Action builds, +Here is the supported OS and arch, where :octocat: represents support for GitHub Action builds, :computer: represents support for local manual builds, and blank represents not currently supported. | | x86_64 | aarch64 | @@ -57,8 +73,6 @@ Here is the architecture support status, where :octocat: represents support for | Windows | | | | FreeBSD | :computer: | :computer: | -> macOS-arm64 is not supported for GitHub Actions, if you are going to build on arm, you can build it manually on your own machine. - Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. ### Supported Extensions @@ -72,7 +86,7 @@ Please first select the extension you want to compile based on the extension lis Here is the current planned roadmap for extension support: [#152](https://github.com/crazywhalecc/static-php-cli/issues/152) . -### GitHub Actions Build +### Build Online (using GitHub Actions) Use GitHub Action to easily build a statically compiled PHP, and at the same time define the extensions to be compiled by yourself. @@ -84,80 +98,77 @@ and at the same time define the extensions to be compiled by yourself. If you enable `debug`, all logs will be output at build time, including compiled logs, for troubleshooting. -- When using ubuntu-latest, it will build linux-x86_64 binary. -- When using macos-latest, it will build macOS-x86_64 binary. +### Build Locally (using SPC binary) -### Manual build (using SPC binary) - -This project provides a binary file of static-php-cli. -You can directly download the binary file of the corresponding platform and then use it to build static PHP. +This project provides a binary file of static-php-cli: `spc`. +You can use `spc` binary instead of installing any runtime like golang app. Currently, the platforms supported by `spc` binary are Linux and macOS. -Here's how to download from GitHub Actions: - -1. Enter [GitHub Actions](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml) or [self-hosted nightly builds](https://dl.static-php.dev/static-php-cli/spc-bin/nightly/). -2. If you download from GHA, select the latest build task, select `Artifacts`, and download the binary file of the corresponding platform. -3. If you download from GHA, unzip the `.zip` file. After decompressing, add execution permissions to it: `chmod +x ./spc`. -4. If you download from self-hosted server, download `spc-$os-$arch` file and just use it (don't forget `chmod +x`). - -> SPC single-file binary is built by phpmicro and box, and it doesn't need to install PHP. Just treat `spc` as a standalone executable. - -### Manual build (using source code) - -Clone repo first: +Download from self-hosted nightly builds using commands below: ```bash +# Download from self-hosted nightly builds (sync with main branch) +# For Linux x86_64 +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64 +# For Linux aarch64 +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-aarch64 +# macOS x86_64 (Intel) +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64 +# macOS aarch64 (Apple) +curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64 + +# add x perm +chmod +x ./spc +./spc --version +``` + +Self-hosted `spc` is built by GitHub Actions, you can also download from Actions artifacts [here](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml). + +### Build Locally (using git source) + +```bash +# just clone me! git clone https://github.com/crazywhalecc/static-php-cli.git ``` -If you have not installed php on your system, you can use package management to install PHP (such as brew, apt, yum, apk etc.). - -And you can also download single-file php binary and composer using command `bin/setup-runtime`. -The PHP runtime for static-php-cli itself will be downloaded at `bin/php`, and composer is at `bin/composer`. +If you have not installed php on your system, we recommend that you use the built-in setup-runtime to install PHP and Composer automatically. ```bash cd static-php-cli chmod +x bin/setup-runtime -# It will download php-cli from self-hosted server and composer from getcomposer.org -./bin/setup-runtime - -# Use this php runtime to run static-php-cli compiler -./bin/php bin/spc - -# Use composer -./bin/php bin/composer - -# Initialize this project -cd static-php-cli -composer update +# it will download static php (from self-hosted server) and composer (from getcomposer) +bin/setup-runtime +# initialize composer deps +bin/composer install +# chmod chmod +x bin/spc +bin/spc --version ``` -### Use static-php-cli +### Start Building PHP -Basic usage for building php and micro with some extensions: +Basic usage for building php with some extensions: > If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands. ```bash -# Check system tool dependencies, fix them if possible -./bin/spc doctor +# Check system tool dependencies, auto-fix them if possible +./bin/spc doctor --auto-fix + # fetch all libraries ./bin/spc download --all -# only fetch necessary sources by needed extensions +# only fetch necessary sources by needed extensions (recommended) ./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite +# download different PHP version (--with-php=x.y, recommend 7.3 ~ 8.3) +./bin/spc download --for-extensions=openssl,curl,mbstring --with-php=8.1 + # with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI ./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro +# build thread-safe (ZTS) version (--enable-zts) +./bin/spc build curl,phar --enable-zts --build-cli ``` -You can also use the parameter `--with-php=x.y` to specify the downloaded PHP version, currently supports 7.4 ~ 8.3: - -```bash -# Using PHP >= 8.0 is recommended, because PHP7 cannot use phpmicro -./bin/spc fetch --with-php=8.2 --all -``` - -Now we support `cli`, `micro`, `fpm`, you can use one or more of the following parameters to specify the compiled SAPI: +Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more of the following parameters to specify the compiled SAPI: - `--build-cli`: build static cli executable - `--build-micro`: build static phpmicro self-extracted executable @@ -169,17 +180,9 @@ If anything goes wrong, use `--debug` option to display full terminal output: ```bash ./bin/spc build openssl,pcntl,mbstring --debug --build-all -./bin/spc fetch --all --debug +./bin/spc download --all --debug ``` -In addition, we build NTS (non-thread-safe) by default. If you are going to build ZTS version, just add `--enable-zts` option. - -```bash -./bin/spc build openssl,pcntl --build-all --enable-zts -``` - -Adding option `--no-strip` can produce binaries with debug symbols, in order to debug (using gdb). Disabling strip will increase the size of static binary. - ## Different SAPI Usage ### Use cli @@ -288,4 +291,3 @@ and they all have their own open source licenses. Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation, and comply with the corresponding project's LICENSE. - From 5f8641f417e4e57165aba133234b6f8028f66a66 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 11:13:47 +0800 Subject: [PATCH 154/415] update README --- README-zh.md | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README-zh.md b/README-zh.md index 9791335a..0da16a73 100755 --- a/README-zh.md +++ b/README-zh.md @@ -29,9 +29,11 @@ static-php-cli(简称 `spc`)有许多特性: - :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html) **静态 php-cli:** + out1 **使用 phpmicro 打包 PHP 代码:** + out2 ## 文档 diff --git a/README.md b/README.md index 157e589f..1039ce84 100755 --- a/README.md +++ b/README.md @@ -31,9 +31,11 @@ static-php-cli (you can call it `spc`) has a lot of features: - :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html) **Single-file standalone php-cli:** + out1 **Combine PHP code with PHP interpreter using phpmicro:** + out2 ## Documentation From 104778d17af707d7615f9f66a22895acb55d00da Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 21:08:25 +0800 Subject: [PATCH 155/415] add windows support --- .github/workflows/tests.yml | 1 + README-zh.md | 13 +- README.md | 3 + bin/setup-runtime.ps1 | 4 +- bin/spc | 1 + bin/spc.ps1 | 5 +- config/ext.json | 4 +- config/lib.json | 4 +- src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/BuilderBase.php | 78 +--- src/SPC/builder/BuilderProvider.php | 7 +- src/SPC/builder/Extension.php | 40 +- src/SPC/builder/extension/glfw.php | 5 + src/SPC/builder/extension/mbregex.php | 2 +- src/SPC/builder/extension/password_argon2.php | 2 +- src/SPC/builder/freebsd/BSDBuilder.php | 8 +- src/SPC/builder/linux/LinuxBuilder.php | 8 +- src/SPC/builder/macos/MacOSBuilder.php | 8 +- src/SPC/builder/traits/LibraryTrait.php | 7 - src/SPC/builder/traits/UnixLibraryTrait.php | 2 - .../UnixBuilderBase.php} | 69 +++- src/SPC/builder/windows/SystemUtil.php | 86 ++++- src/SPC/builder/windows/WindowsBuilder.php | 343 ++++++++++++++++++ .../windows/library/WindowsLibraryBase.php | 40 ++ src/SPC/builder/windows/library/openssl.php | 44 +++ src/SPC/builder/windows/library/zlib.php | 38 ++ src/SPC/command/BuildCliCommand.php | 16 +- src/SPC/command/DownloadCommand.php | 1 + src/SPC/command/MicroCombineCommand.php | 4 + src/SPC/doctor/item/WindowsToolCheckList.php | 84 ++++- src/SPC/store/Downloader.php | 65 +++- src/SPC/store/FileSystem.php | 91 ++--- src/SPC/store/SourcePatcher.php | 50 ++- src/SPC/util/WindowsCmd.php | 5 + src/globals/defines.php | 17 +- src/globals/test-extensions.php | 20 +- src/globals/tests/openssl.php | 6 + src/globals/tests/zlib.php | 1 + tests/SPC/store/FileSystemTest.php | 212 +++++++++++ 39 files changed, 1166 insertions(+), 230 deletions(-) delete mode 100644 src/SPC/builder/traits/LibraryTrait.php rename src/SPC/builder/{traits/UnixBuilderTrait.php => unix/UnixBuilderBase.php} (65%) create mode 100644 src/SPC/builder/windows/WindowsBuilder.php create mode 100644 src/SPC/builder/windows/library/WindowsLibraryBase.php create mode 100644 src/SPC/builder/windows/library/openssl.php create mode 100644 src/SPC/builder/windows/library/zlib.php create mode 100644 src/globals/tests/openssl.php create mode 100644 tests/SPC/store/FileSystemTest.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f7138d01..fe25afa0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -114,6 +114,7 @@ jobs: os: - ubuntu-latest - macos-latest + - windows-latest fail-fast: false steps: - name: "Checkout" diff --git a/README-zh.md b/README-zh.md index 0da16a73..68c5e82c 100755 --- a/README-zh.md +++ b/README-zh.md @@ -254,14 +254,13 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys ## 开源协议 -本项目依据旧版本惯例采用 MIT License 开源,部分扩展的集成编译命令参考或修改自以下项目: +本项目采用 MIT License 许可开源,下面是类似的项目: -- [dixyes/lwmbs](https://github.com/dixyes/lwmbs)(木兰宽松许可证) -- [swoole/swoole-cli](https://github.com/swoole/swoole-cli)(Apache 2.0 LICENSE、SWOOLE-CLI LICENSE) +- [dixyes/lwmbs](https://github.com/dixyes/lwmbs) +- [swoole/swoole-cli](https://github.com/swoole/swoole-cli) + +该项目使用了 [dixyes/lwmbs](https://github.com/dixyes/lwmbs) 中的一些代码,例如 Windows 静态构建目标和 libiconv 库支持。 +lwmbs 使用 [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2) 许可进行分发。对应文件有关于作者和许可的特殊说明,除此之外,均使用 MIT 授权许可。 因本项目的特殊性,使用项目编译过程中会使用很多其他开源项目,例如 curl、protobuf 等,它们都有各自的开源协议。 请在编译完成后,使用命令 `bin/spc dump-license` 导出项目使用项目的开源协议,并遵守对应项目的 LICENSE。 - -## 进阶 - -本项目重构分支为模块化编写。如果你对本项目感兴趣,想加入开发,可以参照文档的 [贡献指南](https://static-php.dev) 贡献代码或文档。 diff --git a/README.md b/README.md index 1039ce84..83fd4005 100755 --- a/README.md +++ b/README.md @@ -287,6 +287,9 @@ These are similar projects: - [dixyes/lwmbs](https://github.com/dixyes/lwmbs) - [swoole/swoole-cli](https://github.com/swoole/swoole-cli) +The project uses some code from [dixyes/lwmbs](https://github.com/dixyes/lwmbs), such as windows static build target and libiconv support. +lwmbs is licensed under the [Mulan PSL 2](http://license.coscl.org.cn/MulanPSL2). + Due to the special nature of this project, many other open source projects such as curl and protobuf will be used during the project compilation process, and they all have their own open source licenses. diff --git a/bin/setup-runtime.ps1 b/bin/setup-runtime.ps1 index b04c3b58..e9c152dd 100644 --- a/bin/setup-runtime.ps1 +++ b/bin/setup-runtime.ps1 @@ -28,7 +28,7 @@ function RemoveFromPath { $currentPath = [System.Environment]::GetEnvironmentVariable('Path', 'User') if ($currentPath -like "*$pathToRemove*") { - $newPath = $currentPath -replace [regex]::Escape($pathToRemove), '' + $newPath = $currentPath -replace [regex]::Escape(';' + $pathToRemove), '' [System.Environment]::SetEnvironmentVariable('Path', $newPath, 'User') Write-Host "Removed Path '$pathToRemove'" } else { @@ -92,7 +92,7 @@ if (-not(Test-Path "runtime\composer.phar")) # create runtime\composer.ps1 $ComposerContent = ' $WorkingDir = (Split-Path -Parent $MyInvocation.MyCommand.Definition) -Start-Process ($WorkingDir + "\php.exe") ($WorkingDir + "\composer.phar " + $args) -NoNewWindow -Wait +& ($WorkingDir + "\php.exe") (Join-Path $WorkingDir "\composer.phar") @args ' $ComposerContent | Set-Content -Path 'runtime\composer.ps1' -Encoding UTF8 diff --git a/bin/spc b/bin/spc index a8571b1b..52a6401b 100755 --- a/bin/spc +++ b/bin/spc @@ -21,4 +21,5 @@ try { (new ConsoleApplication())->run(); } catch (Exception $e) { ExceptionHandler::getInstance()->handle($e); + exit(1); } diff --git a/bin/spc.ps1 b/bin/spc.ps1 index 7123a880..3a2639d0 100644 --- a/bin/spc.ps1 +++ b/bin/spc.ps1 @@ -1,4 +1,4 @@ -$PHP_Exec = "runtime\php.exe" +$PHP_Exec = ".\runtime\php.exe" if (-not(Test-Path $PHP_Exec)) { $PHP_Exec = Get-Command php.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Definition @@ -8,5 +8,4 @@ if (-not(Test-Path $PHP_Exec)) { } } -$phpArgs = "bin\spc " + $args -Start-Process $PHP_Exec -ArgumentList $phpArgs -NoNewWindow -Wait +& "$PHP_Exec" ("bin/spc") @args diff --git a/config/ext.json b/config/ext.json index 2dfc67d6..3ee4cd32 100644 --- a/config/ext.json +++ b/config/ext.json @@ -106,7 +106,8 @@ "source": "ext-glfw", "lib-depends": [ "glfw" - ] + ], + "lib-depends-windows": [] }, "gmp": { "type": "builtin", @@ -238,6 +239,7 @@ "openssl": { "type": "builtin", "arg-type": "custom", + "arg-type-windows": "with", "lib-depends": [ "openssl", "zlib" diff --git a/config/lib.json b/config/lib.json index a56d8772..d9400b76 100644 --- a/config/lib.json +++ b/config/lib.json @@ -57,9 +57,7 @@ "brotli", "nghttp2", "zstd", - "openssl", - "idn2", - "psl" + "openssl" ], "frameworks": [ "CoreFoundation", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index a067e88d..19cf3083 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.0.1'; + public const VERSION = '2.1.0-beta.1'; public function __construct() { diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 729a46c5..531d8ea3 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -9,10 +9,8 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; -use SPC\store\FileSystem; use SPC\store\SourceExtractor; use SPC\util\CustomExt; -use SPC\util\DependencyUtil; abstract class BuilderBase { @@ -43,64 +41,7 @@ abstract class BuilderBase * @throws WrongUsageException * @internal */ - public function buildLibs(array $sorted_libraries): void - { - // search all supported libs - $support_lib_list = []; - $classes = FileSystem::getClassesPsr4( - ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library', - 'SPC\\builder\\' . osfamily2dir() . '\\library' - ); - foreach ($classes as $class) { - if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) { - $support_lib_list[$class::NAME] = $class; - } - } - - // if no libs specified, compile all supported libs - if ($sorted_libraries === [] && $this->isLibsOnly()) { - $libraries = array_keys($support_lib_list); - $sorted_libraries = DependencyUtil::getLibsByDeps($libraries); - } - - // pkg-config must be compiled first, whether it is specified or not - if (!in_array('pkg-config', $sorted_libraries)) { - array_unshift($sorted_libraries, 'pkg-config'); - } - - // add lib object for builder - foreach ($sorted_libraries as $library) { - // if some libs are not supported (but in config "lib.json", throw exception) - if (!isset($support_lib_list[$library])) { - throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); - } - $lib = new ($support_lib_list[$library])($this); - $this->addLib($lib); - } - - // calculate and check dependencies - foreach ($this->libs as $lib) { - $lib->calcDependency(); - } - - // patch point - $this->emitPatchPoint('before-libs-extract'); - - // extract sources - SourceExtractor::initSource(libs: $sorted_libraries); - - $this->emitPatchPoint('after-libs-extract'); - - // build all libs - foreach ($this->libs as $lib) { - match ($lib->tryBuild($this->getOption('rebuild', false))) { - BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), - BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), - BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), - default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), - }; - } - } + abstract public function buildLibs(array $sorted_libraries); /** * Add library to build. @@ -242,6 +183,7 @@ abstract class BuilderBase { $ret = []; foreach ($this->exts as $ext) { + logger()->info($ext->getName() . ' is using ' . $ext->getConfigureArg()); $ret[] = trim($ext->getConfigureArg()); } logger()->debug('Using configure: ' . implode(' ', $ret)); @@ -417,4 +359,20 @@ abstract class BuilderBase ); } } + + /** + * Generate micro extension test php code. + */ + protected function generateMicroExtTests(): string + { + $php = "getExts() as $ext) { + $ext_name = $ext->getDistName(); + $php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n"; + $php .= "assert(extension_loaded('{$ext_name}'));\n\n"; + } + $php .= "echo '[micro-test-end]';\n"; + return $php; + } } diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index d1e0cd77..fb6d3cef 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -7,6 +7,7 @@ namespace SPC\builder; use SPC\builder\freebsd\BSDBuilder; use SPC\builder\linux\LinuxBuilder; use SPC\builder\macos\MacOSBuilder; +use SPC\builder\windows\WindowsBuilder; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; @@ -27,11 +28,7 @@ class BuilderProvider public static function makeBuilderByInput(InputInterface $input): BuilderBase { self::$builder = match (PHP_OS_FAMILY) { - // 'Windows' => new WindowsBuilder( - // binary_sdk_dir: $input->getOption('with-sdk-binary-dir'), - // vs_ver: $input->getOption('vs-ver'), - // arch: $input->getOption('arch'), - // ), + 'Windows' => new WindowsBuilder($input->getOptions()), 'Darwin' => new MacOSBuilder($input->getOptions()), 'Linux' => new LinuxBuilder($input->getOptions()), 'BSD' => new BSDBuilder($input->getOptions()), diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 21f0f574..c5c026ff 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -8,6 +8,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\store\FileSystem; class Extension { @@ -42,7 +43,7 @@ class Extension $arg = $this->getEnableArg(); switch (PHP_OS_FAMILY) { case 'Windows': - $arg = $this->getWindowsConfigureArg(); + $arg .= $this->getWindowsConfigureArg(); break; case 'Darwin': case 'Linux': @@ -164,14 +165,13 @@ 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/tests/{extension_name}.php - * If check failed, throw RuntimeException - * * @throws RuntimeException */ - public function runCliCheck(): void + public function runCliCheckUnix(): void { + // Run compile check if build target is cli + // If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php + // If check failed, throw RuntimeException [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "' . $this->getDistName() . '"', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); @@ -192,6 +192,34 @@ class Extension } } + /** + * @throws RuntimeException + */ + public function runCliCheckWindows(): void + { + // Run compile check if build target is cli + // If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php + // If check failed, throw RuntimeException + [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe --ri "' . $this->getDistName() . '"', false); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); + } + + if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php'))) { + // Trim additional content & escape special characters to allow inline usage + $test = str_replace( + ['getName() . '.php')) + ); + + [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"'); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); + } + } + } + /** * @throws RuntimeException */ diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php index ad1be3a7..c9d0c4f7 100644 --- a/src/SPC/builder/extension/glfw.php +++ b/src/SPC/builder/extension/glfw.php @@ -34,4 +34,9 @@ class glfw extends Extension { return '--enable-glfw --with-glfw-dir=' . BUILD_ROOT_PATH; } + + public function getWindowsConfigureArg(): string + { + return '--enable-glfw=static'; + } } diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 0301557c..8eb40615 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -19,7 +19,7 @@ class mbregex extends Extension /** * mbregex is not an extension, we need to overwrite the default check. */ - public function runCliCheck(): void + public function runCliCheckUnix(): void { [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring" | grep regex', false); if ($ret !== 0) { diff --git a/src/SPC/builder/extension/password_argon2.php b/src/SPC/builder/extension/password_argon2.php index fb3c4b04..db1ada4e 100644 --- a/src/SPC/builder/extension/password_argon2.php +++ b/src/SPC/builder/extension/password_argon2.php @@ -11,7 +11,7 @@ use SPC\util\CustomExt; #[CustomExt('password-argon2')] class password_argon2 extends Extension { - public function runCliCheck(): void + public function runCliCheckUnix(): void { [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"'); if ($ret !== 0) { diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index b1fa8851..15906bea 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -4,19 +4,15 @@ declare(strict_types=1); namespace SPC\builder\freebsd; -use SPC\builder\BuilderBase; -use SPC\builder\traits\UnixBuilderTrait; +use SPC\builder\unix\UnixBuilderBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; -class BSDBuilder extends BuilderBase +class BSDBuilder extends UnixBuilderBase { - /** Unix compatible builder methods */ - use UnixBuilderTrait; - /** @var bool Micro patch phar flag */ private bool $phar_patched = false; diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index f99c9bca..2fe93534 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -4,20 +4,16 @@ declare(strict_types=1); namespace SPC\builder\linux; -use SPC\builder\BuilderBase; use SPC\builder\linux\library\LinuxLibraryBase; -use SPC\builder\traits\UnixBuilderTrait; +use SPC\builder\unix\UnixBuilderBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; -class LinuxBuilder extends BuilderBase +class LinuxBuilder extends UnixBuilderBase { - /** Unix compatible builder methods */ - use UnixBuilderTrait; - /** @var array Tune cflags */ public array $tune_c_flags; diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index b74aaa60..def7d8b0 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -4,20 +4,16 @@ declare(strict_types=1); namespace SPC\builder\macos; -use SPC\builder\BuilderBase; use SPC\builder\macos\library\MacOSLibraryBase; -use SPC\builder\traits\UnixBuilderTrait; +use SPC\builder\unix\UnixBuilderBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; -class MacOSBuilder extends BuilderBase +class MacOSBuilder extends UnixBuilderBase { - /** Unix compatible builder methods */ - use UnixBuilderTrait; - /** @var bool Micro patch phar flag */ private bool $phar_patched = false; diff --git a/src/SPC/builder/traits/LibraryTrait.php b/src/SPC/builder/traits/LibraryTrait.php deleted file mode 100644 index e05a47bf..00000000 --- a/src/SPC/builder/traits/LibraryTrait.php +++ /dev/null @@ -1,7 +0,0 @@ -isLibsOnly()) { + $libraries = array_keys($support_lib_list); + $sorted_libraries = DependencyUtil::getLibsByDeps($libraries); + } + + // pkg-config must be compiled first, whether it is specified or not + if (!in_array('pkg-config', $sorted_libraries)) { + array_unshift($sorted_libraries, 'pkg-config'); + } + + // add lib object for builder + foreach ($sorted_libraries as $library) { + // if some libs are not supported (but in config "lib.json", throw exception) + if (!isset($support_lib_list[$library])) { + throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); + } + $lib = new ($support_lib_list[$library])($this); + $this->addLib($lib); + } + + // calculate and check dependencies + foreach ($this->libs as $lib) { + $lib->calcDependency(); + } + + // patch point + $this->emitPatchPoint('before-libs-extract'); + + // extract sources + SourceExtractor::initSource(libs: $sorted_libraries); + + $this->emitPatchPoint('after-libs-extract'); + + // build all libs + foreach ($this->libs as $lib) { + match ($lib->tryBuild($this->getOption('rebuild', false))) { + BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), + BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), + BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), + default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), + }; + } + } + /** * Sanity check after build complete * @@ -103,7 +166,7 @@ trait UnixBuilderTrait foreach ($this->exts as $ext) { logger()->debug('testing ext: ' . $ext->getName()); - $ext->runCliCheck(); + $ext->runCliCheckUnix(); } } diff --git a/src/SPC/builder/windows/SystemUtil.php b/src/SPC/builder/windows/SystemUtil.php index b1ec35af..668e60b1 100644 --- a/src/SPC/builder/windows/SystemUtil.php +++ b/src/SPC/builder/windows/SystemUtil.php @@ -4,17 +4,25 @@ declare(strict_types=1); namespace SPC\builder\windows; +use SPC\exception\FileSystemException; +use SPC\store\FileSystem; + class SystemUtil { /** - * @param string $name 命令名称 - * @param array $paths 寻找的目标路径(如果不传入,则使用环境变量 PATH) - * @return null|string 找到了返回命令路径,找不到返回 null + * Find windows program using executable name. + * + * @param string $name command name (xxx.exe) + * @param array $paths search path (default use env path) + * @return null|string null if not found, string is absolute path */ - public static function findCommand(string $name, array $paths = []): ?string + public static function findCommand(string $name, array $paths = [], bool $include_sdk_bin = false): ?string { if (!$paths) { $paths = explode(PATH_SEPARATOR, getenv('Path')); + if ($include_sdk_bin) { + $paths[] = PHP_SDK_PATH . '\bin'; + } } foreach ($paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $name)) { @@ -23,4 +31,74 @@ class SystemUtil } return null; } + + /** + * Find Visual Studio installation. + * + * @return array|false False if not installed, array contains 'version' and 'dir' + */ + public static function findVisualStudio(): array|false + { + $check_path = [ + 'C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe' => 'vs17', + 'C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe' => 'vs17', + 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe' => 'vs17', + 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe' => 'vs16', + 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\MSBuild.exe' => 'vs16', + 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe' => 'vs16', + ]; + foreach ($check_path as $path => $vs_version) { + if (file_exists($path)) { + $vs_ver = $vs_version; + $d_dir = dirname($path, 4); + return [ + 'version' => $vs_ver, + 'dir' => $d_dir, + ]; + } + } + return false; + } + + /** + * Get CPU count for concurrency. + */ + public static function getCpuCount(): int + { + $result = f_exec('echo %NUMBER_OF_PROCESSORS%', $out, $code); + if ($code !== 0 || !$result) { + return 1; + } + return intval($result); + } + + /** + * Create CMake toolchain file. + * + * @param null|string $cflags CFLAGS for cmake, default use '/MT /Os /Ob1 /DNDEBUG /D_ACRTIMP= /D_CRTIMP=' + * @param null|string $ldflags LDFLAGS for cmake, default use '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt' + * @throws FileSystemException + */ + public static function makeCmakeToolchainFile(?string $cflags = null, ?string $ldflags = null): string + { + if ($cflags === null) { + $cflags = '/MT /Os /Ob1 /DNDEBUG /D_ACRTIMP= /D_CRTIMP='; + } + if ($ldflags === null) { + $ldflags = '/nodefaultlib:msvcrt /nodefaultlib:msvcrtd /defaultlib:libcmt'; + } + $buildroot = str_replace('\\', '\\\\', BUILD_ROOT_PATH); + $toolchain = <<options = $options; + + // ---------- set necessary options ---------- + // set sdk (require visual studio 16 or 17) + $vs = SystemUtil::findVisualStudio()['version']; + $this->sdk_prefix = PHP_SDK_PATH . "\\phpsdk-{$vs}-x64.bat -t"; + + // set zts + $this->zts = $this->getOption('enable-zts', false); + + // set concurrency + $this->concurrency = SystemUtil::getCpuCount(); + + // make cmake toolchain + $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(); + } + + /** + * @throws RuntimeException + * @throws WrongUsageException + * @throws FileSystemException + */ + public function buildPHP(int $build_target = BUILD_TARGET_NONE): void + { + // ---------- Update extra-libs ---------- + $extra_libs = $this->getOption('extra-libs', ''); + $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); + $this->setOption('extra-libs', $extra_libs); + $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; + + SourcePatcher::patchBeforeBuildconf($this); + + cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} buildconf.bat"); + + SourcePatcher::patchBeforeConfigure($this); + + $zts = $this->zts ? '--enable-zts=yes ' : '--enable-zts=no '; + + cmd()->cd(SOURCE_PATH . '\php-src') + ->exec( + "{$this->sdk_prefix} configure.bat --task-args \"" . + '--disable-all ' . + '--disable-cgi ' . + '--with-php-build=' . BUILD_ROOT_PATH . ' ' . + '--with-extra-includes=' . BUILD_INCLUDE_PATH . ' ' . + '--with-extra-libs=' . BUILD_LIB_PATH . ' ' . + ($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') . + ($enableMicro ? '--enable-micro=yes ' : '--enable-micro=no ') . + ($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') . + "{$this->makeExtensionArgs()} " . + $zts . + '"' + ); + + SourcePatcher::patchBeforeMake($this); + + $this->cleanMake(); + + if ($enableCli) { + logger()->info('building cli'); + $this->buildCli(); + } + if ($enableFpm) { + logger()->warning('Windows does not support fpm SAPI, I will skip it.'); + } + if ($enableMicro) { + logger()->info('building micro'); + $this->buildMicro(); + } + if ($enableEmbed) { + logger()->warning('Windows does not currently support embed SAPI.'); + // logger()->info('building embed'); + $this->buildEmbed(); + } + + $this->sanityCheck($build_target); + } + + /** + * @throws FileSystemException + * @throws RuntimeException + */ + public function buildCli(): void + { + SourcePatcher::patchWindowsCLITarget(); + + // add nmake wrapper + FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_cli_wrapper.bat', "nmake /nologo LIBS_CLI=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" EXTRA_LD_FLAGS_PROGRAM= %*"); + + cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_cli_wrapper.bat --task-args php.exe"); + + $this->deployBinary(BUILD_TARGET_CLI); + } + + public function buildEmbed(): void + { + // TODO: add embed support for windows + /* + FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_embed_wrapper.bat', 'nmake /nologo %*'); + + cmd()->cd(SOURCE_PATH . '\php-src') + ->exec("{$this->sdk_prefix} nmake_embed_wrapper.bat --task-args php8embed.lib"); + */ + } + + /** + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public function buildMicro(): void + { + // workaround for fiber (originally from https://github.com/dixyes/lwmbs/blob/master/windows/MicroBuild.php) + $makefile = FileSystem::readFile(SOURCE_PATH . '\php-src\Makefile'); + if ($this->getPHPVersionID() >= 80200 && str_contains($makefile, 'FIBER_ASM_ARCH')) { + $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ARCH)_ms_pe_masm.obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ARCH)_ms_pe_masm.obj' . "\r\n\r\n"; + } + FileSystem::writeFile(SOURCE_PATH . '\php-src\Makefile', $makefile); + + // add nmake wrapper + $fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' /DPHP_MICRO_FAKE_CLI" ' : ''; + $wrapper = "nmake /nologo LIBS_MICRO=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" %*"; + FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_micro_wrapper.bat', $wrapper); + + // phar patch for micro + if ($this->getExt('phar')) { + $this->phar_patched = true; + SourcePatcher::patchMicro(['phar']); + } + + cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_micro_wrapper.bat --task-args micro"); + + if ($this->phar_patched) { + SourcePatcher::patchMicro(['phar'], true); + } + + $this->deployBinary(BUILD_TARGET_MICRO); + } + + public function buildLibs(array $sorted_libraries): void + { + // search all supported libs + $support_lib_list = []; + $classes = FileSystem::getClassesPsr4( + ROOT_DIR . '\src\SPC\builder\\' . osfamily2dir() . '\\library', + 'SPC\\builder\\' . osfamily2dir() . '\\library' + ); + foreach ($classes as $class) { + if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) { + $support_lib_list[$class::NAME] = $class; + } + } + + // if no libs specified, compile all supported libs + if ($sorted_libraries === [] && $this->isLibsOnly()) { + $libraries = array_keys($support_lib_list); + $sorted_libraries = DependencyUtil::getLibsByDeps($libraries); + } + + // add lib object for builder + foreach ($sorted_libraries as $library) { + // if some libs are not supported (but in config "lib.json", throw exception) + if (!isset($support_lib_list[$library])) { + throw new WrongUsageException('library [' . $library . '] is in the lib.json list but not supported to compile, but in the future I will support it!'); + } + $lib = new ($support_lib_list[$library])($this); + $this->addLib($lib); + } + + // calculate and check dependencies + foreach ($this->libs as $lib) { + $lib->calcDependency(); + } + + // extract sources + SourceExtractor::initSource(libs: $sorted_libraries); + + // build all libs + foreach ($this->libs as $lib) { + match ($lib->tryBuild($this->getOption('rebuild', false))) { + BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), + BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), + BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), + default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), + }; + } + } + + /** + * @throws FileSystemException + * @throws RuntimeException + */ + public function cleanMake(): void + { + FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_clean_wrapper.bat', 'nmake /nologo %*'); + cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_clean_wrapper.bat --task-args \"clean\""); + } + + /** + * Run extension and PHP cli and micro check + * + * @throws RuntimeException + */ + public function sanityCheck(mixed $build_target): void + { + // sanity check for php-cli + if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { + logger()->info('running cli sanity check'); + [$ret, $output] = cmd()->execWithResult(BUILD_ROOT_PATH . '\bin\php.exe -r "echo \"hello\";"'); + if ($ret !== 0 || trim(implode('', $output)) !== 'hello') { + throw new RuntimeException('cli failed sanity check'); + } + + foreach ($this->exts as $ext) { + logger()->debug('testing ext: ' . $ext->getName()); + $ext->runCliCheckWindows(); + } + } + + // sanity check for phpmicro + if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { + if (file_exists(SOURCE_PATH . '\hello.exe')) { + @unlink(SOURCE_PATH . '\hello.exe'); + } + file_put_contents( + SOURCE_PATH . '\hello.exe', + file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') . + ($this->getOption('with-micro-ext-test') ? $this->generateMicroExtTests() : 'execWithResult(SOURCE_PATH . '\hello.exe'); + $raw_out = trim(implode('', $output2)); + $condition[0] = $ret === 0; + $condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); + foreach ($condition as $k => $v) { + if (!$v) { + throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]"); + } + } + } + } + + /** + * 将编译好的二进制文件发布到 buildroot + * + * @param int $type 发布类型 + * @throws RuntimeException + * @throws FileSystemException + */ + public function deployBinary(int $type): bool + { + $ts = $this->zts ? '_TS' : ''; + $src = match ($type) { + BUILD_TARGET_CLI => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\php.exe", + BUILD_TARGET_MICRO => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\micro.sfx", + default => throw new RuntimeException('Deployment does not accept type ' . $type), + }; + logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file'); + FileSystem::createDir(BUILD_ROOT_PATH . '\bin'); + + cmd()->exec('copy ' . escapeshellarg($src) . ' ' . escapeshellarg(BUILD_ROOT_PATH . '\bin\\')); + return true; + } + + /** + * @throws WrongUsageException + * @throws FileSystemException + */ + public function getAllStaticLibFiles(): array + { + $libs = []; + + // reorder libs + foreach ($this->libs as $lib) { + foreach ($lib->getDependencies() as $dep) { + $libs[] = $dep; + } + $libs[] = $lib; + } + + $libFiles = []; + $libNames = []; + // merge libs + foreach ($libs as $lib) { + if (!in_array($lib::NAME, $libNames, true)) { + $libNames[] = $lib::NAME; + array_unshift($libFiles, ...$lib->getStaticLibs()); + } + } + return $libFiles; + } + + /** + * Generate command wrapper prefix for php-sdk internal commands. + * + * @param string $internal_cmd command in php-sdk-tools\bin + * @return string Example: C:\php-sdk-tools\phpsdk-vs17-x64.bat -t source\cmake_wrapper.bat --task-args + */ + public function makeSimpleWrapper(string $internal_cmd): string + { + $wrapper_bat = SOURCE_PATH . '\\' . crc32($internal_cmd) . '_wrapper.bat'; + if (!file_exists($wrapper_bat)) { + file_put_contents($wrapper_bat, $internal_cmd . ' %*'); + } + return "{$this->sdk_prefix} {$wrapper_bat} --task-args"; + } +} diff --git a/src/SPC/builder/windows/library/WindowsLibraryBase.php b/src/SPC/builder/windows/library/WindowsLibraryBase.php new file mode 100644 index 00000000..c3fa49d6 --- /dev/null +++ b/src/SPC/builder/windows/library/WindowsLibraryBase.php @@ -0,0 +1,40 @@ +builder; + } + + /** + * Create a nmake wrapper file. + * + * @param string $content nmake wrapper content + * @param string $default_filename default nmake wrapper filename + * @throws FileSystemException + */ + public function makeNmakeWrapper(string $content, string $default_filename = ''): string + { + if ($default_filename === '') { + $default_filename = $this->source_dir . '\nmake_wrapper.bat'; + } + FileSystem::writeFile($default_filename, $content); + return 'nmake_wrapper.bat'; + } +} diff --git a/src/SPC/builder/windows/library/openssl.php b/src/SPC/builder/windows/library/openssl.php new file mode 100644 index 00000000..18b98438 --- /dev/null +++ b/src/SPC/builder/windows/library/openssl.php @@ -0,0 +1,44 @@ +cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper($perl), + 'Configure zlib VC-WIN64A ' . + 'no-shared ' . + '--prefix=' . quote(BUILD_ROOT_PATH) . ' ' . + '--with-zlib-lib=' . quote(BUILD_LIB_PATH) . ' ' . + '--with-zlib-include=' . quote(BUILD_INCLUDE_PATH) . ' ' . + '--release ' . + 'no-legacy ' + ); + + // patch zlib + FileSystem::replaceFileStr($this->source_dir . '\Makefile', 'ZLIB1', 'zlibstatic.lib'); + // patch debug: https://stackoverflow.com/questions/18486243/how-do-i-build-openssl-statically-linked-against-windows-runtime + FileSystem::replaceFileStr($this->source_dir . '\Makefile', '/debug', '/incremental:no /opt:icf /dynamicbase /nxcompat /ltcg /nodefaultlib:msvcrt'); + cmd()->cd($this->source_dir)->execWithWrapper( + $this->builder->makeSimpleWrapper('nmake'), + 'install_dev ' . + 'CNF_LDFLAGS="/NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:msvcrt /NODEFAULTLIB:msvcrtd /DEFAULTLIB:libcmt /LIBPATH:' . BUILD_LIB_PATH . ' zlibstatic.lib"' + ); + copy($this->source_dir . '\ms\applink.c', BUILD_INCLUDE_PATH . '\openssl\applink.c'); + } +} diff --git a/src/SPC/builder/windows/library/zlib.php b/src/SPC/builder/windows/library/zlib.php new file mode 100644 index 00000000..03fd033b --- /dev/null +++ b/src/SPC/builder/windows/library/zlib.php @@ -0,0 +1,38 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DSKIP_INSTALL_FILES=ON ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + copy(BUILD_LIB_PATH . '\zlibstatic.lib', BUILD_LIB_PATH . '\zlib_a.lib'); + unlink(BUILD_ROOT_PATH . '\bin\zlib.dll'); + unlink(BUILD_LIB_PATH . '\zlib.lib'); + } +} diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 4913751c..e79bc46b 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -36,6 +36,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); + $this->addOption('with-micro-ext-test', null, null, 'Enable phpmicro with extension test code'); } public function handle(): int @@ -120,13 +121,17 @@ class BuildCliCommand extends BuildCommand $fixed = ' (host system)'; } if (($rule & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { - logger()->info('Static php binary path' . $fixed . ': ' . $build_root_path . '/bin/php'); + $win_suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : ''; + $path = FileSystem::convertPath("{$build_root_path}/bin/php{$win_suffix}"); + logger()->info("Static php binary path{$fixed}: {$path}"); } if (($rule & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { - logger()->info('phpmicro binary path' . $fixed . ': ' . $build_root_path . '/bin/micro.sfx'); + $path = FileSystem::convertPath("{$build_root_path}/bin/micro.sfx"); + logger()->info("phpmicro binary path{$fixed}: {$path}"); } - if (($rule & BUILD_TARGET_FPM) === BUILD_TARGET_FPM) { - logger()->info('Static php-fpm binary path' . $fixed . ': ' . $build_root_path . '/bin/php-fpm'); + if (($rule & BUILD_TARGET_FPM) === BUILD_TARGET_FPM && PHP_OS_FAMILY !== 'Windows') { + $path = FileSystem::convertPath("{$build_root_path}/bin/php-fpm"); + logger()->info("Static php-fpm binary path{$fixed}: {$path}"); } // export metadata @@ -135,7 +140,8 @@ class BuildCliCommand extends BuildCommand // export licenses $dumper = new LicenseDumper(); $dumper->addExts($extensions)->addLibs($libraries)->addSources(['php-src'])->dump(BUILD_ROOT_PATH . '/license'); - logger()->info('License path' . $fixed . ': ' . $build_root_path . '/license/'); + $path = FileSystem::convertPath("{$build_root_path}/license/"); + logger()->info("License path{$fixed}: {$path}"); return static::SUCCESS; } catch (WrongUsageException $e) { // WrongUsageException is not an exception, it's a user error, so we just print the error message diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 5bb6e79d..7ee74d77 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -116,6 +116,7 @@ class DownloadCommand extends BaseCommand // get source list that will be downloaded $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); if (empty($sources)) { + logger()->warning('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); $sources = array_keys(Config::getSources()); } } diff --git a/src/SPC/command/MicroCombineCommand.php b/src/SPC/command/MicroCombineCommand.php index 1b14979a..3987ca78 100644 --- a/src/SPC/command/MicroCombineCommand.php +++ b/src/SPC/command/MicroCombineCommand.php @@ -87,6 +87,10 @@ class MicroCombineCommand extends BaseCommand // 8. Combine ! $output = FileSystem::isRelativePath($output) ? (WORKING_DIR . '/' . $output) : $output; $file_target = file_get_contents($micro_file) . $ini_part . file_get_contents($file); + if (PHP_OS_FAMILY === 'Windows' && !str_ends_with(strtolower($output), '.exe')) { + $output .= '.exe'; + } + $output = FileSystem::convertPath($output); $result = file_put_contents($output, $file_target); if ($result === false) { $this->output->writeln('Combine failed.'); diff --git a/src/SPC/doctor/item/WindowsToolCheckList.php b/src/SPC/doctor/item/WindowsToolCheckList.php index 73092233..0115c3da 100644 --- a/src/SPC/doctor/item/WindowsToolCheckList.php +++ b/src/SPC/doctor/item/WindowsToolCheckList.php @@ -9,10 +9,22 @@ use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; use SPC\doctor\CheckResult; use SPC\exception\RuntimeException; +use SPC\store\Downloader; +use SPC\store\FileSystem; class WindowsToolCheckList { - #[AsCheckItem('if git are installed', limit_os: 'Windows', level: 999)] + #[AsCheckItem('if Visual Studio are installed', limit_os: 'Windows', level: 999)] + public function checkVS(): ?CheckResult + { + $vs_ver = SystemUtil::findVisualStudio(); + if ($vs_ver === false) { + return CheckResult::fail('Visual Studio not installed, please install VS 2022/2019.'); + } + return CheckResult::ok($vs_ver['version'] . ' ' . $vs_ver['dir']); + } + + #[AsCheckItem('if git are installed', limit_os: 'Windows', level: 998)] public function checkGit(): ?CheckResult { if (SystemUtil::findCommand('git.exe') === null) { @@ -22,7 +34,7 @@ class WindowsToolCheckList return CheckResult::ok(); } - #[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 998)] + #[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 997)] public function checkSDK(): ?CheckResult { if (!file_exists(PHP_SDK_PATH . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) { @@ -31,14 +43,80 @@ class WindowsToolCheckList return CheckResult::ok(PHP_SDK_PATH); } + #[AsCheckItem('if git associated command exists', limit_os: 'Windows', level: 996)] + public function checkGitPatch(): ?CheckResult + { + if (($path = SystemUtil::findCommand('patch.exe')) === null) { + return CheckResult::fail('Git patch (minGW command) not found in path. You need to add "C:\Program Files\Git\usr\bin" in Path.'); + } + return CheckResult::ok(); + } + + #[AsCheckItem('if nasm installed', limit_os: 'Windows', level: 995)] + public function checkNasm(): ?CheckResult + { + if (SystemUtil::findCommand('nasm.exe', include_sdk_bin: true) === null) { + return CheckResult::fail('nasm.exe not found in path.', 'install-nasm'); + } + return CheckResult::ok(); + } + + #[AsCheckItem('if perl(strawberry) installed', limit_os: 'Windows', level: 994)] + public function checkPerl(): ?CheckResult + { + if (file_exists(BUILD_ROOT_PATH . '\perl\perl\bin\perl.exe')) { + return CheckResult::ok(BUILD_ROOT_PATH . '\perl\perl\bin\perl.exe'); + } + if (($path = SystemUtil::findCommand('perl.exe')) === null) { + return CheckResult::fail('perl not found in path.', 'install-perl'); + } + if (!str_contains(implode('', cmd()->execWithResult(quote($path) . ' -v')[1]), 'MSWin32')) { + return CheckResult::fail($path . ' is not built for msvc.', 'install-perl'); + } + return CheckResult::ok(); + } + #[AsFixItem('install-php-sdk')] public function installPhpSdk(): bool { try { - cmd(true)->exec('git clone https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH); + FileSystem::removeDir(PHP_SDK_PATH); + cmd(true)->exec('git.exe clone --depth 1 https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH); } catch (RuntimeException) { return false; } return true; } + + #[AsFixItem('install-nasm')] + public function installNasm(): bool + { + // The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`. + $nasm_ver = '2.16.01'; + $nasm_dist = "nasm-{$nasm_ver}"; + $source = [ + 'type' => 'url', + 'url' => "https://www.nasm.us/pub/nasm/releasebuilds/{$nasm_ver}/win64/{$nasm_dist}-win64.zip", + ]; + logger()->info('Downloading ' . $source['url']); + Downloader::downloadSource('nasm', $source); + FileSystem::extractSource('nasm', DOWNLOAD_PATH . "\\{$nasm_dist}-win64.zip"); + copy(SOURCE_PATH . "\\nasm\\{$nasm_dist}\\nasm.exe", PHP_SDK_PATH . '\bin\nasm.exe'); + copy(SOURCE_PATH . "\\nasm\\{$nasm_dist}\\ndisasm.exe", PHP_SDK_PATH . '\bin\ndisasm.exe'); + return true; + } + + #[AsFixItem('install-perl')] + public function installPerl(): bool + { + $url = 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip'; + $source = [ + 'type' => 'url', + 'url' => $url, + ]; + logger()->info("Downloading {$url}"); + Downloader::downloadSource('strawberry-perl', $source); + FileSystem::extractSource('strawberry-perl', DOWNLOAD_PATH . '\strawberry-perl-5.38.0.1-64bit-portable.zip', '../buildroot/perl'); + return true; + } } diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index affeac88..2cb0fa37 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -168,14 +168,15 @@ class Downloader public static function downloadFile(string $name, string $url, string $filename, ?string $move_path = null): void { logger()->debug("Downloading {$url}"); - pcntl_signal(SIGINT, function () use ($filename) { - if (file_exists(DOWNLOAD_PATH . '/' . $filename)) { + $cancel_func = function () use ($filename) { + if (file_exists(FileSystem::convertPath(DOWNLOAD_PATH . '/' . $filename))) { logger()->warning('Deleting download file: ' . $filename); - unlink(DOWNLOAD_PATH . '/' . $filename); + unlink(FileSystem::convertPath(DOWNLOAD_PATH . '/' . $filename)); } - }); - self::curlDown(url: $url, path: DOWNLOAD_PATH . "/{$filename}"); - pcntl_signal(SIGINT, SIG_IGN); + }; + self::registerCancelEvent($cancel_func); + self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}")); + self::unregisterCancelEvent(); logger()->debug("Locking {$filename}"); self::lockSource($name, ['source_type' => 'archive', 'filename' => $filename, 'move_path' => $move_path]); } @@ -187,7 +188,7 @@ class Downloader */ public static function lockSource(string $name, array $data): void { - if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { + if (!file_exists(FileSystem::convertPath(DOWNLOAD_PATH . '/.lock.json'))) { $lock = []; } else { $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; @@ -204,24 +205,25 @@ class Downloader */ public static function downloadGit(string $name, string $url, string $branch, ?string $move_path = null): void { - $download_path = DOWNLOAD_PATH . "/{$name}"; + $download_path = FileSystem::convertPath(DOWNLOAD_PATH . "/{$name}"); if (file_exists($download_path)) { FileSystem::removeDir($download_path); } logger()->debug("cloning {$name} source"); $check = !defined('DEBUG_MODE') ? ' -q' : ''; - pcntl_signal(SIGINT, function () use ($download_path) { + $cancel_func = function () use ($download_path) { if (is_dir($download_path)) { logger()->warning('Removing path ' . $download_path); FileSystem::removeDir($download_path); } - }); + }; + self::registerCancelEvent($cancel_func); f_passthru( - 'git clone' . $check . + SPC_GIT_EXEC . ' clone' . $check . ' --config core.autocrlf=false ' . "--branch \"{$branch}\" " . (defined('GIT_SHALLOW_CLONE') ? '--depth 1 --single-branch' : '') . " --recursive \"{$url}\" \"{$download_path}\"" ); - pcntl_signal(SIGINT, SIG_IGN); + self::unregisterCancelEvent(); // Lock logger()->debug("Locking git source {$name}"); @@ -251,7 +253,6 @@ class Downloader * @param null|array $source source meta info: [type, path, rev, url, filename, regex, license] * @throws DownloaderException * @throws FileSystemException - * @throws RuntimeException */ public static function downloadSource(string $name, ?array $source = null, bool $force = false): void { @@ -359,12 +360,12 @@ class Downloader }; $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); - $cmd = "curl -sfSL {$methodArg} {$headerArg} \"{$url}\""; + $cmd = SPC_CURL_EXEC . " -sfSL {$methodArg} {$headerArg} \"{$url}\""; if (getenv('CACHE_API_EXEC') === 'yes') { - if (!file_exists(DOWNLOAD_PATH . '/.curl_exec_cache')) { + if (!file_exists(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache'))) { $cache = []; } else { - $cache = json_decode(file_get_contents(DOWNLOAD_PATH . '/.curl_exec_cache'), true); + $cache = json_decode(file_get_contents(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache')), true); } if (isset($cache[$cmd]) && $cache[$cmd]['expire'] >= time()) { return $cache[$cmd]['cache']; @@ -375,7 +376,7 @@ class Downloader } $cache[$cmd]['cache'] = implode("\n", $output); $cache[$cmd]['expire'] = time() + 3600; - file_put_contents(DOWNLOAD_PATH . '/.curl_exec_cache', json_encode($cache)); + file_put_contents(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache'), json_encode($cache)); return $cache[$cmd]['cache']; } f_exec($cmd, $output, $ret); @@ -404,7 +405,35 @@ class Downloader }; $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); $check = !defined('DEBUG_MODE') ? 's' : '#'; - $cmd = "curl -{$check}fSL -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; + $cmd = SPC_CURL_EXEC . " -{$check}fSL -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; f_passthru($cmd); } + + /** + * Register CTRL+C event for different OS. + * + * @param callable $callback callback function + */ + private static function registerCancelEvent(callable $callback): void + { + if (PHP_OS_FAMILY === 'Windows') { + sapi_windows_set_ctrl_handler($callback); + } elseif (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, $callback); + } else { + logger()->debug('You have not enabled `pcntl` extension, cannot prevent download file corruption when Ctrl+C'); + } + } + + /** + * Unegister CTRL+C event for different OS. + */ + private static function unregisterCancelEvent(): void + { + if (PHP_OS_FAMILY === 'Windows') { + sapi_windows_set_ctrl_handler(null); + } elseif (extension_loaded('pcntl')) { + pcntl_signal(SIGINT, SIG_IGN); + } + } } diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index c08a09bb..f786c8ef 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -160,78 +160,35 @@ class FileSystem } logger()->info("extracting {$name} source to " . ($move_path ?? SOURCE_PATH . "/{$name}") . ' ...'); try { - $target = $move_path ?? (SOURCE_PATH . "/{$name}"); + $target = self::convertPath($move_path ?? (SOURCE_PATH . "/{$name}")); // Git source, just move - if (is_dir($filename)) { - self::copyDir($filename, $target); + if (is_dir(self::convertPath($filename))) { + self::copyDir(self::convertPath($filename), $target); self::emitSourceExtractHook($name); return; } + if (f_mkdir(directory: $target, recursive: true) !== true) { + throw new FileSystemException('create ' . $name . 'source dir failed'); + } + if (in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { - if (f_mkdir(directory: $target, recursive: true) !== true) { - throw new FileSystemException('create ' . $name . 'source dir failed'); - } - switch (self::extname($filename)) { - case 'xz': - case 'txz': - f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"); - // f_passthru("cat {$filename} | xz -d | tar -x -C " . SOURCE_PATH . "/{$name} --strip-components 1"); - break; - case 'gz': - case 'tgz': - f_passthru("tar -xzf {$filename} -C {$target} --strip-components 1"); - break; - case 'bz2': - f_passthru("tar -xjf {$filename} -C {$target} --strip-components 1"); - break; - case 'zip': - f_passthru("unzip {$filename} -d {$target}"); - break; - // case 'zstd': - // case 'zst': - // passthru('cat ' . $filename . ' | zstd -d | tar -x -C ".SOURCE_PATH . "/' . $name . ' --strip-components 1', $ret); - // break; - case 'tar': - f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"); - break; - default: - throw new FileSystemException('unknown archive format: ' . $filename); - } + match (self::extname($filename)) { + 'tar', 'xz', 'txz' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), + 'tgz', 'gz' => f_passthru("tar -xzf {$filename} -C {$target} --strip-components 1"), + 'bz2' => f_passthru("tar -xjf {$filename} -C {$target} --strip-components 1"), + 'zip' => f_passthru("unzip {$filename} -d {$target}"), + default => throw new FileSystemException('unknown archive format: ' . $filename), + }; } elseif (PHP_OS_FAMILY === 'Windows') { - // find 7z - $_7zExe = self::findCommandPath('7z', [ - 'C:\Program Files\7-Zip-Zstandard', - 'C:\Program Files (x86)\7-Zip-Zstandard', - 'C:\Program Files\7-Zip', - 'C:\Program Files (x86)\7-Zip', - ]); - if (!$_7zExe) { - throw new FileSystemException('windows needs 7z to unpack'); - } + // use php-sdk-binary-tools/bin/7za.exe + $_7z = self::convertPath(PHP_SDK_PATH . '/bin/7za.exe'); f_mkdir(SOURCE_PATH . "/{$name}", recursive: true); - switch (self::extname($filename)) { - case 'zstd': - case 'zst': - if (!str_contains($_7zExe, 'Zstandard')) { - throw new FileSystemException("zstd is not supported: {$filename}"); - } - // no break - case 'xz': - case 'txz': - case 'gz': - case 'tgz': - case 'bz2': - f_passthru("\"{$_7zExe}\" x -so {$filename} | tar -f - -x -C {$target} --strip-components 1"); - break; - case 'tar': - f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"); - break; - case 'zip': - f_passthru("\"{$_7zExe}\" x {$filename} -o{$target}"); - break; - default: - throw new FileSystemException("unknown archive format: {$filename}"); - } + match (self::extname($filename)) { + 'tar' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), + 'xz', 'txz', 'gz', 'tgz', 'bz2' => f_passthru("\"{$_7z}\" x -so {$filename} | tar -f - -x -C {$target} --strip-components 1"), + 'zip' => f_passthru("\"{$_7z}\" x {$filename} -o{$target} -y"), + default => throw new FileSystemException("unknown archive format: {$filename}"), + }; } self::emitSourceExtractHook($name); } catch (RuntimeException $e) { @@ -398,7 +355,7 @@ class FileSystem public static function createDir(string $path): void { if (!is_dir($path) && !f_mkdir($path, 0755, true) && !is_dir($path)) { - throw new FileSystemException(sprintf('无法建立目录:%s', $path)); + throw new FileSystemException(sprintf('Unable to create dir: %s', $path)); } } @@ -408,7 +365,7 @@ class FileSystem */ public static function writeFile(string $path, mixed $content, ...$args): bool|int|string { - $dir = pathinfo($path, PATHINFO_DIRNAME); + $dir = pathinfo(self::convertPath($path), PATHINFO_DIRNAME); if (!is_dir($dir) && !mkdir($dir, 0755, true)) { throw new FileSystemException('Write file failed, cannot create parent directory: ' . $dir); } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index fc3e69d4..920d0564 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -6,6 +6,7 @@ namespace SPC\store; use SPC\builder\BuilderBase; use SPC\builder\linux\LinuxBuilder; +use SPC\builder\unix\UnixBuilderBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; @@ -31,6 +32,20 @@ class SourcePatcher logger()->info('Extension [' . $ext->getName() . '] patched before buildconf'); } } + // patch windows php 8.1 bug + if (PHP_OS_FAMILY === 'Windows' && $builder->getPHPVersionID() >= 80100 && $builder->getPHPVersionID() < 80200) { + logger()->info('Patching PHP 8.1 windows Fiber bug'); + FileSystem::replaceFileStr( + SOURCE_PATH . '\php-src\win32\build\config.w32', + "ADD_FLAG('LDFLAGS', '$(BUILD_DIR)\\\\Zend\\\\jump_' + FIBER_ASM_ARCH + '_ms_pe_masm.obj');", + "ADD_FLAG('ASM_OBJS', '$(BUILD_DIR)\\\\Zend\\\\jump_' + FIBER_ASM_ARCH + '_ms_pe_masm.obj $(BUILD_DIR)\\\\Zend\\\\make_' + FIBER_ASM_ARCH + '_ms_pe_masm.obj');" + ); + FileSystem::replaceFileStr( + SOURCE_PATH . '\php-src\win32\build\config.w32', + "ADD_FLAG('LDFLAGS', '$(BUILD_DIR)\\\\Zend\\\\make_' + FIBER_ASM_ARCH + '_ms_pe_masm.obj');", + '' + ); + } } /** @@ -181,9 +196,10 @@ class SourcePatcher FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCPY 1$/m', ''); FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', ''); } - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); - - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); + if ($builder instanceof UnixBuilderBase) { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); + } // call extension patch before make foreach ($builder->getExts() as $ext) { @@ -252,4 +268,32 @@ class SourcePatcher @unlink($embed_c_bak); return $result; } + + /** + * Patch cli SAPI Makefile for Windows. + * + * @throws FileSystemException + * @throws RuntimeException + */ + public static function patchWindowsCLITarget(): void + { + // search Makefile code line contains "$(BUILD_DIR)\php.exe:" + $content = FileSystem::readFile(SOURCE_PATH . '/php-src/Makefile'); + $lines = explode("\r\n", $content); + $line_num = 0; + $found = false; + foreach ($lines as $v) { + if (strpos($v, '$(BUILD_DIR)\php.exe:') !== false) { + $found = $line_num; + break; + } + ++$line_num; + } + if ($found === false) { + throw new RuntimeException('Cannot patch windows CLI Makefile!'); + } + $lines[$line_num] = '$(BUILD_DIR)\php.exe: generated_files $(DEPS_CLI) $(PHP_GLOBAL_OBJS) $(CLI_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)\php.exe.res $(BUILD_DIR)\php.exe.manifest'; + $lines[$line_num + 1] = "\t" . '"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286'; + FileSystem::writeFile(SOURCE_PATH . '/php-src/Makefile', implode("\r\n", $lines)); + } } diff --git a/src/SPC/util/WindowsCmd.php b/src/SPC/util/WindowsCmd.php index cf461725..16530c59 100644 --- a/src/SPC/util/WindowsCmd.php +++ b/src/SPC/util/WindowsCmd.php @@ -50,6 +50,11 @@ class WindowsCmd return $this; } + public function execWithWrapper(string $wrapper, string $args): WindowsCmd + { + return $this->exec($wrapper . ' "' . str_replace('"', '^"', $args) . '"'); + } + public function execWithResult(string $cmd, bool $with_log = true): array { if ($with_log) { diff --git a/src/globals/defines.php b/src/globals/defines.php index 26d2f6d7..aebb7f86 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use SPC\store\FileSystem; use ZM\Logger\ConsoleLogger; define('WORKING_DIR', getcwd()); @@ -10,12 +11,12 @@ define('ROOT_DIR', dirname(__DIR__, 2)); // CLI start time define('START_TIME', microtime(true)); -define('BUILD_ROOT_PATH', is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot')); -define('SOURCE_PATH', is_string($a = getenv('SOURCE_PATH')) ? $a : (WORKING_DIR . '/source')); -define('DOWNLOAD_PATH', is_string($a = getenv('DOWNLOAD_PATH')) ? $a : (WORKING_DIR . '/downloads')); -define('BUILD_BIN_PATH', is_string($a = getenv('INSTALL_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin')); -define('BUILD_LIB_PATH', is_string($a = getenv('INSTALL_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib')); -define('BUILD_INCLUDE_PATH', is_string($a = getenv('INSTALL_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include')); +define('BUILD_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot'))); +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'))); +define('BUILD_BIN_PATH', FileSystem::convertPath(is_string($a = getenv('INSTALL_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin'))); +define('BUILD_LIB_PATH', FileSystem::convertPath(is_string($a = getenv('INSTALL_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib'))); +define('BUILD_INCLUDE_PATH', FileSystem::convertPath(is_string($a = getenv('INSTALL_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include'))); define('SEPARATED_PATH', [ '/' . pathinfo(BUILD_LIB_PATH)['basename'], // lib '/' . pathinfo(BUILD_INCLUDE_PATH)['basename'], // include @@ -26,6 +27,10 @@ if (PHP_OS_FAMILY === 'Windows') { define('PHP_SDK_PATH', is_string($a = getenv('PHP_SDK_PATH')) ? $a : (WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools')); } +// for windows, prevent calling Invoke-WebRequest and wsl command +const SPC_CURL_EXEC = PHP_OS_FAMILY === 'Windows' ? 'curl.exe' : 'curl'; +const SPC_GIT_EXEC = PHP_OS_FAMILY === 'Windows' ? 'git.exe' : 'git'; + // dangerous command const DANGER_CMD = [ 'rm', diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 93156f5f..e353d5b7 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -1,5 +1,7 @@ '', + 'Windows' => 'mbstring,openssl', +}; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). -$with_libs = ''; +$with_libs = match (PHP_OS_FAMILY) { + 'Linux', 'Darwin' => '', + 'Windows' => '', +}; // Please change your test base combination. We recommend testing with `common`. // You can use `common`, `bulk`, `minimal` or `none`. -$base_combination = 'minimal'; +// note: combination is only available for *nix platform. Windows must use `none` combination +$base_combination = match (PHP_OS_FAMILY) { + 'Linux', 'Darwin' => 'minimal', + 'Windows' => 'none', +}; // -------------------------- code area, do not modify -------------------------- @@ -51,6 +63,6 @@ $final_libs = trim($with_libs, $trim_value); echo match ($argv[1]) { 'extensions' => $final_extensions, 'libs' => $final_libs, - 'cmd' => $final_extensions . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), + 'cmd' => '"' . $final_extensions . '"' . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), default => '', }; diff --git a/src/globals/tests/openssl.php b/src/globals/tests/openssl.php new file mode 100644 index 00000000..28e586f9 --- /dev/null +++ b/src/globals/tests/openssl.php @@ -0,0 +1,6 @@ +assertEquals('he11o', file_get_contents($file)); + + unlink($file); + } + + public function testFindCommandPath() + { + $this->assertNull(FileSystem::findCommandPath('randomtestxxxxx')); + if (PHP_OS_FAMILY === 'Windows') { + $this->assertIsString(FileSystem::findCommandPath('explorer')); + } elseif (in_array(PHP_OS_FAMILY, ['Linux', 'Darwin', 'FreeBSD'])) { + $this->assertIsString(FileSystem::findCommandPath('uname')); + } + } + + /** + * @throws FileSystemException + */ + public function testReadFile() + { + $file = WORKING_DIR . '/.testread'; + file_put_contents($file, 'haha'); + $content = FileSystem::readFile($file); + $this->assertEquals('haha', $content); + @unlink($file); + } + + /** + * @throws FileSystemException + */ + public function testReplaceFileUser() + { + $file = WORKING_DIR . '/.txt1'; + file_put_contents($file, 'hello'); + + FileSystem::replaceFileUser($file, function ($file) { + return str_replace('el', '55', $file); + }); + $this->assertEquals('h55lo', file_get_contents($file)); + + unlink($file); + } + + public function testExtname() + { + $this->assertEquals('exe', FileSystem::extname('/tmp/asd.exe')); + $this->assertEquals('', FileSystem::extname('/tmp/asd.')); + } + + /** + * @throws \ReflectionException + * @throws FileSystemException + */ + public function testGetClassesPsr4() + { + $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\\builder\\extension'); + foreach ($classes as $class) { + $this->assertIsString($class); + new \ReflectionClass($class); + } + } + + public function testConvertPath() + { + $this->assertEquals('phar://C:/pharfile.phar', FileSystem::convertPath('phar://C:/pharfile.phar')); + if (DIRECTORY_SEPARATOR === '\\') { + $this->assertEquals('C:\Windows\win.ini', FileSystem::convertPath('C:\Windows/win.ini')); + } + } + + /** + * @throws FileSystemException + */ + public function testCreateDir() + { + FileSystem::createDir(WORKING_DIR . '/.testdir'); + $this->assertDirectoryExists(WORKING_DIR . '/.testdir'); + rmdir(WORKING_DIR . '/.testdir'); + } + + /** + * @throws FileSystemException + */ + public function testReplaceFileStr() + { + $file = WORKING_DIR . '/.txt1'; + file_put_contents($file, 'hello'); + + FileSystem::replaceFileStr($file, 'el', '55'); + $this->assertEquals('h55lo', file_get_contents($file)); + + unlink($file); + } + + /** + * @throws FileSystemException + */ + public function testResetDir() + { + // prepare fake git dir to test + FileSystem::createDir(WORKING_DIR . '/.fake_down_test'); + FileSystem::writeFile(WORKING_DIR . '/.fake_down_test/a.c', 'int main() { return 0; }'); + FileSystem::resetDir(WORKING_DIR . '/.fake_down_test'); + $this->assertFileDoesNotExist(WORKING_DIR . '/.fake_down_test/a.c'); + FileSystem::removeDir(WORKING_DIR . '/.fake_down_test'); + } + + /** + * @throws FileSystemException + * @throws RuntimeException + */ + public function testCopyDir() + { + // prepare fake git dir to test + FileSystem::createDir(WORKING_DIR . '/.fake_down_test'); + FileSystem::writeFile(WORKING_DIR . '/.fake_down_test/a.c', 'int main() { return 0; }'); + FileSystem::copyDir(WORKING_DIR . '/.fake_down_test', WORKING_DIR . '/.fake_down_test2'); + $this->assertDirectoryExists(WORKING_DIR . '/.fake_down_test2'); + $this->assertFileExists(WORKING_DIR . '/.fake_down_test2/a.c'); + FileSystem::removeDir(WORKING_DIR . '/.fake_down_test'); + FileSystem::removeDir(WORKING_DIR . '/.fake_down_test2'); + } + + /** + * @throws FileSystemException + */ + public function testRemoveDir() + { + FileSystem::createDir(WORKING_DIR . '/.fake_down_test'); + $this->assertDirectoryExists(WORKING_DIR . '/.fake_down_test'); + FileSystem::removeDir(WORKING_DIR . '/.fake_down_test'); + $this->assertDirectoryDoesNotExist(WORKING_DIR . '/.fake_down_test'); + } + + /** + * @throws FileSystemException + */ + public function testLoadConfigArray() + { + $arr = FileSystem::loadConfigArray('lib'); + $this->assertArrayHasKey('zlib', $arr); + } + + public function testIsRelativePath() + { + $this->assertTrue(FileSystem::isRelativePath('.')); + $this->assertTrue(FileSystem::isRelativePath('.\\sdf')); + if (DIRECTORY_SEPARATOR === '\\') { + $this->assertFalse(FileSystem::isRelativePath('C:\\asdasd/fwe\asd')); + } + $this->assertTrue(FileSystem::isRelativePath('/fwefwefewf')); + } + + public function testScanDirFiles() + { + $this->assertFalse(FileSystem::scanDirFiles('wfwefewfewf')); + $files = FileSystem::scanDirFiles(ROOT_DIR . '/config', true, true); + $this->assertContains('lib.json', $files); + } + + /** + * @throws FileSystemException + */ + public function testWriteFile() + { + FileSystem::writeFile(WORKING_DIR . '/.txt', 'txt'); + $this->assertFileExists(WORKING_DIR . '/.txt'); + $this->assertEquals('txt', FileSystem::readFile(WORKING_DIR . '/.txt')); + unlink(WORKING_DIR . '/.txt'); + } +} From 5ab4d140d5824a2e1ee37eb8141a509e8682fea0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 21:13:11 +0800 Subject: [PATCH 156/415] fix phpstan --- phpstan.neon | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 1bdf9125..56d8183c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,4 +14,5 @@ parameters: excludePaths: analyseAndScan: - ./src/globals/tests/swoole.php - - ./src/globals/tests/swoole.phpt \ No newline at end of file + - ./src/globals/tests/swoole.phpt + - ./src/globals/test-extensions.php \ No newline at end of file From 34f810571eae463c73a9bf3e3dcda7e932922da8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 21:14:55 +0800 Subject: [PATCH 157/415] fix phpunit test --- tests/SPC/store/FileSystemTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/SPC/store/FileSystemTest.php b/tests/SPC/store/FileSystemTest.php index e27d0e44..aae36d8b 100644 --- a/tests/SPC/store/FileSystemTest.php +++ b/tests/SPC/store/FileSystemTest.php @@ -188,8 +188,9 @@ class FileSystemTest extends TestCase $this->assertTrue(FileSystem::isRelativePath('.\\sdf')); if (DIRECTORY_SEPARATOR === '\\') { $this->assertFalse(FileSystem::isRelativePath('C:\\asdasd/fwe\asd')); + } else { + $this->assertFalse(FileSystem::isRelativePath('/fwefwefewf')); } - $this->assertTrue(FileSystem::isRelativePath('/fwefwefewf')); } public function testScanDirFiles() From a04deb458fb8a1bf865f8379a6c778d7e5d54ab0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 21:19:26 +0800 Subject: [PATCH 158/415] fix test build --- 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 e353d5b7..b65431b9 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -60,9 +60,15 @@ $trim_value = "\r\n \t,"; $final_extensions = trim(trim($extensions, $trim_value) . ',' . _getCombination($base_combination), $trim_value); $final_libs = trim($with_libs, $trim_value); +if (PHP_OS_FAMILY === 'Windows') { + $final_extensions_cmd = '"' . $final_extensions . '"'; +} else { + $final_extensions_cmd = $final_extensions; +} + echo match ($argv[1]) { 'extensions' => $final_extensions, 'libs' => $final_libs, - 'cmd' => '"' . $final_extensions . '"' . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), + 'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), default => '', }; From 0dcecf6ca4909e8bd3c51d8895a295373ef49d61 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 21:33:40 +0800 Subject: [PATCH 159/415] fix windows mbstring --- src/SPC/builder/extension/mbstring.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/extension/mbstring.php b/src/SPC/builder/extension/mbstring.php index 058483a5..2318208e 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 getUnixConfigureArg(): string + public function getConfigureArg(): string { $arg = '--enable-mbstring'; if ($this->builder->getExt('mbregex') === null) { From d916feec62c1fdfbb7dc2cb7c4e3c85ab2eba88c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 10 Jan 2024 23:55:57 +0800 Subject: [PATCH 160/415] test bulk --- 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 b65431b9..32bbd082 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'bulk', 'Windows' => 'none', }; From 61ca501c2ae26521dc39c7dc636795e17ac23bc8 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 11 Jan 2024 09:51:48 +0800 Subject: [PATCH 161/415] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 83fd4005..564f406f 100755 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ static-php-cli (you can call it `spc`) has a lot of features: - :handbag: Build single-file php executable, without any dependencies - :hamburger: Build **[phpmicro](https://github.com/dixyes/phpmicro)** self-extracted executable (glue php binary and php source code into one file) - :pill: Automatic build environment checker (Doctor module) -- :zap: `Linux`, `macOS`, `FreeBSD`, [`Windows (WIP)`](https://github.com/crazywhalecc/static-php-cli/pull/301) support +- :zap: `Linux`, `macOS`, `FreeBSD`, `Windows` support - :wrench: Configurable source code patches - :books: Build dependency management - 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box)) @@ -72,7 +72,7 @@ Here is the supported OS and arch, where :octocat: represents support for GitHub |---------|----------------------|----------------------| | macOS | :octocat: :computer: | :computer: | | Linux | :octocat: :computer: | :octocat: :computer: | -| Windows | | | +| Windows | :computer: | | | FreeBSD | :computer: | :computer: | Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. From 1c3476b8e9737b6f4c631321b7009aef31f701fb Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 11 Jan 2024 10:08:02 +0800 Subject: [PATCH 162/415] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 564f406f..f1b3356b 100755 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ which can be downloaded directly according to your needs. ### Compilation Requirements -- PHP >= 8.1 (static-php-cli is written in PHP) +- PHP >= 8.1 (This is the version required by spc itself, not the build version) - Extension: `mbstring,pcntl,posix,tokenizer,phar` - Supported OS with `curl` and `git` installed From 4b653bc2939b6461642fccd63c1c7b9327598bef Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 11 Jan 2024 10:08:32 +0800 Subject: [PATCH 163/415] Update README-zh.md --- README-zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-zh.md b/README-zh.md index 68c5e82c..ace31198 100755 --- a/README-zh.md +++ b/README-zh.md @@ -52,7 +52,7 @@ static-php-cli(简称 `spc`)有许多特性: ### 编译环境需求 -- PHP >= 8.1(spc 自身是用 PHP 写的) +- PHP >= 8.1(这是 spc 自身需要的版本,不是支持的构建版本) - 扩展:`mbstring,pcntl,posix,tokenizer,phar` - 系统安装了 `curl` 和 `git` From 05c6dc6dab3c4c19493e07ed6cd8cfb5f29da893 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 29 Jan 2024 09:42:08 +0800 Subject: [PATCH 164/415] add more tests --- src/SPC/store/FileSystem.php | 4 +- src/globals/test-extensions.php | 2 +- tests/SPC/globals/GlobalFunctionsTest.php | 101 +++++++++++++ tests/SPC/store/ConfigTest.php | 96 ++++++++++++ tests/SPC/util/ConfigValidatorTest.php | 172 ++++++++++++++++++++++ tests/SPC/util/LicenseDumperTest.php | 8 +- 6 files changed, 379 insertions(+), 4 deletions(-) create mode 100644 tests/SPC/globals/GlobalFunctionsTest.php create mode 100644 tests/SPC/store/ConfigTest.php create mode 100644 tests/SPC/util/ConfigValidatorTest.php diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index f786c8ef..8da010e2 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -14,13 +14,13 @@ class FileSystem /** * @throws FileSystemException */ - public static function loadConfigArray(string $config): array + public static function loadConfigArray(string $config, ?string $config_dir = null): array { $whitelist = ['ext', 'lib', 'source']; if (!in_array($config, $whitelist)) { throw new FileSystemException('Reading ' . $config . '.json is not allowed'); } - $tries = [ + $tries = $config_dir !== null ? [FileSystem::convertPath($config_dir . '/' . $config . '.json')] : [ WORKING_DIR . '/config/' . $config . '.json', ROOT_DIR . '/config/' . $config . '.json', ]; diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 32bbd082..b65431b9 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'bulk', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; diff --git a/tests/SPC/globals/GlobalFunctionsTest.php b/tests/SPC/globals/GlobalFunctionsTest.php new file mode 100644 index 00000000..25c22198 --- /dev/null +++ b/tests/SPC/globals/GlobalFunctionsTest.php @@ -0,0 +1,101 @@ +assertTrue(is_assoc_array(['a' => 1, 'b' => 2])); + $this->assertFalse(is_assoc_array([1, 2, 3])); + } + + public function testLogger(): void + { + $this->assertInstanceOf('Psr\Log\LoggerInterface', logger()); + } + + /** + * @throws WrongUsageException + */ + public function testArch2Gnu(): void + { + $this->assertEquals('x86_64', arch2gnu('x86_64')); + $this->assertEquals('x86_64', arch2gnu('x64')); + $this->assertEquals('x86_64', arch2gnu('amd64')); + $this->assertEquals('aarch64', arch2gnu('arm64')); + $this->assertEquals('aarch64', arch2gnu('aarch64')); + $this->expectException('SPC\exception\WrongUsageException'); + arch2gnu('armv7'); + } + + public function testQuote(): void + { + $this->assertEquals('"hello"', quote('hello')); + $this->assertEquals("'hello'", quote('hello', "'")); + } + + /** + * @throws RuntimeException + */ + public function testFPassthru(): void + { + if (PHP_OS_FAMILY === 'Windows') { + $this->markTestSkipped('Windows not support f_passthru'); + } + $this->assertEquals(null, f_passthru('echo ""')); + $this->expectException('SPC\exception\RuntimeException'); + f_passthru('false'); + } + + public function testFPutenv(): void + { + $this->assertTrue(f_putenv('SPC_TEST_ENV=1')); + $this->assertEquals('1', getenv('SPC_TEST_ENV')); + } + + public function testShell(): void + { + if (PHP_OS_FAMILY === 'Windows') { + $this->markTestSkipped('Windows not support shell'); + } + $shell = shell(); + $this->assertInstanceOf('SPC\util\UnixShell', $shell); + $this->assertInstanceOf('SPC\util\UnixShell', $shell->cd('/')); + $this->assertInstanceOf('SPC\util\UnixShell', $shell->exec('echo ""')); + $this->assertInstanceOf('SPC\util\UnixShell', $shell->setEnv(['SPC_TEST_ENV' => '1'])); + + [$code, $out] = $shell->execWithResult('echo "_"'); + $this->assertEquals(0, $code); + $this->assertEquals('_', implode('', $out)); + + $this->expectException('SPC\exception\RuntimeException'); + $shell->exec('false'); + } +} diff --git a/tests/SPC/store/ConfigTest.php b/tests/SPC/store/ConfigTest.php new file mode 100644 index 00000000..6b7555c9 --- /dev/null +++ b/tests/SPC/store/ConfigTest.php @@ -0,0 +1,96 @@ +assertTrue(is_assoc_array(Config::getExts())); + } + + /** + * @throws FileSystemException + * @throws WrongUsageException + */ + public function testGetLib() + { + $this->assertIsArray(Config::getLib('zlib')); + match (PHP_OS_FAMILY) { + 'FreeBSD', 'Darwin', 'Linux' => $this->assertStringEndsWith('.a', Config::getLib('zlib', 'static-libs', [])[0]), + 'Windows' => $this->assertStringEndsWith('.lib', Config::getLib('zlib', 'static-libs', [])[0]), + default => null, + }; + } + + /** + * @throws WrongUsageException + * @throws FileSystemException + */ + public function testGetExt() + { + $this->assertIsArray(Config::getExt('bcmath')); + $this->assertEquals('builtin', Config::getExt('bcmath', 'type')); + } + + /** + * @throws FileSystemException + */ + public function testGetSources() + { + $this->assertTrue(is_assoc_array(Config::getSources())); + } + + /** + * @throws FileSystemException + */ + public function testGetSource() + { + $this->assertIsArray(Config::getSource('php-src')); + } + + /** + * @throws FileSystemException + */ + public function testGetLibs() + { + $this->assertTrue(is_assoc_array(Config::getLibs())); + } +} diff --git a/tests/SPC/util/ConfigValidatorTest.php b/tests/SPC/util/ConfigValidatorTest.php new file mode 100644 index 00000000..78ecd27b --- /dev/null +++ b/tests/SPC/util/ConfigValidatorTest.php @@ -0,0 +1,172 @@ + [ + 'type' => 'filelist', + 'url' => 'https://example.com', + 'regex' => '.*', + ], + 'source2' => [ + 'type' => 'git', + 'url' => 'https://example.com', + 'rev' => 'master', + ], + 'source3' => [ + 'type' => 'ghtagtar', + 'repo' => 'aaaa/bbbb', + ], + 'source4' => [ + 'type' => 'ghtar', + 'repo' => 'aaa/bbb', + 'path' => 'path/to/dir', + ], + 'source5' => [ + 'type' => 'ghrel', + 'repo' => 'aaa/bbb', + 'match' => '.*', + ], + 'source6' => [ + 'type' => 'url', + 'url' => 'https://example.com', + ], + ]; + try { + ConfigValidator::validateSource($good_source); + $this->assertTrue(true); + } catch (ValidationException $e) { + $this->fail($e->getMessage()); + } + } + + public function testValidateSourceBad(): void + { + $bad_source = [ + 'source1' => [ + 'type' => 'filelist', + 'url' => 'https://example.com', + // no regex + ], + 'source2' => [ + 'type' => 'git', + 'url' => true, // not string + 'rev' => 'master', + ], + 'source3' => [ + 'type' => 'ghtagtar', + 'url' => 'aaaa/bbbb', // not repo + ], + 'source4' => [ + 'type' => 'ghtar', + 'repo' => 'aaa/bbb', + 'path' => true, // not string + ], + 'source5' => [ + 'type' => 'ghrel', + 'repo' => 'aaa/bbb', + 'match' => 1, // not string + ], + 'source6' => [ + 'type' => 'url', // no url + ], + ]; + foreach ($bad_source as $name => $src) { + try { + ConfigValidator::validateSource([$name => $src]); + $this->fail("should throw ValidationException for source {$name}"); + } catch (ValidationException) { + $this->assertTrue(true); + } + } + } + + public function testValidateLibsGood(): void + { + $good_libs = [ + 'lib1' => [ + 'source' => 'source1', + ], + 'lib2' => [ + 'source' => 'source2', + 'lib-depends' => [ + 'lib1', + ], + ], + 'lib3' => [ + 'source' => 'source3', + 'lib-suggests' => [ + 'lib1', + ], + ], + ]; + try { + ConfigValidator::validateLibs($good_libs, ['source1' => [], 'source2' => [], 'source3' => []]); + $this->assertTrue(true); + } catch (ValidationException $e) { + $this->fail($e->getMessage()); + } + } + + public function testValidateLibsBad(): void + { + // lib.json is broken + try { + ConfigValidator::validateLibs('not array'); + $this->fail('should throw ValidationException'); + } catch (ValidationException) { + $this->assertTrue(true); + } + // lib source not exists + try { + ConfigValidator::validateLibs(['lib1' => ['source' => 'source3']], ['source1' => [], 'source2' => []]); + $this->fail('should throw ValidationException'); + } catch (ValidationException) { + $this->assertTrue(true); + } + // source must be string + try { + ConfigValidator::validateLibs(['lib1' => ['source' => true]], ['source1' => [], 'source2' => []]); + $this->fail('should throw ValidationException'); + } catch (ValidationException) { + $this->assertTrue(true); + } + // lib-depends must be list + try { + ConfigValidator::validateLibs(['lib1' => ['source' => 'source1', 'lib-depends' => ['a' => 'not list']]], ['source1' => [], 'source2' => []]); + $this->fail('should throw ValidationException'); + } catch (ValidationException) { + $this->assertTrue(true); + } + // lib-suggests must be list + try { + ConfigValidator::validateLibs(['lib1' => ['source' => 'source1', 'lib-suggests' => ['a' => 'not list']]], ['source1' => [], 'source2' => []]); + $this->fail('should throw ValidationException'); + } catch (ValidationException) { + $this->assertTrue(true); + } + } + + /** + * @throws ValidationException + */ + public function testValidateExts(): void + { + ConfigValidator::validateExts([]); + $this->expectException(ValidationException::class); + ConfigValidator::validateExts(null); + } +} diff --git a/tests/SPC/util/LicenseDumperTest.php b/tests/SPC/util/LicenseDumperTest.php index e1ca06c9..3fdfcf8e 100644 --- a/tests/SPC/util/LicenseDumperTest.php +++ b/tests/SPC/util/LicenseDumperTest.php @@ -13,7 +13,13 @@ use SPC\util\LicenseDumper; */ final class LicenseDumperTest extends TestCase { - private const DIRECTORY = '../../var/license-dump'; + private const DIRECTORY = __DIR__ . '/../../var/license-dump'; + + public static function tearDownAfterClass(): void + { + @rmdir(self::DIRECTORY); + @rmdir(dirname(self::DIRECTORY)); + } protected function setUp(): void { From dc19d0c61d7cfa2aae001ae7e85a355dc7464cee Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 31 Jan 2024 11:26:40 +0800 Subject: [PATCH 165/415] Create build-macos-aarch64.yml --- .github/workflows/build-macos-aarch64.yml | 117 ++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/build-macos-aarch64.yml diff --git a/.github/workflows/build-macos-aarch64.yml b/.github/workflows/build-macos-aarch64.yml new file mode 100644 index 00000000..73a700e8 --- /dev/null +++ b/.github/workflows/build-macos-aarch64.yml @@ -0,0 +1,117 @@ +name: CI on arm64 macOS + +on: + workflow_dispatch: + inputs: + version: + required: true + description: php version to compile + default: '8.2' + type: choice + options: + - '8.3' + - '8.2' + - '8.1' + - '8.0' + - '7.4' + build-cli: + description: build cli binary + default: true + type: boolean + build-micro: + description: build phpmicro binary + type: boolean + build-fpm: + description: build fpm binary + type: boolean + extensions: + description: extensions to compile (comma separated) + required: true + type: string + debug: + type: boolean + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: build ${{ inputs.version }} on macOS arm64 + runs-on: macos-14 + steps: + - uses: actions/checkout@v3 + + # Install macOS missing packages and mark os suffix + - run: | + brew install automake gzip + echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV + + # Cache composer dependencies + - id: cache-composer-deps + uses: actions/cache@v3 + with: + path: vendor + key: composer-dependencies + + # If there's no Composer cache, install dependencies + - if: steps.cache-composer-deps.outputs.cache-hit != 'true' + run: composer update --no-dev --classmap-authoritative + + # Cache downloaded source + - id: cache-download + uses: actions/cache@v3 + with: + path: downloads + key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + + # With or without debug + - if: inputs.debug == true + run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV + + # With target select: cli, micro or both + - if: ${{ inputs.build-cli == true }} + run: echo "SPC_BUILD_CLI=--build-cli" >> $GITHUB_ENV + - if: ${{ inputs.build-micro == true }} + run: echo "SPC_BUILD_MICRO=--build-micro" >> $GITHUB_ENV + - if: ${{ inputs.build-fpm == true }} + run: echo "SPC_BUILD_FPM=--build-fpm" >> $GITHUB_ENV + + # If there's no dependencies cache, fetch sources, with or without debug + - if: steps.cache-download.outputs.cache-hit != 'true' + run: ./bin/spc download --with-php=${{ inputs.version }} --for-extensions=${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} + + # Run build command + - run: ./bin/spc build ${{ inputs.extensions }} ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} + + # Upload cli executable + - if: ${{ inputs.build-cli == true }} + uses: actions/upload-artifact@v3 + with: + name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} + path: buildroot/bin/php + + # Upload micro self-extracted executable + - if: ${{ inputs.build-micro == true }} + uses: actions/upload-artifact@v3 + with: + name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} + path: buildroot/bin/micro.sfx + + # Upload fpm executable + - if: ${{ inputs.build-fpm == true }} + uses: actions/upload-artifact@v3 + with: + name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} + path: buildroot/bin/php-fpm + + # Upload extensions metadata + - uses: actions/upload-artifact@v3 + with: + name: license-files + path: buildroot/license/ + - uses: actions/upload-artifact@v3 + with: + name: build-meta + path: | + buildroot/build-extensions.json + buildroot/build-libraries.json From 2064172bed9fc98ee549cb922e2f9972eaffa0ce Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 31 Jan 2024 11:58:56 +0800 Subject: [PATCH 166/415] Update build-macos-aarch64.yml --- .github/workflows/build-macos-aarch64.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build-macos-aarch64.yml b/.github/workflows/build-macos-aarch64.yml index 73a700e8..f43b1ab5 100644 --- a/.github/workflows/build-macos-aarch64.yml +++ b/.github/workflows/build-macos-aarch64.yml @@ -46,6 +46,16 @@ jobs: brew install automake gzip echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + tools: pecl, composer + extensions: curl, openssl, mbstring, tokenizer + ini-values: memory_limit=-1 + + # Cache composer dependencies - id: cache-composer-deps uses: actions/cache@v3 From 2549597871a7ad84a25c5bdfd571c22f76478b13 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 2 Feb 2024 09:44:37 +0800 Subject: [PATCH 167/415] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1b3356b..6b87108d 100755 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Here is the supported OS and arch, where :octocat: represents support for GitHub | | x86_64 | aarch64 | |---------|----------------------|----------------------| -| macOS | :octocat: :computer: | :computer: | +| macOS | :octocat: :computer: | :octocat: :computer: | | Linux | :octocat: :computer: | :octocat: :computer: | | Windows | :computer: | | | FreeBSD | :computer: | :computer: | From 2591b48abeb811900763f2b77f77af333a04d955 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 2 Feb 2024 09:45:55 +0800 Subject: [PATCH 168/415] Update README-zh.md --- README-zh.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-zh.md b/README-zh.md index ace31198..a7a8e26d 100755 --- a/README-zh.md +++ b/README-zh.md @@ -63,7 +63,7 @@ static-php-cli(简称 `spc`)有许多特性: | | x86_64 | aarch64 | |---------|----------------------|----------------------| -| macOS | :octocat: :computer: | :computer: | +| macOS | :octocat: :computer: | :octocat: :computer: | | Linux | :octocat: :computer: | :octocat: :computer: | | Windows | | | | FreeBSD | :computer: | :computer: | From 839931d65fe0b06b907031ee58b02975a900f75b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 10:56:29 +0800 Subject: [PATCH 169/415] add static-php-cli.version ini for php-src --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/command/BuildCliCommand.php | 3 +++ src/SPC/store/SourcePatcher.php | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 19cf3083..4d2db5fe 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.0-beta.1'; + public const VERSION = '2.1.0-beta.2'; public function __construct() { diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index e79bc46b..9e90cc4c 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -104,6 +104,9 @@ class BuildCliCommand extends BuildCommand SourcePatcher::patchHardcodedINI($custom_ini); } + // add static-php-cli.version to main.c, in order to debug php failure more easily + SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); + // start to build $builder->buildPHP($rule); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 920d0564..a7a9bbca 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -296,4 +296,20 @@ class SourcePatcher $lines[$line_num + 1] = "\t" . '"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CLI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CLI) $(BUILD_DIR)\php.exe.res /out:$(BUILD_DIR)\php.exe $(LDFLAGS) $(LDFLAGS_CLI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286'; FileSystem::writeFile(SOURCE_PATH . '/php-src/Makefile', implode("\r\n", $lines)); } + + /** + * Add additional `static-php-cli.version` ini value for PHP source. + * + * @throws FileSystemException + */ + public static function patchSPCVersionToPHP(string $version = 'unknown'): void + { + // detect patch + $file = FileSystem::readFile(SOURCE_PATH . '/php-src/main/main.c'); + if (!str_contains($file, 'static-php-cli.version')) { + logger()->debug('Inserting static-php-cli.version to php-src'); + $file = str_replace('PHP_INI_BEGIN()', "PHP_INI_BEGIN()\n\tPHP_INI_ENTRY(\"static-php-cli.version\",\t\"{$version}\",\tPHP_INI_ALL,\tNULL)", $file); + FileSystem::writeFile(SOURCE_PATH . '/php-src/main/main.c', $file); + } + } } From 2440a65d8e68532cb286ffb19a5d72674ffedb8e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 11:12:30 +0800 Subject: [PATCH 170/415] fix windows test --- .github/workflows/tests.yml | 2 +- src/globals/test-extensions.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe25afa0..747db27a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -154,4 +154,4 @@ jobs: run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" - run: bin/spc build $(php src/globals/test-extensions.php cmd) --build-cli --build-micro --build-fpm --debug + run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index b65431b9..13d8bba7 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -69,6 +69,7 @@ if (PHP_OS_FAMILY === 'Windows') { echo match ($argv[1]) { 'extensions' => $final_extensions, 'libs' => $final_libs, + 'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), 'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), default => '', }; From 9ee7d7769a16dcff225521e3d01e81f0a0742e76 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 11:22:11 +0800 Subject: [PATCH 171/415] add arm macos test --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 747db27a..b04a1324 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -115,6 +115,7 @@ jobs: - ubuntu-latest - macos-latest - windows-latest + - macos-14 fail-fast: false steps: - name: "Checkout" From 0b1a3216150e85c85f4568b149f2880949fe8ae6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 29 Jan 2024 10:04:21 +0800 Subject: [PATCH 172/415] change with-micro-ext-test to without --- src/SPC/builder/BuilderBase.php | 6 ++++-- src/SPC/builder/unix/UnixBuilderBase.php | 11 ++++++++--- src/SPC/builder/windows/WindowsBuilder.php | 2 +- src/SPC/command/BuildCliCommand.php | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 531d8ea3..ed7a21a3 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -369,8 +369,10 @@ abstract class BuilderBase foreach ($this->getExts() as $ext) { $ext_name = $ext->getDistName(); - $php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n"; - $php .= "assert(extension_loaded('{$ext_name}'));\n\n"; + if (!empty($ext_name)) { + $php .= "echo 'Running micro with {$ext_name} test' . PHP_EOL;\n"; + $php .= "assert(extension_loaded('{$ext_name}'));\n\n"; + } } $php .= "echo '[micro-test-end]';\n"; return $php; diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index b29ebbee..c48c3ef3 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -178,12 +178,17 @@ abstract class UnixBuilderBase extends BuilderBase file_put_contents( SOURCE_PATH . '/hello.exe', file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') . - 'getOption('without-micro-ext-test') ? 'generateMicroExtTests()) ); chmod(SOURCE_PATH . '/hello.exe', 0755); [$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe'); - if ($ret !== 0 || trim($out = implode('', $output2)) !== 'hello') { - throw new RuntimeException('micro failed sanity check, ret[' . $ret . '], out[' . ($out ?? 'NULL') . ']'); + $raw_out = trim(implode('', $output2)); + $condition[0] = $ret === 0; + $condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); + foreach ($condition as $k => $v) { + if (!$v) { + throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]"); + } } } } diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 24b54967..6da15b11 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -261,7 +261,7 @@ class WindowsBuilder extends BuilderBase file_put_contents( SOURCE_PATH . '\hello.exe', file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') . - ($this->getOption('with-micro-ext-test') ? $this->generateMicroExtTests() : 'getOption('without-micro-ext-test') ? 'generateMicroExtTests()) ); chmod(SOURCE_PATH . '\hello.exe', 0755); [$ret, $output2] = cmd()->execWithResult(SOURCE_PATH . '\hello.exe'); diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 9e90cc4c..fa5e40b6 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -36,7 +36,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); - $this->addOption('with-micro-ext-test', null, null, 'Enable phpmicro with extension test code'); + $this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code'); } public function handle(): int From 06e9864d199bbaf6289fb380751941a1b647459f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 11:25:35 +0800 Subject: [PATCH 173/415] fix swoole hook check --- src/SPC/builder/extension/swoole_hook_mysql.php | 2 +- src/SPC/builder/extension/swoole_hook_pgsql.php | 2 +- src/SPC/builder/extension/swoole_hook_sqlite.php | 2 +- src/SPC/command/DownloadCommand.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index 6a239976..b24ac955 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -18,7 +18,7 @@ class swoole_hook_mysql extends Extension return ''; } - public function runCliCheck(): void + public function runCliCheckUnix(): void { // skip if not enable swoole if ($this->builder->getExt('swoole') === null) { diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index 93e6172c..e2ebf8b5 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -22,7 +22,7 @@ class swoole_hook_pgsql extends Extension return '--enable-swoole-pgsql'; } - public function runCliCheck(): void + public function runCliCheckUnix(): void { // skip if not enable swoole if ($this->builder->getExt('swoole') === null) { diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 714c83b6..564cf241 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -22,7 +22,7 @@ class swoole_hook_sqlite extends Extension return '--enable-swoole-sqlite'; } - public function runCliCheck(): void + public function runCliCheckUnix(): void { // skip if not enable swoole if ($this->builder->getExt('swoole') === null) { diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 7ee74d77..542dae34 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -116,7 +116,7 @@ class DownloadCommand extends BaseCommand // get source list that will be downloaded $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); if (empty($sources)) { - logger()->warning('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); + logger()->notice('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); $sources = array_keys(Config::getSources()); } } From d222190fc7464d3d6ee022a53a9dcb15d9dd0beb Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 15:08:47 +0800 Subject: [PATCH 174/415] fix curl bug #327 --- 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 216f42b5..643ecac1 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -52,7 +52,7 @@ trait curl // compile! shell()->cd($this->source_dir . '/build') ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') - ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF {$extra} ..") + ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconf From 59dcb905fea010e463637e3ef7c6850283b406d0 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 15:11:00 +0800 Subject: [PATCH 175/415] add test --- 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 13d8bba7..12843feb 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => '', + 'Linux', 'Darwin' => 'calendar,ctype,curl,dom,fileinfo,filter,gd,iconv,imagick,mbregex,mbstring,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,rar,redis,session,simplexml,soap,sockets,sqlite3,swoole,swoole-hook-mysql,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib', 'Windows' => 'mbstring,openssl', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'none', 'Windows' => 'none', }; From 421b3830b62de904d768798dfb30f14646ff6114 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 15:28:09 +0800 Subject: [PATCH 176/415] fix mbregex test for micro --- src/SPC/builder/extension/mbregex.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index 8eb40615..eca3d5ee 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -11,6 +11,11 @@ use SPC\util\CustomExt; #[CustomExt('mbregex')] class mbregex extends Extension { + public function getDistName(): string + { + return 'mbstring'; + } + public function getConfigureArg(): string { return ''; From 73035067e3c32e37f32bb6cb42a73f670681ed64 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 4 Feb 2024 16:18:20 +0800 Subject: [PATCH 177/415] fix swoole-hook --- src/SPC/builder/extension/swoole_hook_mysql.php | 5 +++++ src/SPC/builder/extension/swoole_hook_pgsql.php | 5 +++++ src/SPC/builder/extension/swoole_hook_sqlite.php | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/src/SPC/builder/extension/swoole_hook_mysql.php b/src/SPC/builder/extension/swoole_hook_mysql.php index b24ac955..979c3d75 100644 --- a/src/SPC/builder/extension/swoole_hook_mysql.php +++ b/src/SPC/builder/extension/swoole_hook_mysql.php @@ -11,6 +11,11 @@ use SPC\util\CustomExt; #[CustomExt('swoole-hook-mysql')] class swoole_hook_mysql extends Extension { + public function getDistName(): string + { + return 'swoole'; + } + public function getUnixConfigureArg(): string { // pdo_mysql doesn't need to be disabled diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index e2ebf8b5..dd77db18 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -12,6 +12,11 @@ use SPC\util\CustomExt; #[CustomExt('swoole-hook-pgsql')] class swoole_hook_pgsql extends Extension { + public function getDistName(): string + { + return 'swoole'; + } + public function getUnixConfigureArg(): string { // pdo_pgsql need to be disabled diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 564cf241..4dbfd0df 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -12,6 +12,11 @@ use SPC\util\CustomExt; #[CustomExt('swoole-hook-sqlite')] class swoole_hook_sqlite extends Extension { + public function getDistName(): string + { + return 'swoole'; + } + public function getUnixConfigureArg(): string { // pdo_pgsql need to be disabled From 0ad501af9a15acffbd11ca2ae0f8ca6007c754ea Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Tue, 30 Jan 2024 10:10:43 +0100 Subject: [PATCH 178/415] Patch for PHP >= 8.4 FIBER_ASSEMBLER and FIBER_ASM_ARCH Makefile variables in Windows build system PHP 8.4 have been removed in favor of the PHP_ASSEMBLER and FIBER_ASM_ABI. --- src/SPC/builder/windows/WindowsBuilder.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 6da15b11..7e77c8c2 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -150,6 +150,8 @@ class WindowsBuilder extends BuilderBase $makefile = FileSystem::readFile(SOURCE_PATH . '\php-src\Makefile'); if ($this->getPHPVersionID() >= 80200 && str_contains($makefile, 'FIBER_ASM_ARCH')) { $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ARCH)_ms_pe_masm.obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ARCH)_ms_pe_masm.obj' . "\r\n\r\n"; + } elseif ($this->getPHPVersionID() >= 84000 && str_contains($makefile, 'FIBER_ASM_ABI')) { + $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ABI).obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ABI).obj' . "\r\n\r\n"; } FileSystem::writeFile(SOURCE_PATH . '\php-src\Makefile', $makefile); From a6f7b938e18903e9600f6785078e50701cc7af3c Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Mon, 5 Feb 2024 10:28:23 +0100 Subject: [PATCH 179/415] Fix PHP version ID --- src/SPC/builder/windows/WindowsBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 7e77c8c2..265751ba 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -150,7 +150,7 @@ class WindowsBuilder extends BuilderBase $makefile = FileSystem::readFile(SOURCE_PATH . '\php-src\Makefile'); if ($this->getPHPVersionID() >= 80200 && str_contains($makefile, 'FIBER_ASM_ARCH')) { $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ARCH)_ms_pe_masm.obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ARCH)_ms_pe_masm.obj' . "\r\n\r\n"; - } elseif ($this->getPHPVersionID() >= 84000 && str_contains($makefile, 'FIBER_ASM_ABI')) { + } elseif ($this->getPHPVersionID() >= 80400 && str_contains($makefile, 'FIBER_ASM_ABI')) { $makefile .= "\r\n" . '$(MICRO_SFX): $(BUILD_DIR)\Zend\jump_$(FIBER_ASM_ABI).obj $(BUILD_DIR)\Zend\make_$(FIBER_ASM_ABI).obj' . "\r\n\r\n"; } FileSystem::writeFile(SOURCE_PATH . '\php-src\Makefile', $makefile); From 39754cde59d1b0f638864488e046b286c112d0a7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 6 Feb 2024 15:56:47 +0800 Subject: [PATCH 180/415] add micro patcher for php84 --- 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 a7a9bbca..c1fe1be7 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -106,7 +106,7 @@ class SourcePatcher } $patch_list = $list ?? $default; $patches = []; - $serial = ['80', '81', '82', '83']; + $serial = ['80', '81', '82', '83', '84']; foreach ($patch_list as $patchName) { if (file_exists(SOURCE_PATH . "/php-src/sapi/micro/patches/{$patchName}.patch")) { $patches[] = "sapi/micro/patches/{$patchName}.patch"; From 1e898d271dff11158052b161b18d9eb973a46615 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 6 Feb 2024 16:06:09 +0800 Subject: [PATCH 181/415] add with-suggested-libs and with-suggested-exts --- src/SPC/command/BuildCliCommand.php | 15 ++++++++------- src/SPC/command/dev/AllExtCommand.php | 5 ++--- src/SPC/util/DependencyUtil.php | 23 +++++++++++++++++++---- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index fa5e40b6..b45ef0b3 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -23,11 +23,11 @@ class BuildCliCommand extends BuildCommand { $this->addArgument('extensions', InputArgument::REQUIRED, 'The extensions will be compiled, comma separated'); $this->addOption('with-libs', null, InputOption::VALUE_REQUIRED, 'add additional libraries, comma separated', ''); - $this->addOption('build-micro', null, null, 'build micro'); - $this->addOption('build-cli', null, null, 'build cli'); - $this->addOption('build-fpm', null, null, 'build fpm'); - $this->addOption('build-embed', null, null, 'build embed'); - $this->addOption('build-all', null, null, 'build cli, micro, fpm, embed'); + $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'); + $this->addOption('build-embed', null, null, 'Build embed SAPI'); + $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('enable-zts', null, null, 'enable ZTS support'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); @@ -61,8 +61,9 @@ class BuildCliCommand extends BuildCommand try { // create builder $builder = BuilderProvider::makeBuilderByInput($this->input); - // calculate dependencies - [$extensions, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps($extensions, $libraries); + $include_suggest_ext = $this->getOption('with-suggested-exts'); + $include_suggest_lib = $this->getOption('with-suggested-libs'); + [$extensions, $libraries, $not_included] = DependencyUtil::getExtsAndLibs($extensions, $libraries, $include_suggest_ext, $include_suggest_lib); // print info $indent_texts = [ diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 399156c2..0a161465 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -15,8 +15,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Style\SymfonyStyle; -use function Laravel\Prompts\table; - #[AsCommand('dev:extensions', 'Helper command that lists available extension details', ['list-ext'])] class AllExtCommand extends BaseCommand { @@ -88,7 +86,8 @@ class AllExtCommand extends BaseCommand if ($data === []) { $style->warning('Unknown extension selected: ' . implode(',', $extensions)); } else { - table($columns, $data); + $func = PHP_OS_FAMILY === 'Windows' ? [$style, 'table'] : '\Laravel\Prompts\table'; + call_user_func($func, $columns, $data); } return static::SUCCESS; diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index 4e0b74b1..fe958b82 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -14,6 +14,20 @@ use SPC\store\Config; */ class DependencyUtil { + public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array + { + if (!$include_suggested_exts && !$include_suggested_libs) { + return self::getExtLibsByDeps($exts, $additional_libs); + } + if ($include_suggested_exts && $include_suggested_libs) { + return self::getAllExtLibsByDeps($exts, $additional_libs); + } + if (!$include_suggested_exts) { + return self::getExtLibsByDeps($exts, $additional_libs); + } + return self::getAllExtLibsByDeps($exts, $additional_libs, false); + } + /** * Obtain the dependent lib list according to the required ext list, and sort according to the dependency * @@ -24,7 +38,7 @@ class DependencyUtil * @throws RuntimeException * @throws FileSystemException */ - public static function getExtLibsByDeps(array $exts, array $additional_libs = []): array + public static function getExtLibsByDeps(array $exts, array $additional_libs = [], bool $include_suggested_exts = false): array { $sorted = []; $visited = []; @@ -99,7 +113,7 @@ class DependencyUtil return $final; } - public static function getAllExtLibsByDeps(array $exts): array + public static function getAllExtLibsByDeps(array $exts, array $additional_libs = [], bool $include_suggested_libs = true): array { $sorted = []; $visited = []; @@ -109,12 +123,13 @@ class DependencyUtil self::visitExtAllDeps($ext, $visited, $sorted); } } - $libs = []; + $libs = $additional_libs; foreach ($sorted as $ext) { if (!in_array($ext, $exts)) { $not_included_exts[] = $ext; } - foreach (array_merge(Config::getExt($ext, 'lib-depends', []), Config::getExt($ext, 'lib-suggests', [])) as $dep) { + $total = $include_suggested_libs ? array_merge(Config::getExt($ext, 'lib-depends', []), Config::getExt($ext, 'lib-suggests', [])) : Config::getExt($ext, 'lib-depends', []); + foreach ($total as $dep) { if (!in_array($dep, $libs)) { $libs[] = $dep; } From 52ed0e2cee9a136d0d60005ead8b98f2c7786ec5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 7 Feb 2024 01:19:54 +0800 Subject: [PATCH 182/415] add glibtoolize check for macos --- src/SPC/doctor/item/MacOSToolCheckList.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index 9f43e8fb..6bbeb864 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -31,6 +31,7 @@ class MacOSToolCheckList 'gzip', 'bzip2', 'cmake', + 'glibtoolize', ]; #[AsCheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)] @@ -72,8 +73,14 @@ class MacOSToolCheckList #[AsFixItem('build-tools')] public function fixBuildTools(array $missing): bool { + $replacement = [ + 'glibtoolize' => 'libtool', + ]; foreach ($missing as $cmd) { try { + if (isset($replacement[$cmd])) { + $cmd = $replacement[$cmd]; + } shell(true)->exec('brew install --formula ' . escapeshellarg($cmd)); } catch (RuntimeException) { return false; From e8351969724352c567037d06d1502bed5cc1c133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Sun, 11 Feb 2024 02:35:09 +0100 Subject: [PATCH 183/415] Add language badges to README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6b87108d..eaa94513 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # static-php-cli +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white)](README-zh.md) +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-white)](README.md) [![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() @@ -14,9 +16,6 @@ Static PHP built by **static-php-cli** supports `cli`, `fpm`, `embed` and `micro **static-php-cli** also has the ability to package PHP projects along with the PHP interpreter into one single executable file. -- [README - English](./README.md) -- [README - 中文](./README-zh.md) - ## Features static-php-cli (you can call it `spc`) has a lot of features: From 3dae904122214ec0bd15a233172009fabf57c6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Sun, 11 Feb 2024 02:36:55 +0100 Subject: [PATCH 184/415] Update README-zh.md --- README-zh.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README-zh.md b/README-zh.md index a7a8e26d..1bfb6554 100755 --- a/README-zh.md +++ b/README-zh.md @@ -1,5 +1,7 @@ # static-php-cli +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-white?style=flat-square)](README.md) +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white?style=flat-square)](README-zh.md) [![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() @@ -12,9 +14,6 @@ **static-php-cli**也支持将 PHP 代码和 PHP 运行时打包为一个文件并运行。 -- [README - English](./README.md) -- [README - 中文](./README-zh.md) - ## 特性 static-php-cli(简称 `spc`)有许多特性: From 957daf0547dfbba45c7b3f56041ff11cee9e000d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Sun, 11 Feb 2024 02:37:38 +0100 Subject: [PATCH 185/415] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eaa94513..4fe6d730 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # static-php-cli -[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white)](README-zh.md) -[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-white)](README.md) +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white?style=flat-square)](README-zh.md) +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-white?style=flat-square)](README.md) [![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() From 4d87cd11cc6a8199855120eae50a9a1b39a553cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 12 Feb 2024 10:39:22 +0100 Subject: [PATCH 186/415] Update README-zh.md --- README-zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index 1bfb6554..509e0caa 100755 --- a/README-zh.md +++ b/README-zh.md @@ -1,7 +1,7 @@ # static-php-cli -[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-white?style=flat-square)](README.md) -[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white?style=flat-square)](README-zh.md) +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md) +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md) [![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() From b977543c7293101ad540f0d0d1cdfd8f136f01c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 12 Feb 2024 10:39:37 +0100 Subject: [PATCH 187/415] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fe6d730..64f64595 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # static-php-cli -[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-white?style=flat-square)](README-zh.md) -[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-white?style=flat-square)](README.md) +[![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md) +[![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md) [![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() [![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() From b8d8461e61e2bd5c5ff9a7ebf5eeeb320cb08f2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Mon, 12 Feb 2024 12:59:51 +0100 Subject: [PATCH 188/415] Fix badges in README (#333) * Fix badges in README * Remove Discord badge * Fix badges in README-zh --- README-zh.md | 9 ++++----- README.md | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README-zh.md b/README-zh.md index 509e0caa..7fb1384c 100755 --- a/README-zh.md +++ b/README-zh.md @@ -2,11 +2,10 @@ [![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md) [![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md) -[![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) -[![](https://dcbadge.vercel.app/api/server/RNpegEYW?style=flat-square&compact=true&theme=default-inverted)](https://discord.gg/RNpegEYW) +[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases) +[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE) +[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/zh/guide/extensions.html) **static-php-cli**是一个用于静态编译、构建 PHP 解释器的工具,支持众多流行扩展。 diff --git a/README.md b/README.md index 64f64595..9f5a5d47 100755 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@ [![Chinese readme](https://img.shields.io/badge/README-%E4%B8%AD%E6%96%87%20%F0%9F%87%A8%F0%9F%87%B3-moccasin?style=flat-square)](README-zh.md) [![English readme](https://img.shields.io/badge/README-English%20%F0%9F%87%AC%F0%9F%87%A7-moccasin?style=flat-square)](README.md) -[![Version](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)]() -[![](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) -[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)]() -[![](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)]([https://static-php.dev/](https://static-php.dev/en/guide/extensions.html)) -[![](https://dcbadge.vercel.app/api/server/RNpegEYW?style=flat-square&compact=true&theme=default-inverted)](https://discord.gg/RNpegEYW) +[![Releases](https://img.shields.io/packagist/v/crazywhalecc/static-php-cli?include_prereleases&label=Release&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/releases) +[![CI](https://img.shields.io/github/actions/workflow/status/crazywhalecc/static-php-cli/tests.yml?branch=main&label=Build%20Test&style=flat-square)](https://github.com/crazywhalecc/static-php-cli/actions/workflows/tests.yml) +[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/crazywhalecc/static-php-cli/blob/main/LICENSE) +[![Extensions](https://img.shields.io/badge/Extension%20Counter-75+-yellow.svg?style=flat-square)](https://static-php.dev/en/guide/extensions.html) **static-php-cli** is a powerful tool designed for building static, standalone PHP runtime with popular extensions. From 9777c9aa93a6b4626eca88d5a18917fac0d05f43 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 14 Feb 2024 00:49:58 +0800 Subject: [PATCH 189/415] Fix openpty bug for linux (#337) * fix openpty bug for linux * add event test * add download retry for download command * use test token * use test token * use test token * use test token * re-fix this bug --- .github/workflows/tests.yml | 14 +++++++++++++- src/SPC/builder/extension/event.php | 13 +++++++++++++ src/SPC/store/SourcePatcher.php | 1 - src/globals/test-extensions.php | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b04a1324..21dcb0e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -129,6 +129,13 @@ jobs: extensions: curl, openssl, mbstring ini-values: memory_limit=-1 + - name: "Use test token if exists" + if: matrix.os != 'windows-latest' + run: | + if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then + echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV + fi + - name: "Cache Composer packages" id: composer-cache uses: actions/cache@v3 @@ -152,7 +159,12 @@ jobs: run: bin/spc doctor --auto-fix - name: "Run Build Tests (download)" - run: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug + uses: nick-fields/retry@v3 + with: + timeout_minutes: 10 + max_attempts: 3 + retry_on: error + command: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug diff --git a/src/SPC/builder/extension/event.php b/src/SPC/builder/extension/event.php index 7339ad17..a1cc7bcc 100644 --- a/src/SPC/builder/extension/event.php +++ b/src/SPC/builder/extension/event.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\macos\MacOSBuilder; use SPC\exception\FileSystemException; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -34,4 +35,16 @@ class event extends Extension FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-levent_openssl/', $this->getLibFilesString()); return true; } + + /** + * @throws FileSystemException + */ + public function patchBeforeMake(): bool + { + // Prevent event extension compile error on macOS + if ($this->builder instanceof MacOSBuilder) { + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); + } + return true; + } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c1fe1be7..53f74ddc 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -197,7 +197,6 @@ class SourcePatcher FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_STRLCAT 1$/m', ''); } if ($builder instanceof UnixBuilderBase) { - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/main/php_config.h', '/^#define HAVE_OPENPTY 1$/m', ''); FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 12843feb..9bc07eba 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'calendar,ctype,curl,dom,fileinfo,filter,gd,iconv,imagick,mbregex,mbstring,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,rar,redis,session,simplexml,soap,sockets,sqlite3,swoole,swoole-hook-mysql,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib', + 'Linux', 'Darwin' => 'event', 'Windows' => 'mbstring,openssl', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', }; From 05e3898e7a497f53f84b9fa9f7835cdbcc4ffd3d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 01:28:10 +0800 Subject: [PATCH 190/415] add gettext support --- README-zh.md | 2 +- README.md | 2 +- config/ext.json | 2 +- config/lib.json | 16 +++++++++++++ config/source.json | 9 ++++++++ src/SPC/builder/extension/gettext.php | 27 ++++++++++++++++++++++ src/SPC/builder/linux/library/gettext.php | 12 ++++++++++ src/SPC/builder/macos/library/gettext.php | 12 ++++++++++ src/SPC/builder/unix/library/gettext.php | 27 ++++++++++++++++++++++ src/SPC/command/BuildCliCommand.php | 2 +- src/globals/objs/test.mo | Bin 0 -> 376 bytes src/globals/test-extensions.php | 2 +- src/globals/tests/gettext.php | 23 ++++++++++++++++++ 13 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 src/SPC/builder/extension/gettext.php create mode 100644 src/SPC/builder/linux/library/gettext.php create mode 100644 src/SPC/builder/macos/library/gettext.php create mode 100644 src/SPC/builder/unix/library/gettext.php create mode 100644 src/globals/objs/test.mo create mode 100644 src/globals/tests/gettext.php diff --git a/README-zh.md b/README-zh.md index 7fb1384c..a4b73279 100755 --- a/README-zh.md +++ b/README-zh.md @@ -248,7 +248,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys ## 赞助本项目 -你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。 +你可以在 [我的个人赞助页](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md) 支持我和我的项目。你捐赠的一部分将会被用于维护 **static-php.dev** 服务器。 ## 开源协议 diff --git a/README.md b/README.md index 9f5a5d47..15e0f556 100755 --- a/README.md +++ b/README.md @@ -272,7 +272,7 @@ Now there is a [static-php](https://github.com/static-php) organization, which i ## Sponsor this project -You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). +You can sponsor my project on [this page](https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md). A portion of your donation will be used to maintain the **static-php.dev** server. ## Open-Source License diff --git a/config/ext.json b/config/ext.json index 3ee4cd32..ed63bf4a 100644 --- a/config/ext.json +++ b/config/ext.json @@ -95,7 +95,7 @@ }, "gettext": { "type": "builtin", - "arg-type": "with", + "arg-type": "with-prefix", "lib-depends": [ "gettext" ] diff --git a/config/lib.json b/config/lib.json index d9400b76..6f3b058e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -83,6 +83,22 @@ "brotli" ] }, + "gettext": { + "source": "gettext", + "static-libs-unix": [ + "libintl.a" + ], + "lib-depends": [ + "libiconv" + ], + "lib-suggests": [ + "ncurses", + "libxml2" + ], + "frameworks": [ + "CoreFoundation" + ] + }, "glfw": { "source": "ext-glfw", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index b62ac334..73212640 100644 --- a/config/source.json +++ b/config/source.json @@ -129,6 +129,15 @@ "path": "LICENSE.TXT" } }, + "gettext": { + "type": "filelist", + "url": "https://ftp.gnu.org/pub/gnu/gettext/", + "regex": "/href=\"(?gettext-(?[^\"]+)\\.tar\\.xz)\"/", + "license": { + "type": "file", + "path": "COPYING" + } + }, "gmp": { "type": "ghtagtar", "repo": "alisw/GMP", diff --git a/src/SPC/builder/extension/gettext.php b/src/SPC/builder/extension/gettext.php new file mode 100644 index 00000000..19f48f7e --- /dev/null +++ b/src/SPC/builder/extension/gettext.php @@ -0,0 +1,27 @@ +builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; + FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lintl/', $this->getLibFilesString() . $frameworks); + return true; + } +} diff --git a/src/SPC/builder/linux/library/gettext.php b/src/SPC/builder/linux/library/gettext.php new file mode 100644 index 00000000..58b54b82 --- /dev/null +++ b/src/SPC/builder/linux/library/gettext.php @@ -0,0 +1,12 @@ +builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : ''; + $extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : ''; + shell()->cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static ' . + '--disable-shared ' . + '--disable-java ' . + $extra . + '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . + '--prefix=' . BUILD_ROOT_PATH + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index fa5e40b6..24d241e3 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -32,7 +32,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('enable-zts', null, null, 'enable ZTS support'); $this->addOption('disable-opcache-jit', null, null, 'disable opcache jit'); $this->addOption('with-hardcoded-ini', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Patch PHP source code, inject hardcoded INI'); - $this->addOption('with-micro-fake-cli', null, null, 'Enable phpmicro fake cli'); + $this->addOption('with-micro-fake-cli', null, null, 'Let phpmicro\'s PHP_SAPI use "cli" instead of "micro"'); $this->addOption('with-suggested-libs', 'L', null, 'Build with suggested libs for selected exts and libs'); $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); diff --git a/src/globals/objs/test.mo b/src/globals/objs/test.mo new file mode 100644 index 0000000000000000000000000000000000000000..208349ee17b90f7980242e3c3ffc61dc78a5dd8f GIT binary patch literal 376 zcmYL@y-ve06h;H$N6N^;!r&cTV5>|)HH}*$>?EXV1#G4@!6?{~Cfn?Mg}lL1@66|lP&1lRCx12yb0|7q|4^7H=j z{rMVX&OWM{$MGCbm20#$1Z8w^Nkczgy` zQ!ZqwaG~TAL7XO|No&&MykF^#b>*r91|k-0rG4Bv3J2DBW#GG)8hpH3`op@C+MJ-- lgLIAZr;}ocyQ^NSb*~&|W@hKwlmvC}v=0Neluvb~f?s;kWEcPd literal 0 HcmV?d00001 diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 9bc07eba..38c97f31 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'event', + 'Linux', 'Darwin' => 'gettext', 'Windows' => 'mbstring,openssl', }; diff --git a/src/globals/tests/gettext.php b/src/globals/tests/gettext.php new file mode 100644 index 00000000..dacc512c --- /dev/null +++ b/src/globals/tests/gettext.php @@ -0,0 +1,23 @@ + Date: Fri, 16 Feb 2024 01:45:14 +0800 Subject: [PATCH 191/415] libxml2 use zlib prefix --- src/SPC/builder/linux/library/libxml2.php | 2 +- src/SPC/builder/macos/library/libxml2.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index e6131224..f0c1c312 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -18,7 +18,7 @@ class libxml2 extends LinuxLibraryBase */ public function build(): void { - $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; + $enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF'; $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 4b22bc4a..3c154aac 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -18,7 +18,7 @@ class libxml2 extends MacOSLibraryBase */ protected function build(): void { - $enable_zlib = $this->builder->getLib('zlib') ? 'ON' : 'OFF'; + $enable_zlib = $this->builder->getLib('zlib') ? ('ON -DZLIB_LIBRARY=' . BUILD_LIB_PATH . '/libz.a -DZLIB_INCLUDE_DIR=' . BUILD_INCLUDE_PATH) : 'OFF'; $enable_icu = $this->builder->getLib('icu') ? 'ON' : 'OFF'; $enable_xz = $this->builder->getLib('xz') ? 'ON' : 'OFF'; From 939db75268eba2d27334fc49548bddd4770745fd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 18:56:33 +0800 Subject: [PATCH 192/415] refactor DependencyUtil, use for-libs and for-sources instead of `by` --- src/SPC/builder/unix/UnixBuilderBase.php | 2 +- src/SPC/builder/windows/WindowsBuilder.php | 2 +- src/SPC/command/BuildLibsCommand.php | 2 +- src/SPC/command/DownloadCommand.php | 2 +- src/SPC/command/DumpLicenseCommand.php | 18 +- src/SPC/command/dev/AllExtCommand.php | 2 +- src/SPC/util/DependencyUtil.php | 286 ++++++++++----------- 7 files changed, 145 insertions(+), 169 deletions(-) diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index c48c3ef3..583ad812 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -107,7 +107,7 @@ abstract class UnixBuilderBase extends BuilderBase // if no libs specified, compile all supported libs if ($sorted_libraries === [] && $this->isLibsOnly()) { $libraries = array_keys($support_lib_list); - $sorted_libraries = DependencyUtil::getLibsByDeps($libraries); + $sorted_libraries = DependencyUtil::getLibs($libraries); } // pkg-config must be compiled first, whether it is specified or not diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 265751ba..b007e7ff 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -192,7 +192,7 @@ class WindowsBuilder extends BuilderBase // if no libs specified, compile all supported libs if ($sorted_libraries === [] && $this->isLibsOnly()) { $libraries = array_keys($support_lib_list); - $sorted_libraries = DependencyUtil::getLibsByDeps($libraries); + $sorted_libraries = DependencyUtil::getLibs($libraries); } // add lib object for builder diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index f3fb8897..f4d3b26c 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -60,7 +60,7 @@ class BuildLibsCommand extends BuildCommand // 只编译 library 的情况下,标记 $builder->setLibsOnly(); // 编译和检查库完整 - $libraries = DependencyUtil::getLibsByDeps($libraries); + $libraries = DependencyUtil::getLibs($libraries); $builder->buildLibs($libraries); $time = round(microtime(true) - START_TIME, 3); diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 542dae34..fa7f7543 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -214,7 +214,7 @@ class DownloadCommand extends BaseCommand */ private function calculateSourcesByExt(array $extensions, bool $include_suggests = true): array { - [$extensions, $libraries] = $include_suggests ? DependencyUtil::getAllExtLibsByDeps($extensions) : DependencyUtil::getExtLibsByDeps($extensions); + [$extensions, $libraries] = $include_suggests ? DependencyUtil::getExtsAndLibs($extensions, [], true, true) : DependencyUtil::getExtsAndLibs($extensions); $sources = []; foreach ($extensions as $extension) { if (Config::getExt($extension, 'type') === 'external') { diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index 5535f820..2d01a692 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -22,8 +22,8 @@ class DumpLicenseCommand extends BaseCommand { $this->addOption('for-extensions', null, InputOption::VALUE_REQUIRED, 'Dump by extensions and related libraries', null); $this->addOption('without-php', null, InputOption::VALUE_NONE, 'Dump without php-src'); - $this->addOption('by-libs', null, InputOption::VALUE_REQUIRED, 'Dump by libraries', null); - $this->addOption('by-sources', null, InputOption::VALUE_REQUIRED, 'Dump by original sources (source.json)', null); + $this->addOption('for-libs', null, InputOption::VALUE_REQUIRED, 'Dump by libraries', null); + $this->addOption('for-sources', null, InputOption::VALUE_REQUIRED, 'Dump by original sources (source.json)', null); $this->addOption('dump-dir', null, InputOption::VALUE_REQUIRED, 'Change dump directory', BUILD_ROOT_PATH . '/license'); } @@ -39,7 +39,7 @@ class DumpLicenseCommand extends BaseCommand // 从参数中获取要编译的 extensions,并转换为数组 $extensions = array_map('trim', array_filter(explode(',', $this->getOption('for-extensions')))); // 根据提供的扩展列表获取依赖库列表并编译 - [$extensions, $libraries] = DependencyUtil::getExtLibsByDeps($extensions); + [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions); $dumper->addExts($extensions); $dumper->addLibs($libraries); if (!$this->getOption('without-php')) { @@ -52,22 +52,22 @@ class DumpLicenseCommand extends BaseCommand $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); return static::SUCCESS; } - if ($this->getOption('by-libs') !== null) { - $libraries = array_map('trim', array_filter(explode(',', $this->getOption('by-libs')))); - $libraries = DependencyUtil::getLibsByDeps($libraries); + if ($this->getOption('for-libs') !== null) { + $libraries = array_map('trim', array_filter(explode(',', $this->getOption('for-libs')))); + $libraries = DependencyUtil::getLibs($libraries); $dumper->addLibs($libraries); $dumper->dump($this->getOption('dump-dir')); $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); return static::SUCCESS; } - if ($this->getOption('by-sources') !== null) { - $sources = array_map('trim', array_filter(explode(',', $this->getOption('by-sources')))); + if ($this->getOption('for-sources') !== null) { + $sources = array_map('trim', array_filter(explode(',', $this->getOption('for-sources')))); $dumper->addSources($sources); $dumper->dump($this->getOption('dump-dir')); $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); return static::SUCCESS; } - $this->output->writeln('You must use one of "--for-extensions=", "--by-libs=", "--by-sources=" to dump'); + $this->output->writeln('You must use one of "--for-extensions=", "--for-libs=", "--for-sources=" to dump'); return static::FAILURE; } } diff --git a/src/SPC/command/dev/AllExtCommand.php b/src/SPC/command/dev/AllExtCommand.php index 0a161465..90675eb5 100644 --- a/src/SPC/command/dev/AllExtCommand.php +++ b/src/SPC/command/dev/AllExtCommand.php @@ -59,7 +59,7 @@ class AllExtCommand extends BaseCommand } try { - [, $libraries, $not_included] = DependencyUtil::getExtLibsByDeps([$extension]); + [, $libraries, $not_included] = DependencyUtil::getExtsAndLibs([$extension]); } catch (WrongUsageException) { $libraries = $not_included = []; } diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index fe958b82..e82a93dc 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -5,104 +5,164 @@ declare(strict_types=1); namespace SPC\util; use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; /** - * 依赖处理工具类,包含处理扩展、库的依赖列表顺序等 + * Dependency processing tool class, including processing extensions, library dependency list order, etc. */ class DependencyUtil { - public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array + /** + * Convert platform extensions to library dependencies and suggestions. + * + * @throws WrongUsageException + * @throws FileSystemException + */ + public static function platExtToLibs(): array { - if (!$include_suggested_exts && !$include_suggested_libs) { - return self::getExtLibsByDeps($exts, $additional_libs); + $exts = Config::getExts(); + $libs = Config::getLibs(); + $dep_list = []; + foreach ($exts as $ext_name => $ext) { + // convert ext-depends value to ext@xxx + $ext_depends = Config::getExt($ext_name, 'ext-depends', []); + $ext_depends = array_map(fn ($x) => "ext@{$x}", $ext_depends); + // convert ext-suggests value to ext@xxx + $ext_suggests = Config::getExt($ext_name, 'ext-suggests', []); + $ext_suggests = array_map(fn ($x) => "ext@{$x}", $ext_suggests); + // merge ext-depends with lib-depends + $lib_depends = Config::getExt($ext_name, 'lib-depends', []); + $depends = array_merge($ext_depends, $lib_depends); + // merge ext-suggests with lib-suggests + $lib_suggests = Config::getExt($ext_name, 'lib-suggests', []); + $suggests = array_merge($ext_suggests, $lib_suggests); + $dep_list["ext@{$ext_name}"] = [ + 'depends' => $depends, + 'suggests' => $suggests, + ]; } - if ($include_suggested_exts && $include_suggested_libs) { - return self::getAllExtLibsByDeps($exts, $additional_libs); + foreach ($libs as $lib_name => $lib) { + $dep_list[$lib_name] = [ + 'depends' => Config::getLib($lib_name, 'lib-depends', []), + 'suggests' => Config::getLib($lib_name, 'lib-suggests', []), + ]; } - if (!$include_suggested_exts) { - return self::getExtLibsByDeps($exts, $additional_libs); - } - return self::getAllExtLibsByDeps($exts, $additional_libs, false); + // here is an array that only contains dependency map + return $dep_list; } /** - * Obtain the dependent lib list according to the required ext list, and sort according to the dependency - * - * @param array $exts extensions list - * @param array $additional_libs List of additional libraries to add to activate the extra library features triggered by lib-suggests - * @return array Returns an array containing three arrays, [extensions, libraries, not included extensions] * @throws WrongUsageException - * @throws RuntimeException * @throws FileSystemException */ - public static function getExtLibsByDeps(array $exts, array $additional_libs = [], bool $include_suggested_exts = false): array + public static function getLibs(array $libs, bool $include_suggested_libs = false): array { - $sorted = []; - $visited = []; - $not_included_exts = []; - foreach ($exts as $ext) { - if (!isset($visited[$ext])) { - self::visitExtDeps($ext, $visited, $sorted); - } - } - $sorted_suggests = []; - $visited_suggests = []; - $final = []; - foreach ($exts as $ext) { - if (!isset($visited_suggests[$ext])) { - self::visitExtAllDeps($ext, $visited_suggests, $sorted_suggests); - } - } - foreach ($sorted_suggests as $suggest) { - if (in_array($suggest, $sorted)) { - $final[] = $suggest; - } - } - $libs = $additional_libs; + $dep_list = self::platExtToLibs(); - foreach ($final as $ext) { - if (!in_array($ext, $exts)) { - $not_included_exts[] = $ext; - } - foreach (Config::getExt($ext, 'lib-depends', []) as $lib) { - if (!in_array($lib, $libs)) { - $libs[] = $lib; + if ($include_suggested_libs) { + foreach ($dep_list as $name => $obj) { + foreach ($obj['suggests'] as $id => $suggest) { + if (!str_starts_with($suggest, 'ext@')) { + $dep_list[$name]['depends'][] = $suggest; + array_splice($dep_list[$name]['suggests'], $id, 1); + } } } } - return [$final, self::getLibsByDeps($libs), $not_included_exts]; + + $final = self::doVisitPlat($libs, $dep_list); + + $libs_final = []; + foreach ($final as $item) { + if (!str_starts_with($item, 'ext@')) { + $libs_final[] = $item; + } + } + return $libs_final; } /** - * 根据 lib 库的依赖关系进行一个排序,同时返回多出来的依赖列表 - * - * @param array $libs 要排序的 libs 列表 - * @return array 排序后的列表 - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException + * @throws FileSystemException|WrongUsageException */ - public static function getLibsByDeps(array $libs): array + public static function getExtsAndLibs(array $exts, array $additional_libs = [], bool $include_suggested_exts = false, bool $include_suggested_libs = false): array { - $sorted = []; - $visited = []; + $dep_list = self::platExtToLibs(); - // 遍历所有 - foreach ($libs as $lib) { - if (!isset($visited[$lib])) { - self::visitLibDeps($lib, $visited, $sorted); + // include suggested extensions + if ($include_suggested_exts) { + // check every deps suggests contains ext@ + foreach ($dep_list as $name => $obj) { + foreach ($obj['suggests'] as $id => $suggest) { + if (str_starts_with($suggest, 'ext@')) { + $dep_list[$name]['depends'][] = $suggest; + array_splice($dep_list[$name]['suggests'], $id, 1); + } + } } } + // include suggested libraries + if ($include_suggested_libs) { + // check every deps suggests + foreach ($dep_list as $name => $obj) { + foreach ($obj['suggests'] as $id => $suggest) { + if (!str_starts_with($suggest, 'ext@')) { + $dep_list[$name]['depends'][] = $suggest; + array_splice($dep_list[$name]['suggests'], $id, 1); + } + } + } + } + + // convert ext_name to ext@ext_name + $origin_exts = $exts; + $exts = array_map(fn ($x) => "ext@{$x}", $exts); + $exts = array_merge($exts, $additional_libs); + + $final = self::doVisitPlat($exts, $dep_list); + + // revert array + $exts_final = []; + $libs_final = []; + $not_included_final = []; + foreach ($final as $item) { + if (str_starts_with($item, 'ext@')) { + $tmp = substr($item, 4); + if (!in_array($tmp, $origin_exts)) { + $not_included_final[] = $tmp; + } + $exts_final[] = $tmp; + } else { + $libs_final[] = $item; + } + } + return [$exts_final, $libs_final, $not_included_final]; + } + + /** + * @throws WrongUsageException + */ + private static function doVisitPlat(array $deps, array $dep_list): array + { + // default: get extension exts and libs sorted by dep_list + $sorted = []; + $visited = []; + foreach ($deps as $ext_name) { + if (!isset($dep_list[$ext_name])) { + $ext_name = str_starts_with($ext_name, 'ext@') ? ('Extension [' . substr($ext_name, 4) . ']') : ('Library [' . $ext_name . ']'); + throw new WrongUsageException("{$ext_name} not exist !"); + } + if (!isset($visited[$ext_name])) { + self::visitPlatDeps($ext_name, $dep_list, $visited, $sorted); + } + } $sorted_suggests = []; $visited_suggests = []; $final = []; - foreach ($libs as $lib) { - if (!isset($visited_suggests[$lib])) { - self::visitLibAllDeps($lib, $visited_suggests, $sorted_suggests); + foreach ($deps as $ext_name) { + if (!isset($visited_suggests[$ext_name])) { + self::visitPlatAllDeps($ext_name, $dep_list, $visited_suggests, $sorted_suggests); } } foreach ($sorted_suggests as $suggest) { @@ -113,50 +173,7 @@ class DependencyUtil return $final; } - public static function getAllExtLibsByDeps(array $exts, array $additional_libs = [], bool $include_suggested_libs = true): array - { - $sorted = []; - $visited = []; - $not_included_exts = []; - foreach ($exts as $ext) { - if (!isset($visited[$ext])) { - self::visitExtAllDeps($ext, $visited, $sorted); - } - } - $libs = $additional_libs; - foreach ($sorted as $ext) { - if (!in_array($ext, $exts)) { - $not_included_exts[] = $ext; - } - $total = $include_suggested_libs ? array_merge(Config::getExt($ext, 'lib-depends', []), Config::getExt($ext, 'lib-suggests', [])) : Config::getExt($ext, 'lib-depends', []); - foreach ($total as $dep) { - if (!in_array($dep, $libs)) { - $libs[] = $dep; - } - } - } - return [$sorted, self::getAllLibsByDeps($libs), $not_included_exts]; - } - - public static function getAllLibsByDeps(array $libs): array - { - $sorted = []; - $visited = []; - - foreach ($libs as $lib) { - if (!isset($visited[$lib])) { - self::visitLibAllDeps($lib, $visited, $sorted); - } - } - return $sorted; - } - - /** - * @throws FileSystemException - * @throws RuntimeException - * @throws WrongUsageException - */ - private static function visitLibAllDeps(string $lib_name, array &$visited, array &$sorted): void + private static function visitPlatAllDeps(string $lib_name, array $dep_list, array &$visited, array &$sorted): void { // 如果已经识别到了,那就不管 if (isset($visited[$lib_name])) { @@ -164,37 +181,13 @@ class DependencyUtil } $visited[$lib_name] = true; // 遍历该依赖的所有依赖(此处的 getLib 如果检测到当前库不存在的话,会抛出异常) - foreach (array_merge(Config::getLib($lib_name, 'lib-depends', []), Config::getLib($lib_name, 'lib-suggests', [])) as $dep) { - self::visitLibDeps($dep, $visited, $sorted); + foreach (array_merge($dep_list[$lib_name]['depends'], $dep_list[$lib_name]['suggests']) as $dep) { + self::visitPlatAllDeps($dep, $dep_list, $visited, $sorted); } $sorted[] = $lib_name; } - /** - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException - */ - private static function visitExtAllDeps(string $ext_name, array &$visited, array &$sorted): void - { - // 如果已经识别到了,那就不管 - if (isset($visited[$ext_name])) { - return; - } - $visited[$ext_name] = true; - // 遍历该依赖的所有依赖(此处的 getLib 如果检测到当前库不存在的话,会抛出异常) - foreach (array_merge(Config::getExt($ext_name, 'ext-depends', []), Config::getExt($ext_name, 'ext-suggests', [])) as $dep) { - self::visitExtDeps($dep, $visited, $sorted); - } - $sorted[] = $ext_name; - } - - /** - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException - */ - private static function visitLibDeps(string $lib_name, array &$visited, array &$sorted): void + private static function visitPlatDeps(string $lib_name, array $dep_list, array &$visited, array &$sorted): void { // 如果已经识别到了,那就不管 if (isset($visited[$lib_name])) { @@ -202,26 +195,9 @@ class DependencyUtil } $visited[$lib_name] = true; // 遍历该依赖的所有依赖(此处的 getLib 如果检测到当前库不存在的话,会抛出异常) - foreach (Config::getLib($lib_name, 'lib-depends', []) as $dep) { - self::visitLibDeps($dep, $visited, $sorted); + foreach ($dep_list[$lib_name]['depends'] as $dep) { + self::visitPlatDeps($dep, $dep_list, $visited, $sorted); } $sorted[] = $lib_name; } - - /** - * @throws RuntimeException - * @throws FileSystemException - * @throws WrongUsageException - */ - private static function visitExtDeps(string $ext_name, array &$visited, array &$sorted): void - { - if (isset($visited[$ext_name])) { - return; - } - $visited[$ext_name] = true; - foreach (Config::getExt($ext_name, 'ext-depends', []) as $dep) { - self::visitExtDeps($dep, $visited, $sorted); - } - $sorted[] = $ext_name; - } } From 2649dcd05cc0f3aaa138b82d317adef42b9154c3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 18:56:59 +0800 Subject: [PATCH 193/415] add BuilderBase::getPHPVersionFromArchive --- src/SPC/builder/BuilderBase.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index ed7a21a3..2314a7f2 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -231,6 +231,30 @@ abstract class BuilderBase throw new RuntimeException('PHP version file format is malformed, please remove it and download again'); } + /** + * Get PHP version from archive file name. + * + * @param null|string $file php-*.*.*.tar.gz filename, read from lockfile if empty + */ + 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) { + return false; + } + } + if (preg_match('/php-(\d+\.\d+\.\d+)/', $file, $match)) { + return $match[1]; + } + return false; + } + /** * Get build type name string to display. * From d9bd96af71a58e25b01bfff6b8e5dadd42cc663d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 18:57:12 +0800 Subject: [PATCH 194/415] add dependency util tests --- tests/SPC/util/DependencyUtilTest.php | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/SPC/util/DependencyUtilTest.php diff --git a/tests/SPC/util/DependencyUtilTest.php b/tests/SPC/util/DependencyUtilTest.php new file mode 100644 index 00000000..b77d9d79 --- /dev/null +++ b/tests/SPC/util/DependencyUtilTest.php @@ -0,0 +1,90 @@ + [ + 'type' => 'url', + 'url' => 'https://pecl.php.net/get/APCu', + 'filename' => 'apcu.tgz', + 'license' => [ + 'type' => 'file', + 'path' => 'LICENSE', + ], + ], + ]; + Config::$lib = [ + 'libaaa' => [ + 'source' => 'test1', + 'static-libs' => ['libaaa.a'], + 'lib-depends' => ['libbbb', 'libccc'], + 'lib-suggests' => ['libeee'], + ], + 'libbbb' => [ + 'source' => 'test1', + 'static-libs' => ['libbbb.a'], + 'lib-suggests' => ['libccc'], + ], + 'libccc' => [ + 'source' => 'test1', + 'static-libs' => ['libccc.a'], + ], + 'libeee' => [ + 'source' => 'test1', + 'static-libs' => ['libeee.a'], + 'lib-suggests' => ['libfff'], + ], + 'libfff' => [ + 'source' => 'test1', + 'static-libs' => ['libfff.a'], + ], + ]; + Config::$ext = [ + 'ext-a' => [ + 'type' => 'builtin', + 'lib-depends' => ['libaaa'], + 'ext-suggests' => ['ext-b'], + ], + 'ext-b' => [ + 'type' => 'builtin', + 'lib-depends' => ['libeee'], + ], + ]; + // test getExtLibsByDeps (notmal test with ext-depends and lib-depends) + + [$exts, $libs, $not_included] = DependencyUtil::getExtsAndLibs(['ext-a'], include_suggested_exts: true); + $this->assertContains('libbbb', $libs); + $this->assertContains('libccc', $libs); + $this->assertContains('ext-b', $exts); + $this->assertContains('ext-b', $not_included); + // test dep order + $this->assertIsInt($b = array_search('libbbb', $libs)); + $this->assertIsInt($c = array_search('libccc', $libs)); + $this->assertIsInt($a = array_search('libaaa', $libs)); + // libbbb, libaaa + $this->assertTrue($b < $a); + $this->assertTrue($c < $a); + $this->assertTrue($c < $b); + } + + public function testNotExistExtException(): void + { + $this->expectException(WrongUsageException::class); + DependencyUtil::getExtsAndLibs(['sdsd']); + } +} From 0954ddcc9681dd443a73dd20e710bd43945ea04a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 18:57:32 +0800 Subject: [PATCH 195/415] refactor some terminal outputs --- src/SPC/command/BuildCliCommand.php | 17 ++++++++++++++--- src/SPC/store/FileSystem.php | 12 ++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index b45ef0b3..01d4e0e7 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -77,12 +77,23 @@ class BuildCliCommand extends BuildCommand if (!empty($this->input->getOption('with-hardcoded-ini'))) { $indent_texts['Hardcoded INI'] = $this->input->getOption('with-hardcoded-ini'); } - $this->printFormatInfo($indent_texts); + if ($this->input->getOption('disable-opcache-jit')) { + $indent_texts['Opcache JIT'] = 'disabled'; + } + try { + $ver = $builder->getPHPVersion(); + $indent_texts['PHP Version'] = $ver; + } catch (\Throwable) { + if (($ver = $builder->getPHPVersionFromArchive()) !== false) { + $indent_texts['PHP Version'] = $ver; + } + } if (!empty($not_included)) { - logger()->warning('Some extensions will be enabled due to dependencies: ' . implode(',', $not_included)); + $indent_texts['Extra Exts (' . count($not_included) . ')'] = implode(', ', $not_included); } - logger()->info('Build will start after 2s ...'); + $this->printFormatInfo($indent_texts); + logger()->notice('Build will start after 2s ...'); sleep(2); if ($this->input->getOption('with-clean')) { diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 8da010e2..7e5411ab 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -227,8 +227,12 @@ class FileSystem { $dir = self::convertPath($dir); // 不是目录不扫,直接 false 处理 + if (!file_exists($dir)) { + logger()->debug('Scan dir failed, no such file or directory.'); + return false; + } if (!is_dir($dir)) { - logger()->warning('Scan dir failed, no such directory.'); + logger()->warning('Scan dir failed, not directory.'); return false; } logger()->debug('scanning directory ' . $dir); @@ -317,8 +321,12 @@ class FileSystem $dir = FileSystem::convertPath($dir); logger()->debug('Removing path recursively: "' . $dir . '"'); // 不是目录不扫,直接 false 处理 + if (!file_exists($dir)) { + logger()->debug('Scan dir failed, no such file or directory.'); + return false; + } if (!is_dir($dir)) { - logger()->warning('Scan dir failed, no such directory.'); + logger()->warning('Scan dir failed, not directory.'); return false; } logger()->debug('scanning directory ' . $dir); From ffa84f8b913378d318f1f8bbd8081413ff788016 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 18:57:44 +0800 Subject: [PATCH 196/415] remove unused exts --- config/ext.json | 21 --------------------- src/globals/test-extensions.php | 6 +++--- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/config/ext.json b/config/ext.json index 3ee4cd32..c88b9bd3 100644 --- a/config/ext.json +++ b/config/ext.json @@ -93,13 +93,6 @@ "freetype" ] }, - "gettext": { - "type": "builtin", - "arg-type": "with", - "lib-depends": [ - "gettext" - ] - }, "glfw": { "type": "external", "arg-type": "custom", @@ -313,13 +306,6 @@ "type": "external", "source": "protobuf" }, - "pspell": { - "type": "builtin", - "arg-type": "with", - "lib-depends": [ - "aspell" - ] - }, "rar": { "type": "external", "source": "rar", @@ -371,13 +357,6 @@ "apcu" ] }, - "snmp": { - "type": "builtin", - "arg-type": "with", - "lib-depends": [ - "net-snmp" - ] - }, "soap": { "type": "builtin", "arg-type": "custom", diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 12843feb..90899a3f 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'calendar,ctype,curl,dom,fileinfo,filter,gd,iconv,imagick,mbregex,mbstring,mysqli,mysqlnd,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,rar,redis,session,simplexml,soap,sockets,sqlite3,swoole,swoole-hook-mysql,tokenizer,xlswriter,xml,xmlreader,xmlwriter,zip,zlib', - 'Windows' => 'mbstring,openssl', + 'Linux', 'Darwin' => '', + 'Windows' => 'mbstring', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', }; From 71c0387ab02fe254ef355f4b029fd98685e50565 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 20:17:34 +0800 Subject: [PATCH 197/415] remove tune flags, add debug output for extension sanity check --- src/SPC/builder/Extension.php | 5 ++++- src/SPC/builder/linux/SystemUtil.php | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index c5c026ff..1776a268 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -185,8 +185,11 @@ class Extension file_get_contents(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php') ); - [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"'); + [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"'); if ($ret !== 0) { + if ($this->builder->getOption('debug')) { + var_dump($out); + } throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check'); } } diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index e04c8e10..0cca1524 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -110,11 +110,7 @@ class SystemUtil public static function getTuneCFlags(string $arch): array { return match ($arch) { - 'x86_64' => [ - '-march=corei7', - '-mtune=core-avx2', - ], - 'arm64', 'aarch64' => [], + 'x86_64', 'arm64', 'aarch64' => [], default => throw new RuntimeException('unsupported arch: ' . $arch), }; } From 49ddb3ec13bbe5d1e7df73a9a083c09bbfa60edd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 23:04:58 +0800 Subject: [PATCH 198/415] fix gettext build --- src/SPC/builder/extension/gettext.php | 11 ++++++++++- src/SPC/builder/unix/library/gettext.php | 1 + src/globals/objs/test.mo | Bin 376 -> 0 bytes src/globals/tests/gettext.php | 6 ++++-- 4 files changed, 15 insertions(+), 3 deletions(-) delete mode 100644 src/globals/objs/test.mo diff --git a/src/SPC/builder/extension/gettext.php b/src/SPC/builder/extension/gettext.php index 19f48f7e..8b29a111 100644 --- a/src/SPC/builder/extension/gettext.php +++ b/src/SPC/builder/extension/gettext.php @@ -16,12 +16,21 @@ class gettext extends Extension { /** * @throws FileSystemException + */ + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl'); + return true; + } + + /** * @throws WrongUsageException + * @throws FileSystemException */ public function patchBeforeConfigure(): bool { $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; - FileSystem::replaceFileRegex(SOURCE_PATH . '/php-src/configure', '/-lintl/', $this->getLibFilesString() . $frameworks); + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks); return true; } } diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 90e6dcfc..3b2dbb30 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -16,6 +16,7 @@ trait gettext '--enable-static ' . '--disable-shared ' . '--disable-java ' . + '--disable-c+ ' . $extra . '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . '--prefix=' . BUILD_ROOT_PATH diff --git a/src/globals/objs/test.mo b/src/globals/objs/test.mo deleted file mode 100644 index 208349ee17b90f7980242e3c3ffc61dc78a5dd8f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 376 zcmYL@y-ve06h;H$N6N^;!r&cTV5>|)HH}*$>?EXV1#G4@!6?{~Cfn?Mg}lL1@66|lP&1lRCx12yb0|7q|4^7H=j z{rMVX&OWM{$MGCbm20#$1Z8w^Nkczgy` zQ!ZqwaG~TAL7XO|No&&MykF^#b>*r91|k-0rG4Bv3J2DBW#GG)8hpH3`op@C+MJ-- lgLIAZr;}ocyQ^NSb*~&|W@hKwlmvC}v=0Neluvb~f?s;kWEcPd diff --git a/src/globals/tests/gettext.php b/src/globals/tests/gettext.php index dacc512c..c161d682 100644 --- a/src/globals/tests/gettext.php +++ b/src/globals/tests/gettext.php @@ -4,13 +4,15 @@ declare(strict_types=1); assert(function_exists('gettext')); assert(function_exists('bindtextdomain')); +assert(function_exists('textdomain')); assert(function_exists('bind_textdomain_codeset')); if (!is_dir('locale/en_US/LC_MESSAGES/')) { mkdir('locale/en_US/LC_MESSAGES/', 0755, true); } if (!file_exists('locale/en_US/LC_MESSAGES/test.mo')) { - file_put_contents('locale/en_US/LC_MESSAGES/test.mo', file_get_contents(__DIR__ . '/../objs/test.mo')); + $mo = '3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABgAAAFEAAAAXAQAAWAAAAAcAAABwAQAAAQAAAAAAAAAAAAAAAgAAAAAAAAAA56S65L6LAFByb2plY3QtSWQtVmVyc2lvbjogUEFDS0FHRSBWRVJTSU9OClJlcG9ydC1Nc2dpZC1CdWdzLVRvOiAKUE8tUmV2aXNpb24tRGF0ZTogWUVBUi1NTy1EQSBITzpNSStaT05FCkxhc3QtVHJhbnNsYXRvcjogRlVMTCBOQU1FIDxFTUFJTEBBRERSRVNTPgpMYW5ndWFnZS1UZWFtOiBMQU5HVUFHRSA8TExAbGkub3JnPgpMYW5ndWFnZTogCk1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA4Yml0CgBFeGFtcGxlAA=='; + file_put_contents('locale/en_US/LC_MESSAGES/test.mo', base64_decode($mo)); } putenv('LANG=en_US'); setlocale(LC_ALL, 'en_US'); @@ -20,4 +22,4 @@ bindtextdomain($domain, 'locale/'); bind_textdomain_codeset($domain, 'UTF-8'); textdomain($domain); -assert(gettext('示例') === 'Example'); +assert(gettext(json_decode('"\u793a\u4f8b"', true)) === 'Example'); From faed569e8aa6d37f9d161c3457dc02deeb5461a2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 16 Feb 2024 23:28:14 +0800 Subject: [PATCH 199/415] fix gettext build for linux --- src/SPC/builder/extension/gettext.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SPC/builder/extension/gettext.php b/src/SPC/builder/extension/gettext.php index 8b29a111..c1176869 100644 --- a/src/SPC/builder/extension/gettext.php +++ b/src/SPC/builder/extension/gettext.php @@ -19,7 +19,9 @@ class gettext extends Extension */ public function patchBeforeBuildconf(): bool { - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl'); + if ($this->builder instanceof MacOSBuilder) { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gettext/config.m4', 'AC_CHECK_LIB($GETTEXT_CHECK_IN_LIB', 'AC_CHECK_LIB(intl'); + } return true; } @@ -29,8 +31,10 @@ class gettext extends Extension */ public function patchBeforeConfigure(): bool { - $frameworks = $this->builder instanceof MacOSBuilder ? ' ' . $this->builder->getFrameworks(true) . ' ' : ''; - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks); + if ($this->builder instanceof MacOSBuilder) { + $frameworks = ' ' . $this->builder->getFrameworks(true) . ' '; + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lintl', $this->getLibFilesString() . $frameworks); + } return true; } } From aeed04a5ecdbf37feafb46895fef2c80e1ff31af Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 17 Feb 2024 00:04:02 +0800 Subject: [PATCH 200/415] Update release-build.yml --- .github/workflows/release-build.yml | 47 +++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 78b91a4c..d328d1cd 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -17,12 +17,13 @@ jobs: php-version: - "8.1" micro-version: - - "8.1.26" + - "8.1.27" operating-system: - "linux-x86_64" - "macos-x86_64" - "linux-aarch64" - "macos-aarch64" + - "windows-x64" steps: - name: "Checkout" uses: "actions/checkout@v4" @@ -59,25 +60,45 @@ jobs: - name: "Download minimal combination" run: | - curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz - tar -zxvf tmp.tgz - + if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then + curl https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ matrix.micro-version }}-micro-win.zip -o tmp.zip + unzip tmp.zip + else + curl https://dl.static-php.dev/static-php-cli/minimal/php-${{ matrix.micro-version }}-micro-${{ matrix.operating-system }}.tar.gz -o tmp.tgz + tar -zxvf tmp.tgz + fi + - name: "Generate Executable" run: | - cat micro.sfx spc.phar > spc - chmod +x spc + if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then + cat micro.sfx spc.phar > spc.exe + else + cat micro.sfx spc.phar > spc + chmod +x spc + fi - name: "Archive Executable" run: | - tar -czf spc-${{ matrix.operating-system }}.tar.gz spc - echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV - echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV - if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then - ./spc dev:extensions + if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then + tar -czf spc-${{ matrix.operating-system }}.tar.gz spc + echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV + echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV + if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then + ./spc dev:extensions + fi + else + echo "filename=spc-${{ matrix.operating-system }}.exe" >> $GITHUB_ENV + echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV fi - name: "Copy file" - run: "mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS" + run: | + if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then + mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS + else + mkdir dist/ && cp ${{ env.filename }} dist/ + echo "SUFFIX=.exe" >> $GITHUB_ENV + fi - name: upload binaries to release uses: softprops/action-gh-release@v1 @@ -100,5 +121,5 @@ jobs: - name: "Upload Artifact" uses: actions/upload-artifact@v3 with: - path: spc + path: spc${{ env.SUFFIX }} name: spc-${{ matrix.operating-system }} From 983521e225aecadbddb060f9a66e5b3380f69cbe Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 17 Feb 2024 00:07:30 +0800 Subject: [PATCH 201/415] Update release-build.yml --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index d328d1cd..81958d42 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -96,7 +96,7 @@ jobs: if [ "${{ matrix.operating-system }}" != "windows-x64" ]; then mkdir dist/ && cp ${{ env.filename }} dist/ && cp spc dist/spc-$OS else - mkdir dist/ && cp ${{ env.filename }} dist/ + mkdir dist/ && cp spc.exe dist/${{ env.filename }} echo "SUFFIX=.exe" >> $GITHUB_ENV fi @@ -122,4 +122,4 @@ jobs: uses: actions/upload-artifact@v3 with: path: spc${{ env.SUFFIX }} - name: spc-${{ matrix.operating-system }} + name: spc-${{ matrix.operating-system }}${{ env.SUFFIX }} From b239f60fe4b19f35ce7f1227d7d416c72916143f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 17 Feb 2024 00:09:32 +0800 Subject: [PATCH 202/415] Update release-build.yml --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 81958d42..1b9d5fc7 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -17,7 +17,7 @@ jobs: php-version: - "8.1" micro-version: - - "8.1.27" + - "8.2.16" operating-system: - "linux-x86_64" - "macos-x86_64" From 2f9a1e86017ea157553dbed94449fe326e2e327c Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 17 Feb 2024 00:09:46 +0800 Subject: [PATCH 203/415] Update release-build.yml --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 1b9d5fc7..81a118c8 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: php-version: - - "8.1" + - "8.2" micro-version: - "8.2.16" operating-system: From a2d1262cbfbed3d64dbeaf641f7258f888af51c1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 17 Feb 2024 00:25:25 +0800 Subject: [PATCH 204/415] update composer.lock --- box.json | 1 - composer.lock | 252 ++++++++++++++++++++++++-------------------------- 2 files changed, 120 insertions(+), 133 deletions(-) diff --git a/box.json b/box.json index 83904e36..6626fa2f 100644 --- a/box.json +++ b/box.json @@ -14,6 +14,5 @@ "vendor/zhamao" ], "git-commit-short": "git_commit_short", - "metadata": "ConsoleApplication::VERSION", "output": "spc.phar" } diff --git a/composer.lock b/composer.lock index 01014a05..505aaf8f 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.39.0", + "version": "v10.44.0", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "63fc240a047788fbc2ebe153de85cb72fce88440" + "reference": "5cedaba39e331cffd73a01cf27ea83229fa11fba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/63fc240a047788fbc2ebe153de85cb72fce88440", - "reference": "63fc240a047788fbc2ebe153de85cb72fce88440", + "url": "https://api.github.com/repos/illuminate/collections/zipball/5cedaba39e331cffd73a01cf27ea83229fa11fba", + "reference": "5cedaba39e331cffd73a01cf27ea83229fa11fba", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-21T14:17:35+00:00" + "time": "2024-02-09T15:56:19+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.39.0", + "version": "v10.44.0", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,16 +109,16 @@ }, { "name": "illuminate/contracts", - "version": "v10.39.0", + "version": "v10.44.0", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "f6bf37a272fda164f6c451407c99f820eb1eb95b" + "reference": "8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/f6bf37a272fda164f6c451407c99f820eb1eb95b", - "reference": "f6bf37a272fda164f6c451407c99f820eb1eb95b", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac", + "reference": "8d7152c4a1f5d9cf7da3e8b71f23e4556f6138ac", "shasum": "" }, "require": { @@ -153,11 +153,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-10-30T00:59:22+00:00" + "time": "2024-01-15T18:52:32+00:00" }, { "name": "illuminate/macroable", - "version": "v10.39.0", + "version": "v10.44.0", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.14", + "version": "v0.1.15", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6" + "reference": "d814a27514d99b03c85aa42b22cfd946568636c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", - "reference": "2219fa9c4b944add1e825c3bdb8ecae8bc503bc6", + "url": "https://api.github.com/repos/laravel/prompts/zipball/d814a27514d99b03c85aa42b22cfd946568636c1", + "reference": "d814a27514d99b03c85aa42b22cfd946568636c1", "shasum": "" }, "require": { @@ -254,9 +254,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.14" + "source": "https://github.com/laravel/prompts/tree/v0.1.15" }, - "time": "2023-12-27T04:18:09+00:00" + "time": "2023-12-29T22:37:42+00:00" }, { "name": "psr/container", @@ -414,16 +414,16 @@ }, { "name": "symfony/console", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0254811a143e6bc6c8deea08b589a7e68a37f625" + "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0254811a143e6bc6c8deea08b589a7e68a37f625", - "reference": "0254811a143e6bc6c8deea08b589a7e68a37f625", + "url": "https://api.github.com/repos/symfony/console/zipball/2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e", + "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e", "shasum": "" }, "require": { @@ -488,7 +488,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.2" + "source": "https://github.com/symfony/console/tree/v6.4.3" }, "funding": [ { @@ -504,7 +504,7 @@ "type": "tidelift" } ], - "time": "2023-12-10T16:15:48+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/deprecation-contracts", @@ -575,16 +575,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -598,9 +598,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -637,7 +634,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -653,20 +650,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "875e90aeea2777b6f135677f618529449334a612" + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/875e90aeea2777b6f135677f618529449334a612", - "reference": "875e90aeea2777b6f135677f618529449334a612", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", "shasum": "" }, "require": { @@ -677,9 +674,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -718,7 +712,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" }, "funding": [ { @@ -734,20 +728,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", - "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", "shasum": "" }, "require": { @@ -758,9 +752,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -802,7 +793,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" }, "funding": [ { @@ -818,20 +809,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -845,9 +836,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -885,7 +873,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -901,7 +889,7 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/service-contracts", @@ -987,16 +975,16 @@ }, { "name": "symfony/string", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc" + "reference": "7a14736fb179876575464e4658fce0c304e8c15b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/7cb80bc10bfcdf6b5492741c0b9357dac66940bc", - "reference": "7cb80bc10bfcdf6b5492741c0b9357dac66940bc", + "url": "https://api.github.com/repos/symfony/string/zipball/7a14736fb179876575464e4658fce0c304e8c15b", + "reference": "7a14736fb179876575464e4658fce0c304e8c15b", "shasum": "" }, "require": { @@ -1053,7 +1041,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.2" + "source": "https://github.com/symfony/string/tree/v6.4.3" }, "funding": [ { @@ -1069,7 +1057,7 @@ "type": "tidelift" } ], - "time": "2023-12-10T16:15:48+00:00" + "time": "2024-01-25T09:26:29+00:00" }, { "name": "zhamao/logger", @@ -2108,16 +2096,16 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", "shasum": "" }, "require": { @@ -2149,9 +2137,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2024-01-30T19:34:25+00:00" }, { "name": "fidry/console", @@ -2377,16 +2365,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.46.0", + "version": "v3.49.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "be6831c9af1740470d2a773119b9273f8ac1c3d2" + "reference": "8742f7aa6f72a399688b65e4f58992c2d4681fc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/be6831c9af1740470d2a773119b9273f8ac1c3d2", - "reference": "be6831c9af1740470d2a773119b9273f8ac1c3d2", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8742f7aa6f72a399688b65e4f58992c2d4681fc2", + "reference": "8742f7aa6f72a399688b65e4f58992c2d4681fc2", "shasum": "" }, "require": { @@ -2456,7 +2444,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.46.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.49.0" }, "funding": [ { @@ -2464,7 +2452,7 @@ "type": "github" } ], - "time": "2024-01-03T21:38:46+00:00" + "time": "2024-02-02T00:41:40+00:00" }, { "name": "humbug/box", @@ -3476,16 +3464,16 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.7.3", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419" + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", - "reference": "3219c6ee25c9ea71e3d9bbaf39c67c9ebd499419", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", "shasum": "" }, "require": { @@ -3528,9 +3516,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.7.3" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" }, - "time": "2023-08-12T11:01:26+00:00" + "time": "2024-01-11T11:49:22+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -3581,16 +3569,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.52", + "version": "1.10.58", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "0cd0c330081d4f1e1d630701fe4f342c3b659685" + "reference": "a23518379ec4defd9e47cbf81019526861623ec2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0cd0c330081d4f1e1d630701fe4f342c3b659685", - "reference": "0cd0c330081d4f1e1d630701fe4f342c3b659685", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a23518379ec4defd9e47cbf81019526861623ec2", + "reference": "a23518379ec4defd9e47cbf81019526861623ec2", "shasum": "" }, "require": { @@ -3639,7 +3627,7 @@ "type": "tidelift" } ], - "time": "2024-01-05T09:51:32+00:00" + "time": "2024-02-12T20:02:57+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3964,16 +3952,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.5", + "version": "10.5.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856" + "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ed21115d505b4b4f7dc7b5651464e19a2c7f7856", - "reference": "ed21115d505b4b4f7dc7b5651464e19a2c7f7856", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50b8e314b6d0dd06521dc31d1abffa73f25f850c", + "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c", "shasum": "" }, "require": { @@ -4045,7 +4033,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.5" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.10" }, "funding": [ { @@ -4061,7 +4049,7 @@ "type": "tidelift" } ], - "time": "2023-12-27T15:13:52+00:00" + "time": "2024-02-04T09:07:51+00:00" }, { "name": "psr/event-dispatcher", @@ -5205,16 +5193,16 @@ }, { "name": "seld/jsonlint", - "version": "1.10.1", + "version": "1.10.2", "source": { "type": "git", "url": "https://github.com/Seldaek/jsonlint.git", - "reference": "76d449a358ece77d6f1d6331c68453e657172202" + "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/76d449a358ece77d6f1d6331c68453e657172202", - "reference": "76d449a358ece77d6f1d6331c68453e657172202", + "url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/9bb7db07b5d66d90f6ebf542f09fc67d800e5259", + "reference": "9bb7db07b5d66d90f6ebf542f09fc67d800e5259", "shasum": "" }, "require": { @@ -5253,7 +5241,7 @@ ], "support": { "issues": "https://github.com/Seldaek/jsonlint/issues", - "source": "https://github.com/Seldaek/jsonlint/tree/1.10.1" + "source": "https://github.com/Seldaek/jsonlint/tree/1.10.2" }, "funding": [ { @@ -5265,20 +5253,20 @@ "type": "tidelift" } ], - "time": "2023-12-18T13:03:25+00:00" + "time": "2024-02-07T12:57:50+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "e95216850555cd55e71b857eb9d6c2674124603a" + "reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e95216850555cd55e71b857eb9d6c2674124603a", - "reference": "e95216850555cd55e71b857eb9d6c2674124603a", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae9d3a6f3003a6caf56acd7466d8d52378d44fef", + "reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef", "shasum": "" }, "require": { @@ -5329,7 +5317,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.2" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.3" }, "funding": [ { @@ -5345,7 +5333,7 @@ "type": "tidelift" } ], - "time": "2023-12-27T22:16:42+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -5425,16 +5413,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59" + "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/952a8cb588c3bc6ce76f6023000fb932f16a6e59", - "reference": "952a8cb588c3bc6ce76f6023000fb932f16a6e59", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", + "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", "shasum": "" }, "require": { @@ -5468,7 +5456,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.0" + "source": "https://github.com/symfony/filesystem/tree/v6.4.3" }, "funding": [ { @@ -5484,7 +5472,7 @@ "type": "tidelift" } ], - "time": "2023-07-26T17:27:13+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/finder", @@ -5619,16 +5607,16 @@ }, { "name": "symfony/process", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241" + "reference": "31642b0818bfcff85930344ef93193f8c607e0a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/c4b1ef0bc80533d87a2e969806172f1c2a980241", - "reference": "c4b1ef0bc80533d87a2e969806172f1c2a980241", + "url": "https://api.github.com/repos/symfony/process/zipball/31642b0818bfcff85930344ef93193f8c607e0a3", + "reference": "31642b0818bfcff85930344ef93193f8c607e0a3", "shasum": "" }, "require": { @@ -5660,7 +5648,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.2" + "source": "https://github.com/symfony/process/tree/v6.4.3" }, "funding": [ { @@ -5676,20 +5664,20 @@ "type": "tidelift" } ], - "time": "2023-12-22T16:42:54+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/stopwatch", - "version": "v6.4.0", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2" + "reference": "416596166641f1f728b0a64f5b9dd07cceb410c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", - "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/416596166641f1f728b0a64f5b9dd07cceb410c1", + "reference": "416596166641f1f728b0a64f5b9dd07cceb410c1", "shasum": "" }, "require": { @@ -5722,7 +5710,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v6.4.0" + "source": "https://github.com/symfony/stopwatch/tree/v6.4.3" }, "funding": [ { @@ -5738,20 +5726,20 @@ "type": "tidelift" } ], - "time": "2023-02-16T10:14:28+00:00" + "time": "2024-01-23T14:35:58+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.4.2", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "68d6573ec98715ddcae5a0a85bee3c1c27a4c33f" + "reference": "0435a08f69125535336177c29d56af3abc1f69da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/68d6573ec98715ddcae5a0a85bee3c1c27a4c33f", - "reference": "68d6573ec98715ddcae5a0a85bee3c1c27a4c33f", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0435a08f69125535336177c29d56af3abc1f69da", + "reference": "0435a08f69125535336177c29d56af3abc1f69da", "shasum": "" }, "require": { @@ -5807,7 +5795,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.2" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.3" }, "funding": [ { @@ -5823,7 +5811,7 @@ "type": "tidelift" } ], - "time": "2023-12-28T19:16:56+00:00" + "time": "2024-01-23T14:53:30+00:00" }, { "name": "thecodingmachine/safe", @@ -6083,5 +6071,5 @@ "ext-mbstring": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } From d59b8457c63d0dc25d47c41f679962e057176aef Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 17 Feb 2024 00:33:23 +0800 Subject: [PATCH 205/415] update composer --- composer.json | 4 +- composer.lock | 696 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 453 insertions(+), 247 deletions(-) diff --git a/composer.json b/composer.json index a827184c..970ed6db 100644 --- a/composer.json +++ b/composer.json @@ -19,10 +19,10 @@ "captainhook/captainhook": "^5.10", "captainhook/plugin-composer": "^5.3", "friendsofphp/php-cs-fixer": "^3.25", - "humbug/box": "^4.3", + "humbug/box": "^4.5", "nunomaduro/collision": "^7.8", "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.3" + "phpunit/phpunit": "^10.3 || ^9" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 505aaf8f..07bd5e9c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "30d9cdb68b65870a63338606f68130f8", + "content-hash": "03f3dbb470b1979639080adb62e6734b", "packages": [ { "name": "illuminate/collections", @@ -2141,6 +2141,76 @@ }, "time": "2024-01-30T19:34:25+00:00" }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:23:10+00:00" + }, { "name": "fidry/console", "version": "0.5.5", @@ -2456,16 +2526,16 @@ }, { "name": "humbug/box", - "version": "4.3.8", + "version": "4.5.1", "source": { "type": "git", "url": "https://github.com/box-project/box.git", - "reference": "55344067891d8be61e6efa50f7c2e59114f32704" + "reference": "1e10a1e974a831b64dab801d09dffa6acd43bd7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/box-project/box/zipball/55344067891d8be61e6efa50f7c2e59114f32704", - "reference": "55344067891d8be61e6efa50f7c2e59114f32704", + "url": "https://api.github.com/repos/box-project/box/zipball/1e10a1e974a831b64dab801d09dffa6acd43bd7f", + "reference": "1e10a1e974a831b64dab801d09dffa6acd43bd7f", "shasum": "" }, "require": { @@ -2473,10 +2543,13 @@ "composer-plugin-api": "^2.2", "composer/semver": "^3.3.2", "composer/xdebug-handler": "^3.0.3", + "ext-iconv": "*", + "ext-mbstring": "*", "ext-phar": "*", "ext-sodium": "*", - "fidry/console": "^0.5.3", - "humbug/php-scoper": "^0.18.3", + "fidry/console": "^0.5.3 || ^0.6.0", + "fidry/filesystem": "^1.1", + "humbug/php-scoper": "^0.18.6", "justinrainbow/json-schema": "^5.2.12", "laravel/serializable-closure": "^1.2.2", "nikic/iter": "^2.2", @@ -2484,11 +2557,15 @@ "paragonie/constant_time_encoding": "^2.6", "php": "^8.1", "phpdocumentor/reflection-docblock": "^5.3", + "phpdocumentor/type-resolver": "^1.7", "psr/log": "^3.0", + "sebastian/diff": "^4.0", "seld/jsonlint": "^1.9", "symfony/console": "^6.1.7", "symfony/filesystem": "^6.1.5", "symfony/finder": "^6.1.3", + "symfony/polyfill-iconv": "^1.28", + "symfony/polyfill-mbstring": "^1.28", "symfony/process": "^6.1.3", "symfony/var-dumper": "^6.1.6", "webmozart/assert": "^1.11" @@ -2501,9 +2578,10 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8.2", "ergebnis/composer-normalize": "^2.29", - "fidry/makefile": "^0.2.1", + "fidry/makefile": "^1.0.1", "mikey179/vfsstream": "^1.6.11", - "phpspec/prophecy-phpunit": "^2.0.1", + "phpspec/prophecy": "^1.17", + "phpspec/prophecy-phpunit": "^2.0.2", "phpunit/phpunit": "^9.5.26", "symfony/phpunit-bridge": "^6.1.6", "symfony/yaml": "^6.2", @@ -2527,7 +2605,6 @@ }, "autoload": { "files": [ - "src/FileSystem/file_system.php", "src/consts.php", "src/functions.php" ], @@ -2560,9 +2637,9 @@ ], "support": { "issues": "https://github.com/box-project/box/issues", - "source": "https://github.com/box-project/box/tree/4.3.8" + "source": "https://github.com/box-project/box/tree/4.5.1" }, - "time": "2023-03-17T08:30:03+00:00" + "time": "2023-11-04T17:51:11+00:00" }, { "name": "humbug/php-scoper", @@ -3631,16 +3708,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "10.1.11", + "version": "9.2.30", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "78c3b7625965c2513ee96569a4dbb62601784145" + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/78c3b7625965c2513ee96569a4dbb62601784145", - "reference": "78c3b7625965c2513ee96569a4dbb62601784145", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca2bd87d2f9215904682a9cb9bb37dda98e76089", + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089", "shasum": "" }, "require": { @@ -3648,18 +3725,18 @@ "ext-libxml": "*", "ext-xmlwriter": "*", "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1", - "phpunit/php-file-iterator": "^4.0", - "phpunit/php-text-template": "^3.0", - "sebastian/code-unit-reverse-lookup": "^3.0", - "sebastian/complexity": "^3.0", - "sebastian/environment": "^6.0", - "sebastian/lines-of-code": "^2.0", - "sebastian/version": "^4.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^10.1" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-pcov": "PHP extension that provides line coverage", @@ -3668,7 +3745,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1-dev" + "dev-master": "9.2-dev" } }, "autoload": { @@ -3697,7 +3774,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.11" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.30" }, "funding": [ { @@ -3705,32 +3782,32 @@ "type": "github" } ], - "time": "2023-12-21T15:38:30+00:00" + "time": "2023-12-22T06:47:57+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "4.1.0", + "version": "3.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", - "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -3757,8 +3834,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" }, "funding": [ { @@ -3766,28 +3842,28 @@ "type": "github" } ], - "time": "2023-08-31T06:24:48+00:00" + "time": "2021-12-02T12:48:52+00:00" }, { "name": "phpunit/php-invoker", - "version": "4.0.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", - "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { "ext-pcntl": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-pcntl": "*" @@ -3795,7 +3871,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -3821,7 +3897,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" }, "funding": [ { @@ -3829,32 +3905,32 @@ "type": "github" } ], - "time": "2023-02-03T06:56:09+00:00" + "time": "2020-09-28T05:58:55+00:00" }, { "name": "phpunit/php-text-template", - "version": "3.0.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", - "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -3880,8 +3956,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" }, "funding": [ { @@ -3889,32 +3964,32 @@ "type": "github" } ], - "time": "2023-08-31T14:07:24+00:00" + "time": "2020-10-26T05:33:50+00:00" }, { "name": "phpunit/php-timer", - "version": "6.0.0", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", - "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -3940,7 +4015,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" }, "funding": [ { @@ -3948,23 +4023,24 @@ "type": "github" } ], - "time": "2023-02-03T06:57:52+00:00" + "time": "2020-10-26T13:16:10+00:00" }, { "name": "phpunit/phpunit", - "version": "10.5.10", + "version": "9.6.16", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c" + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/50b8e314b6d0dd06521dc31d1abffa73f25f850c", - "reference": "50b8e314b6d0dd06521dc31d1abffa73f25f850c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", + "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -3974,26 +4050,27 @@ "myclabs/deep-copy": "^1.10.1", "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", - "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.5", - "phpunit/php-file-iterator": "^4.0", - "phpunit/php-invoker": "^4.0", - "phpunit/php-text-template": "^3.0", - "phpunit/php-timer": "^6.0", - "sebastian/cli-parser": "^2.0", - "sebastian/code-unit": "^2.0", - "sebastian/comparator": "^5.0", - "sebastian/diff": "^5.0", - "sebastian/environment": "^6.0", - "sebastian/exporter": "^5.1", - "sebastian/global-state": "^6.0.1", - "sebastian/object-enumerator": "^5.0", - "sebastian/recursion-context": "^5.0", - "sebastian/type": "^4.0", - "sebastian/version": "^4.0" + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.28", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.5", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^3.2", + "sebastian/version": "^3.0.2" }, "suggest": { - "ext-soap": "To be able to generate mocks based on WSDL files" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -4001,7 +4078,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -4033,7 +4110,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.10" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" }, "funding": [ { @@ -4049,7 +4126,7 @@ "type": "tidelift" } ], - "time": "2024-02-04T09:07:51+00:00" + "time": "2024-01-19T07:03:14+00:00" }, { "name": "psr/event-dispatcher", @@ -4103,28 +4180,28 @@ }, { "name": "sebastian/cli-parser", - "version": "2.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae" + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae", - "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -4147,7 +4224,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" }, "funding": [ { @@ -4155,32 +4232,32 @@ "type": "github" } ], - "time": "2023-02-03T06:58:15+00:00" + "time": "2020-09-28T06:08:49+00:00" }, { "name": "sebastian/code-unit", - "version": "2.0.0", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", - "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -4203,7 +4280,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit", "support": { "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" }, "funding": [ { @@ -4211,32 +4288,32 @@ "type": "github" } ], - "time": "2023-02-03T06:58:43+00:00" + "time": "2020-10-26T13:08:54+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "3.0.0", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", - "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -4258,7 +4335,7 @@ "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", "support": { "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" }, "funding": [ { @@ -4266,36 +4343,34 @@ "type": "github" } ], - "time": "2023-02-03T06:59:15+00:00" + "time": "2020-09-28T05:30:19+00:00" }, { "name": "sebastian/comparator", - "version": "5.0.1", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2db5010a484d53ebf536087a70b4a5423c102372" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", - "reference": "2db5010a484d53ebf536087a70b4a5423c102372", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { - "ext-dom": "*", - "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/diff": "^5.0", - "sebastian/exporter": "^5.0" + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^10.3" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -4334,8 +4409,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -4343,33 +4417,33 @@ "type": "github" } ], - "time": "2023-08-14T13:18:12+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", - "version": "3.2.0", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "68ff824baeae169ec9f2137158ee529584553799" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", - "reference": "68ff824baeae169ec9f2137158ee529584553799", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.2-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -4392,8 +4466,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "security": "https://github.com/sebastianbergmann/complexity/security/policy", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -4401,33 +4474,33 @@ "type": "github" } ], - "time": "2023-12-21T08:37:17+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", - "version": "5.1.0", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f" + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f", - "reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^9.3", "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -4459,8 +4532,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.1.0" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" }, "funding": [ { @@ -4468,27 +4540,27 @@ "type": "github" } ], - "time": "2023-12-22T10:55:06+00:00" + "time": "2023-05-07T05:35:17+00:00" }, { "name": "sebastian/environment", - "version": "6.0.1", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/43c751b41d74f96cbbd4e07b7aec9675651e2951", - "reference": "43c751b41d74f96cbbd4e07b7aec9675651e2951", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-posix": "*" @@ -4496,7 +4568,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -4515,7 +4587,7 @@ } ], "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "https://github.com/sebastianbergmann/environment", + "homepage": "http://www.github.com/sebastianbergmann/environment", "keywords": [ "Xdebug", "environment", @@ -4523,8 +4595,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "security": "https://github.com/sebastianbergmann/environment/security/policy", - "source": "https://github.com/sebastianbergmann/environment/tree/6.0.1" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -4532,34 +4603,34 @@ "type": "github" } ], - "time": "2023-04-11T05:39:26+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", - "version": "5.1.1", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc" + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/64f51654862e0f5e318db7e9dcc2292c63cdbddc", - "reference": "64f51654862e0f5e318db7e9dcc2292c63cdbddc", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { - "ext-mbstring": "*", - "php": ">=8.1", - "sebastian/recursion-context": "^5.0" + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -4601,8 +4672,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.1" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { @@ -4610,35 +4680,38 @@ "type": "github" } ], - "time": "2023-09-24T13:22:09+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", - "version": "6.0.1", + "version": "5.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4" + "reference": "bde739e7565280bda77be70044ac1047bc007e34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/7ea9ead78f6d380d2a667864c132c2f7b83055e4", - "reference": "7ea9ead78f6d380d2a667864c132c2f7b83055e4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", + "reference": "bde739e7565280bda77be70044ac1047bc007e34", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "6.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -4663,8 +4736,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "security": "https://github.com/sebastianbergmann/global-state/security/policy", - "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.1" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" }, "funding": [ { @@ -4672,33 +4744,33 @@ "type": "github" } ], - "time": "2023-07-19T07:19:23+00:00" + "time": "2023-08-02T09:26:13+00:00" }, { "name": "sebastian/lines-of-code", - "version": "2.0.2", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", - "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { "nikic/php-parser": "^4.18 || ^5.0", - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -4721,8 +4793,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -4730,34 +4801,34 @@ "type": "github" } ], - "time": "2023-12-21T08:38:20+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", - "version": "5.0.0", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", - "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", "shasum": "" }, "require": { - "php": ">=8.1", - "sebastian/object-reflector": "^3.0", - "sebastian/recursion-context": "^5.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -4779,7 +4850,7 @@ "homepage": "https://github.com/sebastianbergmann/object-enumerator/", "support": { "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" }, "funding": [ { @@ -4787,32 +4858,32 @@ "type": "github" } ], - "time": "2023-02-03T07:08:32+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { "name": "sebastian/object-reflector", - "version": "3.0.0", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", - "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -4834,7 +4905,7 @@ "homepage": "https://github.com/sebastianbergmann/object-reflector/", "support": { "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" }, "funding": [ { @@ -4842,32 +4913,32 @@ "type": "github" } ], - "time": "2023-02-03T07:06:18+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { "name": "sebastian/recursion-context", - "version": "5.0.0", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "05909fb5bc7df4c52992396d0116aed689f93712" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", - "reference": "05909fb5bc7df4c52992396d0116aed689f93712", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -4897,7 +4968,7 @@ "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -4905,32 +4976,87 @@ "type": "github" } ], - "time": "2023-02-03T07:05:40+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { - "name": "sebastian/type", - "version": "4.0.0", + "name": "sebastian/resource-operations", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/type.git", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", - "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:45:17+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" } }, "autoload": { @@ -4953,7 +5079,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -4961,29 +5087,29 @@ "type": "github" } ], - "time": "2023-02-03T07:10:45+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", - "version": "4.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", - "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=7.3" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "4.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -5006,7 +5132,7 @@ "homepage": "https://github.com/sebastianbergmann/version", "support": { "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" }, "funding": [ { @@ -5014,7 +5140,7 @@ "type": "github" } ], - "time": "2023-02-07T11:34:05+00:00" + "time": "2020-09-28T06:39:44+00:00" }, { "name": "sebastianfeldmann/camino", @@ -5605,6 +5731,86 @@ ], "time": "2023-08-08T10:16:24+00:00" }, + { + "name": "symfony/polyfill-iconv", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-iconv.git", + "reference": "cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f", + "reference": "cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-iconv": "*" + }, + "suggest": { + "ext-iconv": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Iconv\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Iconv extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "iconv", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "symfony/process", "version": "v6.4.3", From 645e2a9fc2dc6fb3231f71795ddf26bfecb63d3a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 17 Feb 2024 00:37:09 +0800 Subject: [PATCH 206/415] update to beta 3 --- 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 4d2db5fe..0c49d8ca 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -23,7 +23,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.0-beta.2'; + public const VERSION = '2.1.0-beta.3'; public function __construct() { From e2ef195a840681f733f0deac0f49ea99ca86ca2f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 17 Feb 2024 00:44:03 +0800 Subject: [PATCH 207/415] Update release-build.yml --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 81a118c8..c363fcea 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -104,7 +104,7 @@ jobs: uses: softprops/action-gh-release@v1 if: ${{startsWith(github.ref, 'refs/tags/') }} with: - files: ${{ env.filename }} + files: dist/${{ env.filename }} - name: "Deploy to Self-Hosted Server" if: github.repository == 'crazywhalecc/static-php-cli' From 3ac3dab6c8598dba7684cc40a76d59ca65c25ad6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 09:44:04 +0800 Subject: [PATCH 208/415] apply default no-ansi output --- src/SPC/command/BaseCommand.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index b29934c1..f3ca525c 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -56,11 +56,6 @@ abstract class BaseCommand extends Command // 如果 return false 则错误会继续递交给 PHP 标准错误处理 return true; }, E_ALL | E_STRICT); - if ($input->getOption('debug')) { - global $ob_logger; - $ob_logger = new ConsoleLogger(LogLevel::DEBUG); - define('DEBUG_MODE', true); - } $version = ConsoleApplication::VERSION; if (!$this->no_motd) { echo " _ _ _ _ @@ -83,6 +78,14 @@ abstract class BaseCommand extends Command $this->input = $input; $this->output = $output; + global $ob_logger; + if ($input->getOption('debug')) { + $ob_logger = new ConsoleLogger(LogLevel::DEBUG, decorated: !$input->getOption('no-ansi')); + define('DEBUG_MODE', true); + } else { + $ob_logger = new ConsoleLogger(decorated: !$input->getOption('no-ansi')); + } + // windows fallback Prompt::fallbackWhen(PHP_OS_FAMILY === 'Windows'); ConfirmPrompt::fallbackUsing(function (ConfirmPrompt $prompt) use ($input, $output) { From a30e054d7d22f3afdf8680c0a0e81782a9351c9a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 13:54:06 +0800 Subject: [PATCH 209/415] Add package management --- .gitignore | 3 + config/pkg.json | 32 +++++ src/SPC/ConsoleApplication.php | 6 +- src/SPC/builder/BuilderBase.php | 8 +- src/SPC/builder/unix/UnixBuilderBase.php | 4 +- src/SPC/builder/windows/WindowsBuilder.php | 4 +- src/SPC/builder/windows/library/openssl.php | 3 +- src/SPC/command/DeleteDownloadCommand.php | 86 ++++++++++++ src/SPC/command/ExtractCommand.php | 6 +- src/SPC/command/InstallPkgCommand.php | 86 ++++++++++++ src/SPC/doctor/item/LinuxMuslCheck.php | 15 +-- src/SPC/doctor/item/WindowsToolCheckList.php | 30 +---- src/SPC/store/Config.php | 15 +++ src/SPC/store/Downloader.php | 86 ++++++++++++ src/SPC/store/FileSystem.php | 125 ++++++++++++------ src/SPC/store/PackageManager.php | 52 ++++++++ ...{SourceExtractor.php => SourceManager.php} | 4 +- src/globals/defines.php | 1 + 18 files changed, 481 insertions(+), 85 deletions(-) create mode 100644 config/pkg.json create mode 100644 src/SPC/command/DeleteDownloadCommand.php create mode 100644 src/SPC/command/InstallPkgCommand.php create mode 100644 src/SPC/store/PackageManager.php rename src/SPC/store/{SourceExtractor.php => SourceManager.php} (96%) diff --git a/.gitignore b/.gitignore index 776dbffd..269a267e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,9 @@ docker/source/ # default source build root directory /buildroot/ +# default package root directory +/pkgroot/ + # tools cache files .php-cs-fixer.cache .phpunit.result.cache diff --git a/config/pkg.json b/config/pkg.json new file mode 100644 index 00000000..a7d1d0c8 --- /dev/null +++ b/config/pkg.json @@ -0,0 +1,32 @@ +{ + "upx-x86_64-linux": { + "type": "url", + "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz", + "extract-files": { + "upx": "{pkg_root_path}/bin/upx" + } + }, + "upx-aarch64-linux": { + "type": "url", + "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-arm64_linux.tar.xz", + "extract-files": { + "upx": "{pkg_root_path}/bin/upx" + } + }, + "nasm-x86_64-win": { + "type": "url", + "url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip", + "extract-files": { + "nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe", + "nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe" + } + }, + "strawberry-perl-x86_64-win": { + "type": "url", + "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" + }, + "musl-toolchain-x86_64-linux": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz" + } +} \ No newline at end of file diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 0c49d8ca..355d5932 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -6,6 +6,7 @@ namespace SPC; use SPC\command\BuildCliCommand; use SPC\command\BuildLibsCommand; +use SPC\command\DeleteDownloadCommand; use SPC\command\dev\AllExtCommand; use SPC\command\dev\PhpVerCommand; use SPC\command\dev\SortConfigCommand; @@ -13,6 +14,7 @@ use SPC\command\DoctorCommand; use SPC\command\DownloadCommand; use SPC\command\DumpLicenseCommand; use SPC\command\ExtractCommand; +use SPC\command\InstallPkgCommand; use SPC\command\MicroCombineCommand; use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\HelpCommand; @@ -23,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.0-beta.3'; + public const VERSION = '2.1.0-beta.4'; public function __construct() { @@ -35,6 +37,8 @@ final class ConsoleApplication extends Application new BuildLibsCommand(), new DoctorCommand(), new DownloadCommand(), + new InstallPkgCommand(), + new DeleteDownloadCommand(), new DumpLicenseCommand(), new ExtractCommand(), new MicroCombineCommand(), diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 2314a7f2..ee4d9d61 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -9,7 +9,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; -use SPC\store\SourceExtractor; +use SPC\store\SourceManager; use SPC\util\CustomExt; abstract class BuilderBase @@ -144,15 +144,15 @@ abstract class BuilderBase { CustomExt::loadCustomExt(); $this->emitPatchPoint('before-php-extract'); - SourceExtractor::initSource(sources: ['php-src']); + SourceManager::initSource(sources: ['php-src']); $this->emitPatchPoint('after-php-extract'); if ($this->getPHPVersionID() >= 80000) { $this->emitPatchPoint('before-micro-extract'); - SourceExtractor::initSource(sources: ['micro']); + SourceManager::initSource(sources: ['micro']); $this->emitPatchPoint('after-micro-extract'); } $this->emitPatchPoint('before-exts-extract'); - SourceExtractor::initSource(exts: $extensions); + SourceManager::initSource(exts: $extensions); $this->emitPatchPoint('after-exts-extract'); foreach ($extensions as $extension) { $class = CustomExt::getExtClass($extension); diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 583ad812..934ddaad 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -11,7 +11,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; -use SPC\store\SourceExtractor; +use SPC\store\SourceManager; use SPC\util\DependencyUtil; abstract class UnixBuilderBase extends BuilderBase @@ -134,7 +134,7 @@ abstract class UnixBuilderBase extends BuilderBase $this->emitPatchPoint('before-libs-extract'); // extract sources - SourceExtractor::initSource(libs: $sorted_libraries); + SourceManager::initSource(libs: $sorted_libraries); $this->emitPatchPoint('after-libs-extract'); diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index b007e7ff..38bfd783 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -10,7 +10,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; -use SPC\store\SourceExtractor; +use SPC\store\SourceManager; use SPC\store\SourcePatcher; use SPC\util\DependencyUtil; @@ -211,7 +211,7 @@ class WindowsBuilder extends BuilderBase } // extract sources - SourceExtractor::initSource(libs: $sorted_libraries); + SourceManager::initSource(libs: $sorted_libraries); // build all libs foreach ($this->libs as $lib) { diff --git a/src/SPC/builder/windows/library/openssl.php b/src/SPC/builder/windows/library/openssl.php index 18b98438..74a3b510 100644 --- a/src/SPC/builder/windows/library/openssl.php +++ b/src/SPC/builder/windows/library/openssl.php @@ -14,7 +14,8 @@ class openssl extends WindowsLibraryBase protected function build(): void { - $perl = file_exists(BUILD_ROOT_PATH . '\perl\perl\bin\perl.exe') ? (BUILD_ROOT_PATH . '\perl\perl\bin\perl.exe') : SystemUtil::findCommand('perl.exe'); + $perl_path_native = PKG_ROOT_PATH . '\strawberry-perl-' . arch2gnu(php_uname('m')) . '-win\perl\bin\perl.exe'; + $perl = file_exists($perl_path_native) ? ($perl_path_native) : SystemUtil::findCommand('perl.exe'); if ($perl === null) { throw new RuntimeException('You need to install perl first! (easiest way is using static-php-cli command "doctor")'); } diff --git a/src/SPC/command/DeleteDownloadCommand.php b/src/SPC/command/DeleteDownloadCommand.php new file mode 100644 index 00000000..a953fbe6 --- /dev/null +++ b/src/SPC/command/DeleteDownloadCommand.php @@ -0,0 +1,86 @@ +addArgument('sources', InputArgument::REQUIRED, 'The sources/packages will be deleted, comma separated'); + $this->addOption('all', 'A', null, 'Delete all downloaded and locked sources/packages'); + } + + public function initialize(InputInterface $input, OutputInterface $output): void + { + if ($input->getOption('all')) { + $input->setArgument('sources', ''); + } + parent::initialize($input, $output); + } + + /** + * @throws FileSystemException + */ + public function handle(): int + { + try { + // get source list that will be downloaded + $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); + if (empty($sources)) { + logger()->notice('Removing downloads/ directory ...'); + FileSystem::removeDir(DOWNLOAD_PATH); + logger()->info('Removed downloads/ dir!'); + return static::SUCCESS; + } + $chosen_sources = $sources; + $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true) ?? []; + + foreach ($chosen_sources as $source) { + $source = trim($source); + if (!isset($lock[$source])) { + logger()->warning("Source/Package [{$source}] not locked or not downloaded, skipped."); + continue; + } + // remove download file/dir if exists + if ($lock[$source]['source_type'] === 'archive') { + if (file_exists($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock[$source]['filename']))) { + logger()->info('Deleting file ' . $path); + unlink($path); + } else { + logger()->warning("Source/Package [{$source}] file not found, skip deleting file."); + } + } else { + if (is_dir($path = FileSystem::convertPath(DOWNLOAD_PATH . '/' . $lock[$source]['dirname']))) { + logger()->info('Deleting dir ' . $path); + FileSystem::removeDir($path); + } else { + logger()->warning("Source/Package [{$source}] directory not found, skip deleting dir."); + } + } + // remove locked sources + unset($lock[$source]); + } + 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) { + logger()->error($e->getMessage()); + return static::FAILURE; + } catch (WrongUsageException $e) { + logger()->critical($e->getMessage()); + return static::FAILURE; + } + } +} diff --git a/src/SPC/command/ExtractCommand.php b/src/SPC/command/ExtractCommand.php index 84768866..aacf5039 100644 --- a/src/SPC/command/ExtractCommand.php +++ b/src/SPC/command/ExtractCommand.php @@ -8,11 +8,11 @@ use SPC\builder\traits\UnixSystemUtilTrait; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; -use SPC\store\SourceExtractor; +use SPC\store\SourceManager; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; -#[AsCommand('extract', 'Extract required sources')] +#[AsCommand('extract', 'Extract required sources', ['extract-source'])] class ExtractCommand extends BaseCommand { use UnixSystemUtilTrait; @@ -34,7 +34,7 @@ class ExtractCommand extends BaseCommand $this->output->writeln('sources cannot be empty, at least contain one !'); return static::FAILURE; } - SourceExtractor::initSource(sources: $sources); + SourceManager::initSource(sources: $sources); logger()->info('Extract done !'); return static::SUCCESS; } diff --git a/src/SPC/command/InstallPkgCommand.php b/src/SPC/command/InstallPkgCommand.php new file mode 100644 index 00000000..b1ea3cd5 --- /dev/null +++ b/src/SPC/command/InstallPkgCommand.php @@ -0,0 +1,86 @@ +addArgument('packages', InputArgument::REQUIRED, 'The packages will be installed, comma separated'); + $this->addOption('shallow-clone', null, null, 'Clone shallow'); + $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); + } + + /** + * @throws FileSystemException + */ + public function handle(): int + { + try { + // Use shallow-clone can reduce git resource download + if ($this->getOption('shallow-clone')) { + define('GIT_SHALLOW_CLONE', true); + } + + // Process -U options + $custom_urls = []; + foreach ($this->input->getOption('custom-url') as $value) { + [$pkg_name, $url] = explode(':', $value, 2); + $custom_urls[$pkg_name] = $url; + } + + $chosen_pkgs = array_map('trim', array_filter(explode(',', $this->getArgument('packages')))); + + // Download them + f_mkdir(DOWNLOAD_PATH); + $ni = 0; + $cnt = count($chosen_pkgs); + + foreach ($chosen_pkgs as $pkg) { + ++$ni; + if (isset($custom_urls[$pkg])) { + $config = Config::getPkg($pkg); + $new_config = [ + 'type' => 'url', + 'url' => $custom_urls[$pkg], + ]; + if (isset($config['extract'])) { + $new_config['extract'] = $config['extract']; + } + if (isset($config['filename'])) { + $new_config['filename'] = $config['filename']; + } + logger()->info("Installing source {$pkg} from custom url [{$ni}/{$cnt}]"); + PackageManager::installPackage($pkg, $new_config); + } else { + logger()->info("Fetching package {$pkg} [{$ni}/{$cnt}]"); + PackageManager::installPackage($pkg, Config::getPkg($pkg)); + } + } + $time = round(microtime(true) - START_TIME, 3); + logger()->info('Install packages complete, used ' . $time . ' s !'); + return static::SUCCESS; + } catch (DownloaderException $e) { + logger()->error($e->getMessage()); + return static::FAILURE; + } catch (WrongUsageException $e) { + logger()->critical($e->getMessage()); + return static::FAILURE; + } + } +} diff --git a/src/SPC/doctor/item/LinuxMuslCheck.php b/src/SPC/doctor/item/LinuxMuslCheck.php index c9639ff4..e672ca20 100644 --- a/src/SPC/doctor/item/LinuxMuslCheck.php +++ b/src/SPC/doctor/item/LinuxMuslCheck.php @@ -14,6 +14,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Downloader; use SPC\store\FileSystem; +use SPC\store\PackageManager; class LinuxMuslCheck { @@ -84,7 +85,6 @@ class LinuxMuslCheck /** @noinspection PhpUnused */ /** - * @throws DownloaderException * @throws FileSystemException * @throws WrongUsageException */ @@ -98,15 +98,10 @@ class LinuxMuslCheck logger()->warning('Current user is not root, using sudo for running command'); } $arch = arch2gnu(php_uname('m')); - $musl_compile_source = [ - 'type' => 'url', - 'url' => "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/{$arch}-musl-toolchain.tgz", - ]; - logger()->info('Downloading ' . $musl_compile_source['url']); - Downloader::downloadSource('musl-compile', $musl_compile_source); - logger()->info('Extracting musl-cross'); - FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); - shell()->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); + PackageManager::installPackage("musl-toolchain-{$arch}-linux"); + $pkg_root = PKG_ROOT_PATH . "/musl-toolchain-{$arch}-linux"; + shell()->exec("{$prefix}cp -rf {$pkg_root}/* /usr/local/musl"); + FileSystem::removeDir($pkg_root); return true; } catch (RuntimeException) { return false; diff --git a/src/SPC/doctor/item/WindowsToolCheckList.php b/src/SPC/doctor/item/WindowsToolCheckList.php index 0115c3da..df4eb050 100644 --- a/src/SPC/doctor/item/WindowsToolCheckList.php +++ b/src/SPC/doctor/item/WindowsToolCheckList.php @@ -9,8 +9,8 @@ use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; use SPC\doctor\CheckResult; use SPC\exception\RuntimeException; -use SPC\store\Downloader; use SPC\store\FileSystem; +use SPC\store\PackageManager; class WindowsToolCheckList { @@ -64,8 +64,9 @@ class WindowsToolCheckList #[AsCheckItem('if perl(strawberry) installed', limit_os: 'Windows', level: 994)] public function checkPerl(): ?CheckResult { - if (file_exists(BUILD_ROOT_PATH . '\perl\perl\bin\perl.exe')) { - return CheckResult::ok(BUILD_ROOT_PATH . '\perl\perl\bin\perl.exe'); + $arch = arch2gnu(php_uname('m')); + if (file_exists(PKG_ROOT_PATH . '\strawberry-perl-' . $arch . '-win\perl\bin\perl.exe')) { + return CheckResult::ok(PKG_ROOT_PATH . '\strawberry-perl-' . $arch . '-win\perl\bin\perl.exe'); } if (($path = SystemUtil::findCommand('perl.exe')) === null) { return CheckResult::fail('perl not found in path.', 'install-perl'); @@ -91,32 +92,15 @@ class WindowsToolCheckList #[AsFixItem('install-nasm')] public function installNasm(): bool { - // The hardcoded version here is to be consistent with the version compiled by `musl-cross-toolchain`. - $nasm_ver = '2.16.01'; - $nasm_dist = "nasm-{$nasm_ver}"; - $source = [ - 'type' => 'url', - 'url' => "https://www.nasm.us/pub/nasm/releasebuilds/{$nasm_ver}/win64/{$nasm_dist}-win64.zip", - ]; - logger()->info('Downloading ' . $source['url']); - Downloader::downloadSource('nasm', $source); - FileSystem::extractSource('nasm', DOWNLOAD_PATH . "\\{$nasm_dist}-win64.zip"); - copy(SOURCE_PATH . "\\nasm\\{$nasm_dist}\\nasm.exe", PHP_SDK_PATH . '\bin\nasm.exe'); - copy(SOURCE_PATH . "\\nasm\\{$nasm_dist}\\ndisasm.exe", PHP_SDK_PATH . '\bin\ndisasm.exe'); + PackageManager::installPackage('nasm-x86_64-win'); return true; } #[AsFixItem('install-perl')] public function installPerl(): bool { - $url = 'https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip'; - $source = [ - 'type' => 'url', - 'url' => $url, - ]; - logger()->info("Downloading {$url}"); - Downloader::downloadSource('strawberry-perl', $source); - FileSystem::extractSource('strawberry-perl', DOWNLOAD_PATH . '\strawberry-perl-5.38.0.1-64bit-portable.zip', '../buildroot/perl'); + $arch = arch2gnu(php_uname('m')); + PackageManager::installPackage("strawberry-perl-{$arch}-win"); return true; } } diff --git a/src/SPC/store/Config.php b/src/SPC/store/Config.php index 01328be2..65340729 100644 --- a/src/SPC/store/Config.php +++ b/src/SPC/store/Config.php @@ -12,6 +12,8 @@ use SPC\exception\WrongUsageException; */ class Config { + public static ?array $pkg = null; + public static ?array $source = null; public static ?array $lib = null; @@ -31,6 +33,19 @@ class Config return self::$source[$name] ?? null; } + /** + * Read pkg from pkg.json + * + * @throws FileSystemException + */ + public static function getPkg(string $name): ?array + { + if (self::$pkg === null) { + self::$pkg = FileSystem::loadConfigArray('pkg'); + } + return self::$pkg[$name] ?? null; + } + /** * 根据不同的操作系统分别选择不同的 lib 库依赖项 * 如果 key 为 null,那么直接返回整个 meta。 diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 2cb0fa37..16e26b2a 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -246,6 +246,92 @@ class Downloader }*/ } + public static function downloadPackage(string $name, ?array $pkg = null, bool $force = false): void + { + if ($pkg === null) { + $pkg = Config::getPkg($name); + } + + if ($pkg === null) { + logger()->warning('Package {name} unknown. Skipping.', ['name' => $name]); + return; + } + + if (!is_dir(DOWNLOAD_PATH)) { + FileSystem::createDir(DOWNLOAD_PATH); + } + + // load lock file + 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 + if (isset($lock[$name]) && !$force) { + if ($lock[$name]['source_type'] === 'archive' && file_exists(DOWNLOAD_PATH . '/' . $lock[$name]['filename'])) { + logger()->notice("Package [{$name}] already downloaded: " . $lock[$name]['filename']); + return; + } + if ($lock[$name]['source_type'] === 'dir' && is_dir(DOWNLOAD_PATH . '/' . $lock[$name]['dirname'])) { + logger()->notice("Package [{$name}] already downloaded: " . $lock[$name]['dirname']); + return; + } + } + + try { + switch ($pkg['type']) { + case 'bitbuckettag': // BitBucket Tag + [$url, $filename] = self::getLatestBitbucketTag($name, $pkg); + self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); + break; + case 'ghtar': // GitHub Release (tar) + [$url, $filename] = self::getLatestGithubTarball($name, $pkg); + self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); + break; + case 'ghtagtar': // GitHub Tag (tar) + [$url, $filename] = self::getLatestGithubTarball($name, $pkg, 'tags'); + self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); + break; + case 'ghrel': // GitHub Release (uploaded) + [$url, $filename] = self::getLatestGithubRelease($name, $pkg); + self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); + break; + case 'filelist': // Basic File List (regex based crawler) + [$url, $filename] = self::getFromFileList($name, $pkg); + self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); + break; + case 'url': // Direct download URL + $url = $pkg['url']; + $filename = $pkg['filename'] ?? basename($pkg['url']); + self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); + break; + case 'git': // Git repo + self::downloadGit($name, $pkg['url'], $pkg['rev'], $pkg['extract'] ?? null); + 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) { + if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { + (new $class())->fetch(); + break; + } + } + break; + default: + throw new DownloaderException('unknown source type: ' . $pkg['type']); + } + } catch (RuntimeException $e) { + // Because sometimes files downloaded through the command line are not automatically deleted after a failure. + // Here we need to manually delete the file if it is detected to exist. + if (isset($filename) && file_exists(DOWNLOAD_PATH . '/' . $filename)) { + logger()->warning('Deleting download file: ' . $filename); + unlink(DOWNLOAD_PATH . '/' . $filename); + } + throw new DownloaderException('Download failed! ' . $e->getMessage()); + } + } + /** * Download source by name and meta. * diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 7e5411ab..04468286 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -16,7 +16,7 @@ class FileSystem */ public static function loadConfigArray(string $config, ?string $config_dir = null): array { - $whitelist = ['ext', 'lib', 'source']; + $whitelist = ['ext', 'lib', 'source', 'pkg']; if (!in_array($config, $whitelist)) { throw new FileSystemException('Reading ' . $config . '.json is not allowed'); } @@ -138,6 +138,37 @@ class FileSystem } } + /** + * @throws RuntimeException + * @throws FileSystemException + */ + public static function extractPackage(string $name, string $filename, ?string $extract_path = null): void + { + if ($extract_path !== null) { + // replace + $extract_path = self::replacePathVariable($extract_path); + $extract_path = self::isRelativePath($extract_path) ? (WORKING_DIR . '/' . $extract_path) : $extract_path; + } else { + $extract_path = PKG_ROOT_PATH . '/' . $name; + } + 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); + } catch (RuntimeException $e) { + if (PHP_OS_FAMILY === 'Windows') { + f_passthru('rmdir /s /q ' . $target); + } else { + f_passthru('rm -r ' . $target); + } + throw new FileSystemException('Cannot extract package ' . $name, $e->getCode(), $e); + } + } + /** * 解压缩下载的资源包到 source 目录 * @@ -152,52 +183,24 @@ class FileSystem if (self::$_extract_hook === []) { SourcePatcher::init(); } - if (!is_dir(SOURCE_PATH)) { - self::createDir(SOURCE_PATH); - } if ($move_path !== null) { $move_path = SOURCE_PATH . '/' . $move_path; } logger()->info("extracting {$name} source to " . ($move_path ?? SOURCE_PATH . "/{$name}") . ' ...'); + $target = self::convertPath($move_path ?? (SOURCE_PATH . "/{$name}")); + if (!is_dir($dir = dirname($target))) { + self::createDir($dir); + } try { - $target = self::convertPath($move_path ?? (SOURCE_PATH . "/{$name}")); - // Git source, just move - if (is_dir(self::convertPath($filename))) { - self::copyDir(self::convertPath($filename), $target); - self::emitSourceExtractHook($name); - return; - } - if (f_mkdir(directory: $target, recursive: true) !== true) { - throw new FileSystemException('create ' . $name . 'source dir failed'); - } - - if (in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { - match (self::extname($filename)) { - 'tar', 'xz', 'txz' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), - 'tgz', 'gz' => f_passthru("tar -xzf {$filename} -C {$target} --strip-components 1"), - 'bz2' => f_passthru("tar -xjf {$filename} -C {$target} --strip-components 1"), - 'zip' => f_passthru("unzip {$filename} -d {$target}"), - default => throw new FileSystemException('unknown archive format: ' . $filename), - }; - } elseif (PHP_OS_FAMILY === 'Windows') { - // use php-sdk-binary-tools/bin/7za.exe - $_7z = self::convertPath(PHP_SDK_PATH . '/bin/7za.exe'); - f_mkdir(SOURCE_PATH . "/{$name}", recursive: true); - match (self::extname($filename)) { - 'tar' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), - 'xz', 'txz', 'gz', 'tgz', 'bz2' => f_passthru("\"{$_7z}\" x -so {$filename} | tar -f - -x -C {$target} --strip-components 1"), - 'zip' => f_passthru("\"{$_7z}\" x {$filename} -o{$target} -y"), - default => throw new FileSystemException("unknown archive format: {$filename}"), - }; - } + self::extractArchive($filename, $target); self::emitSourceExtractHook($name); } catch (RuntimeException $e) { if (PHP_OS_FAMILY === 'Windows') { - f_passthru('rmdir /s /q ' . SOURCE_PATH . "/{$name}"); + f_passthru('rmdir /s /q ' . $target); } else { - f_passthru('rm -r ' . SOURCE_PATH . "/{$name}"); + f_passthru('rm -r ' . $target); } - throw new FileSystemException('Cannot extract source ' . $name, $e->getCode(), $e); + throw new FileSystemException('Cannot extract source ' . $name . ': ' . $e->getMessage(), $e->getCode(), $e); } } @@ -411,6 +414,54 @@ class FileSystem return strlen($path) > 0 && $path[0] !== '/'; } + public static function replacePathVariable(string $path): string + { + $replacement = [ + '{pkg_root_path}' => PKG_ROOT_PATH, + '{php_sdk_path}' => defined('PHP_SDK_PATH') ? PHP_SDK_PATH : WORKING_DIR . '/php-sdk-binary-tools', + '{working_dir}' => WORKING_DIR, + '{download_path}' => DOWNLOAD_PATH, + '{source_path}' => SOURCE_PATH, + ]; + return str_replace(array_keys($replacement), array_values($replacement), $path); + } + + /** + * @throws RuntimeException + * @throws FileSystemException + */ + 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'); + } + + if (in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { + match (self::extname($filename)) { + 'tar', 'xz', 'txz' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), + 'tgz', 'gz' => f_passthru("tar -xzf {$filename} -C {$target} --strip-components 1"), + 'bz2' => f_passthru("tar -xjf {$filename} -C {$target} --strip-components 1"), + 'zip' => f_passthru("unzip {$filename} -d {$target}"), + default => throw new FileSystemException('unknown archive format: ' . $filename), + }; + } elseif (PHP_OS_FAMILY === 'Windows') { + // use php-sdk-binary-tools/bin/7za.exe + $_7z = self::convertPath(PHP_SDK_PATH . '/bin/7za.exe'); + match (self::extname($filename)) { + 'tar' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), + 'xz', 'txz', 'gz', 'tgz', 'bz2' => f_passthru("\"{$_7z}\" x -so {$filename} | tar -f - -x -C {$target} --strip-components 1"), + 'zip' => f_passthru("\"{$_7z}\" x {$filename} -o{$target} -y"), + default => throw new FileSystemException("unknown archive format: {$filename}"), + }; + } + } + /** * @throws FileSystemException */ diff --git a/src/SPC/store/PackageManager.php b/src/SPC/store/PackageManager.php new file mode 100644 index 00000000..3eb68977 --- /dev/null +++ b/src/SPC/store/PackageManager.php @@ -0,0 +1,52 @@ + 'linux', + 'Windows' => 'win', + 'BSD' => 'freebsd', + 'Darwin' => 'macos', + default => throw new WrongUsageException('Unsupported OS!'), + }; + $config = Config::getPkg("{$pkg_name}-{$arch}-{$os}"); + } + if ($config === null) { + throw new WrongUsageException("Package [{$pkg_name}] does not exist, please check the name and correct it !"); + } + + // Download package + Downloader::downloadPackage($pkg_name, $config, $force); + // After download, read lock file name + $lock = json_decode(FileSystem::readFile(DOWNLOAD_PATH . '/.lock.json'), true); + $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); + + // 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'])) { + foreach ($config['extract-files'] as $file => $target) { + $target = FileSystem::convertPath(FileSystem::replacePathVariable($target)); + if (!is_dir($dir = dirname($target))) { + f_mkdir($dir, 0755, true); + } + logger()->debug("Moving package [{$pkg_name}] file {$file} to {$target}"); + rename(FileSystem::convertPath($extract . '/' . $file), $target); + } + FileSystem::removeDir($extract); + } + } +} diff --git a/src/SPC/store/SourceExtractor.php b/src/SPC/store/SourceManager.php similarity index 96% rename from src/SPC/store/SourceExtractor.php rename to src/SPC/store/SourceManager.php index 66a96c25..648c3d68 100644 --- a/src/SPC/store/SourceExtractor.php +++ b/src/SPC/store/SourceManager.php @@ -8,7 +8,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; -class SourceExtractor +class SourceManager { /** * @throws WrongUsageException @@ -59,7 +59,7 @@ class SourceExtractor } // check source dir exist - $check = $lock[$source]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$source]['move_path']); + $check = $lock[$source]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (WORKING_DIR . '/' . $lock[$source]['move_path']); if (!is_dir($check)) { logger()->debug('Extracting source [' . $source . '] to ' . $check . ' ...'); FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']), $lock[$source]['move_path']); diff --git a/src/globals/defines.php b/src/globals/defines.php index aebb7f86..94a9ff9e 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -14,6 +14,7 @@ define('START_TIME', microtime(true)); define('BUILD_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('BUILD_ROOT_PATH')) ? $a : (WORKING_DIR . '/buildroot'))); 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'))); +define('PKG_ROOT_PATH', FileSystem::convertPath(is_string($a = getenv('PKG_ROOT_PATH')) ? $a : (WORKING_DIR . '/pkgroot'))); define('BUILD_BIN_PATH', FileSystem::convertPath(is_string($a = getenv('INSTALL_BIN_PATH')) ? $a : (BUILD_ROOT_PATH . '/bin'))); define('BUILD_LIB_PATH', FileSystem::convertPath(is_string($a = getenv('INSTALL_LIB_PATH')) ? $a : (BUILD_ROOT_PATH . '/lib'))); define('BUILD_INCLUDE_PATH', FileSystem::convertPath(is_string($a = getenv('INSTALL_INCLUDE_PATH')) ? $a : (BUILD_ROOT_PATH . '/include'))); From 8376122634573cfa6c7c669d5ffb040745c6bf76 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 14:02:34 +0800 Subject: [PATCH 210/415] sort pkg.json --- config/pkg.json | 64 +++++++++++------------ src/SPC/command/dev/SortConfigCommand.php | 9 ++++ src/SPC/util/ConfigValidator.php | 5 ++ 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/config/pkg.json b/config/pkg.json index a7d1d0c8..db7cfe84 100644 --- a/config/pkg.json +++ b/config/pkg.json @@ -1,32 +1,32 @@ -{ - "upx-x86_64-linux": { - "type": "url", - "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz", - "extract-files": { - "upx": "{pkg_root_path}/bin/upx" - } - }, - "upx-aarch64-linux": { - "type": "url", - "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-arm64_linux.tar.xz", - "extract-files": { - "upx": "{pkg_root_path}/bin/upx" - } - }, - "nasm-x86_64-win": { - "type": "url", - "url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip", - "extract-files": { - "nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe", - "nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe" - } - }, - "strawberry-perl-x86_64-win": { - "type": "url", - "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" - }, - "musl-toolchain-x86_64-linux": { - "type": "url", - "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz" - } -} \ No newline at end of file +{ + "musl-toolchain-x86_64-linux": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz" + }, + "nasm-x86_64-win": { + "type": "url", + "url": "https://www.nasm.us/pub/nasm/releasebuilds/2.16.01/win64/nasm-2.16.01-win64.zip", + "extract-files": { + "nasm-2.16.01/nasm.exe": "{php_sdk_path}/bin/nasm.exe", + "nasm-2.16.01/ndisasm.exe": "{php_sdk_path}/bin/ndisasm.exe" + } + }, + "strawberry-perl-x86_64-win": { + "type": "url", + "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" + }, + "upx-aarch64-linux": { + "type": "url", + "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-arm64_linux.tar.xz", + "extract-files": { + "upx": "{pkg_root_path}/bin/upx" + } + }, + "upx-x86_64-linux": { + "type": "url", + "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz", + "extract-files": { + "upx": "{pkg_root_path}/bin/upx" + } + } +} diff --git a/src/SPC/command/dev/SortConfigCommand.php b/src/SPC/command/dev/SortConfigCommand.php index 8eb7680a..bc29ed13 100644 --- a/src/SPC/command/dev/SortConfigCommand.php +++ b/src/SPC/command/dev/SortConfigCommand.php @@ -57,6 +57,15 @@ class SortConfigCommand extends BaseCommand return static::FAILURE; } break; + case 'pkg': + $file = json_decode(FileSystem::readFile(ROOT_DIR . '/config/pkg.json'), true); + ConfigValidator::validatePkgs($file); + ksort($file); + if (!file_put_contents(ROOT_DIR . '/config/pkg.json', json_encode($file, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n")) { + $this->output->writeln('Write file pkg.json failed!'); + return static::FAILURE; + } + break; default: $this->output->writeln("invalid config name: {$name}"); return 1; diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index 0126ddf9..ba1d6815 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -70,4 +70,9 @@ class ConfigValidator { is_array($data) || throw new ValidationException('ext.json is broken'); } + + public static function validatePkgs(mixed $data): void + { + is_array($data) || throw new \_PHPStan_c997ea9ee\Nette\Schema\ValidationException('pkg.json is broken'); + } } From d241cb993ec04e328fe6c1558ec2221dc01871cc Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 14:05:15 +0800 Subject: [PATCH 211/415] fix --- src/SPC/util/ConfigValidator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/util/ConfigValidator.php b/src/SPC/util/ConfigValidator.php index ba1d6815..924c1b0c 100644 --- a/src/SPC/util/ConfigValidator.php +++ b/src/SPC/util/ConfigValidator.php @@ -71,8 +71,11 @@ class ConfigValidator is_array($data) || throw new ValidationException('ext.json is broken'); } + /** + * @throws ValidationException + */ public static function validatePkgs(mixed $data): void { - is_array($data) || throw new \_PHPStan_c997ea9ee\Nette\Schema\ValidationException('pkg.json is broken'); + is_array($data) || throw new ValidationException('pkg.json is broken'); } } From ae3298472da2802ec64dc76c26a6da0eb9f17e0c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 14:21:54 +0800 Subject: [PATCH 212/415] upx use ghrel --- config/pkg.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config/pkg.json b/config/pkg.json index db7cfe84..b92fae38 100644 --- a/config/pkg.json +++ b/config/pkg.json @@ -16,15 +16,17 @@ "url": "https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_5380_5361/strawberry-perl-5.38.0.1-64bit-portable.zip" }, "upx-aarch64-linux": { - "type": "url", - "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-arm64_linux.tar.xz", + "type": "ghrel", + "repo": "upx/upx", + "match": "upx.+-arm64_linux\\.tar\\.xz", "extract-files": { "upx": "{pkg_root_path}/bin/upx" } }, "upx-x86_64-linux": { - "type": "url", - "url": "https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz", + "type": "ghrel", + "repo": "upx/upx", + "match": "upx.+-amd64_linux\\.tar\\.xz", "extract-files": { "upx": "{pkg_root_path}/bin/upx" } From b4ae87585ca5f864c864616d75593dd986af19f7 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 14:25:42 +0800 Subject: [PATCH 213/415] treat https://github.com/crazywhalecc/static-php-cli/issues/249 as feature --- src/SPC/command/BuildCliCommand.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 7f239858..1cdfa51e 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -58,6 +58,9 @@ class BuildCliCommand extends BuildCommand $this->output->writeln("\t--build-all\tBuild all SAPI: cli, micro, fpm, embed"); return static::FAILURE; } + if ($rule === BUILD_TARGET_ALL) { + logger()->warning('--build-all option makes `--no-strip` always true, be aware!'); + } try { // create builder $builder = BuilderProvider::makeBuilderByInput($this->input); From 4adf1f5e2e4f9d1b8b6dd68f4198f8e99197ec76 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 18 Feb 2024 14:27:39 +0800 Subject: [PATCH 214/415] add musl-toolchain pkg for aarch64 --- config/pkg.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/pkg.json b/config/pkg.json index b92fae38..216640fd 100644 --- a/config/pkg.json +++ b/config/pkg.json @@ -1,4 +1,8 @@ { + "musl-toolchain-aarch64-linux": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/aarch64-musl-toolchain.tgz" + }, "musl-toolchain-x86_64-linux": { "type": "url", "url": "https://dl.static-php.dev/static-php-cli/deps/musl-toolchain/x86_64-musl-toolchain.tgz" From ab386f820c26bd55703efa25d79f3371b412c7be Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 19 Feb 2024 09:29:45 +0800 Subject: [PATCH 215/415] Update FUNDING.yml --- .github/FUNDING.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 36b494a8..bf341f23 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: [crazywhalecc]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username @@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +custom: #'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 304973d9bcc7ba56864112a71ffa252ea070cc7f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 19 Feb 2024 09:33:54 +0800 Subject: [PATCH 216/415] Update FUNDING.yml --- .github/FUNDING.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index bf341f23..36b494a8 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: [crazywhalecc]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username @@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -custom: #'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] +custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 9db843ab66a43fc0cb2d25b6c3719426bbb398af Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 12:15:34 +0800 Subject: [PATCH 217/415] fix source extract --- src/SPC/store/SourceManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/store/SourceManager.php b/src/SPC/store/SourceManager.php index 648c3d68..78f68ad4 100644 --- a/src/SPC/store/SourceManager.php +++ b/src/SPC/store/SourceManager.php @@ -59,7 +59,7 @@ class SourceManager } // check source dir exist - $check = $lock[$source]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (WORKING_DIR . '/' . $lock[$source]['move_path']); + $check = $lock[$source]['move_path'] === null ? (SOURCE_PATH . '/' . $source) : (SOURCE_PATH . '/' . $lock[$source]['move_path']); if (!is_dir($check)) { logger()->debug('Extracting source [' . $source . '] to ' . $check . ' ...'); FileSystem::extractSource($source, DOWNLOAD_PATH . '/' . ($lock[$source]['filename'] ?? $lock[$source]['dirname']), $lock[$source]['move_path']); From c03220d1ee3f3ad0bbea22201adb561b16fb441e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 12:15:52 +0800 Subject: [PATCH 218/415] fix source extract --- src/SPC/store/FileSystem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 04468286..2a694044 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -163,7 +163,7 @@ class FileSystem if (PHP_OS_FAMILY === 'Windows') { f_passthru('rmdir /s /q ' . $target); } else { - f_passthru('rm -r ' . $target); + f_passthru('rm -rf ' . $target); } throw new FileSystemException('Cannot extract package ' . $name, $e->getCode(), $e); } @@ -186,7 +186,7 @@ class FileSystem if ($move_path !== null) { $move_path = SOURCE_PATH . '/' . $move_path; } - logger()->info("extracting {$name} source to " . ($move_path ?? SOURCE_PATH . "/{$name}") . ' ...'); + logger()->info("extracting {$name} source to " . ($move_path ?? (SOURCE_PATH . "/{$name}")) . ' ...'); $target = self::convertPath($move_path ?? (SOURCE_PATH . "/{$name}")); if (!is_dir($dir = dirname($target))) { self::createDir($dir); @@ -198,7 +198,7 @@ class FileSystem if (PHP_OS_FAMILY === 'Windows') { f_passthru('rmdir /s /q ' . $target); } else { - f_passthru('rm -r ' . $target); + f_passthru('rm -rf ' . $target); } throw new FileSystemException('Cannot extract source ' . $name . ': ' . $e->getMessage(), $e->getCode(), $e); } From 9dd89e6b02b4ee78d4f0041f7c93e2bce0b9cf52 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 12:17:03 +0800 Subject: [PATCH 219/415] add --with-upx-pack command --- config/pkg.json | 8 +++++++ src/SPC/builder/linux/LinuxBuilder.php | 27 +++++++++++++++++---- src/SPC/builder/windows/WindowsBuilder.php | 19 +++++++++++++++ src/SPC/command/BuildCliCommand.php | 28 ++++++++++++++++++++++ src/SPC/store/PackageManager.php | 15 ++++++++++++ src/globals/functions.php | 7 ++++++ 6 files changed, 100 insertions(+), 4 deletions(-) diff --git a/config/pkg.json b/config/pkg.json index 216640fd..74de6fd3 100644 --- a/config/pkg.json +++ b/config/pkg.json @@ -34,5 +34,13 @@ "extract-files": { "upx": "{pkg_root_path}/bin/upx" } + }, + "upx-x86_64-win": { + "type": "ghrel", + "repo": "upx/upx", + "match": "upx.+-win64\\.zip", + "extract-files": { + "upx-*-win64/upx.exe": "{pkg_root_path}/bin/upx.exe" + } } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 2fe93534..5fab99fc 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -169,6 +169,21 @@ class LinuxBuilder extends UnixBuilderBase $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + // upx pack and strip for micro + if ($this->getOption('with-upx-pack', false)) { + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', + '/POST_MICRO_BUILD_COMMANDS=.*/', + 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . $this->getOption('upx-exec') . ' --best \$(SAPI_MICRO_PATH)', + ); + } elseif (!$this->getOption('no-strip', false)) { + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', + '/POST_MICRO_BUILD_COMMANDS=.*/', + 'POST_MICRO_BUILD_COMMANDS=true', + ); + } + shell()->cd(SOURCE_PATH . '/php-src') ->exec( "{$this->getOption('ld_library_path')} " . @@ -238,6 +253,10 @@ class LinuxBuilder extends UnixBuilderBase if (!$this->getOption('no-strip', false)) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php'); + } elseif ($this->getOption('with-upx-pack')) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/cli') + ->exec('strip --strip-all php') + ->exec($this->getOption('upx-exec') . ' --best php'); } $this->deployBinary(BUILD_TARGET_CLI); @@ -267,10 +286,6 @@ class LinuxBuilder extends UnixBuilderBase ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} micro"); - if (!$this->getOption('no-strip', false)) { - shell()->cd(SOURCE_PATH . '/php-src/sapi/micro')->exec('strip --strip-all micro.sfx'); - } - $this->deployBinary(BUILD_TARGET_MICRO); if ($this->phar_patched) { @@ -293,6 +308,10 @@ class LinuxBuilder extends UnixBuilderBase if (!$this->getOption('no-strip', false)) { shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm'); + } elseif ($this->getOption('with-upx-pack')) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm') + ->exec('strip --strip-all php-fpm') + ->exec($this->getOption('upx-exec') . ' --best php-fpm'); } $this->deployBinary(BUILD_TARGET_FPM); diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 38bfd783..f2f8fcc4 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -72,6 +72,19 @@ class WindowsBuilder extends BuilderBase $zts = $this->zts ? '--enable-zts=yes ' : '--enable-zts=no '; + // with-upx-pack for phpmicro + $makefile = FileSystem::convertPath(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.w32'); + if ($this->getOption('with-upx-pack', false)) { + if (!file_exists($makefile . '.originfile')) { + copy($makefile, $makefile . '.originfile'); + FileSystem::replaceFileStr($makefile, '$(MICRO_SFX):', "_MICRO_UPX = {$this->getOption('upx-exec')} --best $(MICRO_SFX)\n$(MICRO_SFX):"); + FileSystem::replaceFileStr($makefile, '@$(_MICRO_MT)', "@$(_MICRO_MT)\n\t@$(_MICRO_UPX)"); + } + } elseif (file_exists($makefile . '.originfile')) { + copy($makefile . '.originfile', $makefile); + unlink($makefile . '.originfile'); + } + cmd()->cd(SOURCE_PATH . '\php-src') ->exec( "{$this->sdk_prefix} configure.bat --task-args \"" . @@ -293,6 +306,12 @@ class WindowsBuilder extends BuilderBase BUILD_TARGET_MICRO => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\micro.sfx", default => throw new RuntimeException('Deployment does not accept type ' . $type), }; + + // with-upx-pack for cli + if ($this->getOption('with-upx-pack', false) && $type === BUILD_TARGET_CLI) { + cmd()->exec($this->getOption('upx-exec') . ' --best ' . escapeshellarg($src)); + } + logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file'); FileSystem::createDir(BUILD_ROOT_PATH . '\bin'); diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 1cdfa51e..44d16873 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -37,6 +37,8 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); $this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code'); + + $this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)'); } public function handle(): int @@ -61,6 +63,28 @@ class BuildCliCommand extends BuildCommand if ($rule === BUILD_TARGET_ALL) { logger()->warning('--build-all option makes `--no-strip` always true, be aware!'); } + // Check upx + $suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : ''; + if ($this->getOption('with-upx-pack')) { + // only available for linux for now + if (!in_array(PHP_OS_FAMILY, ['Linux', 'Windows'])) { + logger()->error('UPX is only available on Linux and Windows!'); + return static::FAILURE; + } + // need to install this manually + if (!file_exists(PKG_ROOT_PATH . '/bin/upx' . $suffix)) { + global $argv; + logger()->error('upx does not exist, please install it first:'); + logger()->error(''); + logger()->error("\t" . $argv[0] . ' install-pkg upx'); + logger()->error(''); + return static::FAILURE; + } + // exclusive with no-strip + if ($this->getOption('no-strip')) { + logger()->warning('--with-upx-pack conflicts with --no-strip, --no-strip won\'t work!'); + } + } try { // create builder $builder = BuilderProvider::makeBuilderByInput($this->input); @@ -83,6 +107,10 @@ class BuildCliCommand extends BuildCommand if ($this->input->getOption('disable-opcache-jit')) { $indent_texts['Opcache JIT'] = 'disabled'; } + if ($this->input->getOption('with-upx-pack') && in_array(PHP_OS_FAMILY, ['Linux', 'Windows'])) { + $indent_texts['UPX Pack'] = 'enabled'; + $builder->setOption('upx-exec', FileSystem::convertPath(PKG_ROOT_PATH . '/bin/upx' . $suffix)); + } try { $ver = $builder->getPHPVersion(); $indent_texts['PHP Version'] = $ver; diff --git a/src/SPC/store/PackageManager.php b/src/SPC/store/PackageManager.php index 3eb68977..336bbd66 100644 --- a/src/SPC/store/PackageManager.php +++ b/src/SPC/store/PackageManager.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SPC\store; +use SPC\exception\FileSystemException; use SPC\exception\WrongUsageException; class PackageManager @@ -38,12 +39,26 @@ class PackageManager // 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'])) { + $scandir = FileSystem::scanDirFiles($extract, true, true); foreach ($config['extract-files'] as $file => $target) { $target = FileSystem::convertPath(FileSystem::replacePathVariable($target)); if (!is_dir($dir = dirname($target))) { f_mkdir($dir, 0755, true); } logger()->debug("Moving package [{$pkg_name}] file {$file} to {$target}"); + // match pattern, needs to scan dir + $file = FileSystem::convertPath($file); + $found = false; + foreach ($scandir as $item) { + if (match_pattern($file, $item)) { + $file = $item; + $found = true; + break; + } + } + if ($found === false) { + throw new FileSystemException('Unable to find extract-files item: ' . $file); + } rename(FileSystem::convertPath($extract . '/' . $file), $target); } FileSystem::removeDir($extract); diff --git a/src/globals/functions.php b/src/globals/functions.php index 7b7540b3..85bcfbad 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -47,6 +47,13 @@ function arch2gnu(string $arch): string }; } +function match_pattern(string $pattern, string $subject): bool +{ + $pattern = str_replace(['\*', '\\\\.*'], ['.*', '\*'], preg_quote($pattern, '/')); + $pattern = '/^' . $pattern . '$/i'; + return preg_match($pattern, $subject) === 1; +} + function quote(string $str, string $quote = '"'): string { return $quote . $str . $quote; From 50fe366c4227f25681640464aeddaa18b08a18e3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 12:27:15 +0800 Subject: [PATCH 220/415] restore strip line --- src/SPC/builder/linux/LinuxBuilder.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 5fab99fc..fbef8767 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -182,6 +182,12 @@ class LinuxBuilder extends UnixBuilderBase '/POST_MICRO_BUILD_COMMANDS=.*/', 'POST_MICRO_BUILD_COMMANDS=true', ); + } else { + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', + '/POST_MICRO_BUILD_COMMANDS=.*/', + 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)', + ); } shell()->cd(SOURCE_PATH . '/php-src') From b9359759ddc4c9d2cf022a5ce256f237a9849db2 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 12:35:23 +0800 Subject: [PATCH 221/415] update README --- README-zh.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README-zh.md b/README-zh.md index a4b73279..f9017749 100755 --- a/README-zh.md +++ b/README-zh.md @@ -25,6 +25,7 @@ static-php-cli(简称 `spc`)有许多特性: - :books: 自带编译依赖管理 - 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建) - :fire: 支持大量 [扩展](https://static-php.dev/zh/guide/extensions.html) +- :floppy_disk: 整合 UPX 工具(减小二进制文件体积) **静态 php-cli:** diff --git a/README.md b/README.md index 15e0f556..504d900f 100755 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ static-php-cli (you can call it `spc`) has a lot of features: - :books: Build dependency management - 📦 Provide `spc` own standalone executable (built by spc and [box](https://github.com/box-project/box)) - :fire: Support many popular [extensions](https://static-php.dev/en/guide/extensions.html) +- :floppy_disk: UPX integration (significantly reduces binary size) **Single-file standalone php-cli:** From 097ecd3fb0ba0da633b78c22161d442af20026d5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 13:43:58 +0800 Subject: [PATCH 222/415] test build spc --- src/SPC/doctor/item/BSDToolCheckList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/BSDToolCheckList.php b/src/SPC/doctor/item/BSDToolCheckList.php index 7f28e57e..2505227b 100644 --- a/src/SPC/doctor/item/BSDToolCheckList.php +++ b/src/SPC/doctor/item/BSDToolCheckList.php @@ -57,7 +57,7 @@ class BSDToolCheckList $prefix = ''; } try { - shell(true)->exec("ASSUME_ALWAYS_YES=yes {$prefix} pkg install -y " . implode(' ', $missing)); + shell(true)->exec("ASSUME_ALWAYS_YES=yes {$prefix}pkg install -y " . implode(' ', $missing)); } catch (RuntimeException) { return false; } From 905e080770d0882a64687a6f5977f74fc1bff1cf Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 19 Feb 2024 15:29:43 +0800 Subject: [PATCH 223/415] fix upx linux build --- src/SPC/builder/linux/LinuxBuilder.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index fbef8767..a1096bb3 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -257,12 +257,12 @@ class LinuxBuilder extends UnixBuilderBase ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} cli"); - if (!$this->getOption('no-strip', false)) { - shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php'); - } elseif ($this->getOption('with-upx-pack')) { + if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli') ->exec('strip --strip-all php') ->exec($this->getOption('upx-exec') . ' --best php'); + } elseif (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php'); } $this->deployBinary(BUILD_TARGET_CLI); @@ -312,14 +312,13 @@ class LinuxBuilder extends UnixBuilderBase ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("make -j{$this->concurrency} {$vars} fpm"); - if (!$this->getOption('no-strip', false)) { - shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm'); - } elseif ($this->getOption('with-upx-pack')) { + if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm') ->exec('strip --strip-all php-fpm') ->exec($this->getOption('upx-exec') . ' --best php-fpm'); + } elseif (!$this->getOption('no-strip', false)) { + shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm'); } - $this->deployBinary(BUILD_TARGET_FPM); } From 62b0bf8af0ded3b2178ee5d6fbd01f36fb7da1a5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 20 Feb 2024 10:56:39 +0800 Subject: [PATCH 224/415] fix no-strip not working for linux micro --- src/SPC/builder/linux/LinuxBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index a1096bb3..7d200d17 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -180,13 +180,13 @@ class LinuxBuilder extends UnixBuilderBase FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', '/POST_MICRO_BUILD_COMMANDS=.*/', - 'POST_MICRO_BUILD_COMMANDS=true', + 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)', ); } else { FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', '/POST_MICRO_BUILD_COMMANDS=.*/', - 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)', + 'POST_MICRO_BUILD_COMMANDS=true', ); } From b0d8b00fccc7647e0c8f08f91f163c0f3d5c4c23 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 20 Feb 2024 14:03:44 +0800 Subject: [PATCH 225/415] optimize pkg-config build process --- src/SPC/builder/unix/library/pkgconfig.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 52ec5e4d..18e9b4b9 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -21,6 +21,8 @@ trait pkgconfig '--disable-shared ' . '--enable-static ' . '--with-internal-glib ' . + '--disable-host-tool ' . + '--with-pic ' . '--prefix=' . BUILD_ROOT_PATH . ' ' . '--without-sysroot ' . '--without-system-include-path ' . @@ -29,6 +31,7 @@ trait pkgconfig ) ->exec('make clean') ->exec("make -j{$this->builder->concurrency}") - ->exec('make install'); + ->exec('make install-exec'); + shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config'); } } From 3945ac037baa9cb92a005be87b1e91bf044a1636 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 22 Feb 2024 14:37:10 +0800 Subject: [PATCH 226/415] Add curl and ssh2 support for windows (#348) * add curl and ssh2 support for windows * add curl and ssh2 test for windows * cs fix * update README [skip ci] * update README [skip ci] * update README [skip ci] * update README [skip ci] * update README [skip ci] --- README-zh.md | 46 ++++++++++++---- README.md | 53 ++++++++++++++----- config/ext.json | 9 ++++ config/lib.json | 14 ++--- .../windows/library/WindowsLibraryBase.php | 32 +++++++++++ src/SPC/builder/windows/library/curl.php | 39 ++++++++++++++ src/SPC/builder/windows/library/libssh2.php | 38 +++++++++++++ src/SPC/builder/windows/library/nghttp2.php | 37 +++++++++++++ src/SPC/store/FileSystem.php | 6 ++- src/globals/test-extensions.php | 2 +- 10 files changed, 244 insertions(+), 32 deletions(-) create mode 100644 src/SPC/builder/windows/library/curl.php create mode 100644 src/SPC/builder/windows/library/libssh2.php create mode 100644 src/SPC/builder/windows/library/nghttp2.php diff --git a/README-zh.md b/README-zh.md index f9017749..586bca67 100755 --- a/README-zh.md +++ b/README-zh.md @@ -20,7 +20,7 @@ static-php-cli(简称 `spc`)有许多特性: - :handbag: 构建独立的单文件 PHP 解释器,无需任何依赖 - :hamburger: 构建 **[phpmicro](https://github.com/dixyes/phpmicro)** 自执行二进制(将 PHP 代码和 PHP 解释器打包为一个文件) - :pill: 提供一键检查和修复编译环境的 Doctor 模块 -- :zap: 支持多个系统:`Linux`、`macOS`、`FreeBSD`、[`Windows (WIP)`](https://github.com/crazywhalecc/static-php-cli/pull/301) +- :zap: 支持多个系统:`Linux`、`macOS`、`FreeBSD`、`Windows` - :wrench: 高度自定义的代码 patch 功能 - :books: 自带编译依赖管理 - 📦 提供由自身编译的独立 `spc` 二进制(使用 spc 和 [box](https://github.com/box-project/box) 构建) @@ -47,16 +47,18 @@ static-php-cli(简称 `spc`)有许多特性: - [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。 - [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/):minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 6MB 左右。 +对于 Windows 系统,目前支持的扩展较少,故仅提供 SPC 自身运行的最小扩展组合的 `cli` 和 `micro`:[扩展组合 - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/)。 + ## 使用 static-php-cli 构建 PHP ### 编译环境需求 - PHP >= 8.1(这是 spc 自身需要的版本,不是支持的构建版本) -- 扩展:`mbstring,pcntl,posix,tokenizer,phar` +- 扩展:`mbstring,tokenizer,phar` - 系统安装了 `curl` 和 `git` 是的,本项目采用 PHP 编写,编译前需要一个 PHP 环境,比较滑稽。 -但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含 mbstring、pcntl 扩展和 PHP 版本大于等于 8.1 即可。 +但本项目默认可通过自身构建的 micro 和 static-php 二进制运行,其他只需要包含上面提到的扩展和 PHP 版本大于等于 8.1 即可。 下面是架构支持情况,:octocat: 代表支持 GitHub Action 构建,:computer: 代表支持本地构建,空 代表暂不支持。 @@ -64,10 +66,26 @@ static-php-cli(简称 `spc`)有许多特性: |---------|----------------------|----------------------| | macOS | :octocat: :computer: | :octocat: :computer: | | Linux | :octocat: :computer: | :octocat: :computer: | -| Windows | | | +| Windows | :computer: | | | FreeBSD | :computer: | :computer: | -目前支持编译的 PHP 版本为:`7.3`,`7.4`,`8.0`,`8.1`,`8.2`,`8.3`。 +当前支持编译的 PHP 版本: + +> :warning: 支持,但可能不再提供修复 +> +> :heavy_check_mark: 支持 +> +> :x: 不支持 + +| PHP Version | Status | Comment | +|-------------|--------------------|------------------------------| +| 7.2 | :x: | | +| 7.3 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | +| 7.4 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | +| 8.0 | :heavy_check_mark: | PHP 官方已停止 8.0 的维护 | +| 8.1 | :heavy_check_mark: | | +| 8.2 | :heavy_check_mark: | | +| 8.3 | :heavy_check_mark: | | ### 支持的扩展 @@ -107,10 +125,16 @@ curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-a curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64 # macOS aarch64 (Apple) curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64 +# Windows (x86_64, win10 build 17063 or later) +curl.exe -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe -# add x perm +# Add execute perm (Linux and macOS only) chmod +x ./spc + +# Run (Linux and macOS) ./spc --version +# Run (Windows powershell) +.\spc.exe --version ``` 自托管 `spc` 由 GitHub Actions 构建,你也可以从 Actions 直接下载:[此处](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml)。 @@ -149,14 +173,16 @@ bin/spc --version # 拉取所有依赖库 ./bin/spc download --all # 只拉取编译指定扩展需要的所有依赖(推荐) -./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite +./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite" # 下载编译不同版本的 PHP (--with-php=x.y,推荐 7.3 ~ 8.3) -./bin/spc download --for-extensions=openssl,curl,mbstring --with-php=8.1 +./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1 # 构建包含 bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl 扩展的 php-cli 和 micro.sfx ./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro # 编译线程安全版本 (--enable-zts) -./bin/spc build curl,phar --enable-zts --build-cli +./bin/spc build "curl,phar" --enable-zts --build-cli +# 编译后使用 UPX 减小可执行文件体积 (--with-upx-pack) (至少压缩至原来的 30~50%) +./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack ``` 其中,目前支持构建 cli,micro,fpm 和 embed,使用以下参数的一个或多个来指定编译的 SAPI: @@ -170,7 +196,7 @@ bin/spc --version 如果出现了任何错误,可以使用 `--debug` 参数来展示完整的输出日志,以供排查错误: ```bash -./bin/spc build openssl,pcntl,mbstring --debug --build-all +./bin/spc build "openssl,pcntl,mbstring" --debug --build-all ./bin/spc download --all --debug ``` diff --git a/README.md b/README.md index 504d900f..4f42756d 100755 --- a/README.md +++ b/README.md @@ -53,16 +53,19 @@ which can be downloaded directly according to your needs. - [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. - [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size. +For Windows systems, there are currently fewer extensions supported, +so only `cli` and `micro` that run the minimum extension combination of SPC itself are provided: [Extension-Combination - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/). + ## Build ### Compilation Requirements -- PHP >= 8.1 (This is the version required by spc itself, not the build version) -- Extension: `mbstring,pcntl,posix,tokenizer,phar` -- Supported OS with `curl` and `git` installed - You can say I made a PHP builder written in PHP, pretty funny. -But static-php-cli runtime only requires an environment above PHP 8.1 and `mbstring`, `pcntl` extension. +But static-php-cli runtime only requires an environment above PHP 8.1 and extensions mentioned below. + +- PHP >= 8.1 (This is the version required by spc itself, not the build version) +- Extension: `mbstring,tokenizer,phar` +- Supported OS with `curl` and `git` installed Here is the supported OS and arch, where :octocat: represents support for GitHub Action builds, :computer: represents support for local manual builds, and blank represents not currently supported. @@ -74,7 +77,23 @@ Here is the supported OS and arch, where :octocat: represents support for GitHub | Windows | :computer: | | | FreeBSD | :computer: | :computer: | -Currently supported PHP versions for compilation are: `7.3`, `7.4`, `8.0`, `8.1`, `8.2`, `8.3`. +Currently supported PHP versions for compilation: + +> :warning: supported but not maintained +> +> :heavy_check_mark: supported +> +> :x: not supported + +| PHP Version | Status | Comment | +|-------------|--------------------|---------------------------------------------------| +| 7.2 | :x: | | +| 7.3 | :warning: | phpmicro and some extensions not supported on 7.x | +| 7.4 | :warning: | phpmicro and some extensions not supported on 7.x | +| 8.0 | :heavy_check_mark: | PHP official has stopped maintenance of 8.0 | +| 8.1 | :heavy_check_mark: | | +| 8.2 | :heavy_check_mark: | | +| 8.3 | :heavy_check_mark: | | ### Supported Extensions @@ -117,10 +136,16 @@ curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-a curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64 # macOS aarch64 (Apple) curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64 +# Windows (x86_64, win10 build 17063 or later) +curl.exe -o spc.exe https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe -# add x perm +# Add execute perm (Linux and macOS only) chmod +x ./spc + +# Run (Linux and macOS) ./spc --version +# Run (Windows powershell) +.\spc.exe --version ``` Self-hosted `spc` is built by GitHub Actions, you can also download from Actions artifacts [here](https://github.com/crazywhalecc/static-php-cli/actions/workflows/release-build.yml). @@ -150,7 +175,7 @@ bin/spc --version Basic usage for building php with some extensions: -> If you are using the packaged `spc` binary, you need to replace `bin/spc` with `./spc` in the following commands. +> If you are using the packaged standalone `spc` binary, you need to replace `bin/spc` with `./spc` or `.\spc.exe` in the following commands. ```bash # Check system tool dependencies, auto-fix them if possible @@ -159,14 +184,16 @@ Basic usage for building php with some extensions: # fetch all libraries ./bin/spc download --all # only fetch necessary sources by needed extensions (recommended) -./bin/spc download --for-extensions=openssl,pcntl,mbstring,pdo_sqlite +./bin/spc download --for-extensions="openssl,pcntl,mbstring,pdo_sqlite" # download different PHP version (--with-php=x.y, recommend 7.3 ~ 8.3) -./bin/spc download --for-extensions=openssl,curl,mbstring --with-php=8.1 +./bin/spc download --for-extensions="openssl,curl,mbstring" --with-php=8.1 # with bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl extension, build both CLI and phpmicro SAPI -./bin/spc build bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl --build-cli --build-micro +./bin/spc build "bcmath,openssl,tokenizer,sqlite3,pdo_sqlite,ftp,curl" --build-cli --build-micro # build thread-safe (ZTS) version (--enable-zts) -./bin/spc build curl,phar --enable-zts --build-cli +./bin/spc build "curl,phar" --enable-zts --build-cli +# build, pack executable with UPX (--with-upx-pack) (reduce binary size for 30~50%) +./bin/spc build "curl,phar" --enable-zts --build-cli --with-upx-pack ``` Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more of the following parameters to specify the compiled SAPI: @@ -180,7 +207,7 @@ Now we support `cli`, `micro`, `fpm` and `embed` SAPI. You can use one or more o If anything goes wrong, use `--debug` option to display full terminal output: ```bash -./bin/spc build openssl,pcntl,mbstring --debug --build-all +./bin/spc build "openssl,pcntl,mbstring" --debug --build-all ./bin/spc download --all --debug ``` diff --git a/config/ext.json b/config/ext.json index 104d527a..af349727 100644 --- a/config/ext.json +++ b/config/ext.json @@ -24,6 +24,10 @@ "arg-type": "with", "lib-depends": [ "curl" + ], + "ext-depends-windows": [ + "zlib", + "openssl" ] }, "dba": { @@ -403,8 +407,13 @@ "type": "external", "source": "ext-ssh2", "arg-type": "with-prefix", + "arg-type-windows": "with", "lib-depends": [ "libssh2" + ], + "ext-depends-windows": [ + "openssl", + "zlib" ] }, "swoole": { diff --git a/config/lib.json b/config/lib.json index 6f3b058e..25b027a5 100644 --- a/config/lib.json +++ b/config/lib.json @@ -45,19 +45,21 @@ "openssl", "zlib" ], - "lib-suggests": [ + "lib-depends-windows": [ + "openssl", + "zlib", + "libssh2", + "nghttp2" + ], + "lib-suggests-unix": [ "libssh2", "brotli", "nghttp2", "zstd" ], "lib-suggests-windows": [ - "zlib", - "libssh2", "brotli", - "nghttp2", - "zstd", - "openssl" + "zstd" ], "frameworks": [ "CoreFoundation", diff --git a/src/SPC/builder/windows/library/WindowsLibraryBase.php b/src/SPC/builder/windows/library/WindowsLibraryBase.php index c3fa49d6..e8de629e 100644 --- a/src/SPC/builder/windows/library/WindowsLibraryBase.php +++ b/src/SPC/builder/windows/library/WindowsLibraryBase.php @@ -8,6 +8,8 @@ use SPC\builder\BuilderBase; use SPC\builder\LibraryBase; use SPC\builder\windows\WindowsBuilder; use SPC\exception\FileSystemException; +use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\FileSystem; abstract class WindowsLibraryBase extends LibraryBase @@ -22,6 +24,36 @@ abstract class WindowsLibraryBase extends LibraryBase return $this->builder; } + /** + * @throws RuntimeException + * @throws FileSystemException + * @throws WrongUsageException + */ + public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string + { + $libs = [$this]; + if ($recursive) { + array_unshift($libs, ...array_values($this->getDependencies(recursive: true))); + } + + $sep = match ($style) { + 'autoconf' => ' ', + 'cmake' => ';', + default => throw new RuntimeException('style only support autoconf and cmake'), + }; + $ret = []; + foreach ($libs as $lib) { + $libFiles = []; + foreach ($lib->getStaticLibs() as $name) { + $name = str_replace(' ', '\ ', FileSystem::convertPath(BUILD_LIB_PATH . "/{$name}")); + $name = str_replace('"', '\"', $name); + $libFiles[] = $name; + } + array_unshift($ret, implode($sep, $libFiles)); + } + return implode($sep, $ret); + } + /** * Create a nmake wrapper file. * diff --git a/src/SPC/builder/windows/library/curl.php b/src/SPC/builder/windows/library/curl.php new file mode 100644 index 00000000..5f8443a0 --- /dev/null +++ b/src/SPC/builder/windows/library/curl.php @@ -0,0 +1,39 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_STATIC_LIBS=ON ' . + '-DBUILD_CURL_EXE=OFF ' . + '-DUSE_ZLIB=ON ' . + '-DCURL_USE_OPENSSL=ON ' . + '-DCURL_USE_LIBLSSH2=ON ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/builder/windows/library/libssh2.php b/src/SPC/builder/windows/library/libssh2.php new file mode 100644 index 00000000..f064e139 --- /dev/null +++ b/src/SPC/builder/windows/library/libssh2.php @@ -0,0 +1,38 @@ +builder->getLib('zlib') ? 'ON' : 'OFF'; + // reset cmake + FileSystem::resetDir($this->source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_STATIC_LIBS=ON ' . + '-DBUILD_TESTING=OFF ' . + "-DENABLE_ZLIB_COMPRESSION={$zlib} " . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/builder/windows/library/nghttp2.php b/src/SPC/builder/windows/library/nghttp2.php new file mode 100644 index 00000000..a17fe89b --- /dev/null +++ b/src/SPC/builder/windows/library/nghttp2.php @@ -0,0 +1,37 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_STATIC_LIBS=ON ' . + '-DENABLE_STATIC_CRT=ON ' . + '-DENABLE_LIB_ONLY=ON ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 2a694044..2cb45e00 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -185,9 +185,11 @@ class FileSystem } if ($move_path !== null) { $move_path = SOURCE_PATH . '/' . $move_path; + } else { + $move_path = SOURCE_PATH . "/{$name}"; } - logger()->info("extracting {$name} source to " . ($move_path ?? (SOURCE_PATH . "/{$name}")) . ' ...'); - $target = self::convertPath($move_path ?? (SOURCE_PATH . "/{$name}")); + $target = self::convertPath($move_path); + logger()->info("extracting {$name} source to {$target}" . ' ...'); if (!is_dir($dir = dirname($target))) { self::createDir($dir); } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 77ff00ac..fd0f1083 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'event,gettext', - 'Windows' => 'mbstring', + 'Windows' => 'mbstring,curl,ssh2', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From f498250001edeba94201b9d43197d68c733696a1 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 23 Feb 2024 00:56:28 +0800 Subject: [PATCH 227/415] Add multiple XML related extensions support for Windows (#349) * update libxml2 version * use msys2 tar.exe instead of system32/tar.exe * add iconv, xml, dom, xmlreader, xmlwriter, soap, libxml, simplexml support * add test * add sysvshm support * add quote * add debug * use mingw target * fix windows tar * fix windows tar * fix windows tar * fix windows tar * fix windows tar [skip ci] --- config/ext.json | 26 +++++++++-- config/lib.json | 23 +++++++--- config/source.json | 11 ++++- src/SPC/builder/Extension.php | 2 +- src/SPC/builder/extension/xml.php | 22 ++++++++++ .../builder/windows/library/libiconv_win.php | 35 +++++++++++++++ src/SPC/builder/windows/library/libxml2.php | 44 +++++++++++++++++++ src/SPC/store/FileSystem.php | 19 +++++++- src/globals/test-extensions.php | 2 +- 9 files changed, 170 insertions(+), 14 deletions(-) create mode 100644 src/SPC/builder/windows/library/libiconv_win.php create mode 100644 src/SPC/builder/windows/library/libxml2.php diff --git a/config/ext.json b/config/ext.json index af349727..8e26de94 100644 --- a/config/ext.json +++ b/config/ext.json @@ -123,8 +123,12 @@ "iconv": { "type": "builtin", "arg-type": "with-prefix", - "lib-depends": [ + "arg-type-windows": "with", + "lib-depends-unix": [ "libiconv" + ], + "lib-depends-windows": [ + "libiconv-win" ] }, "igbinary": { @@ -351,9 +355,11 @@ "simplexml": { "type": "builtin", "arg-type": "custom", - "arg-type-windows": "with", "lib-depends": [ "libxml2" + ], + "ext-depends-windows": [ + "xml" ] }, "snappy": { @@ -373,6 +379,9 @@ "arg-type": "custom", "lib-depends": [ "libxml2" + ], + "ext-depends-windows": [ + "xml" ] }, "sockets": { @@ -488,8 +497,7 @@ "unix-only": true }, "sysvshm": { - "type": "builtin", - "unix-only": true + "type": "builtin" }, "tidy": { "type": "builtin", @@ -534,6 +542,9 @@ "arg-type-windows": "with", "lib-depends": [ "libxml2" + ], + "ext-depends-windows": [ + "iconv" ] }, "xmlreader": { @@ -541,6 +552,10 @@ "arg-type": "custom", "lib-depends": [ "libxml2" + ], + "ext-depends-windows": [ + "xml", + "dom" ] }, "xmlwriter": { @@ -548,6 +563,9 @@ "arg-type": "custom", "lib-depends": [ "libxml2" + ], + "ext-depends-windows": [ + "xml" ] }, "xsl": { diff --git a/config/lib.json b/config/lib.json index 25b027a5..7dfef67c 100644 --- a/config/lib.json +++ b/config/lib.json @@ -245,6 +245,13 @@ "localcharset.h" ] }, + "libiconv-win": { + "source": "libiconv-win", + "static-libs-windows": [ + "libiconv.lib", + "libiconv_a.lib" + ] + }, "libjpeg": { "source": "libjpeg", "static-libs-unix": [ @@ -334,21 +341,25 @@ "libxml2.a" ], "static-libs-windows": [ - [ - "libxml2s.lib", - "libxml2_a.lib" - ] + "libxml2s.lib", + "libxml2_a.lib" ], "headers": [ "libxml2" ], - "lib-depends": [ + "lib-depends-unix": [ "libiconv" ], - "lib-suggests": [ + "lib-suggests-unix": [ "xz", "icu", "zlib" + ], + "lib-depends-windows": [ + "libiconv-win" + ], + "lib-suggests-windows": [ + "zlib" ] }, "libxslt": { diff --git a/config/source.json b/config/source.json index 73212640..11b65f53 100644 --- a/config/source.json +++ b/config/source.json @@ -254,6 +254,15 @@ "path": "COPYING" } }, + "libiconv-win": { + "type": "git", + "rev": "master", + "url": "https://github.com/static-php/libiconv-win.git", + "license": { + "type": "file", + "path": "source/COPYING" + } + }, "libjpeg": { "type": "ghtar", "repo": "libjpeg-turbo/libjpeg-turbo", @@ -331,7 +340,7 @@ }, "libxml2": { "type": "url", - "url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.14.tar.gz", + "url": "https://github.com/GNOME/libxml2/archive/refs/tags/v2.12.5.tar.gz", "license": { "type": "file", "path": "Copyright" diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 1776a268..ea875a78 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -212,7 +212,7 @@ class Extension // Trim additional content & escape special characters to allow inline usage $test = str_replace( ['getName() . '.php')) ); diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index adac92c8..6242be6b 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -6,6 +6,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('xml')] @@ -33,4 +34,25 @@ class xml extends Extension $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; return $arg; } + + public function patchBeforeBuildconf(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/win32/build/config.w32', 'dllmain.c ', ''); + return true; + } + + public function getWindowsConfigureArg(): string + { + $arg = match ($this->name) { + 'xml' => '--with-xml', + 'soap' => '--enable-soap', + 'xmlreader' => '--enable-xmlreader', + 'xmlwriter' => '--enable-xmlwriter', + 'dom' => '--with-dom', + 'simplexml' => '--with-simplexml', + default => throw new RuntimeException('Not accept non-xml extension'), + }; + $arg .= ' --with-libxml'; + return $arg; + } } diff --git a/src/SPC/builder/windows/library/libiconv_win.php b/src/SPC/builder/windows/library/libiconv_win.php new file mode 100644 index 00000000..4f638530 --- /dev/null +++ b/src/SPC/builder/windows/library/libiconv_win.php @@ -0,0 +1,35 @@ + '/MSVC17', + 'vs16' => '/MSVC16', + default => throw new RuntimeException('Current VS version is not supported yet!'), + }; + + // start build + cmd()->cd($this->source_dir . $vs_ver_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('msbuild'), + 'libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64' + ); + FileSystem::createDir(BUILD_LIB_PATH); + FileSystem::createDir(BUILD_INCLUDE_PATH); + copy($this->source_dir . $vs_ver_dir . '\x64\lib\libiconv.lib', BUILD_LIB_PATH . '\libiconv.lib'); + copy($this->source_dir . $vs_ver_dir . '\x64\lib\libiconv_a.lib', BUILD_LIB_PATH . '\libiconv_a.lib'); + copy($this->source_dir . '\source\include\iconv.h', BUILD_INCLUDE_PATH . '\iconv.h'); + } +} diff --git a/src/SPC/builder/windows/library/libxml2.php b/src/SPC/builder/windows/library/libxml2.php new file mode 100644 index 00000000..d4a4b9b4 --- /dev/null +++ b/src/SPC/builder/windows/library/libxml2.php @@ -0,0 +1,44 @@ +builder->getLib('zlib') ? 'ON' : 'OFF'; + // reset cmake + FileSystem::resetDir($this->source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_STATIC_LIBS=ON ' . + "-DLIBXML2_WITH_ZLIB={$zlib} " . + '-DLIBXML2_WITH_PYTHON=OFF ' . + '-DLIBXML2_WITH_ICONV=ON ' . + '-DIconv_LIBRARY=' . BUILD_LIB_PATH . ' ' . + '-DIconv_INCLUDE_DIR=' . BUILD_INCLUDE_PATH . ' ' . + '-DLIBXML2_WITH_LZMA=OFF ' . // xz not supported yet + '-DLIBXML2_WITH_PROGRAMS=OFF ' . + '-DLIBXML2_WITH_TESTS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + copy(BUILD_LIB_PATH . '\libxml2s.lib', BUILD_LIB_PATH . '\libxml2_a.lib'); + } +} diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 2cb45e00..732c5b3c 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -219,6 +219,14 @@ class FileSystem return str_replace('/', DIRECTORY_SEPARATOR, $path); } + public static function convertWinPathToMinGW(string $path): string + { + if (preg_match('/^[A-Za-z]:/', $path)) { + $path = '/' . strtolower(substr($path, 0, 1)) . '/' . str_replace('\\', '/', substr($path, 2)); + } + return $path; + } + /** * 递归或非递归扫描目录,可返回相对目录的文件列表或绝对目录的文件列表 * @@ -443,6 +451,9 @@ class FileSystem if (f_mkdir(directory: $target, recursive: true) !== true) { throw new FileSystemException('create ' . $target . ' dir failed'); } + if (!file_exists($filename)) { + throw new FileSystemException('File not exists'); + } if (in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { match (self::extname($filename)) { @@ -455,9 +466,15 @@ class FileSystem } elseif (PHP_OS_FAMILY === 'Windows') { // use php-sdk-binary-tools/bin/7za.exe $_7z = self::convertPath(PHP_SDK_PATH . '/bin/7za.exe'); + + // Windows notes: I hate windows tar....... + // When extracting .tar.gz like libxml2, it shows a symlink error and returns code[1]. + // Related posts: https://answers.microsoft.com/en-us/windows/forum/all/tar-on-windows-fails-to-extract-archive-containing/0ee9a7ea-9b1f-4fef-86a9-5d9dc35cea2f + // And MinGW tar.exe cannot work on temporarily storage ??? (GitHub Actions hosted runner) + // Yeah, I will be an MS HATER ! match (self::extname($filename)) { 'tar' => f_passthru("tar -xf {$filename} -C {$target} --strip-components 1"), - 'xz', 'txz', 'gz', 'tgz', 'bz2' => f_passthru("\"{$_7z}\" x -so {$filename} | tar -f - -x -C {$target} --strip-components 1"), + 'xz', 'txz', 'gz', 'tgz', 'bz2' => cmd()->execWithResult("\"{$_7z}\" x -so {$filename} | tar -f - -x -C \"{$target}\" --strip-components 1"), 'zip' => f_passthru("\"{$_7z}\" x {$filename} -o{$target} -y"), default => throw new FileSystemException("unknown archive format: {$filename}"), }; diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index fd0f1083..0cb26e07 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'event,gettext', - 'Windows' => 'mbstring,curl,ssh2', + 'Windows' => 'mbstring,iconv,dom,xml,xmlwriter,xmlreader,soap,simplexml', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From 4ab7b6bfdc17e891cee729ae1d5768aa4922b8cd Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 23 Feb 2024 11:14:51 +0800 Subject: [PATCH 228/415] Add sqlite support for Windows (#350) * add sqlite support * cs fix --- config/ext.json | 1 + config/lib.json | 5 +- src/SPC/builder/windows/library/sqlite.php | 21 +++++++ src/globals/extra/Makefile-sqlite | 69 ++++++++++++++++++++++ src/globals/test-extensions.php | 2 +- 5 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/windows/library/sqlite.php create mode 100644 src/globals/extra/Makefile-sqlite diff --git a/config/ext.json b/config/ext.json index 8e26de94..87a11ba3 100644 --- a/config/ext.json +++ b/config/ext.json @@ -397,6 +397,7 @@ "sqlite3": { "type": "builtin", "arg-type": "with-prefix", + "arg-type-windows": "with", "lib-depends": [ "sqlite" ] diff --git a/config/lib.json b/config/lib.json index 7dfef67c..df55c82d 100644 --- a/config/lib.json +++ b/config/lib.json @@ -520,7 +520,10 @@ "static-libs-unix": [ "libsqlite3.a" ], - "headers-unix": [ + "static-libs-windows": [ + "libsqlite3_a.lib" + ], + "headers": [ "sqlite3.h", "sqlite3ext.h" ] diff --git a/src/SPC/builder/windows/library/sqlite.php b/src/SPC/builder/windows/library/sqlite.php new file mode 100644 index 00000000..096c1e97 --- /dev/null +++ b/src/SPC/builder/windows/library/sqlite.php @@ -0,0 +1,21 @@ +source_dir . '/Makefile'); + return true; + } + + protected function build(): void + { + cmd()->cd($this->source_dir)->execWithWrapper($this->builder->makeSimpleWrapper('nmake'), 'PREFIX=' . BUILD_ROOT_PATH . ' install-static'); + } +} diff --git a/src/globals/extra/Makefile-sqlite b/src/globals/extra/Makefile-sqlite new file mode 100644 index 00000000..e122cd9d --- /dev/null +++ b/src/globals/extra/Makefile-sqlite @@ -0,0 +1,69 @@ + +CC=cl.exe /nologo +AR=lib.exe /nologo +LINK=link.exe /nologo + +!IF "" == "$(MACHINE)" +MACHINE=x64 +!ENDIF + +!IF "" == "$(CRT)" +CRT=vc15 +!ENDIF + +!IF "" == "$(PREFIX)" +PREFIX="$(CRT)-$(MACHINE)" +!ENDIF + +COMMON_CFLAGS=/D SQLITE_THREADSAFE=1 /DSQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_FTS4=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_JSON1=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 +!IF "$(DEBUG)"=="1" +SQLITE3_STATIC_BASE=libsqlite3_a_debug +SQLITE3_DLL_BASE=libsqlite3_debug +SQLITE3_EXE_BASE=sqlite3 +CFLAGS=$(COMMON_CFLAGS) /Zi /MDd /Od /W3 +LDFLAGS=/DEBUG /GUARD:CF /INCREMENTAL:NO +!ELSE +SQLITE3_STATIC_BASE=libsqlite3_a +SQLITE3_DLL_BASE=libsqlite3 +SQLITE3_EXE_BASE=sqlite3 +CFLAGS=$(COMMON_CFLAGS) /Zi /MT /guard:cf /Zc:inline /Qspectre /Ox /W3 /GF /GL /Gw +LDFLAGS=/GUARD:CF /INCREMENTAL:NO /NXCOMPAT /DYNAMICBASE +!ENDIF + + +all: $(SQLITE3_STATIC_BASE).lib $(SQLITE3_EXE_BASE).exe $(SQLITE3_DLL_BASE).dll + +install: all + if not exist $(PREFIX)\bin mkdir $(PREFIX)\bin + if not exist $(PREFIX)\include mkdir $(PREFIX)\include + if not exist $(PREFIX)\lib mkdir $(PREFIX)\lib + copy /Y sqlite3.h $(PREFIX)\include + copy /Y sqlite3ext.h $(PREFIX)\include + copy /Y $(SQLITE3_STATIC_BASE).lib $(PREFIX)\lib + copy /Y $(SQLITE3_STATIC_BASE).pdb $(PREFIX)\lib + copy /Y $(SQLITE3_DLL_BASE).lib $(PREFIX)\lib + copy /Y $(SQLITE3_DLL_BASE).pdb $(PREFIX)\bin + copy /Y $(SQLITE3_DLL_BASE).dll $(PREFIX)\bin + copy /Y $(SQLITE3_EXE_BASE).exe $(PREFIX)\bin + copy /Y $(SQLITE3_EXE_BASE).pdb $(PREFIX)\bin + +install-static: $(SQLITE3_STATIC_BASE).lib + if not exist $(PREFIX)\include mkdir $(PREFIX)\include + if not exist $(PREFIX)\lib mkdir $(PREFIX)\lib + copy /Y sqlite3.h $(PREFIX)\include + copy /Y sqlite3ext.h $(PREFIX)\include + copy /Y $(SQLITE3_STATIC_BASE).lib $(PREFIX)\lib + +clean: + del *.obj *.lib *.exe *.pdb *.dll *.exp + +$(SQLITE3_STATIC_BASE).lib: sqlite3.c sqlite3.h + $(CC) $(CFLAGS) /Fd$(SQLITE3_STATIC_BASE).pdb /c sqlite3.c + $(AR) sqlite3.obj /OUT:$(SQLITE3_STATIC_BASE).lib + +$(SQLITE3_EXE_BASE).exe: shell.c sqlite3.c sqlite3.h + $(CC) $(CFLAGS) shell.c sqlite3.c /Fd$(SQLITE3_EXE_BASE).pdb /Fe$(SQLITE3_EXE_BASE).exe + +$(SQLITE3_DLL_BASE).dll: sqlite3.c sqlite3.h + $(CC) $(CFLAGS) /DSQLITE_API=__declspec(dllexport) /Fd$(SQLITE3_DLL_BASE).pdb /c sqlite3.c + $(LINK) /DLL /OUT:$(SQLITE3_DLL_BASE).dll sqlite3.obj \ No newline at end of file diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 0cb26e07..3e00b921 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'event,gettext', - 'Windows' => 'mbstring,iconv,dom,xml,xmlwriter,xmlreader,soap,simplexml', + 'Windows' => 'mbstring,pdo_sqlite', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From df0e37cd0fd8b5bed7f4a2471def9cd4807c1981 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 23 Feb 2024 11:41:35 +0800 Subject: [PATCH 229/415] Add mbregex support for windows (#351) * add mbregex support for windows * cs fix * fix curl http2 support --- config/lib.json | 6 ++-- src/SPC/builder/extension/mbregex.php | 12 ++++++++ src/SPC/builder/extension/mbstring.php | 2 ++ src/SPC/builder/windows/library/curl.php | 1 + src/SPC/builder/windows/library/onig.php | 37 ++++++++++++++++++++++++ src/globals/test-extensions.php | 3 +- 6 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 src/SPC/builder/windows/library/onig.php diff --git a/config/lib.json b/config/lib.json index df55c82d..f4d48e88 100644 --- a/config/lib.json +++ b/config/lib.json @@ -440,10 +440,8 @@ "libonig.a" ], "static-libs-windows": [ - [ - "onig.lib", - "onig_a.lib" - ] + "onig.lib", + "onig_a.lib" ], "headers": [ "oniggnu.h", diff --git a/src/SPC/builder/extension/mbregex.php b/src/SPC/builder/extension/mbregex.php index eca3d5ee..be1290d1 100644 --- a/src/SPC/builder/extension/mbregex.php +++ b/src/SPC/builder/extension/mbregex.php @@ -31,4 +31,16 @@ class mbregex extends Extension throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); } } + + public function runCliCheckWindows(): void + { + [$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false); + if ($ret !== 0) { + throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !'); + } + $out = implode("\n", $out); + if (!str_contains($out, 'regex')) { + 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/mbstring.php b/src/SPC/builder/extension/mbstring.php index 2318208e..5fcb88bd 100644 --- a/src/SPC/builder/extension/mbstring.php +++ b/src/SPC/builder/extension/mbstring.php @@ -15,6 +15,8 @@ class mbstring extends Extension $arg = '--enable-mbstring'; if ($this->builder->getExt('mbregex') === null) { $arg .= ' --disable-mbregex'; + } else { + $arg .= ' --enable-mbregex'; } return $arg; } diff --git a/src/SPC/builder/windows/library/curl.php b/src/SPC/builder/windows/library/curl.php index 5f8443a0..4423a16c 100644 --- a/src/SPC/builder/windows/library/curl.php +++ b/src/SPC/builder/windows/library/curl.php @@ -29,6 +29,7 @@ class curl extends WindowsLibraryBase '-DUSE_ZLIB=ON ' . '-DCURL_USE_OPENSSL=ON ' . '-DCURL_USE_LIBLSSH2=ON ' . + '-DUSE_NGHTTP2=ON ' . // php-src with curl needs nghttp2 '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' ) ->execWithWrapper( diff --git a/src/SPC/builder/windows/library/onig.php b/src/SPC/builder/windows/library/onig.php new file mode 100644 index 00000000..11ce815e --- /dev/null +++ b/src/SPC/builder/windows/library/onig.php @@ -0,0 +1,37 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_STATIC_LIBS=ON ' . + '-DMSVC_STATIC_RUNTIME=ON ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + copy(BUILD_LIB_PATH . '/onig.lib', BUILD_LIB_PATH . '/onig_a.lib'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 3e00b921..29c0e0a1 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'event,gettext', - 'Windows' => 'mbstring,pdo_sqlite', + 'Linux', 'Darwin' => 'event,gettext', + 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From 5012da96be14d289947ebf46d8910fdc37cfdddf Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 23 Feb 2024 11:42:10 +0800 Subject: [PATCH 230/415] Update ConsoleApplication.php --- 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 355d5932..64131af6 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.0-beta.4'; + public const VERSION = '2.1.0'; public function __construct() { From d5dcd193cfa40ad4990a35f321b2ae7888c914e9 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 26 Feb 2024 00:19:30 +0800 Subject: [PATCH 231/415] update generated spc binary --- .github/workflows/release-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index c363fcea..d3b2b2be 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -70,10 +70,10 @@ jobs: - name: "Generate Executable" run: | + bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G" if [ "${{ matrix.operating-system }}" = "windows-x64" ]; then - cat micro.sfx spc.phar > spc.exe + mv spc spc.exe else - cat micro.sfx spc.phar > spc chmod +x spc fi From 5f6c1a0f402d9d0fb0801aba0fed68ae1b704c81 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 26 Feb 2024 19:55:47 +0800 Subject: [PATCH 232/415] update postgresql version to 16.2 (#355) * update postgresql version to 16.2 * add tests * add tests --- config/source.json | 2 +- src/SPC/builder/unix/library/postgresql.php | 29 +++++++++++++++++---- src/globals/test-extensions.php | 3 +-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/config/source.json b/config/source.json index 11b65f53..d9287da2 100644 --- a/config/source.json +++ b/config/source.json @@ -449,7 +449,7 @@ }, "postgresql": { "type": "url", - "url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz", + "url": "https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.bz2", "license": { "type": "file", "path": "COPYRIGHT" diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 4061f13e..0b3c7c61 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -58,11 +58,17 @@ trait postgresql FileSystem::resetDir($this->source_dir . '/build'); - # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile - shell()->cd($this->source_dir . '/build') - ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') - ->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib') - ->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib'); + $version = $this->getVersion(); + // 16.1 workaround + if (version_compare($version, '16.1') >= 0) { + # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile + shell()->cd($this->source_dir . '/build') + ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') + ->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib') + ->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib'); + } else { + throw new RuntimeException('Unsupported version for postgresql: ' . $version . ' !'); + } // configure shell()->cd($this->source_dir . '/build') @@ -101,4 +107,17 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); } + + private function getVersion(): string + { + try { + $file = FileSystem::readFile($this->source_dir . '/meson.build'); + if (preg_match("/^\\s+version:\\s?'(.*)'/m", $file, $match)) { + return $match[1]; + } + return 'unknown'; + } catch (FileSystemException) { + return 'unknown'; + } + } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 29c0e0a1..0f93a9ea 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'event,gettext', - 'Linux', 'Darwin' => 'event,gettext', + 'Linux', 'Darwin' => 'pgsql,pdo_pgsql', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; From 254764761dd07cf335459eb0a0f03df7012eee8e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 26 Feb 2024 20:11:09 +0800 Subject: [PATCH 233/415] bump version to 2.1.1 --- 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 64131af6..ba43d83c 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.0'; + public const VERSION = '2.1.1'; public function __construct() { From 842e0add29abcd6badc533ec51d0a919fc5723da Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 29 Feb 2024 15:34:06 +0800 Subject: [PATCH 234/415] Add ffi support for windows x64 (#357) * add ffi support for windows x64 * add ffi test --- config/ext.json | 5 +- config/lib.json | 11 +++++ config/source.json | 9 ++++ src/SPC/builder/extension/ffi.php | 5 ++ .../builder/windows/library/libffi_win.php | 46 +++++++++++++++++++ src/globals/test-extensions.php | 2 +- 6 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/windows/library/libffi_win.php diff --git a/config/ext.json b/config/ext.json index 87a11ba3..0106f6e5 100644 --- a/config/ext.json +++ b/config/ext.json @@ -63,8 +63,11 @@ "ffi": { "arg-type": "custom", "type": "builtin", - "lib-depends": [ + "lib-depends-unix": [ "libffi" + ], + "lib-depends-windows": [ + "libffi-win" ] }, "fileinfo": { diff --git a/config/lib.json b/config/lib.json index f4d48e88..4d656ae0 100644 --- a/config/lib.json +++ b/config/lib.json @@ -233,6 +233,17 @@ "ffitarget.h" ] }, + "libffi-win": { + "source": "libffi-win", + "static-libs-windows": [ + "libffi.lib" + ], + "headers-windows": [ + "ffi.h", + "ffitarget.h", + "fficonfig.h" + ] + }, "libiconv": { "source": "libiconv", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index d9287da2..d59f5c54 100644 --- a/config/source.json +++ b/config/source.json @@ -245,6 +245,15 @@ "path": "LICENSE" } }, + "libffi-win": { + "type": "git", + "rev": "master", + "url": "https://github.com/static-php/libffi-win.git", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libiconv": { "type": "filelist", "url": "https://ftp.gnu.org/gnu/libiconv/", diff --git a/src/SPC/builder/extension/ffi.php b/src/SPC/builder/extension/ffi.php index f0cf9fe6..6f294481 100644 --- a/src/SPC/builder/extension/ffi.php +++ b/src/SPC/builder/extension/ffi.php @@ -14,4 +14,9 @@ class ffi extends Extension { return '--with-ffi --enable-zend-signals'; } + + public function getWindowsConfigureArg(): string + { + return '--with-ffi'; + } } diff --git a/src/SPC/builder/windows/library/libffi_win.php b/src/SPC/builder/windows/library/libffi_win.php new file mode 100644 index 00000000..07bc909a --- /dev/null +++ b/src/SPC/builder/windows/library/libffi_win.php @@ -0,0 +1,46 @@ + '/win32/vs17_x64', + 'vs16' => '/win32/vs16_x64', + default => throw new RuntimeException('Current VS version is not supported yet!'), + }; + + // start build + cmd()->cd($this->source_dir . $vs_ver_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('msbuild'), + 'libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64' + ); + FileSystem::createDir(BUILD_LIB_PATH); + FileSystem::createDir(BUILD_INCLUDE_PATH); + copy($this->source_dir . $vs_ver_dir . '\x64\Release\libffi.lib', BUILD_LIB_PATH . '\libffi.lib'); + copy($this->source_dir . $vs_ver_dir . '\x64\Release\libffi.pdb', BUILD_LIB_PATH . '\libffi.pdb'); + copy($this->source_dir . '\include\ffi.h', BUILD_INCLUDE_PATH . '\ffi.h'); + + FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\ffi.h', '#define LIBFFI_H', "#define LIBFFI_H\n#define FFI_BUILDING"); + copy($this->source_dir . '\src\x86\ffitarget.h', BUILD_INCLUDE_PATH . '\ffitarget.h'); + copy($this->source_dir . '\fficonfig.h', BUILD_INCLUDE_PATH . '\fficonfig.h'); + + // copy($this->source_dir . '\msvc_build\out\static-Release\X64\libffi.lib', BUILD_LIB_PATH . '\libffi.lib'); + // copy($this->source_dir . '\msvc_build\include\ffi.h', BUILD_INCLUDE_PATH . '\ffi.h'); + // copy($this->source_dir . '\msvc_build\include\fficonfig.h', BUILD_INCLUDE_PATH . '\fficonfig.h'); + // copy($this->source_dir . '\src\x86\ffitarget.h', BUILD_INCLUDE_PATH . '\ffitarget.h'); + + // FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '\ffi.h', '..\..\src\x86\ffitarget.h', 'ffitarget.h'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 0f93a9ea..d342e8f6 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'pgsql,pdo_pgsql', - 'Windows' => 'mbstring,pdo_sqlite,mbregex', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From b46655ecfee038025b41f8c0d6747d63221c8adc Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 29 Feb 2024 15:35:02 +0800 Subject: [PATCH 235/415] Add custom Windows micro logo support (#358) * add custom windows micro logo option `--with-micro-logo` * bump version 2.1.2 --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/windows/WindowsBuilder.php | 10 +++++++++- src/SPC/command/BuildCliCommand.php | 12 ++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index ba43d83c..35330406 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.1'; + public const VERSION = '2.1.2'; public function __construct() { diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index f2f8fcc4..ff7209d5 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -85,6 +85,14 @@ class WindowsBuilder extends BuilderBase unlink($makefile . '.originfile'); } + if (($logo = $this->getOption('with-micro-logo')) !== null) { + // realpath + $logo = realpath($logo); + $micro_logo = '--enable-micro-logo=' . escapeshellarg($logo) . ' '; + } else { + $micro_logo = ''; + } + cmd()->cd(SOURCE_PATH . '\php-src') ->exec( "{$this->sdk_prefix} configure.bat --task-args \"" . @@ -94,7 +102,7 @@ class WindowsBuilder extends BuilderBase '--with-extra-includes=' . BUILD_INCLUDE_PATH . ' ' . '--with-extra-libs=' . BUILD_LIB_PATH . ' ' . ($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') . - ($enableMicro ? '--enable-micro=yes ' : '--enable-micro=no ') . + ($enableMicro ? ('--enable-micro=yes ' . $micro_logo) : '--enable-micro=no ') . ($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') . "{$this->makeExtensionArgs()} " . $zts . diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 44d16873..5105c43c 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -39,6 +39,10 @@ class BuildCliCommand extends BuildCommand $this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code'); $this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)'); + + if (PHP_OS_FAMILY === 'Windows') { + $this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx'); + } } public function handle(): int @@ -63,6 +67,14 @@ class BuildCliCommand extends BuildCommand if ($rule === BUILD_TARGET_ALL) { logger()->warning('--build-all option makes `--no-strip` always true, be aware!'); } + if (($rule & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO && $this->getOption('with-micro-logo')) { + $logo = $this->getOption('with-micro-logo'); + if (!file_exists($logo)) { + logger()->error('Logo file ' . $logo . ' not exist !'); + return static::FAILURE; + } + } + // Check upx $suffix = PHP_OS_FAMILY === 'Windows' ? '.exe' : ''; if ($this->getOption('with-upx-pack')) { From 9664709f2141400583881c19ff8ad70106796ed1 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 1 Mar 2024 19:19:47 +0800 Subject: [PATCH 236/415] Add libtiff support (#361) * add libtiff support * fix command option not working on *nix * fix test with libs ext test --- config/lib.json | 9 ++++++- config/source.json | 9 +++++++ src/SPC/builder/linux/library/libtiff.php | 12 +++++++++ src/SPC/builder/macos/library/libtiff.php | 12 +++++++++ src/SPC/builder/unix/library/libtiff.php | 30 +++++++++++++++++++++++ src/SPC/command/BuildCliCommand.php | 6 +---- src/globals/test-extensions.php | 11 +++++---- 7 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 src/SPC/builder/linux/library/libtiff.php create mode 100644 src/SPC/builder/macos/library/libtiff.php create mode 100644 src/SPC/builder/unix/library/libtiff.php diff --git a/config/lib.json b/config/lib.json index 4d656ae0..b64cc7c4 100644 --- a/config/lib.json +++ b/config/lib.json @@ -147,7 +147,8 @@ "libpng", "libjpeg", "libwebp", - "freetype" + "freetype", + "libtiff" ], "lib-suggests": [ "zstd", @@ -330,6 +331,12 @@ "zlib" ] }, + "libtiff": { + "source": "libtiff", + "static-libs-unix": [ + "libtiff.a" + ] + }, "libuv": { "source": "libuv", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index d59f5c54..37b5a7e0 100644 --- a/config/source.json +++ b/config/source.json @@ -325,6 +325,15 @@ "path": "COPYING" } }, + "libtiff": { + "type": "filelist", + "url": "https://download.osgeo.org/libtiff/", + "regex": "/href=\"(?tiff-(?[^\"]+)\\.tar\\.xz)\"/", + "license": { + "type": "file", + "path": "LICENSE.md" + } + }, "libuv": { "type": "ghtar", "repo": "libuv/libuv", diff --git a/src/SPC/builder/linux/library/libtiff.php b/src/SPC/builder/linux/library/libtiff.php new file mode 100644 index 00000000..fe3d15ad --- /dev/null +++ b/src/SPC/builder/linux/library/libtiff.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static --disable-shared ' . + '--disable-cxx ' . + '--prefix=' + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $this->patchPkgconfPrefix(['libtiff-4.pc']); + } +} diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 5105c43c..3c5c2276 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -37,12 +37,8 @@ class BuildCliCommand extends BuildCommand $this->addOption('with-suggested-exts', 'E', null, 'Build with suggested extensions for selected exts'); $this->addOption('with-added-patch', 'P', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Inject patch script outside'); $this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code'); - $this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)'); - - if (PHP_OS_FAMILY === 'Windows') { - $this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx'); - } + $this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx (windows only)'); } public function handle(): int diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index d342e8f6..ba11efbb 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'pgsql,pdo_pgsql', + 'Linux', 'Darwin' => 'imagick,zstd,bz2,zip,xml,dom', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // 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' => 'xz', 'Windows' => '', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; @@ -62,6 +62,7 @@ $final_libs = trim($with_libs, $trim_value); if (PHP_OS_FAMILY === 'Windows') { $final_extensions_cmd = '"' . $final_extensions . '"'; + $final_libs = $final_libs === '' ? '' : ('"' . $final_libs . '"'); } else { $final_extensions_cmd = $final_extensions; } @@ -69,7 +70,7 @@ if (PHP_OS_FAMILY === 'Windows') { echo match ($argv[1]) { 'extensions' => $final_extensions, 'libs' => $final_libs, - 'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), - 'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs="' . $final_libs . '"')), + 'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), + 'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), default => '', }; From f5d1df54076723a4ed15f98f84e8f873ffab7a29 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 1 Mar 2024 20:10:48 +0800 Subject: [PATCH 237/415] add uuid/libuuid for linux and macos (#363) --- config/ext.json | 8 ++++++ config/lib.json | 6 +++++ config/source.json | 19 ++++++++++++++ src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/linux/library/libuuid.php | 12 +++++++++ src/SPC/builder/macos/library/libuuid.php | 12 +++++++++ src/SPC/builder/unix/library/libuuid.php | 31 +++++++++++++++++++++++ src/globals/test-extensions.php | 4 +-- 8 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 src/SPC/builder/linux/library/libuuid.php create mode 100644 src/SPC/builder/macos/library/libuuid.php create mode 100644 src/SPC/builder/unix/library/libuuid.php diff --git a/config/ext.json b/config/ext.json index 0106f6e5..32c6ea34 100644 --- a/config/ext.json +++ b/config/ext.json @@ -513,6 +513,14 @@ "tokenizer": { "type": "builtin" }, + "uuid": { + "type": "external", + "source": "ext-uuid", + "arg-type": "with-prefix", + "lib-depends": [ + "libuuid" + ] + }, "uv": { "type": "external", "source": "ext-uv", diff --git a/config/lib.json b/config/lib.json index b64cc7c4..586e3f96 100644 --- a/config/lib.json +++ b/config/lib.json @@ -337,6 +337,12 @@ "libtiff.a" ] }, + "libuuid": { + "source": "libuuid", + "static-libs-unix": [ + "libuuid.a" + ] + }, "libuv": { "source": "libuv", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 37b5a7e0..c9d8c687 100644 --- a/config/source.json +++ b/config/source.json @@ -100,6 +100,16 @@ "path": "LICENSE" } }, + "ext-uuid": { + "type": "url", + "url": "https://pecl.php.net/get/uuid", + "path": "php-src/ext/uuid", + "filename": "uuid.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-uv": { "type": "url", "url": "https://pecl.php.net/get/uv", @@ -334,6 +344,15 @@ "path": "LICENSE.md" } }, + "libuuid": { + "type": "git", + "url": "https://github.com/cloudbase/libuuid.git", + "rev": "master", + "license": { + "type": "file", + "path": "COPYING" + } + }, "libuv": { "type": "ghtar", "repo": "libuv/libuv", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 35330406..63eae94e 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.2'; + public const VERSION = '2.1.3'; public function __construct() { diff --git a/src/SPC/builder/linux/library/libuuid.php b/src/SPC/builder/linux/library/libuuid.php new file mode 100644 index 00000000..85f0d215 --- /dev/null +++ b/src/SPC/builder/linux/library/libuuid.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec('chmod +x configure') + ->exec('chmod +x install-sh') + ->exec( + './configure ' . + '--enable-static --disable-shared ' . + '--prefix=' + ) + ->exec('make clean') + ->exec("make -j{$this->builder->concurrency}") + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $this->patchPkgconfPrefix(['uuid.pc']); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ba11efbb..c01071be 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // 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,zstd,bz2,zip,xml,dom', + 'Linux', 'Darwin' => 'uuid', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // 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' => 'xz', + 'Linux', 'Darwin' => '', 'Windows' => '', }; From d4c02901959600e183aaf22abf9568aa5a6b5379 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 1 Mar 2024 21:27:51 +0800 Subject: [PATCH 238/415] Fix libuuid random bug when `make clean` (#364) * fix libuuid random bug when `make clean` * test * test [skip ci] --- src/SPC/builder/unix/library/libuuid.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SPC/builder/unix/library/libuuid.php b/src/SPC/builder/unix/library/libuuid.php index 624999f9..abbc4a9f 100644 --- a/src/SPC/builder/unix/library/libuuid.php +++ b/src/SPC/builder/unix/library/libuuid.php @@ -6,9 +6,16 @@ namespace SPC\builder\unix\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; trait libuuid { + public function patchBeforeBuild(): bool + { + FileSystem::replaceFileStr($this->source_dir . '/configure', '-${am__api_version}', ''); + return true; + } + /** * @throws FileSystemException * @throws RuntimeException From 96dd5ba87b22e029497bbd76a09d04575accd420 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 4 Mar 2024 10:40:23 +0800 Subject: [PATCH 239/415] Add amqp/librabbitmq support for linux, macos, windows (#366) * add amqp/librabbitmq support for linux, macos, windows * add test for amqp --- config/ext.json | 11 ++++++ config/lib.json | 12 +++++++ config/source.json | 19 ++++++++++ src/SPC/builder/extension/amqp.php | 35 ++++++++++++++++++ src/SPC/builder/linux/library/librabbitmq.php | 12 +++++++ src/SPC/builder/macos/library/librabbitmq.php | 12 +++++++ src/SPC/builder/unix/library/librabbitmq.php | 35 ++++++++++++++++++ .../builder/windows/library/librabbitmq.php | 36 +++++++++++++++++++ src/globals/test-extensions.php | 6 ++-- 9 files changed, 175 insertions(+), 3 deletions(-) create mode 100644 src/SPC/builder/extension/amqp.php create mode 100644 src/SPC/builder/linux/library/librabbitmq.php create mode 100644 src/SPC/builder/macos/library/librabbitmq.php create mode 100644 src/SPC/builder/unix/library/librabbitmq.php create mode 100644 src/SPC/builder/windows/library/librabbitmq.php diff --git a/config/ext.json b/config/ext.json index 32c6ea34..b8fccc63 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1,4 +1,15 @@ { + "amqp": { + "type": "external", + "arg-type": "custom", + "source": "amqp", + "lib-depends": [ + "librabbitmq" + ], + "ext-depends-windows": [ + "openssl" + ] + }, "apcu": { "type": "external", "source": "apcu" diff --git a/config/lib.json b/config/lib.json index 586e3f96..5b47bc91 100644 --- a/config/lib.json +++ b/config/lib.json @@ -305,6 +305,18 @@ "zlib" ] }, + "librabbitmq": { + "source": "librabbitmq", + "static-libs-unix": [ + "librabbitmq.a" + ], + "static-libs-windows": [ + "rabbitmq.4.lib" + ], + "lib-depends": [ + "openssl" + ] + }, "libsodium": { "source": "libsodium", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index c9d8c687..e9f9dc8a 100644 --- a/config/source.json +++ b/config/source.json @@ -6,6 +6,16 @@ "path": "LICENSE" } }, + "amqp": { + "type": "url", + "url": "https://pecl.php.net/get/amqp", + "path": "php-src/ext/amqp", + "filename": "amqp.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "apcu": { "type": "url", "url": "https://pecl.php.net/get/APCu", @@ -317,6 +327,15 @@ "path": "LICENSE" } }, + "librabbitmq": { + "type": "git", + "url": "https://github.com/alanxz/rabbitmq-c.git", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libsodium": { "type": "ghrel", "repo": "jedisct1/libsodium", diff --git a/src/SPC/builder/extension/amqp.php b/src/SPC/builder/extension/amqp.php new file mode 100644 index 00000000..d795f47d --- /dev/null +++ b/src/SPC/builder/extension/amqp.php @@ -0,0 +1,35 @@ +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 ' . + '..' + ) + ->exec("cmake --build . -j {$this->builder->concurrency}") + ->exec('make install'); + } +} diff --git a/src/SPC/builder/windows/library/librabbitmq.php b/src/SPC/builder/windows/library/librabbitmq.php new file mode 100644 index 00000000..19c33a31 --- /dev/null +++ b/src/SPC/builder/windows/library/librabbitmq.php @@ -0,0 +1,36 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_STATIC_LIBS=ON ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + rename(BUILD_LIB_PATH . '\librabbitmq.4.lib', BUILD_LIB_PATH . '\rabbitmq.4.lib'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index c01071be..c8282021 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'uuid', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', + 'Linux', 'Darwin' => 'amqp', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,amqp', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', }; From 8e58592a6e93d02a501bc30849273d0c41b8d9b0 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 4 Mar 2024 15:31:39 +0800 Subject: [PATCH 240/415] Fix swoole compile bug on Linux (#367) * swoole ci test * swoole ci test * fix swoole (disable-thread-context) * restore pgsql ver * bump version to 2.1.4 --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/extension/swoole.php | 4 ++-- src/globals/test-extensions.php | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 63eae94e..a0f65f26 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.3'; + public const VERSION = '2.1.4'; public function __construct() { diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index f9da2005..1e892ee5 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -15,8 +15,8 @@ class swoole extends Extension // enable swoole $arg = '--enable-swoole'; - // commonly-used feature: coroutine-time, thread-context - $arg .= ' --enable-swoole-coro-time --enable-thread-context'; + // commonly-used feature: coroutine-time, disable-thread-context + $arg .= ' --enable-swoole-coro-time --disable-thread-context'; // required feature: curl, openssl (but curl hook is buggy for php 8.0) $arg .= $this->builder->getPHPVersionID() >= 80100 ? ' --enable-swoole-curl' : ' --disable-swoole-curl'; diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index c8282021..cd12034c 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'amqp', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,amqp', + 'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,openssl,curl,pdo_mysql', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; From 03510073c61097867ac5989a5312186f8a209d0d Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 5 Mar 2024 21:43:09 +0800 Subject: [PATCH 241/415] Fix windows curl build (#368) * fix curl on windows build needs nghttp2.dll bug * add curl on windows tests * cs fix * fix curl headers * exit powershell properly * reproduce zend_mm_heap corrupted * reproduce zend_mm_heap corrupted * reproduce zend_mm_heap corrupted * add for-libs option for download * add for-libs option for download * add for-libs option for download --- .github/workflows/tests.yml | 3 ++- bin/spc.ps1 | 1 + config/ext.json | 3 +++ config/lib.json | 2 +- src/SPC/builder/windows/WindowsBuilder.php | 12 +++++---- src/SPC/builder/windows/library/curl.php | 28 +++++---------------- src/SPC/builder/windows/library/nghttp2.php | 4 +-- src/SPC/command/BuildCliCommand.php | 4 +-- src/SPC/command/DownloadCommand.php | 26 ++++++++++++++++++- src/globals/test-extensions.php | 6 ++--- 10 files changed, 52 insertions(+), 37 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 21dcb0e8..789b12ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -164,7 +164,8 @@ jobs: timeout_minutes: 10 max_attempts: 3 retry_on: error - command: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug + command: | + bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug - name: "Run Build Tests (build)" run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug diff --git a/bin/spc.ps1 b/bin/spc.ps1 index 3a2639d0..2efd09ea 100644 --- a/bin/spc.ps1 +++ b/bin/spc.ps1 @@ -9,3 +9,4 @@ if (-not(Test-Path $PHP_Exec)) { } & "$PHP_Exec" ("bin/spc") @args +exit $LASTEXITCODE diff --git a/config/ext.json b/config/ext.json index b8fccc63..3bddb23b 100644 --- a/config/ext.json +++ b/config/ext.json @@ -52,6 +52,9 @@ "lib-depends": [ "libxml2", "zlib" + ], + "ext-depends-windows": [ + "xml" ] }, "event": { diff --git a/config/lib.json b/config/lib.json index 5b47bc91..746f508e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -36,7 +36,7 @@ "libcurl.a" ], "static-libs-windows": [ - "libcurl.lib" + "libcurl_a.lib" ], "headers": [ "curl" diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index ff7209d5..256b392b 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -88,7 +88,7 @@ class WindowsBuilder extends BuilderBase if (($logo = $this->getOption('with-micro-logo')) !== null) { // realpath $logo = realpath($logo); - $micro_logo = '--enable-micro-logo=' . escapeshellarg($logo) . ' '; + $micro_logo = '--enable-micro-logo=' . $logo . ' '; } else { $micro_logo = ''; } @@ -187,10 +187,12 @@ class WindowsBuilder extends BuilderBase SourcePatcher::patchMicro(['phar']); } - cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_micro_wrapper.bat --task-args micro"); - - if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); + try { + cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_micro_wrapper.bat --task-args micro"); + } finally { + if ($this->phar_patched) { + SourcePatcher::patchMicro(['phar'], true); + } } $this->deployBinary(BUILD_TARGET_MICRO); diff --git a/src/SPC/builder/windows/library/curl.php b/src/SPC/builder/windows/library/curl.php index 4423a16c..1f25910a 100644 --- a/src/SPC/builder/windows/library/curl.php +++ b/src/SPC/builder/windows/library/curl.php @@ -12,29 +12,13 @@ class curl extends WindowsLibraryBase protected function build(): void { - // reset cmake - FileSystem::resetDir($this->source_dir . '\build'); - - // start build - cmd()->cd($this->source_dir) + cmd()->cd($this->source_dir . '\winbuild') ->execWithWrapper( - $this->builder->makeSimpleWrapper('cmake'), - '-B build ' . - '-A x64 ' . - "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . - '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DBUILD_STATIC_LIBS=ON ' . - '-DBUILD_CURL_EXE=OFF ' . - '-DUSE_ZLIB=ON ' . - '-DCURL_USE_OPENSSL=ON ' . - '-DCURL_USE_LIBLSSH2=ON ' . - '-DUSE_NGHTTP2=ON ' . // php-src with curl needs nghttp2 - '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' - ) - ->execWithWrapper( - $this->builder->makeSimpleWrapper('cmake'), - "--build build --config Release --target install -j{$this->builder->concurrency}" + $this->builder->makeSimpleWrapper('nmake'), + '/f Makefile.vc WITH_DEVEL=' . BUILD_ROOT_PATH . ' ' . + 'WITH_PREFIX=' . BUILD_ROOT_PATH . ' ' . + 'mode=static RTLIBCFG=static WITH_SSL=static WITH_NGHTTP2=static WITH_SSH2=static ENABLE_IPV6=yes WITH_ZLIB=static MACHINE=x64 DEBUG=no' ); + FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl'); } } diff --git a/src/SPC/builder/windows/library/nghttp2.php b/src/SPC/builder/windows/library/nghttp2.php index a17fe89b..85332202 100644 --- a/src/SPC/builder/windows/library/nghttp2.php +++ b/src/SPC/builder/windows/library/nghttp2.php @@ -23,8 +23,8 @@ class nghttp2 extends WindowsLibraryBase '-A x64 ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . '-DCMAKE_BUILD_TYPE=Release ' . - '-DBUILD_SHARED_LIBS=OFF ' . - '-DBUILD_STATIC_LIBS=ON ' . + '-DENABLE_SHARED_LIB=OFF ' . + '-DENABLE_STATIC_LIB=ON ' . '-DENABLE_STATIC_CRT=ON ' . '-DENABLE_LIB_ONLY=ON ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 3c5c2276..85d5e39c 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -104,8 +104,8 @@ class BuildCliCommand extends BuildCommand $indent_texts = [ 'Build OS' => PHP_OS_FAMILY . ' (' . php_uname('m') . ')', 'Build SAPI' => $builder->getBuildTypeName($rule), - 'Extensions (' . count($extensions) . ')' => implode(', ', $extensions), - 'Libraries (' . count($libraries) . ')' => implode(', ', $libraries), + 'Extensions (' . count($extensions) . ')' => implode(',', $extensions), + 'Libraries (' . count($libraries) . ')' => implode(',', $libraries), 'Strip Binaries' => $builder->getOption('no-strip') ? 'no' : 'yes', 'Enable ZTS' => $builder->getOption('enable-zts') ? 'yes' : 'no', ]; diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index fa7f7543..a0eb4bce 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -36,6 +36,7 @@ class DownloadCommand extends BaseCommand $this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"'); $this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive'); $this->addOption('for-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); + $this->addOption('for-libs', 'l', InputOption::VALUE_REQUIRED, 'Fetch by libraries, e.g "libcares,openssl,onig"'); $this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions'); } @@ -46,6 +47,7 @@ class DownloadCommand extends BaseCommand || $input->getOption('clean') || $input->getOption('from-zip') || $input->getOption('for-extensions') + || $input->getOption('for-libs') ) { $input->setArgument('sources', ''); } @@ -112,6 +114,9 @@ class DownloadCommand extends BaseCommand $ext = array_map('trim', array_filter(explode(',', $for_ext))); $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggestions')); array_unshift($sources, 'php-src', 'micro', 'pkg-config'); + } elseif ($for_lib = $this->getOption('for-libs')) { + $lib = array_map('trim', array_filter(explode(',', $for_lib))); + $sources = $this->calculateSourcesByLib($lib, !$this->getOption('without-suggestions')); } else { // get source list that will be downloaded $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); @@ -208,7 +213,8 @@ class DownloadCommand extends BaseCommand /** * Calculate the sources by extensions * - * @param array $extensions extension list + * @param array $extensions extension list + * @param bool $include_suggests include suggested libs and extensions (default: true) * @throws FileSystemException * @throws WrongUsageException */ @@ -226,4 +232,22 @@ class DownloadCommand extends BaseCommand } return array_values(array_unique($sources)); } + + /** + * Calculate the sources by libraries + * + * @param array $libs library list + * @param bool $include_suggests include suggested libs (default: true) + * @throws FileSystemException + * @throws WrongUsageException + */ + private function calculateSourcesByLib(array $libs, bool $include_suggests = true): array + { + $libs = DependencyUtil::getLibs($libs, $include_suggests); + $sources = []; + foreach ($libs as $library) { + $sources[] = Config::getLib($library, 'source'); + } + return array_values(array_unique($sources)); + } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index cd12034c..7e549aa1 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,openssl,curl,pdo_mysql', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', + 'Linux', 'Darwin' => 'zlib,openssl,curl,pcntl,posix,mbstring,tokenizer,phar', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,curl', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'none', 'Windows' => 'none', }; From d202de3f502f9180034740ca52244951acf34922 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 8 Mar 2024 14:10:12 +0800 Subject: [PATCH 242/415] fix libxml2 build on RHEL/CentOS bug --- src/SPC/builder/macos/library/libxml2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/macos/library/libxml2.php b/src/SPC/builder/macos/library/libxml2.php index 3c154aac..c0ed36c0 100644 --- a/src/SPC/builder/macos/library/libxml2.php +++ b/src/SPC/builder/macos/library/libxml2.php @@ -29,6 +29,7 @@ class libxml2 extends MacOSLibraryBase // '--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 ' . From 71017361b5c0ff9f528871e9c5a51dfcf6978440 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 8 Mar 2024 14:17:39 +0800 Subject: [PATCH 243/415] fix libxml2 build on RHEL/CentOS bug --- src/SPC/builder/linux/library/libxml2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/builder/linux/library/libxml2.php b/src/SPC/builder/linux/library/libxml2.php index f0c1c312..6f42d672 100644 --- a/src/SPC/builder/linux/library/libxml2.php +++ b/src/SPC/builder/linux/library/libxml2.php @@ -28,6 +28,7 @@ class libxml2 extends LinuxLibraryBase '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 ' . '-DIconv_IS_BUILT_IN=OFF ' . From e23daaa355dd3ea12d699f1448084f33e9421530 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Mar 2024 10:58:58 +0800 Subject: [PATCH 244/415] enhancement for download command --- src/SPC/command/DownloadCommand.php | 81 +++++++++++++++-------- src/SPC/store/Downloader.php | 8 ++- src/SPC/store/source/CustomSourceBase.php | 2 +- src/SPC/store/source/PhpSource.php | 6 +- src/SPC/store/source/PostgreSQLSource.php | 6 +- 5 files changed, 65 insertions(+), 38 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index a0eb4bce..0d984337 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -38,26 +38,58 @@ class DownloadCommand extends BaseCommand $this->addOption('for-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); $this->addOption('for-libs', 'l', InputOption::VALUE_REQUIRED, 'Fetch by libraries, e.g "libcares,openssl,onig"'); $this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions'); + $this->addOption('ignore-cache-sources', null, InputOption::VALUE_REQUIRED, 'Ignore some source caches, comma separated, e.g "php-src,curl,openssl"', ''); } + /** + * @throws FileSystemException + * @throws WrongUsageException + */ public function initialize(InputInterface $input, OutputInterface $output): void { - if ( - $input->getOption('all') - || $input->getOption('clean') - || $input->getOption('from-zip') - || $input->getOption('for-extensions') - || $input->getOption('for-libs') - ) { + // mode: --all + if ($input->getOption('all')) { + $input->setArgument('sources', implode(',', array_keys(Config::getSources()))); + parent::initialize($input, $output); + return; + } + // mode: --clean and --from-zip + if ($input->getOption('clean') || $input->getOption('from-zip')) { $input->setArgument('sources', ''); + parent::initialize($input, $output); + return; + } + // mode: normal + if (!empty($input->getArgument('sources'))) { + $final_sources = array_map('trim', array_filter(explode(',', $input->getArgument('sources')))); + } else { + $final_sources = []; + } + // mode: --for-extensions + if ($for_ext = $input->getOption('for-extensions')) { + $ext = array_map('trim', array_filter(explode(',', $for_ext))); + $sources = $this->calculateSourcesByExt($ext, !$input->getOption('without-suggestions')); + if (PHP_OS_FAMILY !== 'Windows') { + array_unshift($sources, 'pkg-config'); + } + array_unshift($sources, 'php-src', 'micro'); + $final_sources = array_merge($final_sources, array_diff($sources, $final_sources)); + } + // mode: --for-libs + if ($for_lib = $input->getOption('for-libs')) { + $lib = array_map('trim', array_filter(explode(',', $for_lib))); + $sources = $this->calculateSourcesByLib($lib, !$input->getOption('without-suggestions')); + $final_sources = array_merge($final_sources, array_diff($sources, $final_sources)); + } + if (!empty($final_sources)) { + $input->setArgument('sources', implode(',', $final_sources)); } parent::initialize($input, $output); } /** - * @throws DownloaderException - * @throws RuntimeException * @throws FileSystemException + * @throws RuntimeException */ public function handle(): int { @@ -109,23 +141,12 @@ class DownloadCommand extends BaseCommand Config::$source['openssl']['regex'] = '/href="(?openssl-(?1.[^"]+)\.tar\.gz)\"/'; } - // --for-extensions - if ($for_ext = $this->getOption('for-extensions')) { - $ext = array_map('trim', array_filter(explode(',', $for_ext))); - $sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggestions')); - array_unshift($sources, 'php-src', 'micro', 'pkg-config'); - } elseif ($for_lib = $this->getOption('for-libs')) { - $lib = array_map('trim', array_filter(explode(',', $for_lib))); - $sources = $this->calculateSourcesByLib($lib, !$this->getOption('without-suggestions')); - } else { - // get source list that will be downloaded - $sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); - if (empty($sources)) { - logger()->notice('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); - $sources = array_keys(Config::getSources()); - } + $chosen_sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); + $force_list = array_map('trim', array_filter(explode(',', $this->getOption('ignore-cache-sources')))); + + if ($this->getOption('all')) { + logger()->notice('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); } - $chosen_sources = $sources; // Process -U options $custom_urls = []; @@ -156,7 +177,7 @@ class DownloadCommand extends BaseCommand Downloader::downloadSource($source, $new_config, true); } else { logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); - Downloader::downloadSource($source, Config::getSource($source)); + Downloader::downloadSource($source, Config::getSource($source), in_array($source, $force_list)); } } $time = round(microtime(true) - START_TIME, 3); @@ -171,6 +192,10 @@ class DownloadCommand extends BaseCommand } } + /** + * @throws RuntimeException + * @throws WrongUsageException + */ private function downloadFromZip(string $path): int { if (!file_exists($path)) { @@ -196,8 +221,10 @@ class DownloadCommand extends BaseCommand if (PHP_OS_FAMILY !== 'Windows') { $abs_path = realpath($path); f_passthru('mkdir ' . DOWNLOAD_PATH . ' && cd ' . DOWNLOAD_PATH . ' && unzip ' . escapeshellarg($abs_path)); + } else { + // Windows TODO + throw new WrongUsageException('Windows currently does not support --from-zip !'); } - // Windows TODO if (!file_exists(DOWNLOAD_PATH . '/.lock.json')) { throw new RuntimeException('.lock.json not exist in "downloads/"'); diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 16e26b2a..1770538e 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -246,6 +246,10 @@ class Downloader }*/ } + /** + * @throws DownloaderException + * @throws FileSystemException + */ public static function downloadPackage(string $name, ?array $pkg = null, bool $force = false): void { if ($pkg === null) { @@ -313,7 +317,7 @@ class Downloader $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\\store\\source'); foreach ($classes as $class) { if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { - (new $class())->fetch(); + (new $class())->fetch($force); break; } } @@ -407,7 +411,7 @@ class Downloader $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\\store\\source'); foreach ($classes as $class) { if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { - (new $class())->fetch(); + (new $class())->fetch($force); break; } } diff --git a/src/SPC/store/source/CustomSourceBase.php b/src/SPC/store/source/CustomSourceBase.php index fd6c18f6..da7c4ce1 100644 --- a/src/SPC/store/source/CustomSourceBase.php +++ b/src/SPC/store/source/CustomSourceBase.php @@ -8,5 +8,5 @@ abstract class CustomSourceBase { public const NAME = 'unknown'; - abstract public function fetch(); + abstract public function fetch(bool $force = false); } diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 30e583a8..16b5b7e4 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -7,7 +7,6 @@ namespace SPC\store\source; use JetBrains\PhpStorm\ArrayShape; use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\Downloader; class PhpSource extends CustomSourceBase @@ -16,13 +15,12 @@ class PhpSource extends CustomSourceBase /** * @throws DownloaderException - * @throws RuntimeException * @throws FileSystemException */ - public function fetch(): void + public function fetch(bool $force = false): void { $major = defined('SPC_BUILD_PHP_VERSION') ? SPC_BUILD_PHP_VERSION : '8.1'; - Downloader::downloadSource('php-src', self::getLatestPHPInfo($major)); + Downloader::downloadSource('php-src', self::getLatestPHPInfo($major), $force); } /** diff --git a/src/SPC/store/source/PostgreSQLSource.php b/src/SPC/store/source/PostgreSQLSource.php index 66276db0..1f5d9bc0 100644 --- a/src/SPC/store/source/PostgreSQLSource.php +++ b/src/SPC/store/source/PostgreSQLSource.php @@ -6,7 +6,6 @@ namespace SPC\store\source; use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; -use SPC\exception\RuntimeException; use SPC\store\Downloader; class PostgreSQLSource extends CustomSourceBase @@ -15,12 +14,11 @@ class PostgreSQLSource extends CustomSourceBase /** * @throws DownloaderException - * @throws RuntimeException * @throws FileSystemException */ - public function fetch(): void + public function fetch(bool $force = false): void { - Downloader::downloadSource('postgresql', self::getLatestInfo()); + Downloader::downloadSource('postgresql', self::getLatestInfo(), $force); } /** From 88796bc017314939c619b8276a434de718cc0ea1 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Mar 2024 11:01:59 +0800 Subject: [PATCH 245/415] update tests --- .github/workflows/tests.yml | 2 +- src/globals/test-extensions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 789b12ee..a096b1fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -165,7 +165,7 @@ jobs: max_attempts: 3 retry_on: error command: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug + bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug - name: "Run Build Tests (build)" run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 7e549aa1..46a205e0 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // 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,openssl,curl,pcntl,posix,mbstring,tokenizer,phar', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,curl', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From e4d8e5e4d283e2627024d4ef8403d9a52a770b3a Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Mar 2024 11:48:52 +0800 Subject: [PATCH 246/415] fix ncurses build command --- 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 790c77b6..41bad41b 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -23,7 +23,7 @@ trait ncurses '--without-tests ' . '--without-dlsym ' . '--without-debug ' . - '-enable-symlinks' . + '-enable-symlinks ' . '--bindir=' . BUILD_ROOT_PATH . '/bin ' . '--includedir=' . BUILD_ROOT_PATH . '/include ' . '--libdir=' . BUILD_ROOT_PATH . '/lib ' . From 94b3afe6bcee749fcc9802d16910e024d54fe2af Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Mar 2024 14:58:19 +0800 Subject: [PATCH 247/415] add pdo_sqlsrv for macOS and Linux --- config/ext.json | 9 +++++++++ config/source.json | 10 ++++++++++ src/SPC/ConsoleApplication.php | 2 +- src/globals/test-extensions.php | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index 3bddb23b..f927f3cd 100644 --- a/config/ext.json +++ b/config/ext.json @@ -317,6 +317,15 @@ "sqlite" ] }, + "pdo_sqlsrv": { + "type": "external", + "source": "pdo_sqlsrv", + "arg-type": "with", + "ext-depends": [ + "pdo", + "sqlsrv" + ] + }, "pgsql": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/source.json b/config/source.json index e9f9dc8a..406bb368 100644 --- a/config/source.json +++ b/config/source.json @@ -495,6 +495,16 @@ "path": "LICENSE.txt" } }, + "pdo_sqlsrv": { + "type": "url", + "url": "https://pecl.php.net/get/pdo_sqlsrv", + "path": "php-src/ext/pdo_sqlsrv", + "filename": "pdo_sqlsrv.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "pkg-config": { "type": "url", "url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index a0f65f26..9922d8a8 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.4'; + public const VERSION = '2.1.5'; public function __construct() { diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 46a205e0..2854885c 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // 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,openssl,curl,pcntl,posix,mbstring,tokenizer,phar', + 'Linux', 'Darwin' => 'zlib,openssl,curl,pcntl,posix,mbstring,tokenizer,phar,pdo_sqlsrv', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; From e21b5676e7c1008583495403c62a3b8c900b7794 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Mar 2024 16:23:30 +0800 Subject: [PATCH 248/415] add --retry for download command --- src/SPC/command/DownloadCommand.php | 5 + src/SPC/store/Downloader.php | 147 +++++++++++++++++++--------- src/SPC/store/source/PhpSource.php | 5 +- 3 files changed, 110 insertions(+), 47 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 0d984337..36f5cea2 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -39,6 +39,7 @@ class DownloadCommand extends BaseCommand $this->addOption('for-libs', 'l', InputOption::VALUE_REQUIRED, 'Fetch by libraries, e.g "libcares,openssl,onig"'); $this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions'); $this->addOption('ignore-cache-sources', null, InputOption::VALUE_REQUIRED, 'Ignore some source caches, comma separated, e.g "php-src,curl,openssl"', ''); + $this->addOption('retry', 'R', InputOption::VALUE_REQUIRED, 'Set retry time when downloading failed (default: 0)', '0'); } /** @@ -127,6 +128,10 @@ class DownloadCommand extends BaseCommand return static::FAILURE; } + // retry + $retry = intval($this->getOption('retry')); + f_putenv('SPC_RETRY_TIME=' . $retry); + // Use shallow-clone can reduce git resource download if ($this->getOption('shallow-clone')) { define('GIT_SHALLOW_CLONE', true); diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 1770538e..0b396b05 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -7,6 +7,7 @@ namespace SPC\store; use SPC\exception\DownloaderException; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; use SPC\store\source\CustomSourceBase; /** @@ -26,7 +27,8 @@ class Downloader { logger()->debug("finding {$name} source from bitbucket tag"); $data = json_decode(self::curlExec( - url: "https://api.bitbucket.org/2.0/repositories/{$source['repo']}/refs/tags" + url: "https://api.bitbucket.org/2.0/repositories/{$source['repo']}/refs/tags", + retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) ), true); $ver = $data['values'][0]['name']; if (!$ver) { @@ -35,7 +37,8 @@ class Downloader $url = "https://bitbucket.org/{$source['repo']}/get/{$ver}.tar.gz"; $headers = self::curlExec( url: $url, - method: 'HEAD' + method: 'HEAD', + retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) ); preg_match('/^content-disposition:\s+attachment;\s*filename=("?)(?.+\.tar\.gz)\1/im', $headers, $matches); if ($matches) { @@ -62,7 +65,8 @@ class Downloader logger()->debug("finding {$name} source from github {$type} tarball"); $data = json_decode(self::curlExec( url: "https://api.github.com/repos/{$source['repo']}/{$type}", - hooks: [[CurlHook::class, 'setupGithubToken']] + hooks: [[CurlHook::class, 'setupGithubToken']], + retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) ), true); $url = $data[0]['tarball_url']; if (!$url) { @@ -72,6 +76,7 @@ class Downloader url: $url, method: 'HEAD', hooks: [[CurlHook::class, 'setupGithubToken']], + retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) ); preg_match('/^content-disposition:\s+attachment;\s*filename=("?)(?.+\.tar\.gz)\1/im', $headers, $matches); if ($matches) { @@ -97,6 +102,7 @@ class Downloader $data = json_decode(self::curlExec( url: "https://api.github.com/repos/{$source['repo']}/releases", hooks: [[CurlHook::class, 'setupGithubToken']], + retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) ), true); $url = null; foreach ($data as $release) { @@ -130,7 +136,7 @@ class Downloader public static function getFromFileList(string $name, array $source): array { logger()->debug("finding {$name} source from file list"); - $page = self::curlExec($source['url']); + $page = self::curlExec($source['url'], retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0)); preg_match_all($source['regex'], $page, $matches); if (!$matches) { throw new DownloaderException("Failed to get {$name} version"); @@ -175,7 +181,7 @@ class Downloader } }; self::registerCancelEvent($cancel_func); - self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}")); + self::curlDown(url: $url, path: FileSystem::convertPath(DOWNLOAD_PATH . "/{$filename}"), retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0)); self::unregisterCancelEvent(); logger()->debug("Locking {$filename}"); self::lockSource($name, ['source_type' => 'archive', 'filename' => $filename, 'move_path' => $move_path]); @@ -203,7 +209,7 @@ class Downloader * @throws FileSystemException * @throws RuntimeException */ - public static function downloadGit(string $name, string $url, string $branch, ?string $move_path = null): void + public static function downloadGit(string $name, string $url, string $branch, ?string $move_path = null, int $retry = 0): void { $download_path = FileSystem::convertPath(DOWNLOAD_PATH . "/{$name}"); if (file_exists($download_path)) { @@ -217,14 +223,25 @@ class Downloader FileSystem::removeDir($download_path); } }; - self::registerCancelEvent($cancel_func); - f_passthru( - SPC_GIT_EXEC . ' clone' . $check . - ' --config core.autocrlf=false ' . - "--branch \"{$branch}\" " . (defined('GIT_SHALLOW_CLONE') ? '--depth 1 --single-branch' : '') . " --recursive \"{$url}\" \"{$download_path}\"" - ); - self::unregisterCancelEvent(); - + try { + self::registerCancelEvent($cancel_func); + f_passthru( + SPC_GIT_EXEC . ' clone' . $check . + ' --config core.autocrlf=false ' . + "--branch \"{$branch}\" " . (defined('GIT_SHALLOW_CLONE') ? '--depth 1 --single-branch' : '') . " --recursive \"{$url}\" \"{$download_path}\"" + ); + } catch (RuntimeException $e) { + if ($e->getCode() === SIGINT) { + throw new WrongUsageException('Keyboard interrupted, download failed !'); + } + if ($retry > 0) { + self::downloadGit($name, $url, $branch, $move_path, $retry - 1); + return; + } + throw $e; + } finally { + self::unregisterCancelEvent(); + } // Lock logger()->debug("Locking git source {$name}"); self::lockSource($name, ['source_type' => 'dir', 'dirname' => $name, 'move_path' => $move_path]); @@ -311,7 +328,13 @@ class Downloader self::downloadFile($name, $url, $filename, $pkg['extract'] ?? null); break; case 'git': // Git repo - self::downloadGit($name, $pkg['url'], $pkg['rev'], $pkg['extract'] ?? null); + self::downloadGit( + $name, + $pkg['url'], + $pkg['rev'], + $pkg['extract'] ?? null, + intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + ); break; case 'custom': // Custom download method, like API-based download or other $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\\store\\source'); @@ -405,7 +428,13 @@ class Downloader self::downloadFile($name, $url, $filename, $source['path'] ?? null); break; case 'git': // Git repo - self::downloadGit($name, $source['url'], $source['rev'], $source['path'] ?? null); + self::downloadGit( + $name, + $source['url'], + $source['rev'], + $source['path'] ?? null, + intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + ); break; case 'custom': // Custom download method, like API-based download or other $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/store/source', 'SPC\\store\\source'); @@ -435,57 +464,71 @@ class Downloader * * @throws DownloaderException */ - public static function curlExec(string $url, string $method = 'GET', array $headers = [], array $hooks = []): string + public static function curlExec(string $url, string $method = 'GET', array $headers = [], array $hooks = [], int $retry = 0): string { foreach ($hooks as $hook) { $hook($method, $url, $headers); } - FileSystem::findCommandPath('curl'); + try { + FileSystem::findCommandPath('curl'); - $methodArg = match ($method) { - 'GET' => '', - 'HEAD' => '-I', - default => "-X \"{$method}\"", - }; - $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); + $methodArg = match ($method) { + 'GET' => '', + 'HEAD' => '-I', + default => "-X \"{$method}\"", + }; + $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); - $cmd = SPC_CURL_EXEC . " -sfSL {$methodArg} {$headerArg} \"{$url}\""; - if (getenv('CACHE_API_EXEC') === 'yes') { - if (!file_exists(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache'))) { - $cache = []; - } else { - $cache = json_decode(file_get_contents(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache')), true); - } - if (isset($cache[$cmd]) && $cache[$cmd]['expire'] >= time()) { + $cmd = SPC_CURL_EXEC . " -sfSL {$methodArg} {$headerArg} \"{$url}\""; + if (getenv('CACHE_API_EXEC') === 'yes') { + if (!file_exists(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache'))) { + $cache = []; + } else { + $cache = json_decode(file_get_contents(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache')), true); + } + if (isset($cache[$cmd]) && $cache[$cmd]['expire'] >= time()) { + return $cache[$cmd]['cache']; + } + f_exec($cmd, $output, $ret); + if ($ret === SIGINT) { + throw new RuntimeException('failed http fetch'); + } + if ($ret !== 0) { + throw new DownloaderException('failed http fetch'); + } + $cache[$cmd]['cache'] = implode("\n", $output); + $cache[$cmd]['expire'] = time() + 3600; + file_put_contents(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache'), json_encode($cache)); return $cache[$cmd]['cache']; } f_exec($cmd, $output, $ret); + if ($ret === SIGINT) { + throw new RuntimeException('failed http fetch'); + } if ($ret !== 0) { throw new DownloaderException('failed http fetch'); } - $cache[$cmd]['cache'] = implode("\n", $output); - $cache[$cmd]['expire'] = time() + 3600; - file_put_contents(FileSystem::convertPath(DOWNLOAD_PATH . '/.curl_exec_cache'), json_encode($cache)); - return $cache[$cmd]['cache']; + return implode("\n", $output); + } catch (DownloaderException $e) { + if ($retry > 0) { + logger()->notice('Retrying curl exec ...'); + return self::curlExec($url, $method, $headers, $hooks, $retry - 1); + } + throw $e; } - f_exec($cmd, $output, $ret); - if ($ret !== 0) { - throw new DownloaderException('failed http fetch'); - } - return implode("\n", $output); } /** * Use curl to download sources from url * - * @throws DownloaderException * @throws RuntimeException */ - public static function curlDown(string $url, string $path, string $method = 'GET', array $headers = [], array $hooks = []): void + public static function curlDown(string $url, string $path, string $method = 'GET', array $headers = [], array $hooks = [], int $retry = 0): void { + $used_headers = $headers; foreach ($hooks as $hook) { - $hook($method, $url, $headers); + $hook($method, $url, $used_headers); } $methodArg = match ($method) { @@ -493,10 +536,22 @@ class Downloader 'HEAD' => '-I', default => "-X \"{$method}\"", }; - $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $headers)); + $headerArg = implode(' ', array_map(fn ($v) => '"-H' . $v . '"', $used_headers)); $check = !defined('DEBUG_MODE') ? 's' : '#'; $cmd = SPC_CURL_EXEC . " -{$check}fSL -o \"{$path}\" {$methodArg} {$headerArg} \"{$url}\""; - f_passthru($cmd); + try { + f_passthru($cmd); + } catch (RuntimeException $e) { + if ($e->getCode() === SIGINT) { + throw new WrongUsageException('Keyboard interrupted, download failed !'); + } + if ($retry > 0) { + logger()->notice('Retrying curl download ...'); + self::curlDown($url, $path, $method, $used_headers, retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0)); + return; + } + throw $e; + } } /** diff --git a/src/SPC/store/source/PhpSource.php b/src/SPC/store/source/PhpSource.php index 16b5b7e4..f4cc7d44 100644 --- a/src/SPC/store/source/PhpSource.php +++ b/src/SPC/store/source/PhpSource.php @@ -32,7 +32,10 @@ class PhpSource extends CustomSourceBase public function getLatestPHPInfo(string $major_version): array { // 查找最新的小版本号 - $info = json_decode(Downloader::curlExec(url: "https://www.php.net/releases/index.php?json&version={$major_version}"), true); + $info = json_decode(Downloader::curlExec( + url: "https://www.php.net/releases/index.php?json&version={$major_version}", + retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) + ), true); if (!isset($info['version'])) { throw new DownloaderException("Version {$major_version} not found."); } From 8358a985b38913d9ae0a480195ef88fa53e3cf22 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 10 Mar 2024 16:35:19 +0800 Subject: [PATCH 249/415] fix retry for windows --- src/SPC/store/Downloader.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 0b396b05..1665ff66 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -231,7 +231,7 @@ class Downloader "--branch \"{$branch}\" " . (defined('GIT_SHALLOW_CLONE') ? '--depth 1 --single-branch' : '') . " --recursive \"{$url}\" \"{$download_path}\"" ); } catch (RuntimeException $e) { - if ($e->getCode() === SIGINT) { + if ($e->getCode() === 2 || $e->getCode() === -1073741510) { throw new WrongUsageException('Keyboard interrupted, download failed !'); } if ($retry > 0) { @@ -491,7 +491,7 @@ class Downloader return $cache[$cmd]['cache']; } f_exec($cmd, $output, $ret); - if ($ret === SIGINT) { + if ($ret === 2 || $ret === -1073741510) { throw new RuntimeException('failed http fetch'); } if ($ret !== 0) { @@ -503,7 +503,7 @@ class Downloader return $cache[$cmd]['cache']; } f_exec($cmd, $output, $ret); - if ($ret === SIGINT) { + if ($ret === 2 || $ret === -1073741510) { throw new RuntimeException('failed http fetch'); } if ($ret !== 0) { @@ -542,7 +542,8 @@ class Downloader try { f_passthru($cmd); } catch (RuntimeException $e) { - if ($e->getCode() === SIGINT) { + var_dump($e->getCode()); + if ($e->getCode() === 2 || $e->getCode() === -1073741510) { throw new WrongUsageException('Keyboard interrupted, download failed !'); } if ($retry > 0) { @@ -564,7 +565,7 @@ class Downloader if (PHP_OS_FAMILY === 'Windows') { sapi_windows_set_ctrl_handler($callback); } elseif (extension_loaded('pcntl')) { - pcntl_signal(SIGINT, $callback); + pcntl_signal(2, $callback); } else { logger()->debug('You have not enabled `pcntl` extension, cannot prevent download file corruption when Ctrl+C'); } @@ -578,7 +579,7 @@ class Downloader if (PHP_OS_FAMILY === 'Windows') { sapi_windows_set_ctrl_handler(null); } elseif (extension_loaded('pcntl')) { - pcntl_signal(SIGINT, SIG_IGN); + pcntl_signal(2, SIG_IGN); } } } From 632f904f30d5188b58e9549ff561d2b8eb5c772b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Mar 2024 14:17:48 +0800 Subject: [PATCH 250/415] fix install-pkg different arch cache bug --- src/SPC/store/PackageManager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/store/PackageManager.php b/src/SPC/store/PackageManager.php index 336bbd66..6ff2faef 100644 --- a/src/SPC/store/PackageManager.php +++ b/src/SPC/store/PackageManager.php @@ -24,6 +24,7 @@ class PackageManager default => throw new WrongUsageException('Unsupported OS!'), }; $config = Config::getPkg("{$pkg_name}-{$arch}-{$os}"); + $pkg_name = "{$pkg_name}-{$arch}-{$os}"; } if ($config === null) { throw new WrongUsageException("Package [{$pkg_name}] does not exist, please check the name and correct it !"); From 8092f1e481f40cbd9f1654a76c296999457c2273 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 15 Mar 2024 22:44:05 +0800 Subject: [PATCH 251/415] Update FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 36b494a8..9a174e3a 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -10,4 +10,5 @@ liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +buy_me_a_coffee: crazywhalecc custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 96c3e6b9357ad2283167eb5a77593cdf1e6cfb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 15 Mar 2024 20:14:04 +0100 Subject: [PATCH 252/415] fix: false postive with binutils-gold --- src/SPC/doctor/item/LinuxToolCheckList.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index f57f01ce..f81b4a13 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -40,6 +40,10 @@ class LinuxToolCheckList 'xz', ]; + private const PROVIDED_COMMAND = [ + 'binutils-gold' => 'ld.gold', + ]; + /** @noinspection PhpUnused */ #[AsCheckItem('if necessary tools are installed', limit_os: 'Linux', level: 999)] public function checkCliTools(): ?CheckResult @@ -52,9 +56,9 @@ class LinuxToolCheckList default => self::TOOLS_DEBIAN, }; $missing = []; - foreach ($required as $cmd) { - if ($this->findCommand($cmd) === null) { - $missing[] = $cmd; + foreach ($required as $package) { + if ($this->findCommand(self::PROVIDED_COMMAND[$package] ?? $package) === null) { + $missing[] = $package; } } if (!empty($missing)) { From 46984b6df1ab6b105bcc87f74a96f52b130d782f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 16 Mar 2024 22:37:39 +0800 Subject: [PATCH 253/415] Fix latest libsodium compatibility (#388) * fix #384 * bypass password-argon2 micro sanity check * ignore funding yaml schema [skip ci] * test linux compatibility for libargon2 and libsodium * update composer.json to prevent smart-aleck composer [skip ci] --- .github/FUNDING.yml | 1 + composer.json | 8 +++++++- config/source.json | 2 +- src/SPC/builder/extension/password_argon2.php | 5 +++++ src/SPC/builder/linux/library/libargon2.php | 5 ----- src/globals/test-extensions.php | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 9a174e3a..205c48a1 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -10,5 +10,6 @@ liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +# noinspection YAMLSchemaValidation buy_me_a_coffee: crazywhalecc custom: 'https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md' # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/composer.json b/composer.json index 970ed6db..e7bc4b91 100644 --- a/composer.json +++ b/composer.json @@ -54,5 +54,11 @@ }, "optimize-autoloader": true, "sort-packages": true - } + }, + "funding": [ + { + "type": "other", + "url": "https://github.com/crazywhalecc/crazywhalecc/blob/master/FUNDING.md" + } + ] } diff --git a/config/source.json b/config/source.json index 406bb368..6838f050 100644 --- a/config/source.json +++ b/config/source.json @@ -224,7 +224,7 @@ "libargon2": { "type": "git", "rev": "master", - "url": "https://github.com/mpociot/phc-winner-argon2", + "url": "https://github.com/static-php/phc-winner-argon2", "license": { "type": "file", "path": "LICENSE" diff --git a/src/SPC/builder/extension/password_argon2.php b/src/SPC/builder/extension/password_argon2.php index db1ada4e..da0e740e 100644 --- a/src/SPC/builder/extension/password_argon2.php +++ b/src/SPC/builder/extension/password_argon2.php @@ -11,6 +11,11 @@ use SPC\util\CustomExt; #[CustomExt('password-argon2')] class password_argon2 extends Extension { + public function getDistName(): string + { + return ''; + } + public function runCliCheckUnix(): void { [$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"'); diff --git a/src/SPC/builder/linux/library/libargon2.php b/src/SPC/builder/linux/library/libargon2.php index ca4a72ac..1193089c 100644 --- a/src/SPC/builder/linux/library/libargon2.php +++ b/src/SPC/builder/linux/library/libargon2.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace SPC\builder\linux\library; -use SPC\exception\WrongUsageException; use SPC\store\FileSystem; class libargon2 extends LinuxLibraryBase @@ -15,10 +14,6 @@ class libargon2 extends LinuxLibraryBase public function patchBeforeBuild(): bool { - // detect libsodium (The libargon2 conflicts with the libsodium library.) - if ($this->builder->getLib('libsodium') !== null) { - throw new WrongUsageException('libargon2 (required by password-argon2) conflicts with the libsodium library !'); - } FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib'); return true; } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 2854885c..e608ec0d 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // 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,openssl,curl,pcntl,posix,mbstring,tokenizer,phar,pdo_sqlsrv', + 'Linux', 'Darwin' => 'intl,pdo_sqlite,sqlite3,curl,openssl,tokenizer,bcmath,bz2,calendar,dba,ftp,iconv,mysqli,mbstring,mbregex,xml,simplexml,ctype,dom,pdo,filter,session,zlib,fileinfo,pdo_mysql,posix,sockets,shmop,sodium,sysvmsg,sysvsem,sysvshm,gd,zip,gmp,redis,xmlwriter,phar,exif,xmlreader,readline,pcntl,soap,imagick,ffi,password-argon2,pgsql,pdo_pgsql,imap,ldap,xsl', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // 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' => 'nghttp2', 'Windows' => '', }; From 32f14e16c8f71dd61ca1d8011fd3bcfa92586294 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 20 Mar 2024 21:50:05 +0800 Subject: [PATCH 254/415] fix pkg-config build for macOS sonoma (#391) * fix pkg-config build for macOS sonoma * cs fix * bump version to 2.1.6 [skip ci] --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/traits/UnixLibraryTrait.php | 2 +- src/SPC/builder/unix/library/pkgconfig.php | 2 +- src/SPC/command/BaseCommand.php | 2 +- src/SPC/command/BuildCommand.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 9922d8a8..ed37f578 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.5'; + public const VERSION = '2.1.6'; public function __construct() { diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 19005476..9561663f 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -48,7 +48,7 @@ trait UnixLibraryTrait * @throws RuntimeException * @throws WrongUsageException */ - public function makeAutoconfEnv(string $prefix = null): string + public function makeAutoconfEnv(?string $prefix = null): string { if ($prefix === null) { $prefix = str_replace('-', '_', strtoupper(static::NAME)); diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 18e9b4b9..eac7ab03 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -8,7 +8,7 @@ trait pkgconfig { protected function build(): void { - $macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration' "; + $macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion' "; $linux_env = 'LDFLAGS=--static '; shell()->cd($this->source_dir) diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index f3ca525c..31064123 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -25,7 +25,7 @@ abstract class BaseCommand extends Command protected OutputInterface $output; - public function __construct(string $name = null) + public function __construct(?string $name = null) { parent::__construct($name); $this->addOption('debug', null, null, 'Enable debug mode'); diff --git a/src/SPC/command/BuildCommand.php b/src/SPC/command/BuildCommand.php index 4d3f7d06..bea9c119 100644 --- a/src/SPC/command/BuildCommand.php +++ b/src/SPC/command/BuildCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputOption; abstract class BuildCommand extends BaseCommand { - public function __construct(string $name = null) + public function __construct(?string $name = null) { parent::__construct($name); From d445668d9fbdf7ef0155f8cb917f0afd7a43a9e3 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sun, 31 Mar 2024 15:36:38 +0800 Subject: [PATCH 255/415] trigger tests and nightly builds --- src/SPC/ConsoleApplication.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index ed37f578..a869fef7 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -33,6 +33,7 @@ final class ConsoleApplication extends Application $this->addCommands( [ + // Common commands new BuildCliCommand(), new BuildLibsCommand(), new DoctorCommand(), From d3a001d80824bba1bc9435ad9900363ee66ed4fc Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 2 Apr 2024 11:31:29 +0800 Subject: [PATCH 256/415] use old xz mirror, fix CVE-2024-3094 (#399) * use old xz mirror, fix CVE-2024-3094 * add test --- config/source.json | 5 ++--- src/globals/test-extensions.php | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config/source.json b/config/source.json index 6838f050..2647c85e 100644 --- a/config/source.json +++ b/config/source.json @@ -646,9 +646,8 @@ } }, "xz": { - "type": "ghrel", - "repo": "tukaani-project/xz", - "match": "xz-.+\\.tar\\.gz", + "type": "url", + "url": "https://fossies.org/linux/misc/xz-5.4.6.tar.xz", "license": { "type": "file", "path": "COPYING" diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index e608ec0d..63394824 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'intl,pdo_sqlite,sqlite3,curl,openssl,tokenizer,bcmath,bz2,calendar,dba,ftp,iconv,mysqli,mbstring,mbregex,xml,simplexml,ctype,dom,pdo,filter,session,zlib,fileinfo,pdo_mysql,posix,sockets,shmop,sodium,sysvmsg,sysvsem,sysvshm,gd,zip,gmp,redis,xmlwriter,phar,exif,xmlreader,readline,pcntl,soap,imagick,ffi,password-argon2,pgsql,pdo_pgsql,imap,ldap,xsl', + 'Linux', 'Darwin' => 'xml,imagick', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', }; // 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' => 'nghttp2', + 'Linux', 'Darwin' => 'xz', 'Windows' => '', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; From da6d9ffb4bedc8c39e71db47b2ee7ddb6490cad1 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 2 Apr 2024 15:05:49 +0800 Subject: [PATCH 257/415] Cmake version check (#400) * add cmake version checker for doctor * fix linux distro checker message --- src/SPC/doctor/item/LinuxToolCheckList.php | 16 ++++++++++++++++ src/SPC/doctor/item/OSCheckList.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index f81b4a13..a8665e69 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -74,6 +74,22 @@ class LinuxToolCheckList return CheckResult::ok(); } + #[AsCheckItem('if cmake version >= 3.18', limit_os: 'Linux')] + public function checkCMakeVersion(): ?CheckResult + { + $check_cmd = 'cmake --version'; + $pattern = '/cmake version (.*)/m'; + $out = shell()->execWithResult($check_cmd, false)[1][0]; + if (preg_match($pattern, $out, $match)) { + $ver = $match[1]; + if (version_compare($ver, '3.18.0') <= 0) { + return CheckResult::fail('cmake version is too low (' . $ver . '), please update it manually!'); + } + return CheckResult::ok($match[1]); + } + return CheckResult::fail('Failed to get cmake version'); + } + /** @noinspection PhpUnused */ #[AsCheckItem('if necessary linux headers are installed', limit_os: 'Linux')] public function checkSystemOSPackages(): ?CheckResult diff --git a/src/SPC/doctor/item/OSCheckList.php b/src/SPC/doctor/item/OSCheckList.php index eef30f60..7975dde9 100644 --- a/src/SPC/doctor/item/OSCheckList.php +++ b/src/SPC/doctor/item/OSCheckList.php @@ -20,7 +20,7 @@ class OSCheckList return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY); } $distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : ''; - $known_distro = PHP_OS_FAMILY === 'Linux' && in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros()); + $known_distro = PHP_OS_FAMILY !== 'Linux' || in_array(SystemUtil::getOSRelease()['dist'], SystemUtil::getSupportedDistros()); return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)')); } } From 1e494a22131c0f898e2c4717096de82ba419ec1b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 2 Apr 2024 15:06:54 +0800 Subject: [PATCH 258/415] bump version --- 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 a869fef7..6cdc73bf 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.6'; + public const VERSION = '2.1.7'; public function __construct() { From 9fd56987efb3b0185227416a7efc729693cbf861 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 2 Apr 2024 15:54:28 +0800 Subject: [PATCH 259/415] Add extension ds support (#401) * add extension ds * add ds tests --- config/ext.json | 4 ++++ config/source.json | 10 ++++++++++ src/globals/test-extensions.php | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index f927f3cd..19e33836 100644 --- a/config/ext.json +++ b/config/ext.json @@ -57,6 +57,10 @@ "xml" ] }, + "ds": { + "type": "external", + "source": "ext-ds" + }, "event": { "type": "external", "source": "ext-event", diff --git a/config/source.json b/config/source.json index 2647c85e..6b3ca414 100644 --- a/config/source.json +++ b/config/source.json @@ -52,6 +52,16 @@ "path": "COPYING" } }, + "ext-ds": { + "type": "url", + "url": "https://pecl.php.net/get/ds", + "path": "php-src/ext/ds", + "filename": "ds.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-event": { "type": "url", "url": "https://bitbucket.org/osmanov/pecl-event/get/3.0.8.tar.gz", diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 63394824..9cdaaf60 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'xml,imagick', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', + 'Linux', 'Darwin' => 'ds', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds', }; // 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' => 'xz', + 'Linux', 'Darwin' => '', 'Windows' => '', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', }; From c77dc1af6c38298b5db62e7ed2386e4effd40475 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 2 Apr 2024 16:57:59 +0800 Subject: [PATCH 260/415] Add extension simdjson support (#402) * add extension simdjson support * add extension simdjson tests * fix windows build for simdjson --- config/ext.json | 5 ++++ config/source.json | 10 ++++++++ src/SPC/builder/extension/simdjson.php | 34 ++++++++++++++++++++++++++ src/globals/test-extensions.php | 4 +-- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/extension/simdjson.php diff --git a/config/ext.json b/config/ext.json index 19e33836..e74f64af 100644 --- a/config/ext.json +++ b/config/ext.json @@ -382,6 +382,11 @@ "shmop": { "type": "builtin" }, + "simdjson": { + "type": "external", + "source": "ext-simdjson", + "cpp-extension": true + }, "simplexml": { "type": "builtin", "arg-type": "custom", diff --git a/config/source.json b/config/source.json index 6b3ca414..6ed35f5d 100644 --- a/config/source.json +++ b/config/source.json @@ -100,6 +100,16 @@ "path": "LICENSE" } }, + "ext-simdjson": { + "type": "url", + "url": "https://pecl.php.net/get/simdjson", + "path": "php-src/ext/simdjson", + "filename": "simdjson.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-snappy": { "type": "git", "path": "php-src/ext/snappy", diff --git a/src/SPC/builder/extension/simdjson.php b/src/SPC/builder/extension/simdjson.php new file mode 100644 index 00000000..71796ebe --- /dev/null +++ b/src/SPC/builder/extension/simdjson.php @@ -0,0 +1,34 @@ +builder->getPHPVersionID(); + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/ext/simdjson/config.m4', + '/php_version=(`.*`)$/m', + 'php_version=' . strval($php_ver) + ); + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/simdjson/config.m4', + 'if test -z "$PHP_CONFIG"; then', + 'if false; then' + ); + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/simdjson/config.w32', + "'yes',", + 'PHP_SIMDJSON_SHARED,' + ); + return true; + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 9cdaaf60..e2aa441e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'ds', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds', + 'Linux', 'Darwin' => 'ds,simdjson', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds,simdjson', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From 99aadd3e7367a3ad222bae10a6b0cb1977e8115a Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 12 Apr 2024 00:49:15 +0800 Subject: [PATCH 261/415] fix openssl build with corrupted pkg-config file (#406) * fix openssl build with corrupted pkg-config file * add test * fix linux openssl * add exec exit error counter for postgresql --- src/SPC/builder/linux/library/openssl.php | 11 +++++++++++ src/SPC/builder/macos/library/openssl.php | 11 +++++++++++ src/SPC/builder/unix/library/postgresql.php | 8 ++++++++ src/globals/test-extensions.php | 4 ++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 5a9c5bfd..31dcd9ff 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -24,6 +24,7 @@ use SPC\builder\linux\SystemUtil; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; class openssl extends LinuxLibraryBase { @@ -76,5 +77,15 @@ class openssl extends LinuxLibraryBase ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") ->exec("make install_sw DESTDIR={$destdir}"); $this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']); + // patch for openssl 3.3.0+ + if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) { + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file); + } + if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) { + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file); + } + if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) { + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file); + } } } diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index c768512d..cb9de460 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -23,6 +23,7 @@ namespace SPC\builder\macos\library; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; class openssl extends MacOSLibraryBase { @@ -58,5 +59,15 @@ class openssl extends MacOSLibraryBase ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") ->exec("make install_sw DESTDIR={$destdir}"); $this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']); + // patch for openssl 3.3.0+ + if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc'), 'prefix=')) { + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file); + } + if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc'), 'prefix=')) { + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/openssl.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file); + } + if (!str_contains($file = FileSystem::readFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc'), 'prefix=')) { + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', 'prefix=' . BUILD_ROOT_PATH . "\n" . $file); + } } } diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 0b3c7c61..ce3679e9 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -27,26 +27,31 @@ trait postgresql 'libxslt' => 'libxslt', 'icu' => 'icu-i18n', ]; + $error_exec_cnt = 0; foreach ($optional_packages as $lib => $pkg) { if ($this->getBuilder()->getLib($lib)) { $packages .= ' ' . $pkg; $output = shell()->execWithResult("pkg-config --static {$pkg}"); + $error_exec_cnt += $output[0] === 0 ? 0 : 1; logger()->info(var_export($output[1], true)); } } $output = shell()->execWithResult("pkg-config --cflags-only-I --static {$packages}"); + $error_exec_cnt += $output[0] === 0 ? 0 : 1; if (!empty($output[1][0])) { $cppflags = $output[1][0]; $envs .= " CPPFLAGS=\"{$cppflags}\""; } $output = shell()->execWithResult("pkg-config --libs-only-L --static {$packages}"); + $error_exec_cnt += $output[0] === 0 ? 0 : 1; if (!empty($output[1][0])) { $ldflags = $output[1][0]; $envs .= $this instanceof MacOSLibraryBase ? " LDFLAGS=\"{$ldflags}\" " : " LDFLAGS=\"{$ldflags} -static\" "; } $output = shell()->execWithResult("pkg-config --libs-only-l --static {$packages}"); + $error_exec_cnt += $output[0] === 0 ? 0 : 1; if (!empty($output[1][0])) { $libs = $output[1][0]; $libcpp = ''; @@ -55,6 +60,9 @@ trait postgresql } $envs .= " LIBS=\"{$libs}{$libcpp}\" "; } + if ($error_exec_cnt > 0) { + throw new RuntimeException('Failed to get pkg-config information!'); + } FileSystem::resetDir($this->source_dir . '/build'); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index e2aa441e..7a855c06 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'ds,simdjson', + 'Linux', 'Darwin' => 'pgsql,intl,xml,openssl', 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds,simdjson', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'common', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; From b4ed4ea956d80b6733523715b02f93fd7b375f28 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 12 Apr 2024 01:43:27 +0800 Subject: [PATCH 262/415] Add ext yac (#407) * add ext yac * enable yac for windows * enable yac test for windows * correct --- config/ext.json | 8 ++++++++ config/source.json | 10 ++++++++++ src/SPC/builder/extension/yac.php | 26 ++++++++++++++++++++++++++ src/globals/test-extensions.php | 4 ++-- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/extension/yac.php diff --git a/config/ext.json b/config/ext.json index e74f64af..6d5765e5 100644 --- a/config/ext.json +++ b/config/ext.json @@ -623,6 +623,14 @@ "dom" ] }, + "yac": { + "type": "external", + "source": "yac", + "arg-type-unix": "custom", + "ext-depends-unix": [ + "igbinary" + ] + }, "yaml": { "type": "external", "source": "yaml", diff --git a/config/source.json b/config/source.json index 6ed35f5d..87099347 100644 --- a/config/source.json +++ b/config/source.json @@ -673,6 +673,16 @@ "path": "COPYING" } }, + "yac": { + "type": "url", + "url": "https://pecl.php.net/get/yac", + "path": "php-src/ext/yac", + "filename": "yac.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "yaml": { "type": "git", "path": "php-src/ext/yaml", diff --git a/src/SPC/builder/extension/yac.php b/src/SPC/builder/extension/yac.php new file mode 100644 index 00000000..a4152e42 --- /dev/null +++ b/src/SPC/builder/extension/yac.php @@ -0,0 +1,26 @@ + 'pgsql,intl,xml,openssl', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,ds,simdjson', + 'Linux', 'Darwin' => 'yac', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,yac', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From e3c542d9dfa81db226d5eac3efbe67ae321c90cb Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 12 Apr 2024 15:53:38 +0800 Subject: [PATCH 263/415] add qdbm for dba (#409) * add qdbm for dba * add windows support for dba-qdbm * fix test scripts * fix test scripts --- .github/workflows/tests.yml | 2 +- config/ext.json | 5 +++- config/lib.json | 12 ++++++++ config/source.json | 9 ++++++ src/SPC/builder/extension/dba.php | 24 ++++++++++++++++ src/SPC/builder/linux/library/qdbm.php | 12 ++++++++ src/SPC/builder/macos/library/qdbm.php | 12 ++++++++ src/SPC/builder/unix/library/qdbm.php | 33 ++++++++++++++++++++++ src/SPC/builder/windows/WindowsBuilder.php | 3 ++ src/SPC/builder/windows/library/qdbm.php | 24 ++++++++++++++++ src/globals/test-extensions.php | 9 +++--- 11 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 src/SPC/builder/extension/dba.php create mode 100644 src/SPC/builder/linux/library/qdbm.php create mode 100644 src/SPC/builder/macos/library/qdbm.php create mode 100644 src/SPC/builder/unix/library/qdbm.php create mode 100644 src/SPC/builder/windows/library/qdbm.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a096b1fa..2eda9ad3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -168,4 +168,4 @@ jobs: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug - name: "Run Build Tests (build)" - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug + run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug diff --git a/config/ext.json b/config/ext.json index 6d5765e5..f4c6ecbe 100644 --- a/config/ext.json +++ b/config/ext.json @@ -43,7 +43,10 @@ }, "dba": { "type": "builtin", - "arg-type-windows": "with" + "arg-type": "custom", + "lib-suggests": [ + "qdbm" + ] }, "dom": { "type": "builtin", diff --git a/config/lib.json b/config/lib.json index 746f508e..6dc2caac 100644 --- a/config/lib.json +++ b/config/lib.json @@ -525,6 +525,18 @@ "zstd" ] }, + "qdbm": { + "source": "qdbm", + "static-libs-unix": [ + "libqdbm.a" + ], + "static-libs-windows": [ + "qdbm_a.lib" + ], + "headers-windows": [ + "depot.h" + ] + }, "readline": { "source": "readline", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 87099347..0ecbb49d 100644 --- a/config/source.json +++ b/config/source.json @@ -551,6 +551,15 @@ "path": "LICENSE" } }, + "qdbm": { + "type": "git", + "url": "https://github.com/static-php/qdbm.git", + "rev": "main", + "license": { + "type": "file", + "path": "COPYING" + } + }, "rar": { "type": "git", "url": "https://github.com/static-php/php-rar.git", diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php new file mode 100644 index 00000000..011e4746 --- /dev/null +++ b/src/SPC/builder/extension/dba.php @@ -0,0 +1,24 @@ +builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : ''; + return '--enable-dba' . $qdbm; + } + + public function getWindowsConfigureArg(): string + { + $qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : ''; + return '--with-dba' . $qdbm; + } +} diff --git a/src/SPC/builder/linux/library/qdbm.php b/src/SPC/builder/linux/library/qdbm.php new file mode 100644 index 00000000..b0bc8960 --- /dev/null +++ b/src/SPC/builder/linux/library/qdbm.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static --disable-shared ' . + '--prefix=' + ) + ->exec('make clean'); + 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); + $this->patchPkgconfPrefix(['qdbm.pc']); + } +} diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 256b392b..2e5a2d0d 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -46,6 +46,9 @@ class WindowsBuilder extends BuilderBase // make cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(); + + f_mkdir(BUILD_INCLUDE_PATH, recursive: true); + f_mkdir(BUILD_LIB_PATH, recursive: true); } /** diff --git a/src/SPC/builder/windows/library/qdbm.php b/src/SPC/builder/windows/library/qdbm.php new file mode 100644 index 00000000..67617b34 --- /dev/null +++ b/src/SPC/builder/windows/library/qdbm.php @@ -0,0 +1,24 @@ +cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('nmake'), + '/f VCMakefile' + ); + copy($this->source_dir . '\qdbm_a.lib', BUILD_LIB_PATH . '\qdbm_a.lib'); + copy($this->source_dir . '\depot.h', BUILD_INCLUDE_PATH . '\depot.h'); + // FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 07497e67..eb96a1e8 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,14 +13,14 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'yac', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,yac', + 'Linux', 'Darwin' => 'dba', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,dba', }; // 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' => '', - 'Windows' => '', + 'Linux', 'Darwin' => 'qdbm', + 'Windows' => 'qdbm', }; // Please change your test base combination. We recommend testing with `common`. @@ -62,7 +62,6 @@ $final_libs = trim($with_libs, $trim_value); if (PHP_OS_FAMILY === 'Windows') { $final_extensions_cmd = '"' . $final_extensions . '"'; - $final_libs = $final_libs === '' ? '' : ('"' . $final_libs . '"'); } else { $final_extensions_cmd = $final_extensions; } From 847535721c97cb2d976a6bf48b005fc3ce01c4ed Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 12 Apr 2024 15:55:36 +0800 Subject: [PATCH 264/415] add macOS brew arch check for doctor --- src/SPC/doctor/item/MacOSToolCheckList.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SPC/doctor/item/MacOSToolCheckList.php b/src/SPC/doctor/item/MacOSToolCheckList.php index 6bbeb864..6defdb2a 100644 --- a/src/SPC/doctor/item/MacOSToolCheckList.php +++ b/src/SPC/doctor/item/MacOSToolCheckList.php @@ -37,10 +37,12 @@ class MacOSToolCheckList #[AsCheckItem('if homebrew has installed', limit_os: 'Darwin', level: 998)] public function checkBrew(): ?CheckResult { - // 检查 homebrew 是否已经安装 - if ($this->findCommand('brew') === null) { + if (($path = $this->findCommand('brew')) === null) { return CheckResult::fail('Homebrew is not installed', 'brew'); } + if ($path !== '/opt/homebrew/bin/brew' && php_uname('m') === 'arm64') { + return CheckResult::fail('Current homebrew (/usr/local/bin/homebrew) is not installed for M1 Mac, please re-install homebrew in /opt/homebrew/ !'); + } return CheckResult::ok(); } From 4cb176443981a81fcbc1cdb81a2f9005c8c885cf Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 12 Apr 2024 21:05:51 +0800 Subject: [PATCH 265/415] Fix libuuid build source (#411) * fix libuuid build source * fix libuuid build source tests --- config/lib.json | 3 ++ config/source.json | 2 +- src/SPC/builder/unix/library/libuuid.php | 40 ++++++++++++++---------- src/globals/test-extensions.php | 8 ++--- src/globals/tests/uuid.php | 6 ++++ 5 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 src/globals/tests/uuid.php diff --git a/config/lib.json b/config/lib.json index 6dc2caac..b7a92d04 100644 --- a/config/lib.json +++ b/config/lib.json @@ -353,6 +353,9 @@ "source": "libuuid", "static-libs-unix": [ "libuuid.a" + ], + "headers": [ + "uuid/uuid.h" ] }, "libuv": { diff --git a/config/source.json b/config/source.json index 0ecbb49d..9d5fb36e 100644 --- a/config/source.json +++ b/config/source.json @@ -385,7 +385,7 @@ }, "libuuid": { "type": "git", - "url": "https://github.com/cloudbase/libuuid.git", + "url": "https://github.com/static-php/libuuid.git", "rev": "master", "license": { "type": "file", diff --git a/src/SPC/builder/unix/library/libuuid.php b/src/SPC/builder/unix/library/libuuid.php index abbc4a9f..65ed02ac 100644 --- a/src/SPC/builder/unix/library/libuuid.php +++ b/src/SPC/builder/unix/library/libuuid.php @@ -10,29 +10,37 @@ use SPC\store\FileSystem; trait libuuid { - public function patchBeforeBuild(): bool - { - FileSystem::replaceFileStr($this->source_dir . '/configure', '-${am__api_version}', ''); - return true; - } - /** * @throws FileSystemException * @throws RuntimeException */ protected function build(): void { - shell()->cd($this->source_dir) - ->exec('chmod +x configure') - ->exec('chmod +x install-sh') + FileSystem::resetDir($this->source_dir . '/build'); + shell()->cd($this->source_dir . '/build') ->exec( - './configure ' . - '--enable-static --disable-shared ' . - '--prefix=' + 'cmake ' . + "{$this->builder->makeCmakeArgs()} " . + '..' ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); - $this->patchPkgconfPrefix(['uuid.pc']); + ->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'); + copy($this->source_dir . '/uuid.h', BUILD_INCLUDE_PATH . '/uuid/uuid.h'); + $pc = FileSystem::readFile($this->source_dir . '/uuid.pc.in'); + $pc = str_replace([ + '@prefix@', + '@exec_prefix@', + '@libdir@', + '@includedir@', + '@LIBUUID_VERSION@', + ], [ + BUILD_ROOT_PATH, + '${prefix}', + '${prefix}/lib', + '${prefix}/include', + '1.0.3', + ], $pc); + FileSystem::writeFile(BUILD_LIB_PATH . '/pkgconfig/uuid.pc', $pc); } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index eb96a1e8..c7127f0d 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,14 +13,14 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'dba', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,dba', + 'Linux', 'Darwin' => 'uuid', + 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // 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' => 'qdbm', - 'Windows' => 'qdbm', + 'Linux', 'Darwin' => '', + 'Windows' => '', }; // Please change your test base combination. We recommend testing with `common`. diff --git a/src/globals/tests/uuid.php b/src/globals/tests/uuid.php new file mode 100644 index 00000000..3ae30539 --- /dev/null +++ b/src/globals/tests/uuid.php @@ -0,0 +1,6 @@ + Date: Sat, 13 Apr 2024 16:12:05 +0800 Subject: [PATCH 266/415] add Archlinux doctor support --- src/SPC/builder/linux/SystemUtil.php | 2 ++ src/SPC/doctor/item/LinuxToolCheckList.php | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/SPC/builder/linux/SystemUtil.php b/src/SPC/builder/linux/SystemUtil.php index 0cca1524..7cd3f098 100644 --- a/src/SPC/builder/linux/SystemUtil.php +++ b/src/SPC/builder/linux/SystemUtil.php @@ -220,6 +220,8 @@ class SystemUtil 'redhat', // alpine 'alpine', + // arch + 'arch', 'manjaro', ]; } } diff --git a/src/SPC/doctor/item/LinuxToolCheckList.php b/src/SPC/doctor/item/LinuxToolCheckList.php index a8665e69..88b310a7 100644 --- a/src/SPC/doctor/item/LinuxToolCheckList.php +++ b/src/SPC/doctor/item/LinuxToolCheckList.php @@ -40,8 +40,13 @@ class LinuxToolCheckList 'xz', ]; + public const TOOLS_ARCH = [ + 'base-devel', 'cmake', + ]; + private const PROVIDED_COMMAND = [ 'binutils-gold' => 'ld.gold', + 'base-devel' => 'automake', ]; /** @noinspection PhpUnused */ @@ -53,6 +58,7 @@ class LinuxToolCheckList $required = match ($distro['dist']) { 'alpine' => self::TOOLS_ALPINE, 'redhat' => self::TOOLS_RHEL, + 'arch' => self::TOOLS_ARCH, default => self::TOOLS_DEBIAN, }; $missing = []; @@ -67,6 +73,7 @@ class LinuxToolCheckList 'alpine', 'redhat', 'Deepin', + 'arch', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]), default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'), }; @@ -114,6 +121,7 @@ class LinuxToolCheckList 'ubuntu', 'debian', 'Deepin' => 'apt-get install -y', 'alpine' => 'apk add', 'redhat' => 'dnf install -y', + 'arch' => 'pacman -S --noconfirm', default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'), }; $prefix = ''; From bd8f91d466d8b9db48a0e6f7b108bb944f059d33 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Apr 2024 15:52:24 +0800 Subject: [PATCH 267/415] add env manager --- src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/LibraryBase.php | 5 + src/SPC/builder/linux/LinuxBuilder.php | 138 +++++--------- src/SPC/builder/linux/library/openssl.php | 8 +- src/SPC/builder/macos/MacOSBuilder.php | 85 +++------ src/SPC/builder/macos/library/openssl.php | 3 +- src/SPC/builder/traits/UnixLibraryTrait.php | 15 ++ src/SPC/builder/unix/library/brotli.php | 7 +- src/SPC/builder/unix/library/bzip2.php | 5 +- src/SPC/builder/unix/library/curl.php | 7 +- src/SPC/builder/unix/library/freetype.php | 9 +- src/SPC/builder/unix/library/gettext.php | 9 +- src/SPC/builder/unix/library/gmp.php | 7 +- src/SPC/builder/unix/library/imagemagick.php | 15 +- src/SPC/builder/unix/library/ldap.php | 10 +- src/SPC/builder/unix/library/libargon2.php | 5 +- src/SPC/builder/unix/library/libavif.php | 7 +- src/SPC/builder/unix/library/libcares.php | 5 +- src/SPC/builder/unix/library/libevent.php | 5 +- src/SPC/builder/unix/library/pkgconfig.php | 15 +- src/SPC/builder/windows/WindowsBuilder.php | 14 +- src/SPC/command/BuildCliCommand.php | 22 ++- src/SPC/util/GlobalEnvManager.php | 187 +++++++++++++++++++ src/SPC/util/UnixShell.php | 7 +- 24 files changed, 389 insertions(+), 203 deletions(-) create mode 100644 src/SPC/util/GlobalEnvManager.php diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 6cdc73bf..09b6b622 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.1.7'; + public const VERSION = '2.2.0'; public function __construct() { diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index 51ab7e30..cff8ff2b 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -206,4 +206,9 @@ abstract class LibraryBase } logger()->debug('enabling ' . static::NAME . " without {$name}"); } + + protected function getSnakeCaseName(): string + { + return str_replace('-', '_', static::NAME); + } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 7d200d17..b7abf159 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -11,68 +11,42 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; +use SPC\util\GlobalEnvManager; class LinuxBuilder extends UnixBuilderBase { - /** @var array Tune cflags */ - public array $tune_c_flags; - /** @var bool Micro patch phar flag */ private bool $phar_patched = false; /** * @throws FileSystemException - * @throws RuntimeException * @throws WrongUsageException */ public function __construct(array $options = []) { $this->options = $options; - // ---------- set necessary options ---------- - // set C/C++ compilers (default: alpine: gcc, others: musl-cross-make) - if (SystemUtil::isMuslDist()) { - f_putenv("CC={$this->getOption('cc', 'gcc')}"); - f_putenv("CXX={$this->getOption('cxx', 'g++')}"); - f_putenv("AR={$this->getOption('ar', 'ar')}"); - f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); - } else { - $arch = arch2gnu(php_uname('m')); - f_putenv("CC={$this->getOption('cc', "{$arch}-linux-musl-gcc")}"); - f_putenv("CXX={$this->getOption('cxx', "{$arch}-linux-musl-g++")}"); - f_putenv("AR={$this->getOption('ar', "{$arch}-linux-musl-ar")}"); - f_putenv("LD={$this->getOption('ld', 'ld.gold')}"); - f_putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); - - // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) - $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"); - - // check musl-cross make installed if we use musl-cross-make - if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { - throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); - } + // check musl-cross make installed if we use musl-cross-make + $arch = arch2gnu(php_uname('m')); + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { + throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); } - // set PKG_CONFIG - f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); - // set PKG_CONFIG_PATH - f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig'); + // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) + $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"); - // set arch (default: current) - $this->setOptionIfNotExist('arch', php_uname('m')); - $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); + GlobalEnvManager::init($this); // concurrency - $this->concurrency = SystemUtil::getCpuCount(); + $this->concurrency = intval(getenv('SPC_CONCURRENCY')); // cflags - $this->arch_c_flags = SystemUtil::getArchCFlags(getenv('CC'), $this->getOption('arch')); - $this->arch_cxx_flags = SystemUtil::getArchCFlags(getenv('CXX'), $this->getOption('arch')); - $this->tune_c_flags = SystemUtil::checkCCFlags(SystemUtil::getTuneCFlags($this->getOption('arch')), getenv('CC')); + $this->arch_c_flags = getenv('SPC_DEFAULT_C_FLAGS'); + $this->arch_cxx_flags = getenv('SPC_DEFAULT_CXX_FLAGS'); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile( 'Linux', - $this->getOption('arch'), + $arch, $this->arch_c_flags, getenv('CC'), getenv('CXX'), @@ -124,8 +98,8 @@ class LinuxBuilder extends UnixBuilderBase public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { // ---------- Update extra-libs ---------- - $extra_libs = $this->getOption('extra-libs', ''); - // non-bloat linking + $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; + // bloat means force-load all static libraries, even if they are not used if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { @@ -133,21 +107,13 @@ class LinuxBuilder extends UnixBuilderBase } // add libstdc++, some extensions or libraries need it $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lstdc++ ' : ''); - $this->setOption('extra-libs', $extra_libs); + f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); $cflags = $this->arch_c_flags; - // prepare build php envs - $envs_build_php = SystemUtil::makeEnvVarString([ - 'CFLAGS' => $cflags, - 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, - 'LDFLAGS' => '-L' . BUILD_LIB_PATH, - 'LIBS' => '-ldl -lpthread', - ]); - $this->emitPatchPoint('before-php-buildconf'); SourcePatcher::patchBeforeBuildconf($this); - shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); + shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_BUILDCONF')); $this->emitPatchPoint('before-php-configure'); SourcePatcher::patchBeforeConfigure($this); @@ -169,20 +135,31 @@ class LinuxBuilder extends UnixBuilderBase $enableMicro = ($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO; $enableEmbed = ($build_target & BUILD_TARGET_EMBED) === BUILD_TARGET_EMBED; + // prepare build php envs + $envs_build_php = SystemUtil::makeEnvVarString([ + 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'), + 'CPPFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS'), + 'LDFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS'), + 'LIBS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), + ]); + // upx pack and strip for micro if ($this->getOption('with-upx-pack', false)) { + // with upx pack always need strip FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', '/POST_MICRO_BUILD_COMMANDS=.*/', - 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . $this->getOption('upx-exec') . ' --best \$(SAPI_MICRO_PATH)', + 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . getenv('UPX_EXEC') . ' --best \$(SAPI_MICRO_PATH)', ); } elseif (!$this->getOption('no-strip', false)) { + // not-no-strip means strip (default behavior) FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', '/POST_MICRO_BUILD_COMMANDS=.*/', 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)', ); } else { + // just no strip FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', '/POST_MICRO_BUILD_COMMANDS=.*/', @@ -193,14 +170,7 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( "{$this->getOption('ld_library_path')} " . - './configure ' . - '--prefix= ' . - '--with-valgrind=no ' . - '--enable-shared=no ' . - '--enable-static=yes ' . - '--disable-all ' . - '--disable-cgi ' . - '--disable-phpdbg ' . + getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . ($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . @@ -252,15 +222,15 @@ class LinuxBuilder extends UnixBuilderBase */ protected function buildCli(): void { - $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); + $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("make -j{$this->concurrency} {$vars} cli"); + ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} cli"); if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli') ->exec('strip --strip-all php') - ->exec($this->getOption('upx-exec') . ' --best php'); + ->exec(getenv('UPX_EXEC') . ' --best php'); } elseif (!$this->getOption('no-strip', false)) { shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php'); } @@ -285,12 +255,16 @@ class LinuxBuilder extends UnixBuilderBase SourcePatcher::patchMicro(['phar']); } - $vars = SystemUtil::makeEnvVarString($this->getBuildVars([ - 'EXTRA_CFLAGS' => $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : '', - ])); + $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; + $vars = $this->getMakeExtraVars(); + + // patch fake cli for micro + $vars['EXTRA_CFLAGS'] .= $enable_fake_cli; + $vars = SystemUtil::makeEnvVarString($vars); + shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("make -j{$this->concurrency} {$vars} micro"); + ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} micro"); $this->deployBinary(BUILD_TARGET_MICRO); @@ -307,15 +281,15 @@ class LinuxBuilder extends UnixBuilderBase */ protected function buildFpm(): void { - $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); + $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec("make -j{$this->concurrency} {$vars} fpm"); + ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} fpm"); if ($this->getOption('with-upx-pack')) { shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm') ->exec('strip --strip-all php-fpm') - ->exec($this->getOption('upx-exec') . ' --best php-fpm'); + ->exec(getenv('UPX_EXEC') . ' --best php-fpm'); } elseif (!$this->getOption('no-strip', false)) { shell()->cd(SOURCE_PATH . '/php-src/sapi/fpm')->exec('strip --strip-all php-fpm'); } @@ -329,29 +303,19 @@ class LinuxBuilder extends UnixBuilderBase */ protected function buildEmbed(): void { - $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); + $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); - shell() - ->cd(SOURCE_PATH . '/php-src') + shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') - ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install"); + ->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . ' INSTALL_ROOT=' . BUILD_ROOT_PATH . " {$vars} install"); } - private function getBuildVars($input = []): array + private function getMakeExtraVars(): array { - $use_lld = ''; - if (str_ends_with(getenv('CC'), 'clang') && SystemUtil::findCommand('lld')) { - $use_lld = '-Xcompiler -fuse-ld=lld'; - } - $optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os'; - $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; - $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; - $ldflags = isset($input['EXTRA_LDFLAGS_PROGRAM']) && $input['EXTRA_LDFLAGS_PROGRAM'] ? " {$input['EXTRA_LDFLAGS_PROGRAM']}" : ''; - $tune_c_flags = implode(' ', array_map(fn ($x) => "-Xcompiler {$x}", $this->tune_c_flags)); return [ - 'EXTRA_CFLAGS' => "{$optimization} -fno-ident -fPIE {$tune_c_flags}{$cflags}", - 'EXTRA_LIBS' => "{$this->getOption('extra-libs', '')} {$libs}", - 'EXTRA_LDFLAGS_PROGRAM' => "{$use_lld} -all-static{$ldflags}", + 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), + 'EXTRA_LIBS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'), + 'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'), ]; } } diff --git a/src/SPC/builder/linux/library/openssl.php b/src/SPC/builder/linux/library/openssl.php index 31dcd9ff..9c3b043e 100644 --- a/src/SPC/builder/linux/library/openssl.php +++ b/src/SPC/builder/linux/library/openssl.php @@ -42,8 +42,7 @@ class openssl extends LinuxLibraryBase $extra = ''; $ex_lib = '-ldl -pthread'; - $env = "CFLAGS='{$this->builder->arch_c_flags}'"; - $env .= " CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH . + $env = "CC='" . getenv('CC') . ' -static -idirafter ' . BUILD_INCLUDE_PATH . ' -idirafter /usr/include/ ' . ' -idirafter /usr/include/' . $this->builder->getOption('arch') . '-linux-gnu/ ' . "' "; @@ -64,7 +63,8 @@ class openssl extends LinuxLibraryBase $clang_postfix = SystemUtil::getCCType(getenv('CC')) === 'clang' ? '-clang' : ''; shell()->cd($this->source_dir) - ->exec( + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $this->builder->arch_c_flags, 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv( "{$env} ./Configure no-shared {$extra} " . '--prefix=/ ' . '--libdir=lib ' . @@ -74,7 +74,7 @@ class openssl extends LinuxLibraryBase "linux-{$this->builder->getOption('arch')}{$clang_postfix}" ) ->exec('make clean') - ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") + ->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") ->exec("make install_sw DESTDIR={$destdir}"); $this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']); // patch for openssl 3.3.0+ diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index def7d8b0..522c12d3 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -11,6 +11,7 @@ use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; +use SPC\util\GlobalEnvManager; class MacOSBuilder extends UnixBuilderBase { @@ -26,28 +27,15 @@ class MacOSBuilder extends UnixBuilderBase { $this->options = $options; - // ---------- set necessary options ---------- - // set C Compiler (default: clang) - f_putenv('CC=' . $this->getOption('cc', 'clang')); - // set C++ Composer (default: clang++) - f_putenv('CXX=' . $this->getOption('cxx', 'clang++')); - // set PATH - f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); - // set PKG_CONFIG - f_putenv('PKG_CONFIG=' . BUILD_ROOT_PATH . '/bin/pkg-config'); - // set PKG_CONFIG_PATH - f_putenv('PKG_CONFIG_PATH=' . BUILD_LIB_PATH . '/pkgconfig/'); + // apply global environment variables + GlobalEnvManager::init($this); - // set arch (default: current) - $this->setOptionIfNotExist('arch', php_uname('m')); - $this->setOptionIfNotExist('gnu-arch', arch2gnu($this->getOption('arch'))); - - // ---------- set necessary compile environments ---------- + // ---------- set necessary compile vars ---------- // concurrency - $this->concurrency = SystemUtil::getCpuCount(); + $this->concurrency = intval(getenv('SPC_CONCURRENCY')); // cflags - $this->arch_c_flags = SystemUtil::getArchCFlags($this->getOption('arch')); - $this->arch_cxx_flags = SystemUtil::getArchCFlags($this->getOption('arch')); + $this->arch_c_flags = getenv('SPC_DEFAULT_C_FLAGS'); + $this->arch_cxx_flags = getenv('SPC_DEFAULT_CXX_FLAGS'); // cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags); @@ -123,24 +111,25 @@ class MacOSBuilder extends UnixBuilderBase */ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { + $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; // ---------- Update extra-libs ---------- - $extra_libs = $this->getOption('extra-libs', ''); // add macOS frameworks $extra_libs .= (empty($extra_libs) ? '' : ' ') . $this->getFrameworks(true); // add libc++, some extensions or libraries need it (C++ cannot be linked statically) $extra_libs .= (empty($extra_libs) ? '' : ' ') . ($this->hasCpp() ? '-lc++ ' : ''); + // bloat means force-load all static libraries, even if they are not used if (!$this->getOption('bloat', false)) { $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); } else { logger()->info('bloat linking'); $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', array_map(fn ($x) => "-Wl,-force_load,{$x}", array_filter($this->getAllStaticLibFiles()))); } - $this->setOption('extra-libs', $extra_libs); + f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); $this->emitPatchPoint('before-php-buildconf'); SourcePatcher::patchBeforeBuildconf($this); - shell()->cd(SOURCE_PATH . '/php-src')->exec('./buildconf --force'); + shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_BUILDCONF')); $this->emitPatchPoint('before-php-configure'); SourcePatcher::patchBeforeConfigure($this); @@ -155,9 +144,9 @@ class MacOSBuilder extends UnixBuilderBase // prepare build php envs $envs_build_php = SystemUtil::makeEnvVarString([ - 'CFLAGS' => " {$this->arch_c_flags} -Werror=unknown-warning-option ", - 'CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, - 'LDFLAGS' => '-L' . BUILD_LIB_PATH, + 'CFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS'), + 'CPPFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS'), + 'LDFLAGS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS'), ]); if ($this->getLib('postgresql')) { @@ -170,14 +159,7 @@ class MacOSBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( - './configure ' . - '--prefix= ' . - '--with-valgrind=no ' . // Not detect memory leak - '--enable-shared=no ' . - '--enable-static=yes ' . - '--disable-all ' . - '--disable-cgi ' . - '--disable-phpdbg ' . + getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . ($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . @@ -227,10 +209,10 @@ class MacOSBuilder extends UnixBuilderBase */ protected function buildCli(): void { - $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); + $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); $shell = shell()->cd(SOURCE_PATH . '/php-src'); - $shell->exec("make -j{$this->concurrency} {$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'); } @@ -255,18 +237,17 @@ class MacOSBuilder extends UnixBuilderBase } $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; - $vars = [ - // with debug information, optimize for size, remove identifiers, patch fake cli for micro - 'EXTRA_CFLAGS' => '-g -Os -fno-ident' . $enable_fake_cli, - ]; - $vars = $this->getBuildVars($vars); + $vars = $this->getMakeExtraVars(); + + // 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("make -j{$this->concurrency} {$vars} micro"); + shell()->cd(SOURCE_PATH . '/php-src')->exec(getenv('SPC_CMD_PREFIX_PHP_MAKE') . " {$vars} micro"); + $this->deployBinary(BUILD_TARGET_MICRO); if ($this->phar_patched) { @@ -282,10 +263,10 @@ class MacOSBuilder extends UnixBuilderBase */ protected function buildFpm(): void { - $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); + $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); $shell = shell()->cd(SOURCE_PATH . '/php-src'); - $shell->exec("make -j{$this->concurrency} {$vars} fpm"); + $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'); } @@ -299,11 +280,10 @@ class MacOSBuilder extends UnixBuilderBase */ protected function buildEmbed(): void { - $vars = SystemUtil::makeEnvVarString($this->getBuildVars()); + $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); - shell() - ->cd(SOURCE_PATH . '/php-src') - ->exec('make INSTALL_ROOT=' . BUILD_ROOT_PATH . " -j{$this->concurrency} {$vars} install") + 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') @@ -314,14 +294,11 @@ class MacOSBuilder extends UnixBuilderBase ->exec('rm -Rf ' . BUILD_ROOT_PATH . '/lib/php-o'); } - private function getBuildVars($input = []): array + private function getMakeExtraVars(): array { - $optimization = $this->getOption('no-strip', false) ? '-g -O0' : '-g0 -Os'; - $cflags = isset($input['EXTRA_CFLAGS']) && $input['EXTRA_CFLAGS'] ? " {$input['EXTRA_CFLAGS']}" : ''; - $libs = isset($input['EXTRA_LIBS']) && $input['EXTRA_LIBS'] ? " {$input['EXTRA_LIBS']}" : ''; return [ - 'EXTRA_CFLAGS' => "{$optimization} {$cflags} " . $this->getOption('x-extra-cflags'), - 'EXTRA_LIBS' => "{$this->getOption('extra-libs')} -lresolv {$libs} " . $this->getOption('x-extra-libs'), + 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), + 'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'), ]; } } diff --git a/src/SPC/builder/macos/library/openssl.php b/src/SPC/builder/macos/library/openssl.php index cb9de460..b5753b8d 100644 --- a/src/SPC/builder/macos/library/openssl.php +++ b/src/SPC/builder/macos/library/openssl.php @@ -48,6 +48,7 @@ class openssl extends MacOSLibraryBase } shell()->cd($this->source_dir) + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) ->exec( "./Configure no-shared {$extra} " . '--prefix=/ ' . // use prefix=/ @@ -56,7 +57,7 @@ class openssl extends MacOSLibraryBase "darwin64-{$this->builder->getOption('arch')}-cc" ) ->exec('make clean') - ->exec("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") + ->execWithEnv("make -j{$this->builder->concurrency} CNF_EX_LIBS=\"{$ex_lib}\"") ->exec("make install_sw DESTDIR={$destdir}"); $this->patchPkgconfPrefix(['libssl.pc', 'openssl.pc', 'libcrypto.pc']); // patch for openssl 3.3.0+ diff --git a/src/SPC/builder/traits/UnixLibraryTrait.php b/src/SPC/builder/traits/UnixLibraryTrait.php index 9561663f..c40db0f4 100644 --- a/src/SPC/builder/traits/UnixLibraryTrait.php +++ b/src/SPC/builder/traits/UnixLibraryTrait.php @@ -99,4 +99,19 @@ trait UnixLibraryTrait } } } + + public function getLibExtraCFlags(): string + { + return getenv($this->getSnakeCaseName() . '_CFLAGS') ?: ''; + } + + public function getLibExtraLdFlags(): string + { + return getenv($this->getSnakeCaseName() . '_LDFLAGS') ?: ''; + } + + public function getLibExtraLibs(): string + { + return getenv($this->getSnakeCaseName() . '_LIBS') ?: ''; + } } diff --git a/src/SPC/builder/unix/library/brotli.php b/src/SPC/builder/unix/library/brotli.php index 08eae3a1..e84c6577 100644 --- a/src/SPC/builder/unix/library/brotli.php +++ b/src/SPC/builder/unix/library/brotli.php @@ -18,14 +18,15 @@ trait brotli { FileSystem::resetDir($this->source_dir . '/build-dir'); shell()->cd($this->source_dir . '/build-dir') - ->exec( + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv( 'cmake ' . "{$this->builder->makeCmakeArgs()} " . '-DBUILD_SHARED_LIBS=OFF ' . '..' ) - ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") + ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libbrotlicommon.pc', 'libbrotlidec.pc', 'libbrotlienc.pc']); shell()->cd(BUILD_ROOT_PATH . '/lib')->exec('ln -sf libbrotlicommon.a libbrotli.a'); foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) { diff --git a/src/SPC/builder/unix/library/bzip2.php b/src/SPC/builder/unix/library/bzip2.php index 71990125..23428317 100644 --- a/src/SPC/builder/unix/library/bzip2.php +++ b/src/SPC/builder/unix/library/bzip2.php @@ -9,8 +9,9 @@ trait bzip2 protected function build(): void { shell()->cd($this->source_dir) - ->exec("make PREFIX='" . BUILD_ROOT_PATH . "' clean") - ->exec("make -j{$this->builder->concurrency} {$this->builder->getEnvString()} PREFIX='" . BUILD_ROOT_PATH . "' libbz2.a") + ->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) ->exec('cp bzlib.h ' . BUILD_INCLUDE_PATH); } diff --git a/src/SPC/builder/unix/library/curl.php b/src/SPC/builder/unix/library/curl.php index 643ecac1..1ace7218 100644 --- a/src/SPC/builder/unix/library/curl.php +++ b/src/SPC/builder/unix/library/curl.php @@ -51,10 +51,11 @@ trait curl FileSystem::resetDir($this->source_dir . '/build'); // compile! shell()->cd($this->source_dir . '/build') + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) ->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ../CMakeLists.txt') - ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->execWithEnv("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DBUILD_LIBCURL_DOCS=OFF {$extra} ..") + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconf $this->patchPkgconfPrefix(['libcurl.pc']); shell()->cd(BUILD_LIB_PATH . '/cmake/CURL/') diff --git a/src/SPC/builder/unix/library/freetype.php b/src/SPC/builder/unix/library/freetype.php index 3158d828..6f91a3ec 100644 --- a/src/SPC/builder/unix/library/freetype.php +++ b/src/SPC/builder/unix/library/freetype.php @@ -26,15 +26,16 @@ trait freetype $suggested .= ' '; shell()->cd($this->source_dir) + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) ->exec('sh autogen.sh') - ->exec( + ->execWithEnv( './configure ' . '--enable-static --disable-shared --without-harfbuzz --prefix= ' . $suggested ) - ->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(['freetype2.pc']); FileSystem::replaceFileStr( BUILD_ROOT_PATH . '/lib/pkgconfig/freetype2.pc', diff --git a/src/SPC/builder/unix/library/gettext.php b/src/SPC/builder/unix/library/gettext.php index 3b2dbb30..6a1995c4 100644 --- a/src/SPC/builder/unix/library/gettext.php +++ b/src/SPC/builder/unix/library/gettext.php @@ -11,7 +11,8 @@ trait gettext $extra = $this->builder->getLib('ncurses') ? ('--with-libncurses-prefix=' . BUILD_ROOT_PATH . ' ') : ''; $extra .= $this->builder->getLib('libxml2') ? ('--with-libxml2-prefix=' . BUILD_ROOT_PATH . ' ') : ''; shell()->cd($this->source_dir) - ->exec( + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv( './configure ' . '--enable-static ' . '--disable-shared ' . @@ -21,8 +22,8 @@ trait gettext '--with-libiconv-prefix=' . BUILD_ROOT_PATH . ' ' . '--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'); } } diff --git a/src/SPC/builder/unix/library/gmp.php b/src/SPC/builder/unix/library/gmp.php index f1902dde..0748c870 100644 --- a/src/SPC/builder/unix/library/gmp.php +++ b/src/SPC/builder/unix/library/gmp.php @@ -16,13 +16,14 @@ trait gmp 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 ' . '--prefix=' ) - ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") + ->execWithEnv('make clean') + ->execWithEnv("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['gmp.pc']); } diff --git a/src/SPC/builder/unix/library/imagemagick.php b/src/SPC/builder/unix/library/imagemagick.php index a75969ac..ac011e5f 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -39,15 +39,18 @@ trait imagemagick } } - $ldflags = $this instanceof LinuxLibraryBase ? ('LDFLAGS="-static" ') : ''; + $ldflags = $this instanceof LinuxLibraryBase ? ('-static') : ''; // libxml iconv patch - $required_libs .= $this instanceof MacOSLibraryBase ? (' -liconv') : ''; + $required_libs .= $this instanceof MacOSLibraryBase ? ('-liconv') : ''; shell()->cd($this->source_dir) - ->exec( - 'PKG_CONFIG="$PKG_CONFIG --static" ' . - $ldflags . - "LIBS='{$required_libs}' " . + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, + 'LIBS' => $this->getLibExtraLibs() ?: $required_libs, + 'PKG_CONFIG' => '$PKG_CONFIG --static', + ]) + ->execWithEnv( './configure ' . '--enable-static --disable-shared ' . $extra . diff --git a/src/SPC/builder/unix/library/ldap.php b/src/SPC/builder/unix/library/ldap.php index d1807d89..a061ce7f 100644 --- a/src/SPC/builder/unix/library/ldap.php +++ b/src/SPC/builder/unix/library/ldap.php @@ -25,9 +25,15 @@ trait ldap $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'); + $ldflags = '-L' . BUILD_LIB_PATH; shell()->cd($this->source_dir) - ->exec( - $this->builder->makeAutoconfFlags(AUTOCONF_LDFLAGS | AUTOCONF_CPPFLAGS) . + ->setEnv([ + 'CFLAGS' => $this->getLibExtraCFlags(), + 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, + 'LIBS' => $this->getLibExtraLibs(), + ]) + ->execWithEnv( + $this->builder->makeAutoconfFlags(AUTOCONF_CPPFLAGS) . ' ./configure ' . '--enable-static ' . '--disable-shared ' . diff --git a/src/SPC/builder/unix/library/libargon2.php b/src/SPC/builder/unix/library/libargon2.php index 222e8b43..8cdd1e63 100644 --- a/src/SPC/builder/unix/library/libargon2.php +++ b/src/SPC/builder/unix/library/libargon2.php @@ -11,9 +11,10 @@ trait libargon2 protected function build() { shell()->cd($this->source_dir) + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) ->exec("make PREFIX='' clean") - ->exec("make -j{$this->builder->concurrency} PREFIX=''") - ->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); + ->execWithEnv("make -j{$this->builder->concurrency} PREFIX=''") + ->execWithEnv("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libargon2.pc']); diff --git a/src/SPC/builder/unix/library/libavif.php b/src/SPC/builder/unix/library/libavif.php index 592899b2..c427094e 100644 --- a/src/SPC/builder/unix/library/libavif.php +++ b/src/SPC/builder/unix/library/libavif.php @@ -22,9 +22,10 @@ trait libavif FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec("cmake {$this->builder->makeCmakeArgs()} -DBUILD_SHARED_LIBS=OFF ..") - ->exec("cmake --build . -j {$this->builder->concurrency}") - ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + ->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 DESTDIR=' . BUILD_ROOT_PATH); // patch pkgconfig $this->patchPkgconfPrefix(['libavif.pc']); $this->cleanLaFiles(); diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php index 6d570174..c57ef375 100644 --- a/src/SPC/builder/unix/library/libcares.php +++ b/src/SPC/builder/unix/library/libcares.php @@ -14,8 +14,9 @@ trait libcares protected function build(): void { shell()->cd($this->source_dir) - ->exec('./configure --prefix=' . BUILD_ROOT_PATH . ' --enable-static --disable-shared --disable-tests') - ->exec("make -j {$this->builder->concurrency}") + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv('./configure --prefix=' . BUILD_ROOT_PATH . ' --enable-static --disable-shared --disable-tests') + ->execWithEnv("make -j {$this->builder->concurrency}") ->exec('make install'); } } diff --git a/src/SPC/builder/unix/library/libevent.php b/src/SPC/builder/unix/library/libevent.php index d9b2d81b..b3114156 100644 --- a/src/SPC/builder/unix/library/libevent.php +++ b/src/SPC/builder/unix/library/libevent.php @@ -20,7 +20,8 @@ trait libevent FileSystem::resetDir($this->source_dir . '/build'); // Start build shell()->cd($this->source_dir . '/build') - ->exec( + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags(), 'LDFLAGS' => $this->getLibExtraLdFlags(), 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv( 'cmake ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . @@ -33,7 +34,7 @@ trait libevent '-DEVENT__DISABLE_SAMPLES=ON ' . '..' ) - ->exec("cmake --build . -j {$this->builder->concurrency}") + ->execWithEnv("cmake --build . -j {$this->builder->concurrency}") ->exec('make install'); } } diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index eac7ab03..80510157 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -8,15 +8,12 @@ trait pkgconfig { protected function build(): void { - $macos_env = "CFLAGS='{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion' "; - $linux_env = 'LDFLAGS=--static '; + $cflags = PHP_OS_FAMILY === 'Darwin' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : ''; + $ldflags = PHP_OS_FAMILY === 'Darwin' ? '' : '--static'; shell()->cd($this->source_dir) - ->exec( - match (PHP_OS_FAMILY) { - 'Darwin' => $macos_env, - default => $linux_env, - } . + ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()]) + ->execWithEnv( './configure ' . '--disable-shared ' . '--enable-static ' . @@ -30,8 +27,8 @@ trait pkgconfig '--without-pc-path' ) ->exec('make clean') - ->exec("make -j{$this->builder->concurrency}") - ->exec('make install-exec'); + ->execWithEnv("make -j{$this->builder->concurrency}") + ->execWithEnv('make install-exec'); shell()->exec('strip ' . BUILD_ROOT_PATH . '/bin/pkg-config'); } } diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 2e5a2d0d..dff8b746 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -13,6 +13,7 @@ use SPC\store\FileSystem; use SPC\store\SourceManager; use SPC\store\SourcePatcher; use SPC\util\DependencyUtil; +use SPC\util\GlobalEnvManager; class WindowsBuilder extends BuilderBase { @@ -33,6 +34,8 @@ class WindowsBuilder extends BuilderBase { $this->options = $options; + GlobalEnvManager::init($this); + // ---------- set necessary options ---------- // set sdk (require visual studio 16 or 17) $vs = SystemUtil::findVisualStudio()['version']; @@ -42,7 +45,7 @@ class WindowsBuilder extends BuilderBase $this->zts = $this->getOption('enable-zts', false); // set concurrency - $this->concurrency = SystemUtil::getCpuCount(); + $this->concurrency = intval(getenv('SPC_CONCURRENCY')); // make cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(); @@ -59,9 +62,10 @@ class WindowsBuilder extends BuilderBase public function buildPHP(int $build_target = BUILD_TARGET_NONE): void { // ---------- Update extra-libs ---------- - $extra_libs = $this->getOption('extra-libs', ''); + $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; $extra_libs .= (empty($extra_libs) ? '' : ' ') . implode(' ', $this->getAllStaticLibFiles()); - $this->setOption('extra-libs', $extra_libs); + f_putenv('SPC_EXTRA_LIBS=' . $extra_libs); + $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; @@ -80,7 +84,7 @@ class WindowsBuilder extends BuilderBase if ($this->getOption('with-upx-pack', false)) { if (!file_exists($makefile . '.originfile')) { copy($makefile, $makefile . '.originfile'); - FileSystem::replaceFileStr($makefile, '$(MICRO_SFX):', "_MICRO_UPX = {$this->getOption('upx-exec')} --best $(MICRO_SFX)\n$(MICRO_SFX):"); + FileSystem::replaceFileStr($makefile, '$(MICRO_SFX):', '_MICRO_UPX = ' . getenv('UPX_EXEC') . " --best $(MICRO_SFX)\n$(MICRO_SFX):"); FileSystem::replaceFileStr($makefile, '@$(_MICRO_MT)', "@$(_MICRO_MT)\n\t@$(_MICRO_UPX)"); } } elseif (file_exists($makefile . '.originfile')) { @@ -322,7 +326,7 @@ class WindowsBuilder extends BuilderBase // with-upx-pack for cli if ($this->getOption('with-upx-pack', false) && $type === BUILD_TARGET_CLI) { - cmd()->exec($this->getOption('upx-exec') . ' --best ' . escapeshellarg($src)); + cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($src)); } logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file'); diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 85d5e39c..cef61f99 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -10,6 +10,7 @@ use SPC\exception\WrongUsageException; use SPC\store\FileSystem; use SPC\store\SourcePatcher; use SPC\util\DependencyUtil; +use SPC\util\GlobalEnvManager; use SPC\util\LicenseDumper; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Input\InputArgument; @@ -117,7 +118,6 @@ class BuildCliCommand extends BuildCommand } if ($this->input->getOption('with-upx-pack') && in_array(PHP_OS_FAMILY, ['Linux', 'Windows'])) { $indent_texts['UPX Pack'] = 'enabled'; - $builder->setOption('upx-exec', FileSystem::convertPath(PKG_ROOT_PATH . '/bin/upx' . $suffix)); } try { $ver = $builder->getPHPVersion(); @@ -132,6 +132,7 @@ class BuildCliCommand extends BuildCommand $indent_texts['Extra Exts (' . count($not_included) . ')'] = implode(', ', $not_included); } $this->printFormatInfo($indent_texts); + $this->printFormatInfo($this->getDefinedEnvs(), true); logger()->notice('Build will start after 2s ...'); sleep(2); @@ -226,7 +227,18 @@ class BuildCliCommand extends BuildCommand return $rule; } - private function printFormatInfo(array $indent_texts): void + private function getDefinedEnvs(): array + { + $envs = GlobalEnvManager::getInitializedEnv(); + $final = []; + foreach ($envs as $env) { + $exp = explode('=', $env, 2); + $final['Init var [' . $exp[0] . ']'] = $exp[1]; + } + return $final; + } + + private function printFormatInfo(array $indent_texts, bool $debug = false): void { // calculate space count for every line $maxlen = 0; @@ -236,14 +248,14 @@ class BuildCliCommand extends BuildCommand foreach ($indent_texts as $k => $v) { if (is_string($v)) { /* @phpstan-ignore-next-line */ - logger()->info($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($v)); + logger()->{$debug ? 'debug' : 'info'}($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($v)); } elseif (is_array($v) && !is_assoc_array($v)) { $first = array_shift($v); /* @phpstan-ignore-next-line */ - logger()->info($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($first)); + logger()->{$debug ? 'debug' : 'info'}($k . ': ' . str_pad('', $maxlen - strlen($k)) . ConsoleColor::yellow($first)); foreach ($v as $vs) { /* @phpstan-ignore-next-line */ - logger()->info(str_pad('', $maxlen + 2) . ConsoleColor::yellow($vs)); + logger()->{$debug ? 'debug' : 'info'}(str_pad('', $maxlen + 2) . ConsoleColor::yellow($vs)); } } } diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php new file mode 100644 index 00000000..8753869c --- /dev/null +++ b/src/SPC/util/GlobalEnvManager.php @@ -0,0 +1,187 @@ + self::initWindowsEnv($builder), + 'Darwin' => self::initDarwinEnv($builder), + 'Linux' => self::initLinuxEnv($builder), + 'BSD' => 'TODO', + default => logger()->warning('Unknown OS: ' . PHP_OS_FAMILY), + }; + + // Init SPC env + self::initIfNotExists('SPC_CONCURRENCY', match (PHP_OS_FAMILY) { + 'Windows' => (string) WindowsSystemUtil::getCpuCount(), + 'Darwin' => (string) MacOSSystemUtil::getCpuCount(), + 'Linux' => (string) LinuxSystemUtil::getCpuCount(), + 'BSD' => (string) BSDSystemUtil::getCpuCount(), + default => '1', + }); + } + + private static function initWindowsEnv(BuilderBase $builder): void + { + // Windows need php-sdk binary tools + self::initIfNotExists('PHP_SDK_PATH', WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools'); + } + + private static function initLinuxEnv(BuilderBase $builder): void + { + // Init C Compiler and C++ Compiler (alpine) + if (\SPC\builder\linux\SystemUtil::isMuslDist()) { + self::initIfNotExists('CC', 'gcc'); + self::initIfNotExists('CXX', 'g++'); + self::initIfNotExists('AR', 'ar'); + self::initIfNotExists('LD', 'ld.gold'); + } else { + $arch = arch2gnu(php_uname('m')); + self::initIfNotExists('CC', "{$arch}-linux-musl-gcc"); + self::initIfNotExists('CXX', "{$arch}-linux-musl-g++"); + self::initIfNotExists('AR', "{$arch}-linux-musl-ar"); + self::initIfNotExists('LD', 'ld.gold'); + self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); + } + + // Init arch-specific cflags + self::initIfNotExists('SPC_DEFAULT_C_FLAGS', ''); + self::initIfNotExists('SPC_DEFAULT_CXX_FLAGS', ''); + self::initIfNotExists('SPC_EXTRA_LIBS', ''); + + // Init linux-only env + self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . '/bin/upx'); + self::initIfNotExists('GNU_ARCH', arch2gnu(php_uname('m'))); + + // optimization flags with different strip option + $php_extra_cflags_optimize = $builder->getOption('no-strip') ? '-g -O0' : '-g -Os'; + // optimization flags with different c compiler + $clang_use_lld = str_ends_with(getenv('CC'), 'clang') && LinuxSystemUtil::findCommand('lld') ? '-Xcompiler -fuse-ld=lld ' : ''; + + $init_spc_cmd_maps = [ + // Init default build command prefix + 'SPC_CMD_PREFIX_PHP_BUILDCONF' => './buildconf --force', + 'SPC_CMD_PREFIX_PHP_CONFIGURE' => $builder->getOption('ld_library_path') . ' ./configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg', + 'SPC_CMD_PREFIX_PHP_MAKE' => 'make -j' . getenv('SPC_CONCURRENCY'), + // Init default build vars for build command + 'SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS' => getenv('SPC_DEFAULT_C_FLAGS'), + 'SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, + 'SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS' => '-L' . BUILD_LIB_PATH, + 'SPC_CMD_VAR_PHP_CONFIGURE_LIBS' => '-ldl -lpthread', + 'SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS' => $php_extra_cflags_optimize . ' -fno-ident -fPIE', + 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS' => '', + 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM' => $clang_use_lld . '-all-static', + ]; + + foreach ($init_spc_cmd_maps as $name => $value) { + self::initIfNotExists($name, $value); + } + + self::initUnixEnv($builder); + } + + private static function initDarwinEnv(BuilderBase $builder): void + { + // Init C Compiler and C++ Compiler + self::initIfNotExists('CC', 'clang'); + self::initIfNotExists('CXX', 'clang++'); + + // Init arch-specific cflags + self::initIfNotExists('SPC_DEFAULT_C_FLAGS', match (php_uname('m')) { + 'arm64', 'aarch64' => '--target=arm64-apple-darwin', + default => '--target=x86_64-apple-darwin', + }); + // Init arch-specific cxxflags + self::initIfNotExists('SPC_DEFAULT_CXX_FLAGS', match (php_uname('m')) { + 'arm64', 'aarch64' => '--target=arm64-apple-darwin', + default => '--target=x86_64-apple-darwin', + }); + + // Init extra libs (will be appended before `before-php-buildconf` event point) + self::initIfNotExists('SPC_EXTRA_LIBS', ''); + + $init_spc_cmd_maps = [ + // Init default build command prefix + 'SPC_CMD_PREFIX_PHP_BUILDCONF' => './buildconf --force', + 'SPC_CMD_PREFIX_PHP_CONFIGURE' => './configure --prefix= --with-valgrind=no --enable-shared=no --enable-static=yes --disable-all --disable-cgi --disable-phpdbg', + 'SPC_CMD_PREFIX_PHP_MAKE' => 'make -j' . getenv('SPC_CONCURRENCY'), + // Init default build vars for build command + 'SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS' => getenv('SPC_DEFAULT_C_FLAGS') . ' -Werror=unknown-warning-option', + 'SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, + 'SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS' => '-L' . BUILD_LIB_PATH, + 'SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS' => $builder->getOption('no-strip') ? '-g -O0' : '-g -Os', + 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS' => '-lresolv', + ]; + foreach ($init_spc_cmd_maps as $name => $value) { + self::initIfNotExists($name, $value); + } + + self::initUnixEnv($builder); + } + + private static function initUnixEnv(BuilderBase $builder): void + { + self::putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); + self::putenv('PKG_CONFIG=' . BUILD_BIN_PATH . '/pkg-config'); + self::putenv('PKG_CONFIG_PATH=' . BUILD_ROOT_PATH . '/lib/pkgconfig'); + } + + /** + * Initialize the environment variable if it does not exist + * + * @param string $name Environment variable name + * @param string $value Environment variable value + */ + private static function initIfNotExists(string $name, string $value): void + { + if (($val = getenv($name)) === false) { + self::putenv($name . '=' . $value); + } else { + logger()->debug("env [{$name}] existing: {$val}"); + } + } + + private static function putenv(string $val): void + { + f_putenv($val); + self::$env_cache[] = $val; + } +} diff --git a/src/SPC/util/UnixShell.php b/src/SPC/util/UnixShell.php index 2c0ba5d1..d26425f4 100644 --- a/src/SPC/util/UnixShell.php +++ b/src/SPC/util/UnixShell.php @@ -62,7 +62,12 @@ class UnixShell public function setEnv(array $env): UnixShell { - $this->env = array_merge($this->env, $env); + foreach ($env as $k => $v) { + if ($v === '') { + continue; + } + $this->env[$k] = $v; + } return $this; } From 3a2683bb0c0027719d7f5795a9dbd6767d761511 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Apr 2024 16:26:21 +0800 Subject: [PATCH 268/415] fix LinuxBuilder with env manager --- src/SPC/builder/linux/LinuxBuilder.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b7abf159..2f509f1e 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -28,9 +28,6 @@ class LinuxBuilder extends UnixBuilderBase // check musl-cross make installed if we use musl-cross-make $arch = arch2gnu(php_uname('m')); - if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { - throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); - } // set library path, some libraries need it. (We cannot use `putenv` here, because cmake will be confused) $this->setOptionIfNotExist('library_path', "LIBRARY_PATH=/usr/local/musl/{$arch}-linux-musl/lib"); @@ -38,6 +35,10 @@ class LinuxBuilder extends UnixBuilderBase GlobalEnvManager::init($this); + if (str_ends_with(getenv('CC'), 'linux-musl-gcc') && !file_exists("/usr/local/musl/bin/{$arch}-linux-musl-gcc")) { + throw new WrongUsageException('musl-cross-make not installed, please install it first. (You can use `doctor` command to install it)'); + } + // concurrency $this->concurrency = intval(getenv('SPC_CONCURRENCY')); // cflags @@ -169,7 +170,6 @@ class LinuxBuilder extends UnixBuilderBase shell()->cd(SOURCE_PATH . '/php-src') ->exec( - "{$this->getOption('ld_library_path')} " . getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . ($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . @@ -314,7 +314,7 @@ class LinuxBuilder extends UnixBuilderBase { return [ 'EXTRA_CFLAGS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS'), - 'EXTRA_LIBS' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'), + 'EXTRA_LIBS' => getenv('SPC_EXTRA_LIBS') . ' ' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS'), 'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'), ]; } From 4d227ca7eff2bf4c9fde35c34bd2412b65f4702f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 7 Apr 2024 16:35:41 +0800 Subject: [PATCH 269/415] fix macOS build libpng error with old option mode --- src/SPC/builder/macos/library/libpng.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/macos/library/libpng.php b/src/SPC/builder/macos/library/libpng.php index b41f8510..39522a8c 100644 --- a/src/SPC/builder/macos/library/libpng.php +++ b/src/SPC/builder/macos/library/libpng.php @@ -35,7 +35,7 @@ class libpng extends MacOSLibraryBase */ protected function build(): void { - $optimizations = match ($this->builder->getOption('arch')) { + $optimizations = match (php_uname('m')) { 'x86_64' => '--enable-intel-sse ', 'arm64' => '--enable-arm-neon ', default => '', @@ -45,7 +45,7 @@ class libpng extends MacOSLibraryBase ->exec('chmod +x ./install-sh') ->exec( './configure ' . - "--host={$this->builder->getOption('gnu-arch')}-apple-darwin " . + '--host=' . arch2gnu(php_uname('m')) . '-apple-darwin ' . '--disable-shared ' . '--enable-static ' . '--enable-hardware-optimizations ' . From 21dbb8af4679132de71bbe32660e4af55bae3ec2 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 8 Apr 2024 15:34:07 +0800 Subject: [PATCH 270/415] change SPC_CONCURRENCT order --- src/SPC/util/GlobalEnvManager.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 8753869c..72bc937f 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -40,15 +40,6 @@ class GlobalEnvManager self::putenv('SOURCE_PATH=' . SOURCE_PATH); self::putenv('DOWNLOAD_PATH=' . DOWNLOAD_PATH); - // Init system-specific env - match (PHP_OS_FAMILY) { - 'Windows' => self::initWindowsEnv($builder), - 'Darwin' => self::initDarwinEnv($builder), - 'Linux' => self::initLinuxEnv($builder), - 'BSD' => 'TODO', - default => logger()->warning('Unknown OS: ' . PHP_OS_FAMILY), - }; - // Init SPC env self::initIfNotExists('SPC_CONCURRENCY', match (PHP_OS_FAMILY) { 'Windows' => (string) WindowsSystemUtil::getCpuCount(), @@ -57,6 +48,15 @@ class GlobalEnvManager 'BSD' => (string) BSDSystemUtil::getCpuCount(), default => '1', }); + + // Init system-specific env + match (PHP_OS_FAMILY) { + 'Windows' => self::initWindowsEnv($builder), + 'Darwin' => self::initDarwinEnv($builder), + 'Linux' => self::initLinuxEnv($builder), + 'BSD' => 'TODO', + default => logger()->warning('Unknown OS: ' . PHP_OS_FAMILY), + }; } private static function initWindowsEnv(BuilderBase $builder): void From 6b96feb538b55ac7223813c22448d0546cc8e4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Mon, 22 Apr 2024 09:58:08 +0200 Subject: [PATCH 271/415] fix: use C++ 17 compiler for ICU (#414) * fix: use C++ 17 compiler for ICU * wip * hack CXX env var to force C++17 * test intl * test intl * add retry for CI test download * patch * separate intl with newer icu c++ patch --------- Co-authored-by: crazywhalecc --- .github/workflows/tests.yml | 2 +- src/SPC/builder/extension/intl.php | 26 ++++++++++++++++++++++++++ src/SPC/builder/linux/library/icu.php | 2 +- src/globals/test-extensions.php | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 src/SPC/builder/extension/intl.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2eda9ad3..83ae9cc9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -165,7 +165,7 @@ jobs: max_attempts: 3 retry_on: error command: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug + bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3 - name: "Run Build Tests (build)" run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug diff --git a/src/SPC/builder/extension/intl.php b/src/SPC/builder/extension/intl.php new file mode 100644 index 00000000..8130b5d3 --- /dev/null +++ b/src/SPC/builder/extension/intl.php @@ -0,0 +1,26 @@ +cd($this->source_dir . '/source') ->exec( diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index c7127f0d..3aae34b1 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'uuid', + 'Linux', 'Darwin' => 'intl,posix', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; From 1a87ce41944f1e897ca98eaeb5b2683db53c6fbc Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 25 Apr 2024 15:55:08 +0800 Subject: [PATCH 272/415] Fix windows nghttp2 dynamic linking bug (#422) * fix windows nghttp2 dynamic linking bug * add tests for fixing windows nghttp2 dynamic linking bug --- src/SPC/builder/windows/library/nghttp2.php | 2 ++ src/globals/test-extensions.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/SPC/builder/windows/library/nghttp2.php b/src/SPC/builder/windows/library/nghttp2.php index 85332202..7e6e999d 100644 --- a/src/SPC/builder/windows/library/nghttp2.php +++ b/src/SPC/builder/windows/library/nghttp2.php @@ -25,6 +25,8 @@ class nghttp2 extends WindowsLibraryBase '-DCMAKE_BUILD_TYPE=Release ' . '-DENABLE_SHARED_LIB=OFF ' . '-DENABLE_STATIC_LIB=ON ' . + '-DBUILD_STATIC_LIBS=ON ' . + '-DBUILD_SHARED_LIBS=OFF ' . '-DENABLE_STATIC_CRT=ON ' . '-DENABLE_LIB_ONLY=ON ' . '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 3aae34b1..4c91a420 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,7 +14,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'intl,posix', - 'Windows' => 'mbstring,pdo_sqlite,mbregex', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,curl', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From b14894fab7e7e44bedc96010fd79afd565ba9fe6 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 25 Apr 2024 16:48:31 +0800 Subject: [PATCH 273/415] Fix windows UPX_EXEC env var missing (#423) --- src/SPC/util/GlobalEnvManager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 72bc937f..2c65075f 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -63,6 +63,7 @@ class GlobalEnvManager { // Windows need php-sdk binary tools self::initIfNotExists('PHP_SDK_PATH', WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools'); + self::initIfNotExists('UPX_EXEC', PKG_ROOT_PATH . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'upx.exe'); } private static function initLinuxEnv(BuilderBase $builder): void From aaa4510f25307fd4d3fae2bc70cd7ea6c9f0cffb Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 26 Apr 2024 11:00:33 +0800 Subject: [PATCH 274/415] Fix linux imagick openmp linking issue (#424) --- src/SPC/builder/extension/imagick.php | 6 +++--- src/SPC/builder/unix/library/imagemagick.php | 2 +- src/globals/test-extensions.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SPC/builder/extension/imagick.php b/src/SPC/builder/extension/imagick.php index d7721a24..7becb143 100644 --- a/src/SPC/builder/extension/imagick.php +++ b/src/SPC/builder/extension/imagick.php @@ -14,11 +14,11 @@ class imagick extends Extension public function patchBeforeMake(): bool { // imagick may call omp_pause_all which requires -lgomp - $extra_libs = $this->builder->getOption('extra-libs', ''); + $extra_libs = getenv('SPC_EXTRA_LIBS') ?: ''; if ($this->builder instanceof LinuxBuilder) { - $extra_libs .= ' -lgomp '; + $extra_libs .= (empty($extra_libs) ? '' : ' ') . '-lgomp '; } - $this->builder->setOption('extra-libs', $extra_libs); + 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 ac011e5f..ed08c667 100644 --- a/src/SPC/builder/unix/library/imagemagick.php +++ b/src/SPC/builder/unix/library/imagemagick.php @@ -19,7 +19,7 @@ trait imagemagick protected function build(): void { // TODO: imagemagick build with bzip2 failed with bugs, we need to fix it in the future - $extra = '--without-jxl --without-x --disable-openmp --without-bzlib '; + $extra = '--without-jxl --without-x --enable-openmp --without-bzlib '; $required_libs = ''; $optional_libs = [ 'libzip' => 'zip', diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 4c91a420..a94d50e4 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'intl,posix', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,curl', + 'Linux', 'Darwin' => 'imagick', + 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From d98d6aeffb347dceb8ed50a0ecec3ae4b530275a Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 26 Apr 2024 16:03:03 +0800 Subject: [PATCH 275/415] Fix FreeBSD pkg-config linking issue (#426) --- src/SPC/builder/unix/library/pkgconfig.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SPC/builder/unix/library/pkgconfig.php b/src/SPC/builder/unix/library/pkgconfig.php index 80510157..ca93fd25 100644 --- a/src/SPC/builder/unix/library/pkgconfig.php +++ b/src/SPC/builder/unix/library/pkgconfig.php @@ -8,8 +8,8 @@ trait pkgconfig { protected function build(): void { - $cflags = PHP_OS_FAMILY === 'Darwin' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : ''; - $ldflags = PHP_OS_FAMILY === 'Darwin' ? '' : '--static'; + $cflags = PHP_OS_FAMILY !== 'Linux' ? "{$this->builder->arch_c_flags} -Wimplicit-function-declaration -Wno-int-conversion" : ''; + $ldflags = PHP_OS_FAMILY !== 'Linux' ? '' : '--static'; shell()->cd($this->source_dir) ->setEnv(['CFLAGS' => $this->getLibExtraCFlags() ?: $cflags, 'LDFLAGS' => $this->getLibExtraLdFlags() ?: $ldflags, 'LIBS' => $this->getLibExtraLibs()]) From 7a8e0a7e67e2261297d4d400a8800c9c67ecaa19 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 29 Apr 2024 02:12:03 +0100 Subject: [PATCH 276/415] Fix Intel Mac build action (#427) * Fix Intel Mac build action * Use x64 build server * Use macos-13 runner --- .github/workflows/build-macos-x86_64.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index a942a39f..a36a4f4c 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -37,7 +37,7 @@ env: jobs: build: name: build ${{ inputs.version }} on macOS x86_64 - runs-on: macos-latest + runs-on: macos-13 steps: - uses: actions/checkout@v3 @@ -46,6 +46,14 @@ jobs: brew install automake gzip echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + tools: pecl, composer + extensions: curl, openssl, mbstring, tokenizer + ini-values: memory_limit=-1 + # Cache composer dependencies - id: cache-composer-deps uses: actions/cache@v3 From 15c2935d48cff8153064ea69e24d27b070f7bdd8 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 29 Apr 2024 14:24:47 +0100 Subject: [PATCH 277/415] Update actions (#428) * Update action versions * Use same dependency cache key naming logic Bring consistency across the whole pipeline --- .github/workflows/build-linux-arm.yml | 32 +++++++++++++++++------ .github/workflows/build-linux-x86_64.yml | 23 +++++++++------- .github/workflows/build-macos-aarch64.yml | 23 +++++++++------- .github/workflows/build-macos-x86_64.yml | 23 +++++++++------- 4 files changed, 66 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-linux-arm.yml b/.github/workflows/build-linux-arm.yml index 1a062727..20f17fb9 100644 --- a/.github/workflows/build-linux-arm.yml +++ b/.github/workflows/build-linux-arm.yml @@ -45,14 +45,30 @@ jobs: name: build ${{ inputs.version }} on ${{ inputs.operating-system }} runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + # Cache composer dependencies + - id: cache-composer-deps + uses: actions/cache@v4 + with: + path: vendor + key: composer-dependencies + + # If there's no Composer cache, install dependencies + - if: steps.cache-composer-deps.outputs.cache-hit != 'true' + run: composer update --no-dev --classmap-authoritative + + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV # Cache downloaded source - id: cache-download - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true @@ -75,31 +91,31 @@ jobs: # Upload cli executable - if: ${{ inputs.build-cli == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-${{ inputs.version }}-linux-${{ inputs.operating-system }} path: buildroot/bin/php # Upload micro self-extracted executable - if: ${{ inputs.build-micro == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: micro-${{ inputs.version }}-linux-${{ inputs.operating-system }} path: buildroot/bin/micro.sfx # Upload fpm executable - if: ${{ inputs.build-fpm == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-fpm-${{ inputs.version }}-linux-${{ inputs.operating-system }} path: buildroot/bin/php-fpm # Upload extensions metadata - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: license-files path: buildroot/license/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: build-meta path: | diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index 91803677..262eb930 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -39,11 +39,11 @@ jobs: name: build ${{ inputs.version }} on Linux x86_64 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Cache composer dependencies - id: cache-composer-deps - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: composer-dependencies @@ -52,12 +52,17 @@ jobs: - if: steps.cache-composer-deps.outputs.cache-hit != 'true' run: composer update --no-dev --classmap-authoritative + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true @@ -80,31 +85,31 @@ jobs: # Upload cli executable - if: ${{ inputs.build-cli == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/php # Upload micro self-extracted executable - if: ${{ inputs.build-micro == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/micro.sfx # Upload fpm executable - if: ${{ inputs.build-fpm == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/php-fpm # Upload extensions metadata - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: license-files path: buildroot/license/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: build-meta path: | diff --git a/.github/workflows/build-macos-aarch64.yml b/.github/workflows/build-macos-aarch64.yml index f43b1ab5..591b2ad4 100644 --- a/.github/workflows/build-macos-aarch64.yml +++ b/.github/workflows/build-macos-aarch64.yml @@ -39,7 +39,7 @@ jobs: name: build ${{ inputs.version }} on macOS arm64 runs-on: macos-14 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Install macOS missing packages and mark os suffix - run: | @@ -58,7 +58,7 @@ jobs: # Cache composer dependencies - id: cache-composer-deps - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: composer-dependencies @@ -67,12 +67,17 @@ jobs: - if: steps.cache-composer-deps.outputs.cache-hit != 'true' run: composer update --no-dev --classmap-authoritative + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true @@ -95,31 +100,31 @@ jobs: # Upload cli executable - if: ${{ inputs.build-cli == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/php # Upload micro self-extracted executable - if: ${{ inputs.build-micro == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/micro.sfx # Upload fpm executable - if: ${{ inputs.build-fpm == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/php-fpm # Upload extensions metadata - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: license-files path: buildroot/license/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: build-meta path: | diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index a36a4f4c..5f753988 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -39,7 +39,7 @@ jobs: name: build ${{ inputs.version }} on macOS x86_64 runs-on: macos-13 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Install macOS missing packages and mark os suffix - run: | @@ -56,7 +56,7 @@ jobs: # Cache composer dependencies - id: cache-composer-deps - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: composer-dependencies @@ -65,12 +65,17 @@ jobs: - if: steps.cache-composer-deps.outputs.cache-hit != 'true' run: composer update --no-dev --classmap-authoritative + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true @@ -93,31 +98,31 @@ jobs: # Upload cli executable - if: ${{ inputs.build-cli == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/php # Upload micro self-extracted executable - if: ${{ inputs.build-micro == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: micro-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/micro.sfx # Upload fpm executable - if: ${{ inputs.build-fpm == true }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: php-fpm-${{ inputs.version }}-${{ env.SPC_BUILD_OS }} path: buildroot/bin/php-fpm # Upload extensions metadata - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: license-files path: buildroot/license/ - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: build-meta path: | From 3ecc603770701ce3c318338be05ea0655ba820be Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 30 Apr 2024 13:57:44 +0800 Subject: [PATCH 278/415] Fix ncurses pkg-config bug temporarily (#432) * Fix ncurses pkg-config bug temporarily * Add tests --- config/source.json | 10 +++++++--- src/globals/test-extensions.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/source.json b/config/source.json index 9d5fb36e..d8aa9b84 100644 --- a/config/source.json +++ b/config/source.json @@ -480,9 +480,13 @@ } }, "ncurses": { - "type": "filelist", - "url": "https://ftp.gnu.org/pub/gnu/ncurses/", - "regex": "/href=\"(?ncurses-(?[^\"]+)\\.tar\\.gz)\"/", + "alt": { + "type": "filelist", + "url": "https://ftp.gnu.org/pub/gnu/ncurses/", + "regex": "/href=\"(?ncurses-(?[^\"]+)\\.tar\\.gz)\"/" + }, + "type": "url", + "url": "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.4.tar.gz", "license": { "type": "file", "path": "COPYING" diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index a94d50e4..aeed4c94 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,7 +13,7 @@ declare(strict_types=1); // 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' => 'readline', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; From 30af182aff0c07b0e6a42fd92c578d17aaa26e36 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Mon, 6 May 2024 04:59:02 +0100 Subject: [PATCH 279/415] Windows build GitHub Action (#420) * Create build-windows-x86_64.yml * Update build-windows-x86_64.yml * Fix CLI param * Fix env writing in Powershell * Run doctor first, per docs * Fix file paths * Generate an acceptable cache key * Change shell * Improve cache key generation * Update upload-artifact action * Update actions * Attempt to fix cache key storage * Remove FPM build option --- .github/workflows/build-windows-x86_64.yml | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/build-windows-x86_64.yml diff --git a/.github/workflows/build-windows-x86_64.yml b/.github/workflows/build-windows-x86_64.yml new file mode 100644 index 00000000..e6665d66 --- /dev/null +++ b/.github/workflows/build-windows-x86_64.yml @@ -0,0 +1,108 @@ +name: CI on x86_64 Windows + +on: + workflow_dispatch: + inputs: + version: + required: true + description: php version to compile + default: '8.2' + type: choice + options: + - '8.3' + - '8.2' + - '8.1' + - '8.0' + - '7.4' + build-cli: + description: build cli binary + default: true + type: boolean + build-micro: + description: build phpmicro binary + type: boolean + extensions: + description: extensions to compile (comma separated) + required: true + type: string + debug: + type: boolean + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: build ${{ inputs.version }} on Windows x86_64 + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + # Cache composer dependencies + - id: cache-composer-deps + uses: actions/cache@v4 + with: + path: vendor + key: composer-dependencies + + # If there's no Composer cache, install dependencies + - if: steps.cache-composer-deps.outputs.cache-hit != 'true' + run: composer update --no-dev --classmap-authoritative + + - name: Generate hashed key for download cache + shell: bash + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> "$GITHUB_ENV" + + # Cache downloaded source + - id: cache-download + uses: actions/cache@v4 + with: + path: downloads + key: php-${{ env.INPUT_HASH }} + + # With or without debug + - if: inputs.debug == true + run: echo "SPC_BUILD_DEBUG=--debug" >> $env:GITHUB_ENV + + # With target select: cli, micro or both + - if: ${{ inputs.build-cli == true }} + run: echo "SPC_BUILD_CLI=--build-cli" >> $env:GITHUB_ENV + - if: ${{ inputs.build-micro == true }} + run: echo "SPC_BUILD_MICRO=--build-micro" >> $env:GITHUB_ENV + + - run: ./bin/spc doctor + + # If there's no dependencies cache, fetch sources, with or without debug + - if: steps.cache-download.outputs.cache-hit != 'true' + run: ./bin/spc download --with-php="${{ inputs.version }}" --for-extensions="${{ inputs.extensions }}" ${{ env.SPC_BUILD_DEBUG }} + + # Run build command + - run: ./bin/spc build "${{ inputs.extensions }}" ${{ env.SPC_BUILD_DEBUG }} ${{ env.SPC_BUILD_CLI }} ${{ env.SPC_BUILD_MICRO }} ${{ env.SPC_BUILD_FPM }} + + # Upload cli executable + - if: ${{ inputs.build-cli == true }} + uses: actions/upload-artifact@v4 + with: + name: php-${{ inputs.version }} + path: buildroot/bin/php.exe + + # Upload micro self-extracted executable + - if: ${{ inputs.build-micro == true }} + uses: actions/upload-artifact@v4 + with: + name: micro-${{ inputs.version }} + path: buildroot/bin/micro.sfx + + # Upload extensions metadata + - uses: actions/upload-artifact@v4 + with: + name: license-files + path: buildroot/license/ + - uses: actions/upload-artifact@v4 + with: + name: build-meta + path: | + buildroot/build-extensions.json + buildroot/build-libraries.json From e1e6270d86e8d677da2578273222593dfa60204f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 6 May 2024 12:08:35 +0800 Subject: [PATCH 280/415] update README --- README-zh.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README-zh.md b/README-zh.md index 586bca67..2a26b156 100755 --- a/README-zh.md +++ b/README-zh.md @@ -66,7 +66,7 @@ static-php-cli(简称 `spc`)有许多特性: |---------|----------------------|----------------------| | macOS | :octocat: :computer: | :octocat: :computer: | | Linux | :octocat: :computer: | :octocat: :computer: | -| Windows | :computer: | | +| Windows | :octocat: :computer: | | | FreeBSD | :computer: | :computer: | 当前支持编译的 PHP 版本: diff --git a/README.md b/README.md index 4f42756d..7d423681 100755 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Here is the supported OS and arch, where :octocat: represents support for GitHub |---------|----------------------|----------------------| | macOS | :octocat: :computer: | :octocat: :computer: | | Linux | :octocat: :computer: | :octocat: :computer: | -| Windows | :computer: | | +| Windows | :octocat: :computer: | | | FreeBSD | :computer: | :computer: | Currently supported PHP versions for compilation: From 69e6d82e83dfe0f0fbe28cc7ec810bca6d1d0fda Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 6 May 2024 12:32:43 +0800 Subject: [PATCH 281/415] add linux env var: SPC_NO_MUSL_PATH (#437) --- src/SPC/util/GlobalEnvManager.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 2c65075f..0c5a0c1a 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -80,7 +80,9 @@ class GlobalEnvManager self::initIfNotExists('CXX', "{$arch}-linux-musl-g++"); self::initIfNotExists('AR', "{$arch}-linux-musl-ar"); self::initIfNotExists('LD', 'ld.gold'); - self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); + if (getenv('SPC_NO_MUSL_PATH') !== 'yes') { + self::putenv("PATH=/usr/local/musl/bin:/usr/local/musl/{$arch}-linux-musl/bin:" . getenv('PATH')); + } } // Init arch-specific cflags @@ -106,12 +108,11 @@ class GlobalEnvManager 'SPC_CMD_VAR_PHP_CONFIGURE_CFLAGS' => getenv('SPC_DEFAULT_C_FLAGS'), 'SPC_CMD_VAR_PHP_CONFIGURE_CPPFLAGS' => '-I' . BUILD_INCLUDE_PATH, 'SPC_CMD_VAR_PHP_CONFIGURE_LDFLAGS' => '-L' . BUILD_LIB_PATH, - 'SPC_CMD_VAR_PHP_CONFIGURE_LIBS' => '-ldl -lpthread', + 'SPC_CMD_VAR_PHP_CONFIGURE_LIBS' => '-ldl -lpthread -lm', 'SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS' => $php_extra_cflags_optimize . ' -fno-ident -fPIE', 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LIBS' => '', 'SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM' => $clang_use_lld . '-all-static', ]; - foreach ($init_spc_cmd_maps as $name => $value) { self::initIfNotExists($name, $value); } From 0fee62884281a2976d164abc2f766583c0e9f26a Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 6 May 2024 12:55:38 +0800 Subject: [PATCH 282/415] Fix xz build on macOS and Linux (#438) * fix xz build * add xz tests --- src/SPC/builder/macos/library/xz.php | 16 ---------------- src/SPC/builder/unix/library/xz.php | 1 - src/globals/test-extensions.php | 4 ++-- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/src/SPC/builder/macos/library/xz.php b/src/SPC/builder/macos/library/xz.php index d656e35e..2719e9c9 100644 --- a/src/SPC/builder/macos/library/xz.php +++ b/src/SPC/builder/macos/library/xz.php @@ -1,20 +1,4 @@ - * - * lwmbs is licensed under Mulan PSL v2. You can use this - * software according to the terms and conditions of the - * Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, - * WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * - * See the Mulan PSL v2 for more details. - */ declare(strict_types=1); diff --git a/src/SPC/builder/unix/library/xz.php b/src/SPC/builder/unix/library/xz.php index 7cd7e74b..1869f589 100644 --- a/src/SPC/builder/unix/library/xz.php +++ b/src/SPC/builder/unix/library/xz.php @@ -20,7 +20,6 @@ trait xz './configure ' . '--enable-static ' . '--disable-shared ' . - "--host={$this->builder->getOption('gnu-arch')}-unknown-linux " . '--disable-scripts ' . '--disable-doc ' . '--with-libiconv ' . diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index aeed4c94..2650d7a8 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'readline', + 'Linux', 'Darwin' => 'curl', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // 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' => 'xz', 'Windows' => '', }; From 954f8f4ddcdf43bc4ff06b0c14cf5581d7f74dbf Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 6 May 2024 14:11:50 +0800 Subject: [PATCH 283/415] fix ncurses 6.5 build (#439) --- config/source.json | 10 +++------- src/SPC/builder/unix/library/ncurses.php | 2 +- src/globals/test-extensions.php | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/config/source.json b/config/source.json index d8aa9b84..9d5fb36e 100644 --- a/config/source.json +++ b/config/source.json @@ -480,13 +480,9 @@ } }, "ncurses": { - "alt": { - "type": "filelist", - "url": "https://ftp.gnu.org/pub/gnu/ncurses/", - "regex": "/href=\"(?ncurses-(?[^\"]+)\\.tar\\.gz)\"/" - }, - "type": "url", - "url": "https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.4.tar.gz", + "type": "filelist", + "url": "https://ftp.gnu.org/pub/gnu/ncurses/", + "regex": "/href=\"(?ncurses-(?[^\"]+)\\.tar\\.gz)\"/", "license": { "type": "file", "path": "COPYING" diff --git a/src/SPC/builder/unix/library/ncurses.php b/src/SPC/builder/unix/library/ncurses.php index 41bad41b..29a80885 100644 --- a/src/SPC/builder/unix/library/ncurses.php +++ b/src/SPC/builder/unix/library/ncurses.php @@ -17,7 +17,7 @@ trait ncurses '--with-curses-h ' . '--enable-pc-files ' . '--enable-echo ' . - // '--enable-widec ' . + '--disable-widec ' . '--with-normal ' . '--with-ticlib ' . '--without-tests ' . diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 2650d7a8..96001af2 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'curl', + 'Linux', 'Darwin' => 'readline,pgsql,xml,dom,mbstring,mbregex,pdo_pgsql', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // 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' => 'xz', + 'Linux', 'Darwin' => '', 'Windows' => '', }; @@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'none', 'Windows' => 'none', }; From bde18054e5fcad82f5dbc3d1e3a97dcc84f0ec7c Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 6 May 2024 14:12:40 +0800 Subject: [PATCH 284/415] Fix micro upx compress bug (#440) * triple compression for micro with upx * place debug info first --- src/SPC/builder/linux/LinuxBuilder.php | 12 +++++ src/SPC/command/BuildCliCommand.php | 2 +- src/globals/extra/micro-triple-Makefile.frag | 51 ++++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/globals/extra/micro-triple-Makefile.frag diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index 2f509f1e..b191440c 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -145,7 +145,19 @@ class LinuxBuilder extends UnixBuilderBase ]); // upx pack and strip for micro + // but always restore Makefile.frag.bak first + if (file_exists(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak')) { + copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'); + } if ($this->getOption('with-upx-pack', false)) { + // judge $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` count + // if 2, replace src/globals/extra/micro-triple-Makefile.frag file content + if (substr_count(FileSystem::readFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'), '$(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)`') === 2) { + // bak first + copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak'); + // replace Makefile.frag content + FileSystem::writeFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', FileSystem::readFile(ROOT_DIR . '/src/globals/extra/micro-triple-Makefile.frag')); + } // with upx pack always need strip FileSystem::replaceFileRegex( SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index cef61f99..478cc883 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -131,8 +131,8 @@ class BuildCliCommand extends BuildCommand if (!empty($not_included)) { $indent_texts['Extra Exts (' . count($not_included) . ')'] = implode(', ', $not_included); } - $this->printFormatInfo($indent_texts); $this->printFormatInfo($this->getDefinedEnvs(), true); + $this->printFormatInfo($indent_texts); logger()->notice('Build will start after 2s ...'); sleep(2); diff --git a/src/globals/extra/micro-triple-Makefile.frag b/src/globals/extra/micro-triple-Makefile.frag new file mode 100644 index 00000000..45a250cc --- /dev/null +++ b/src/globals/extra/micro-triple-Makefile.frag @@ -0,0 +1,51 @@ + +micro: $(SAPI_MICRO_PATH) + +micro_2s_objs: + rm $(MICRO_2STAGE_OBJS) || : + $(MAKE) $(MICRO_2STAGE_OBJS) + +EXTRA_MICRO_BUILD_COMMANDS= +POST_MICRO_BUILD_COMMANDS=$(STRIP) $(MICRO_STRIP_FLAGS) $(SAPI_MICRO_PATH) + +$(SAPI_MICRO_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_MICRO_OBJS) + $(MAKE) micro_2s_objs SFX_FILESIZE=0xcafebabe + $(BUILD_MICRO) + $(EXTRA_MICRO_BUILD_COMMANDS) + $(POST_MICRO_BUILD_COMMANDS) + $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` + $(BUILD_MICRO) + $(EXTRA_MICRO_BUILD_COMMANDS) + $(POST_MICRO_BUILD_COMMANDS) + $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` + $(BUILD_MICRO) + $(EXTRA_MICRO_BUILD_COMMANDS) + $(POST_MICRO_BUILD_COMMANDS) + $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` + $(BUILD_MICRO) + $(EXTRA_MICRO_BUILD_COMMANDS) + $(POST_MICRO_BUILD_COMMANDS) + +MICRO_EXES = sapi/micro/tests/simpleecho.exe sapi/micro/tests/fakecmd.exe + +$(MICRO_EXES): $(SAPI_MICRO_PATH) + @binname=$@;\ + cat $(SAPI_MICRO_PATH) $${binname%.exe}.php > $@ || {\ + rm $@; \ + exit 1; \ + } + @chmod 0755 $@ + +MICRO_FAKECMD=sapi/micro/tests/fakecmd.exe + +micro_test: $(SAPI_MICRO_PATH) $(MICRO_EXES) + @[ x"hello world" = "x`sapi/micro/tests/simpleecho.exe nonce world`" ] || {\ + echo sanity check for micro.sfx failed, the sfx generated may be corrupt. >&2 ;\ + exit 1;\ + } + @SKIP_IO_CAPTURE_TESTS=yes \ + TEST_PHP_EXECUTABLE=$(MICRO_FAKECMD) \ + TEST_PHP_SRCDIR=$(top_srcdir) \ + CC="$(CC)" \ + $(MICRO_FAKECMD) -n $(PHP_TEST_SETTINGS) $(top_srcdir)/run-tests.php -n $(TESTS); \ + exit $$?; From 7416b8079b1c93451bdb7c92719b12d3c2f24d11 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 6 May 2024 14:23:32 +0800 Subject: [PATCH 285/415] Fix dependency util suggest calculate bug (#441) * fix dependency util suggest calculate bug * fix dependency util suggest calculate bug --- src/SPC/util/DependencyUtil.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/SPC/util/DependencyUtil.php b/src/SPC/util/DependencyUtil.php index e82a93dc..a4d76ddb 100644 --- a/src/SPC/util/DependencyUtil.php +++ b/src/SPC/util/DependencyUtil.php @@ -62,12 +62,17 @@ class DependencyUtil if ($include_suggested_libs) { foreach ($dep_list as $name => $obj) { + $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (!str_starts_with($suggest, 'ext@')) { $dep_list[$name]['depends'][] = $suggest; - array_splice($dep_list[$name]['suggests'], $id, 1); + $del_list[] = $id; } } + foreach ($del_list as $id) { + unset($dep_list[$name]['suggests'][$id]); + } + $dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']); } } @@ -93,12 +98,17 @@ class DependencyUtil if ($include_suggested_exts) { // check every deps suggests contains ext@ foreach ($dep_list as $name => $obj) { + $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (str_starts_with($suggest, 'ext@')) { $dep_list[$name]['depends'][] = $suggest; - array_splice($dep_list[$name]['suggests'], $id, 1); + $del_list[] = $id; } } + foreach ($del_list as $id) { + unset($dep_list[$name]['suggests'][$id]); + } + $dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']); } } @@ -106,12 +116,17 @@ class DependencyUtil if ($include_suggested_libs) { // check every deps suggests foreach ($dep_list as $name => $obj) { + $del_list = []; foreach ($obj['suggests'] as $id => $suggest) { if (!str_starts_with($suggest, 'ext@')) { $dep_list[$name]['depends'][] = $suggest; - array_splice($dep_list[$name]['suggests'], $id, 1); + $del_list[] = $id; } } + foreach ($del_list as $id) { + unset($dep_list[$name]['suggests'][$id]); + } + $dep_list[$name]['suggests'] = array_values($dep_list[$name]['suggests']); } } From 3fcb7ebf03acc3dd6e8581beba2e78280177d205 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 6 May 2024 14:25:24 +0800 Subject: [PATCH 286/415] update spc binary php version --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index d3b2b2be..62099e08 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -17,7 +17,7 @@ jobs: php-version: - "8.2" micro-version: - - "8.2.16" + - "8.2.18" operating-system: - "linux-x86_64" - "macos-x86_64" From e6c308c24275a30a173b2e5cb4bcda1dfdccf09d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 6 May 2024 15:52:55 +0800 Subject: [PATCH 287/415] imap ext fix --- config/ext.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index f4c6ecbe..59ba89f4 100644 --- a/config/ext.json +++ b/config/ext.json @@ -173,7 +173,7 @@ "lib-depends": [ "imap" ], - "lib-suggests": [ + "ext-suggests": [ "openssl" ] }, From 1632c252232eadf6da1d7d1a095621c15ad60d8f Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Sat, 11 May 2024 14:46:36 +0800 Subject: [PATCH 288/415] Add extension parallel support (#444) * Add extension parallel support * add parallel windows support * add parallel test * add zts limit for parallel * sort config * add parallel test * add dev-php test * use macos-13 instead of macos-latest * revert dev-php tests --- .github/workflows/tests.yml | 4 +-- config/ext.json | 13 +++++++++ config/lib.json | 6 ++++ config/source.json | 19 ++++++++++++ src/SPC/builder/extension/parallel.php | 21 ++++++++++++++ .../builder/windows/library/pthreads4w.php | 29 +++++++++++++++++++ src/globals/test-extensions.php | 9 ++++-- src/globals/tests/parallel.php | 5 ++++ 8 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 src/SPC/builder/extension/parallel.php create mode 100644 src/SPC/builder/windows/library/pthreads4w.php create mode 100644 src/globals/tests/parallel.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83ae9cc9..f1d07663 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -113,7 +113,7 @@ jobs: - "8.3" os: - ubuntu-latest - - macos-latest + - macos-13 - windows-latest - macos-14 fail-fast: false @@ -168,4 +168,4 @@ jobs: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3 - name: "Run Build Tests (build)" - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug + run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug diff --git a/config/ext.json b/config/ext.json index 59ba89f4..8886dd54 100644 --- a/config/ext.json +++ b/config/ext.json @@ -187,6 +187,11 @@ "icu" ] }, + "parallel": { + "type": "external", + "source": "parallel", + "arg-type-windows": "with" + }, "ldap": { "type": "builtin", "arg-type": "with-prefix", @@ -280,6 +285,14 @@ "zlib" ] }, + "parallel": { + "type": "external", + "source": "parallel", + "arg-type-windows": "with", + "lib-depends-windows": [ + "pthreads4w" + ] + }, "password-argon2": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/lib.json b/config/lib.json index b7a92d04..d2364a3a 100644 --- a/config/lib.json +++ b/config/lib.json @@ -528,6 +528,12 @@ "zstd" ] }, + "pthreads4w": { + "source": "pthreads4w", + "static-libs-windows": [ + "libpthreadVC3.lib" + ] + }, "qdbm": { "source": "qdbm", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 9d5fb36e..b666ca6c 100644 --- a/config/source.json +++ b/config/source.json @@ -515,6 +515,16 @@ "path": "LICENSE.txt" } }, + "parallel": { + "type": "url", + "url": "https://pecl.php.net/get/parallel", + "path": "php-src/ext/parallel", + "filename": "parallel.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "pdo_sqlsrv": { "type": "url", "url": "https://pecl.php.net/get/pdo_sqlsrv", @@ -551,6 +561,15 @@ "path": "LICENSE" } }, + "pthreads4w": { + "type": "git", + "rev": "master", + "url": "https://git.code.sf.net/p/pthreads4w/code", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "qdbm": { "type": "git", "url": "https://github.com/static-php/qdbm.git", diff --git a/src/SPC/builder/extension/parallel.php b/src/SPC/builder/extension/parallel.php new file mode 100644 index 00000000..8fdf1824 --- /dev/null +++ b/src/SPC/builder/extension/parallel.php @@ -0,0 +1,21 @@ +builder->getOption('enable-zts')) { + throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!'); + } + return parent::getConfigureArg(); // TODO: Change the autogenerated stub + } +} diff --git a/src/SPC/builder/windows/library/pthreads4w.php b/src/SPC/builder/windows/library/pthreads4w.php new file mode 100644 index 00000000..66707cbb --- /dev/null +++ b/src/SPC/builder/windows/library/pthreads4w.php @@ -0,0 +1,29 @@ +cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper( + 'nmake /E /nologo /f Makefile ' . + 'DESTROOT=' . BUILD_ROOT_PATH . ' ' . + 'XCFLAGS="/MT" ' . // no dll + 'EHFLAGS="/I. /DHAVE_CONFIG_H /Os /Ob2 /D__PTW32_STATIC_LIB /D__PTW32_BUILD_INLINED"' + ), + 'pthreadVC3.inlined_static_stamp' + ); + copy($this->source_dir . '\libpthreadVC3.lib', BUILD_LIB_PATH . '\libpthreadVC3.lib'); + copy($this->source_dir . '\_ptw32.h', BUILD_INCLUDE_PATH . '\_ptw32.h'); + copy($this->source_dir . '\pthread.h', BUILD_INCLUDE_PATH . '\pthread.h'); + copy($this->source_dir . '\sched.h', BUILD_INCLUDE_PATH . '\sched.h'); + copy($this->source_dir . '\semaphore.h', BUILD_INCLUDE_PATH . '\semaphore.h'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 96001af2..0dfc8312 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -11,10 +11,12 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- +$zts = true; + // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'readline,pgsql,xml,dom,mbstring,mbregex,pdo_pgsql', - 'Windows' => 'mbstring,pdo_sqlite,mbregex', + 'Linux', 'Darwin' => 'parallel', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,parallel', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -27,7 +29,7 @@ $with_libs = match (PHP_OS_FAMILY) { // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'none', + 'Linux', 'Darwin' => 'minimal', 'Windows' => 'none', }; @@ -71,5 +73,6 @@ echo match ($argv[1]) { 'libs' => $final_libs, 'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), 'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), + 'zts' => $zts ? '--enable-zts' : '', default => '', }; diff --git a/src/globals/tests/parallel.php b/src/globals/tests/parallel.php new file mode 100644 index 00000000..d74c15cf --- /dev/null +++ b/src/globals/tests/parallel.php @@ -0,0 +1,5 @@ + Date: Thu, 16 May 2024 10:51:31 +0800 Subject: [PATCH 289/415] Fix php74 upx bug (#450) * fix php74 cannot compile with no-strip or with-upx-pack (including lint some code) * use captainhook installer instead of plugin composer * use captainhook installer instead of plugin composer * add [no build test] flag * update actions/cache version [no build test] * test update actions/cache version * test update actions/cache version * test update actions/cache version --- .github/workflows/tests.yml | 8 +- composer.json | 8 +- composer.lock | 1688 +++++++++++++++++------- config/ext.json | 5 - src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/freebsd/BSDBuilder.php | 2 +- src/SPC/builder/linux/LinuxBuilder.php | 110 +- src/SPC/command/BaseCommand.php | 10 + src/SPC/command/BuildCliCommand.php | 2 +- src/SPC/command/BuildLibsCommand.php | 2 + src/SPC/command/DumpLicenseCommand.php | 7 +- src/SPC/util/GlobalEnvManager.php | 6 +- src/SPC/util/LicenseDumper.php | 22 +- src/SPC/util/Patcher.php | 38 - src/SPC/util/UnixShell.php | 3 + src/SPC/util/WindowsCmd.php | 3 + src/globals/functions.php | 79 +- 17 files changed, 1349 insertions(+), 646 deletions(-) delete mode 100644 src/SPC/util/Patcher.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f1d07663..d3f688d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,7 +48,7 @@ jobs: - name: "Cache Composer packages" id: composer-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-phpstan-${{ hashFiles('**/composer.lock') }} @@ -86,7 +86,7 @@ jobs: - name: "Cache Composer packages" id: composer-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} @@ -136,9 +136,9 @@ jobs: echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV fi - - name: "Cache Composer packages" + - name: "Cache composer packages" id: composer-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} diff --git a/composer.json b/composer.json index e7bc4b91..6bee5fba 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ "zhamao/logger": "^1.0" }, "require-dev": { - "captainhook/captainhook": "^5.10", - "captainhook/plugin-composer": "^5.3", + "captainhook/captainhook-phar": "^5.23", + "captainhook/hook-installer": "^1.0", "friendsofphp/php-cs-fixer": "^3.25", "humbug/box": "^4.5", "nunomaduro/collision": "^7.8", @@ -50,7 +50,9 @@ "config": { "allow-plugins": { "phpstan/extension-installer": true, - "captainhook/plugin-composer": true + "captainhook/hook-installer": true, + "captainhook/plugin-composer": true, + "captainhook/captainhook-phar": true }, "optimize-autoloader": true, "sort-packages": true diff --git a/composer.lock b/composer.lock index 07bd5e9c..37203606 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "03f3dbb470b1979639080adb62e6734b", + "content-hash": "186e104804f9b096eaf08f153e52fb36", "packages": [ { "name": "illuminate/collections", - "version": "v10.44.0", + "version": "v10.48.10", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "5cedaba39e331cffd73a01cf27ea83229fa11fba" + "reference": "f9589f1063a449111dcaa1d68285b507d9483a95" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/5cedaba39e331cffd73a01cf27ea83229fa11fba", - "reference": "5cedaba39e331cffd73a01cf27ea83229fa11fba", + "url": "https://api.github.com/repos/illuminate/collections/zipball/f9589f1063a449111dcaa1d68285b507d9483a95", + "reference": "f9589f1063a449111dcaa1d68285b507d9483a95", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-02-09T15:56:19+00:00" + "time": "2024-03-20T20:09:13+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.44.0", + "version": "v10.48.10", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.44.0", + "version": "v10.48.10", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.44.0", + "version": "v10.48.10", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.15", + "version": "v0.1.21", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "d814a27514d99b03c85aa42b22cfd946568636c1" + "reference": "23ea808e8a145653e0ab29e30d4385e49f40a920" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/d814a27514d99b03c85aa42b22cfd946568636c1", - "reference": "d814a27514d99b03c85aa42b22cfd946568636c1", + "url": "https://api.github.com/repos/laravel/prompts/zipball/23ea808e8a145653e0ab29e30d4385e49f40a920", + "reference": "23ea808e8a145653e0ab29e30d4385e49f40a920", "shasum": "" }, "require": { @@ -252,11 +252,12 @@ "license": [ "MIT" ], + "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.15" + "source": "https://github.com/laravel/prompts/tree/v0.1.21" }, - "time": "2023-12-29T22:37:42+00:00" + "time": "2024-04-30T12:46:16+00:00" }, { "name": "psr/container", @@ -414,16 +415,16 @@ }, { "name": "symfony/console", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e" + "reference": "a170e64ae10d00ba89e2acbb590dc2e54da8ad8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e", - "reference": "2aaf83b4de5b9d43b93e4aec6f2f8b676f7c567e", + "url": "https://api.github.com/repos/symfony/console/zipball/a170e64ae10d00ba89e2acbb590dc2e54da8ad8f", + "reference": "a170e64ae10d00ba89e2acbb590dc2e54da8ad8f", "shasum": "" }, "require": { @@ -488,7 +489,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.3" + "source": "https://github.com/symfony/console/tree/v6.4.7" }, "funding": [ { @@ -504,20 +505,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:51:35+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.4.0", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", "shasum": "" }, "require": { @@ -526,7 +527,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -555,7 +556,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" }, "funding": [ { @@ -571,7 +572,7 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/polyfill-ctype", @@ -893,21 +894,22 @@ }, { "name": "symfony/service-contracts", - "version": "v3.4.1", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", - "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^1.1|^2.0" + "psr/container": "^1.1|^2.0", + "symfony/deprecation-contracts": "^2.5|^3" }, "conflict": { "ext-psr": "<1.1|>=2" @@ -915,7 +917,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -955,7 +957,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" }, "funding": [ { @@ -971,20 +973,20 @@ "type": "tidelift" } ], - "time": "2023-12-26T14:02:43+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/string", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "7a14736fb179876575464e4658fce0c304e8c15b" + "reference": "ffeb9591c61f65a68d47f77d12b83fa530227a69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/7a14736fb179876575464e4658fce0c304e8c15b", - "reference": "7a14736fb179876575464e4658fce0c304e8c15b", + "url": "https://api.github.com/repos/symfony/string/zipball/ffeb9591c61f65a68d47f77d12b83fa530227a69", + "reference": "ffeb9591c61f65a68d47f77d12b83fa530227a69", "shasum": "" }, "require": { @@ -1041,7 +1043,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.3" + "source": "https://github.com/symfony/string/tree/v6.4.7" }, "funding": [ { @@ -1057,7 +1059,7 @@ "type": "tidelift" } ], - "time": "2024-01-25T09:26:29+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "zhamao/logger", @@ -1132,16 +1134,16 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.6.2", + "version": "v2.6.4", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb" + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", - "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", + "url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", "shasum": "" }, "require": { @@ -1153,8 +1155,8 @@ "ext-json": "*", "jetbrains/phpstorm-stubs": "^2019.3", "phpunit/phpunit": "^7 | ^8 | ^9", - "psalm/phar": "^3.11@dev", - "react/promise": "^2" + "react/promise": "^2", + "vimeo/psalm": "^3.12" }, "type": "library", "extra": { @@ -1209,7 +1211,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.6.2" + "source": "https://github.com/amphp/amp/tree/v2.6.4" }, "funding": [ { @@ -1217,20 +1219,20 @@ "type": "github" } ], - "time": "2022-02-20T17:52:18+00:00" + "time": "2024-03-21T18:52:26+00:00" }, { "name": "amphp/byte-stream", - "version": "v1.8.1", + "version": "v1.8.2", "source": { "type": "git", "url": "https://github.com/amphp/byte-stream.git", - "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd" + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/acbd8002b3536485c997c4e019206b3f10ca15bd", - "reference": "acbd8002b3536485c997c4e019206b3f10ca15bd", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc", + "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc", "shasum": "" }, "require": { @@ -1246,11 +1248,6 @@ "psalm/phar": "^3.11.4" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, "autoload": { "files": [ "lib/functions.php" @@ -1274,7 +1271,7 @@ } ], "description": "A stream abstraction to make working with non-blocking I/O simple.", - "homepage": "http://amphp.org/byte-stream", + "homepage": "https://amphp.org/byte-stream", "keywords": [ "amp", "amphp", @@ -1284,9 +1281,8 @@ "stream" ], "support": { - "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/v1.8.1" + "source": "https://github.com/amphp/byte-stream/tree/v1.8.2" }, "funding": [ { @@ -1294,7 +1290,7 @@ "type": "github" } ], - "time": "2021-03-30T17:13:30+00:00" + "time": "2024-04-13T18:00:56+00:00" }, { "name": "amphp/parallel", @@ -1430,16 +1426,16 @@ }, { "name": "amphp/parser", - "version": "v1.1.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/amphp/parser.git", - "reference": "ff1de4144726c5dad5fab97f66692ebe8de3e151" + "reference": "3cf1f8b32a0171d4b1bed93d25617637a77cded7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/parser/zipball/ff1de4144726c5dad5fab97f66692ebe8de3e151", - "reference": "ff1de4144726c5dad5fab97f66692ebe8de3e151", + "url": "https://api.github.com/repos/amphp/parser/zipball/3cf1f8b32a0171d4b1bed93d25617637a77cded7", + "reference": "3cf1f8b32a0171d4b1bed93d25617637a77cded7", "shasum": "" }, "require": { @@ -1480,7 +1476,7 @@ ], "support": { "issues": "https://github.com/amphp/parser/issues", - "source": "https://github.com/amphp/parser/tree/v1.1.0" + "source": "https://github.com/amphp/parser/tree/v1.1.1" }, "funding": [ { @@ -1488,26 +1484,26 @@ "type": "github" } ], - "time": "2022-12-30T18:08:47+00:00" + "time": "2024-03-21T19:16:53+00:00" }, { "name": "amphp/process", - "version": "v1.1.4", + "version": "v1.1.7", "source": { "type": "git", "url": "https://github.com/amphp/process.git", - "reference": "76e9495fd6818b43a20167cb11d8a67f7744ee0f" + "reference": "1949d85b6d71af2818ff68144304a98495628f19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/process/zipball/76e9495fd6818b43a20167cb11d8a67f7744ee0f", - "reference": "76e9495fd6818b43a20167cb11d8a67f7744ee0f", + "url": "https://api.github.com/repos/amphp/process/zipball/1949d85b6d71af2818ff68144304a98495628f19", + "reference": "1949d85b6d71af2818ff68144304a98495628f19", "shasum": "" }, "require": { "amphp/amp": "^2", "amphp/byte-stream": "^1.4", - "php": ">=7" + "php": ">=7.1" }, "require-dev": { "amphp/php-cs-fixer-config": "dev-master", @@ -1545,7 +1541,7 @@ "homepage": "https://github.com/amphp/process", "support": { "issues": "https://github.com/amphp/process/issues", - "source": "https://github.com/amphp/process/tree/v1.1.4" + "source": "https://github.com/amphp/process/tree/v1.1.7" }, "funding": [ { @@ -1553,7 +1549,7 @@ "type": "github" } ], - "time": "2022-07-06T23:50:12+00:00" + "time": "2024-04-19T03:00:28+00:00" }, { "name": "amphp/serialization", @@ -1682,54 +1678,36 @@ "time": "2021-10-25T18:29:10+00:00" }, { - "name": "captainhook/captainhook", - "version": "5.19.2", + "name": "captainhook/captainhook-phar", + "version": "5.23.0", "source": { "type": "git", - "url": "https://github.com/captainhookphp/captainhook.git", - "reference": "604bfc55fa40d6fe8c0275ca707ee80920b3b3f1" + "url": "https://github.com/captainhookphp/captainhook-phar.git", + "reference": "055e6e109170a1d79353f9c94a6099e08bab15cd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/captainhook/zipball/604bfc55fa40d6fe8c0275ca707ee80920b3b3f1", - "reference": "604bfc55fa40d6fe8c0275ca707ee80920b3b3f1", + "url": "https://api.github.com/repos/captainhookphp/captainhook-phar/zipball/055e6e109170a1d79353f9c94a6099e08bab15cd", + "reference": "055e6e109170a1d79353f9c94a6099e08bab15cd", "shasum": "" }, "require": { - "captainhook/secrets": "^0.9.4", + "composer-plugin-api": "^1.1||^2.0", "ext-json": "*", "ext-spl": "*", - "ext-xml": "*", - "php": ">=8.0", - "sebastianfeldmann/camino": "^0.9.2", - "sebastianfeldmann/cli": "^3.3", - "sebastianfeldmann/git": "^3.9", - "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0", - "symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "replace": { - "sebastianfeldmann/captainhook": "*" + "phar-io/composer-distributor": "^1.0", + "php": "^8.0 || ^8.1 || ^8.2" }, "require-dev": { - "composer/composer": "~1 || ^2.0", - "mikey179/vfsstream": "~1" + "composer/composer": "^1.1 || ^2.0" }, - "bin": [ - "bin/captainhook" - ], - "type": "library", + "type": "composer-plugin", "extra": { - "branch-alias": { - "dev-main": "6.0.x-dev" - }, - "captainhook": { - "config": "captainhook.json" - } + "class": "CaptainHook\\Composer\\Plugin" }, "autoload": { "psr-4": { - "CaptainHook\\App\\": "src/" + "CaptainHook\\Composer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1743,7 +1721,7 @@ } ], "description": "PHP git hook manager", - "homepage": "http://php.captainhook.info/", + "homepage": "https://github.com/captainhookphp/captainhook", "keywords": [ "commit-msg", "git", @@ -1755,7 +1733,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook/tree/5.19.2" + "source": "https://github.com/captainhookphp/captainhook-phar/tree/5.23.0" }, "funding": [ { @@ -1763,40 +1741,36 @@ "type": "github" } ], - "time": "2023-12-18T14:06:12+00:00" + "time": "2023-12-13T23:08:05+00:00" }, { - "name": "captainhook/plugin-composer", - "version": "5.3.3", + "name": "captainhook/hook-installer", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/captainhookphp/plugin-composer.git", - "reference": "0a802aaf7742ef22b5cbccd586d99e16d9d23a39" + "url": "https://github.com/captainhookphp/hook-installer.git", + "reference": "3308a9152727af4e3d1c7b63ca219d6938b702b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/plugin-composer/zipball/0a802aaf7742ef22b5cbccd586d99e16d9d23a39", - "reference": "0a802aaf7742ef22b5cbccd586d99e16d9d23a39", + "url": "https://api.github.com/repos/captainhookphp/hook-installer/zipball/3308a9152727af4e3d1c7b63ca219d6938b702b8", + "reference": "3308a9152727af4e3d1c7b63ca219d6938b702b8", "shasum": "" }, "require": { - "captainhook/captainhook": "^5.0", "composer-plugin-api": "^1.1|^2.0", - "php": ">=7.1" + "php": ">=8.0" }, "require-dev": { "composer/composer": "*" }, "type": "composer-plugin", "extra": { - "class": "CaptainHook\\Plugin\\Composer\\ComposerPlugin", - "branch-alias": { - "dev-fluffy_hedgehog": "5.0.x-dev" - } + "class": "CaptainHook\\HookInstaller\\ComposerPlugin" }, "autoload": { "psr-4": { - "CaptainHook\\Plugin\\Composer\\": "src" + "CaptainHook\\HookInstaller\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1804,44 +1778,44 @@ "MIT" ], "authors": [ - { - "name": "Andreas Heigl", - "email": "andreas@heigl.org" - }, { "name": "Sebastian Feldmann", "email": "sf@sebastian-feldmann.info" } ], - "description": "Composer-Plugin handling your git-hooks", + "description": "Composer Plugin that makes everyone activate the CaptainHook git hooks locally", "support": { - "issues": "https://github.com/captainhookphp/plugin-composer/issues", - "source": "https://github.com/captainhookphp/plugin-composer/tree/5.3.3" + "issues": "https://github.com/captainhookphp/hook-installer/issues", + "source": "https://github.com/captainhookphp/hook-installer/tree/1.0.3" }, - "time": "2022-01-28T04:35:22+00:00" + "time": "2024-03-21T13:39:59+00:00" }, { - "name": "captainhook/secrets", - "version": "0.9.5", + "name": "clue/ndjson-react", + "version": "v1.3.0", "source": { "type": "git", - "url": "https://github.com/captainhookphp/secrets.git", - "reference": "8aa90d5b9b7892abd11b9da2fc172a7b32b90cbe" + "url": "https://github.com/clue/reactphp-ndjson.git", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/captainhookphp/secrets/zipball/8aa90d5b9b7892abd11b9da2fc172a7b32b90cbe", - "reference": "8aa90d5b9b7892abd11b9da2fc172a7b32b90cbe", + "url": "https://api.github.com/repos/clue/reactphp-ndjson/zipball/392dc165fce93b5bb5c637b67e59619223c931b0", + "reference": "392dc165fce93b5bb5c637b67e59619223c931b0", "shasum": "" }, "require": { - "ext-mbstring": "*", - "php": ">=8.0" + "php": ">=5.3", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35", + "react/event-loop": "^1.2" }, "type": "library", "autoload": { "psr-4": { - "CaptainHook\\Secrets\\": "src/" + "Clue\\React\\NDJson\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1850,44 +1824,48 @@ ], "authors": [ { - "name": "Sebastian Feldmann", - "email": "sf@sebastian-feldmann.info" + "name": "Christian Lück", + "email": "christian@clue.engineering" } ], - "description": "Utility classes to detect secrets", + "description": "Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.", + "homepage": "https://github.com/clue/reactphp-ndjson", "keywords": [ - "commit-msg", - "keys", - "passwords", - "post-merge", - "prepare-commit-msg", - "secrets", - "tokens" + "NDJSON", + "json", + "jsonlines", + "newline", + "reactphp", + "streaming" ], "support": { - "issues": "https://github.com/captainhookphp/secrets/issues", - "source": "https://github.com/captainhookphp/secrets/tree/0.9.5" + "issues": "https://github.com/clue/reactphp-ndjson/issues", + "source": "https://github.com/clue/reactphp-ndjson/tree/v1.3.0" }, "funding": [ { - "url": "https://github.com/sponsors/sebastianfeldmann", + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", "type": "github" } ], - "time": "2023-11-30T18:10:18+00:00" + "time": "2022-12-23T10:58:28+00:00" }, { "name": "composer/pcre", - "version": "3.1.1", + "version": "3.1.3", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", - "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", + "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", "shasum": "" }, "require": { @@ -1929,7 +1907,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.1" + "source": "https://github.com/composer/pcre/tree/3.1.3" }, "funding": [ { @@ -1945,7 +1923,7 @@ "type": "tidelift" } ], - "time": "2023-10-11T07:11:09+00:00" + "time": "2024-03-19T10:26:25+00:00" }, { "name": "composer/semver", @@ -2030,16 +2008,16 @@ }, { "name": "composer/xdebug-handler", - "version": "3.0.3", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "ced299686f41dce890debac69273b47ffe98a40c" + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", - "reference": "ced299686f41dce890debac69273b47ffe98a40c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef", + "reference": "6c1925561632e83d60a44492e0b344cf48ab85ef", "shasum": "" }, "require": { @@ -2050,7 +2028,7 @@ "require-dev": { "phpstan/phpstan": "^1.0", "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^6.0" + "phpunit/phpunit": "^8.5 || ^9.6 || ^10.5" }, "type": "library", "autoload": { @@ -2074,9 +2052,9 @@ "performance" ], "support": { - "irc": "irc://irc.freenode.org/composer", + "irc": "ircs://irc.libera.chat:6697/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" + "source": "https://github.com/composer/xdebug-handler/tree/3.0.5" }, "funding": [ { @@ -2092,7 +2070,7 @@ "type": "tidelift" } ], - "time": "2022-02-25T21:32:43+00:00" + "time": "2024-05-06T16:37:16+00:00" }, { "name": "doctrine/deprecations", @@ -2211,6 +2189,53 @@ ], "time": "2022-12-30T00:23:10+00:00" }, + { + "name": "evenement/evenement", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/igorw/evenement.git", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", + "shasum": "" + }, + "require": { + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^9 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Evenement\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "description": "Événement is a very simple event dispatching library for PHP", + "keywords": [ + "event-dispatcher", + "event-emitter" + ], + "support": { + "issues": "https://github.com/igorw/evenement/issues", + "source": "https://github.com/igorw/evenement/tree/v3.0.2" + }, + "time": "2023-08-08T05:53:35+00:00" + }, { "name": "fidry/console", "version": "0.5.5", @@ -2295,6 +2320,67 @@ ], "time": "2022-12-18T10:49:34+00:00" }, + { + "name": "fidry/cpu-core-counter", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/theofidry/cpu-core-counter.git", + "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theofidry/cpu-core-counter/zipball/f92996c4d5c1a696a6a970e20f7c4216200fcc42", + "reference": "f92996c4d5c1a696a6a970e20f7c4216200fcc42", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "fidry/makefile": "^0.2.0", + "fidry/php-cs-fixer-config": "^1.1.2", + "phpstan/extension-installer": "^1.2.0", + "phpstan/phpstan": "^1.9.2", + "phpstan/phpstan-deprecation-rules": "^1.0.0", + "phpstan/phpstan-phpunit": "^1.2.2", + "phpstan/phpstan-strict-rules": "^1.4.4", + "phpunit/phpunit": "^8.5.31 || ^9.5.26", + "webmozarts/strict-phpunit": "^7.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Fidry\\CpuCoreCounter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Théo FIDRY", + "email": "theo.fidry@gmail.com" + } + ], + "description": "Tiny utility to get the number of CPU cores.", + "keywords": [ + "CPU", + "core" + ], + "support": { + "issues": "https://github.com/theofidry/cpu-core-counter/issues", + "source": "https://github.com/theofidry/cpu-core-counter/tree/1.1.0" + }, + "funding": [ + { + "url": "https://github.com/theofidry", + "type": "github" + } + ], + "time": "2024-02-07T09:43:46+00:00" + }, { "name": "fidry/filesystem", "version": "1.2.1", @@ -2435,26 +2521,33 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.49.0", + "version": "v3.57.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "8742f7aa6f72a399688b65e4f58992c2d4681fc2" + "reference": "3f7efe667a8c9818aacceee478add7c0fc24cb21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8742f7aa6f72a399688b65e4f58992c2d4681fc2", - "reference": "8742f7aa6f72a399688b65e4f58992c2d4681fc2", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/3f7efe667a8c9818aacceee478add7c0fc24cb21", + "reference": "3f7efe667a8c9818aacceee478add7c0fc24cb21", "shasum": "" }, "require": { + "clue/ndjson-react": "^1.0", "composer/semver": "^3.4", "composer/xdebug-handler": "^3.0.3", "ext-filter": "*", "ext-json": "*", "ext-tokenizer": "*", + "fidry/cpu-core-counter": "^1.0", "php": "^7.4 || ^8.0", - "sebastian/diff": "^4.0 || ^5.0", + "react/child-process": "^0.6.5", + "react/event-loop": "^1.0", + "react/promise": "^2.0 || ^3.0", + "react/socket": "^1.0", + "react/stream": "^1.0", + "sebastian/diff": "^4.0 || ^5.0 || ^6.0", "symfony/console": "^5.4 || ^6.0 || ^7.0", "symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0", "symfony/filesystem": "^5.4 || ^6.0 || ^7.0", @@ -2468,6 +2561,7 @@ }, "require-dev": { "facile-it/paraunit": "^1.3 || ^2.0", + "infection/infection": "^0.27.11", "justinrainbow/json-schema": "^5.2", "keradus/cli-executor": "^2.1", "mikey179/vfsstream": "^1.6.11", @@ -2475,7 +2569,8 @@ "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", - "phpunit/phpunit": "^9.6 || ^10.5.5", + "phpunit/phpunit": "^9.6 || ^10.5.5 || ^11.0.2", + "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, "suggest": { @@ -2514,7 +2609,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.49.0" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.57.1" }, "funding": [ { @@ -2522,7 +2617,7 @@ "type": "github" } ], - "time": "2024-02-02T00:41:40+00:00" + "time": "2024-05-15T22:01:07+00:00" }, { "name": "humbug/box", @@ -3015,21 +3110,21 @@ }, { "name": "nikic/php-parser", - "version": "v4.18.0", + "version": "v4.19.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999" + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1bcbb2179f97633e98bbbc87044ee2611c7d7999", - "reference": "1bcbb2179f97633e98bbbc87044ee2611c7d7999", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", + "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.1" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", @@ -3065,9 +3160,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.18.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" }, - "time": "2023-12-10T21:03:43+00:00" + "time": "2024-03-17T08:10:35+00:00" }, { "name": "nunomaduro/collision", @@ -3253,16 +3348,16 @@ }, { "name": "paragonie/constant_time_encoding", - "version": "v2.6.3", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/paragonie/constant_time_encoding.git", - "reference": "58c3f47f650c94ec05a151692652a868995d2938" + "reference": "52a0d99e69f56b9ec27ace92ba56897fe6993105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/58c3f47f650c94ec05a151692652a868995d2938", - "reference": "58c3f47f650c94ec05a151692652a868995d2938", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/52a0d99e69f56b9ec27ace92ba56897fe6993105", + "reference": "52a0d99e69f56b9ec27ace92ba56897fe6993105", "shasum": "" }, "require": { @@ -3316,24 +3411,239 @@ "issues": "https://github.com/paragonie/constant_time_encoding/issues", "source": "https://github.com/paragonie/constant_time_encoding" }, - "time": "2022-06-14T06:56:20+00:00" + "time": "2024-05-08T12:18:48+00:00" }, { - "name": "phar-io/manifest", - "version": "2.0.3", + "name": "phar-io/composer-distributor", + "version": "1.0.2", "source": { "type": "git", - "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "url": "https://github.com/phar-io/composer-distributor.git", + "reference": "dd7d936290b2a42b0c64bfe08090b5c597c280c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/composer-distributor/zipball/dd7d936290b2a42b0c64bfe08090b5c597c280c9", + "reference": "dd7d936290b2a42b0c64bfe08090b5c597c280c9", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "ext-dom": "*", + "ext-libxml": "*", + "phar-io/filesystem": "^2.0", + "phar-io/gnupg": "^1.0", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "phpunit/phpunit": "^9.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "PharIo\\ComposerDistributor\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Heigl", + "email": "andreas@heigl.org", + "role": "Developer" + }, + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Feldmann", + "email": "sf@sebastian-feldmann.info", + "role": "Developer" + } + ], + "description": "Base Code for a composer plugin that installs PHAR-files", + "homepage": "https://phar.io", + "keywords": [ + "bin", + "binary", + "composer", + "distribute", + "phar", + "phive" + ], + "support": { + "issues": "https://github.com/phar-io/composer-distributor/issues", + "source": "https://github.com/phar-io/composer-distributor/tree/1.0.2" + }, + "funding": [ + { + "url": "https://phar.io", + "type": "other" + } + ], + "time": "2023-05-31T17:05:49+00:00" + }, + { + "name": "phar-io/executor", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/executor.git", + "reference": "5bfb7400224a0c1cf83343660af85c7f5a073473" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/executor/zipball/5bfb7400224a0c1cf83343660af85c7f5a073473", + "reference": "5bfb7400224a0c1cf83343660af85c7f5a073473", + "shasum": "" + }, + "require": { + "phar-io/filesystem": "^2.0", + "php": "^7.2||^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + } + ], + "support": { + "issues": "https://github.com/phar-io/executor/issues", + "source": "https://github.com/phar-io/executor/tree/1.0.1" + }, + "time": "2020-11-30T10:53:57+00:00" + }, + { + "name": "phar-io/filesystem", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/filesystem.git", + "reference": "222e3ea432262a05706b7066697c21257664d9d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/filesystem/zipball/222e3ea432262a05706b7066697c21257664d9d1", + "reference": "222e3ea432262a05706b7066697c21257664d9d1", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + } + ], + "support": { + "issues": "https://github.com/phar-io/filesystem/issues", + "source": "https://github.com/phar-io/filesystem/tree/2.0.1" + }, + "time": "2020-11-30T10:16:22+00:00" + }, + { + "name": "phar-io/gnupg", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/phar-io/gnupg.git", + "reference": "3c106d39f62ba3941f830ca24e125cb1b9290a87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/gnupg/zipball/3c106d39f62ba3941f830ca24e125cb1b9290a87", + "reference": "3c106d39f62ba3941f830ca24e125cb1b9290a87", + "shasum": "" + }, + "require": { + "phar-io/executor": "^1.0", + "phar-io/filesystem": "^2.0", + "php": "^7.2||^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + } + ], + "description": "Thin GnuPG wrapper class around the gnupg binary, mimicking the pecl/gnupg api", + "support": { + "issues": "https://github.com/phar-io/gnupg/issues", + "source": "https://github.com/phar-io/gnupg/tree/1.0.2" + }, + "time": "2020-11-30T10:21:26+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -3374,9 +3684,15 @@ "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -3484,28 +3800,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "version": "5.4.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "mockery/mockery": "~1.3.5", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^5.13" }, "type": "library", "extra": { @@ -3529,33 +3852,33 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2024-04-09T21:13:58+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.8.0", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc" + "reference": "153ae662783729388a584b4361f2545e4d841e3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/fad452781b3d774e3337b0c0b245dd8e5a4455fc", - "reference": "fad452781b3d774e3337b0c0b245dd8e5a4455fc", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", + "reference": "153ae662783729388a584b4361f2545e4d841e3c", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", - "php": "^7.4 || ^8.0", + "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", "phpstan/phpdoc-parser": "^1.13" }, @@ -3593,22 +3916,22 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" }, - "time": "2024-01-11T11:49:22+00:00" + "time": "2024-02-23T11:10:43+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.25.0", + "version": "1.29.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", - "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc", + "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc", "shasum": "" }, "require": { @@ -3640,22 +3963,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0" }, - "time": "2024-01-04T17:06:16+00:00" + "time": "2024-05-06T12:04:23+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.58", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "a23518379ec4defd9e47cbf81019526861623ec2" + "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/a23518379ec4defd9e47cbf81019526861623ec2", - "reference": "a23518379ec4defd9e47cbf81019526861623ec2", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e524358f930e41a2b4cca1320e3b04fc26b39e0b", + "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b", "shasum": "" }, "require": { @@ -3698,26 +4021,22 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-02-12T20:02:57+00:00" + "time": "2024-05-15T08:00:59+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.30", + "version": "9.2.31", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089" + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca2bd87d2f9215904682a9cb9bb37dda98e76089", - "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", "shasum": "" }, "require": { @@ -3774,7 +4093,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.30" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" }, "funding": [ { @@ -3782,7 +4101,7 @@ "type": "github" } ], - "time": "2023-12-22T06:47:57+00:00" + "time": "2024-03-02T06:37:42+00:00" }, { "name": "phpunit/php-file-iterator", @@ -4027,16 +4346,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.16", + "version": "9.6.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f" + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3767b2c56ce02d01e3491046f33466a1ae60a37f", - "reference": "3767b2c56ce02d01e3491046f33466a1ae60a37f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", "shasum": "" }, "require": { @@ -4110,7 +4429,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.16" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" }, "funding": [ { @@ -4126,7 +4445,7 @@ "type": "tidelift" } ], - "time": "2024-01-19T07:03:14+00:00" + "time": "2024-04-05T04:35:58+00:00" }, { "name": "psr/event-dispatcher", @@ -4179,17 +4498,547 @@ "time": "2019-01-08T18:20:26+00:00" }, { - "name": "sebastian/cli-parser", - "version": "1.0.1", + "name": "react/cache", + "version": "v1.2.0", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + "url": "https://github.com/reactphp/cache.git", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", - "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b", + "reference": "d47c472b64aa5608225f47965a484b75c7817d5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/promise": "^3.0 || ^2.0 || ^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, Promise-based cache interface for ReactPHP", + "keywords": [ + "cache", + "caching", + "promise", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/cache/issues", + "source": "https://github.com/reactphp/cache/tree/v1.2.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2022-11-30T15:59:55+00:00" + }, + { + "name": "react/child-process", + "version": "v0.6.5", + "source": { + "type": "git", + "url": "https://github.com/reactphp/child-process.git", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/event-loop": "^1.2", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/socket": "^1.8", + "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\ChildProcess\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven library for executing child processes with ReactPHP.", + "keywords": [ + "event-driven", + "process", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/child-process/issues", + "source": "https://github.com/reactphp/child-process/tree/v0.6.5" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-09-16T13:41:56+00:00" + }, + { + "name": "react/dns", + "version": "v1.12.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/dns.git", + "reference": "c134600642fa615b46b41237ef243daa65bb64ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/dns/zipball/c134600642fa615b46b41237ef243daa65bb64ec", + "reference": "c134600642fa615b46b41237ef243daa65bb64ec", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "react/cache": "^1.0 || ^0.6 || ^0.5", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.7 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4 || ^3 || ^2", + "react/promise-timer": "^1.9" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Dns\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async DNS resolver for ReactPHP", + "keywords": [ + "async", + "dns", + "dns-resolver", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/dns/issues", + "source": "https://github.com/reactphp/dns/tree/v1.12.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-29T12:41:06+00:00" + }, + { + "name": "react/event-loop", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/event-loop.git", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "reference": "bbe0bd8c51ffc05ee43f1729087ed3bdf7d53354", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "suggest": { + "ext-pcntl": "For signal handling support when using the StreamSelectLoop" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\EventLoop\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.", + "keywords": [ + "asynchronous", + "event-loop" + ], + "support": { + "issues": "https://github.com/reactphp/event-loop/issues", + "source": "https://github.com/reactphp/event-loop/tree/v1.5.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-13T13:48:05+00:00" + }, + { + "name": "react/promise", + "version": "v3.1.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise.git", + "reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise/zipball/e563d55d1641de1dea9f5e84f3cccc66d2bfe02c", + "reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "require-dev": { + "phpstan/phpstan": "1.10.39 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A lightweight implementation of CommonJS Promises/A for PHP", + "keywords": [ + "promise", + "promises" + ], + "support": { + "issues": "https://github.com/reactphp/promise/issues", + "source": "https://github.com/reactphp/promise/tree/v3.1.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-11-16T16:21:57+00:00" + }, + { + "name": "react/socket", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/socket.git", + "reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/socket/zipball/216d3aec0b87f04a40ca04f481e6af01bdd1d038", + "reference": "216d3aec0b87f04a40ca04f481e6af01bdd1d038", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/dns": "^1.11", + "react/event-loop": "^1.2", + "react/promise": "^3 || ^2.6 || ^1.2.1", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", + "react/async": "^4 || ^3 || ^2", + "react/promise-stream": "^1.4", + "react/promise-timer": "^1.10" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Socket\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP", + "keywords": [ + "Connection", + "Socket", + "async", + "reactphp", + "stream" + ], + "support": { + "issues": "https://github.com/reactphp/socket/issues", + "source": "https://github.com/reactphp/socket/tree/v1.15.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-12-15T11:02:10+00:00" + }, + { + "name": "react/stream", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/stream.git", + "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/stream/zipball/6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.8", + "react/event-loop": "^1.2" + }, + "require-dev": { + "clue/stream-filter": "~1.2", + "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP", + "keywords": [ + "event-driven", + "io", + "non-blocking", + "pipe", + "reactphp", + "readable", + "stream", + "writable" + ], + "support": { + "issues": "https://github.com/reactphp/stream/issues", + "source": "https://github.com/reactphp/stream/tree/v1.3.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-06-16T10:52:11+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", "shasum": "" }, "require": { @@ -4224,7 +5073,7 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" }, "funding": [ { @@ -4232,7 +5081,7 @@ "type": "github" } ], - "time": "2020-09-28T06:08:49+00:00" + "time": "2024-03-02T06:27:43+00:00" }, { "name": "sebastian/code-unit", @@ -4478,16 +5327,16 @@ }, { "name": "sebastian/diff", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", "shasum": "" }, "require": { @@ -4532,7 +5381,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" }, "funding": [ { @@ -4540,7 +5389,7 @@ "type": "github" } ], - "time": "2023-05-07T05:35:17+00:00" + "time": "2024-03-02T06:30:58+00:00" }, { "name": "sebastian/environment", @@ -4607,16 +5456,16 @@ }, { "name": "sebastian/exporter", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", - "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", "shasum": "" }, "require": { @@ -4672,7 +5521,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" }, "funding": [ { @@ -4680,20 +5529,20 @@ "type": "github" } ], - "time": "2022-09-14T06:03:37+00:00" + "time": "2024-03-02T06:33:00+00:00" }, { "name": "sebastian/global-state", - "version": "5.0.6", + "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bde739e7565280bda77be70044ac1047bc007e34" + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34", - "reference": "bde739e7565280bda77be70044ac1047bc007e34", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", "shasum": "" }, "require": { @@ -4736,7 +5585,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6" + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" }, "funding": [ { @@ -4744,7 +5593,7 @@ "type": "github" } ], - "time": "2023-08-02T09:26:13+00:00" + "time": "2024-03-02T06:35:11+00:00" }, { "name": "sebastian/lines-of-code", @@ -4980,16 +5829,16 @@ }, { "name": "sebastian/resource-operations", - "version": "3.0.3", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", - "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", "shasum": "" }, "require": { @@ -5001,7 +5850,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-main": "3.0-dev" } }, "autoload": { @@ -5022,8 +5871,7 @@ "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" }, "funding": [ { @@ -5031,7 +5879,7 @@ "type": "github" } ], - "time": "2020-09-28T06:45:17+00:00" + "time": "2024-03-14T16:00:52+00:00" }, { "name": "sebastian/type", @@ -5142,181 +5990,6 @@ ], "time": "2020-09-28T06:39:44+00:00" }, - { - "name": "sebastianfeldmann/camino", - "version": "0.9.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianfeldmann/camino.git", - "reference": "bf2e4c8b2a029e9eade43666132b61331e3e8184" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianfeldmann/camino/zipball/bf2e4c8b2a029e9eade43666132b61331e3e8184", - "reference": "bf2e4c8b2a029e9eade43666132b61331e3e8184", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "SebastianFeldmann\\Camino\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Sebastian Feldmann", - "email": "sf@sebastian-feldmann.info" - } - ], - "description": "Path management the OO way", - "homepage": "https://github.com/sebastianfeldmann/camino", - "keywords": [ - "file system", - "path" - ], - "support": { - "issues": "https://github.com/sebastianfeldmann/camino/issues", - "source": "https://github.com/sebastianfeldmann/camino/tree/0.9.5" - }, - "funding": [ - { - "url": "https://github.com/sebastianfeldmann", - "type": "github" - } - ], - "time": "2022-01-03T13:15:10+00:00" - }, - { - "name": "sebastianfeldmann/cli", - "version": "3.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianfeldmann/cli.git", - "reference": "8a932e99e9455981fb32fa6c085492462fe8f8cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianfeldmann/cli/zipball/8a932e99e9455981fb32fa6c085492462fe8f8cf", - "reference": "8a932e99e9455981fb32fa6c085492462fe8f8cf", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "require-dev": { - "symfony/process": "^4.3 | ^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4.x-dev" - } - }, - "autoload": { - "psr-4": { - "SebastianFeldmann\\Cli\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Sebastian Feldmann", - "email": "sf@sebastian-feldmann.info" - } - ], - "description": "PHP cli helper classes", - "homepage": "https://github.com/sebastianfeldmann/cli", - "keywords": [ - "cli" - ], - "support": { - "issues": "https://github.com/sebastianfeldmann/cli/issues", - "source": "https://github.com/sebastianfeldmann/cli/tree/3.4.1" - }, - "funding": [ - { - "url": "https://github.com/sebastianfeldmann", - "type": "github" - } - ], - "time": "2021-12-20T14:59:49+00:00" - }, - { - "name": "sebastianfeldmann/git", - "version": "3.9.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianfeldmann/git.git", - "reference": "eb2ca84a2b45a461f0bf5d4fd400df805649e83a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianfeldmann/git/zipball/eb2ca84a2b45a461f0bf5d4fd400df805649e83a", - "reference": "eb2ca84a2b45a461f0bf5d4fd400df805649e83a", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-xml": "*", - "php": ">=7.2", - "sebastianfeldmann/cli": "^3.0" - }, - "require-dev": { - "mikey179/vfsstream": "^1.6" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "SebastianFeldmann\\Git\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Sebastian Feldmann", - "email": "sf@sebastian-feldmann.info" - } - ], - "description": "PHP git wrapper", - "homepage": "https://github.com/sebastianfeldmann/git", - "keywords": [ - "git" - ], - "support": { - "issues": "https://github.com/sebastianfeldmann/git/issues", - "source": "https://github.com/sebastianfeldmann/git/tree/3.9.3" - }, - "funding": [ - { - "url": "https://github.com/sebastianfeldmann", - "type": "github" - } - ], - "time": "2023-10-13T09:10:48+00:00" - }, { "name": "seld/jsonlint", "version": "1.10.2", @@ -5383,16 +6056,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef" + "reference": "d84384f3f67de3cb650db64d685d70395dacfc3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae9d3a6f3003a6caf56acd7466d8d52378d44fef", - "reference": "ae9d3a6f3003a6caf56acd7466d8d52378d44fef", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d84384f3f67de3cb650db64d685d70395dacfc3f", + "reference": "d84384f3f67de3cb650db64d685d70395dacfc3f", "shasum": "" }, "require": { @@ -5443,7 +6116,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.3" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.7" }, "funding": [ { @@ -5459,20 +6132,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:51:35+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v3.4.0", + "version": "v3.5.0", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "a76aed96a42d2b521153fb382d418e30d18b59df" + "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/a76aed96a42d2b521153fb382d418e30d18b59df", - "reference": "a76aed96a42d2b521153fb382d418e30d18b59df", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/8f93aec25d41b72493c6ddff14e916177c9efc50", + "reference": "8f93aec25d41b72493c6ddff14e916177c9efc50", "shasum": "" }, "require": { @@ -5482,7 +6155,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.4-dev" + "dev-main": "3.5-dev" }, "thanks": { "name": "symfony/contracts", @@ -5519,7 +6192,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0" + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.0" }, "funding": [ { @@ -5535,26 +6208,27 @@ "type": "tidelift" } ], - "time": "2023-05-23T14:45:45+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/filesystem", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb" + "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", - "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/78dde75f8f6dbbca4ec436a4b0087f7af02076d4", + "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4", "shasum": "" }, "require": { "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8" + "symfony/polyfill-mbstring": "~1.8", + "symfony/process": "^5.4|^6.4" }, "type": "library", "autoload": { @@ -5582,7 +6256,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.3" + "source": "https://github.com/symfony/filesystem/tree/v6.4.7" }, "funding": [ { @@ -5598,20 +6272,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:51:35+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/finder", - "version": "v6.4.0", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "11d736e97f116ac375a81f96e662911a34cd50ce" + "reference": "511c48990be17358c23bf45c5d71ab85d40fb764" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/11d736e97f116ac375a81f96e662911a34cd50ce", - "reference": "11d736e97f116ac375a81f96e662911a34cd50ce", + "url": "https://api.github.com/repos/symfony/finder/zipball/511c48990be17358c23bf45c5d71ab85d40fb764", + "reference": "511c48990be17358c23bf45c5d71ab85d40fb764", "shasum": "" }, "require": { @@ -5646,7 +6320,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.4.0" + "source": "https://github.com/symfony/finder/tree/v6.4.7" }, "funding": [ { @@ -5662,20 +6336,20 @@ "type": "tidelift" } ], - "time": "2023-10-31T17:30:12+00:00" + "time": "2024-04-23T10:36:43+00:00" }, { "name": "symfony/options-resolver", - "version": "v6.4.0", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "22301f0e7fdeaacc14318928612dee79be99860e" + "reference": "9a3c92b490716ba6771f5beced13c6eda7183eed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/22301f0e7fdeaacc14318928612dee79be99860e", - "reference": "22301f0e7fdeaacc14318928612dee79be99860e", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9a3c92b490716ba6771f5beced13c6eda7183eed", + "reference": "9a3c92b490716ba6771f5beced13c6eda7183eed", "shasum": "" }, "require": { @@ -5713,7 +6387,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v6.4.0" + "source": "https://github.com/symfony/options-resolver/tree/v6.4.7" }, "funding": [ { @@ -5729,7 +6403,7 @@ "type": "tidelift" } ], - "time": "2023-08-08T10:16:24+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/polyfill-iconv", @@ -5813,16 +6487,16 @@ }, { "name": "symfony/process", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "31642b0818bfcff85930344ef93193f8c607e0a3" + "reference": "cdb1c81c145fd5aa9b0038bab694035020943381" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/31642b0818bfcff85930344ef93193f8c607e0a3", - "reference": "31642b0818bfcff85930344ef93193f8c607e0a3", + "url": "https://api.github.com/repos/symfony/process/zipball/cdb1c81c145fd5aa9b0038bab694035020943381", + "reference": "cdb1c81c145fd5aa9b0038bab694035020943381", "shasum": "" }, "require": { @@ -5854,7 +6528,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.3" + "source": "https://github.com/symfony/process/tree/v6.4.7" }, "funding": [ { @@ -5870,20 +6544,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:51:35+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/stopwatch", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "416596166641f1f728b0a64f5b9dd07cceb410c1" + "reference": "ffec95ba269e541eb2232126c0c20f83086b5c68" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/416596166641f1f728b0a64f5b9dd07cceb410c1", - "reference": "416596166641f1f728b0a64f5b9dd07cceb410c1", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/ffec95ba269e541eb2232126c0c20f83086b5c68", + "reference": "ffec95ba269e541eb2232126c0c20f83086b5c68", "shasum": "" }, "require": { @@ -5916,7 +6590,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v6.4.3" + "source": "https://github.com/symfony/stopwatch/tree/v6.4.7" }, "funding": [ { @@ -5932,20 +6606,20 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:35:58+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.4.3", + "version": "v6.4.7", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "0435a08f69125535336177c29d56af3abc1f69da" + "reference": "7a9cd977cd1c5fed3694bee52990866432af07d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/0435a08f69125535336177c29d56af3abc1f69da", - "reference": "0435a08f69125535336177c29d56af3abc1f69da", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/7a9cd977cd1c5fed3694bee52990866432af07d7", + "reference": "7a9cd977cd1c5fed3694bee52990866432af07d7", "shasum": "" }, "require": { @@ -6001,7 +6675,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.3" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.7" }, "funding": [ { @@ -6017,7 +6691,7 @@ "type": "tidelift" } ], - "time": "2024-01-23T14:53:30+00:00" + "time": "2024-04-18T09:22:46+00:00" }, { "name": "thecodingmachine/safe", @@ -6160,16 +6834,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b2ad5003ca10d4ee50a12da31de12a5774ba6b96", - "reference": "b2ad5003ca10d4ee50a12da31de12a5774ba6b96", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -6198,7 +6872,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.2" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -6206,7 +6880,7 @@ "type": "github" } ], - "time": "2023-11-20T00:12:19+00:00" + "time": "2024-03-03T12:36:25+00:00" }, { "name": "webmozart/assert", @@ -6277,5 +6951,5 @@ "ext-mbstring": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/config/ext.json b/config/ext.json index 8886dd54..f3529fc2 100644 --- a/config/ext.json +++ b/config/ext.json @@ -187,11 +187,6 @@ "icu" ] }, - "parallel": { - "type": "external", - "source": "parallel", - "arg-type-windows": "with" - }, "ldap": { "type": "builtin", "arg-type": "with-prefix", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 09b6b622..22a89ed1 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Command\ListCommand; */ final class ConsoleApplication extends Application { - public const VERSION = '2.2.0'; + public const VERSION = '2.2.1'; public function __construct() { diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 15906bea..2317bccb 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -28,7 +28,7 @@ class BSDBuilder extends UnixBuilderBase // ---------- set necessary options ---------- // set C Compiler (default: clang) f_putenv('CC=' . $this->getOption('cc', 'clang')); - // set C++ Composer (default: clang++) + // set C++ Compiler (default: clang++) f_putenv('CXX=' . $this->getOption('cxx', 'clang++')); // set PATH f_putenv('PATH=' . BUILD_ROOT_PATH . '/bin:' . getenv('PATH')); diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index b191440c..c921ff69 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -92,6 +92,9 @@ class LinuxBuilder extends UnixBuilderBase } /** + * Build PHP from source. + * + * @param int $build_target Build target, use `BUILD_TARGET_*` constants * @throws RuntimeException * @throws FileSystemException * @throws WrongUsageException @@ -131,10 +134,10 @@ class LinuxBuilder extends UnixBuilderBase } $disable_jit = $this->getOption('disable-opcache-jit', false) ? '--disable-opcache-jit ' : ''; - $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; + $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; // prepare build php envs $envs_build_php = SystemUtil::makeEnvVarString([ @@ -144,49 +147,18 @@ class LinuxBuilder extends UnixBuilderBase 'LIBS' => getenv('SPC_CMD_VAR_PHP_CONFIGURE_LIBS'), ]); - // upx pack and strip for micro - // but always restore Makefile.frag.bak first - if (file_exists(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak')) { - copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'); - } - if ($this->getOption('with-upx-pack', false)) { - // judge $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` count - // if 2, replace src/globals/extra/micro-triple-Makefile.frag file content - if (substr_count(FileSystem::readFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'), '$(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)`') === 2) { - // bak first - copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak'); - // replace Makefile.frag content - FileSystem::writeFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', FileSystem::readFile(ROOT_DIR . '/src/globals/extra/micro-triple-Makefile.frag')); - } - // with upx pack always need strip - FileSystem::replaceFileRegex( - SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', - '/POST_MICRO_BUILD_COMMANDS=.*/', - 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . getenv('UPX_EXEC') . ' --best \$(SAPI_MICRO_PATH)', - ); - } elseif (!$this->getOption('no-strip', false)) { - // not-no-strip means strip (default behavior) - FileSystem::replaceFileRegex( - SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', - '/POST_MICRO_BUILD_COMMANDS=.*/', - 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)', - ); - } else { - // just no strip - FileSystem::replaceFileRegex( - SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', - '/POST_MICRO_BUILD_COMMANDS=.*/', - 'POST_MICRO_BUILD_COMMANDS=true', - ); + // process micro upx patch if micro sapi enabled + if ($enable_micro) { + $this->processMicroUPX(); } shell()->cd(SOURCE_PATH . '/php-src') ->exec( getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . - ($enableCli ? '--enable-cli ' : '--disable-cli ') . - ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . - ($enableEmbed ? '--enable-embed=static ' : '--disable-embed ') . - ($enableMicro ? '--enable-micro=all-static ' : '--disable-micro ') . + ($enable_cli ? '--enable-cli ' : '--disable-cli ') . + ($enable_fpm ? '--enable-fpm ' : '--disable-fpm ') . + ($enable_embed ? '--enable-embed=static ' : '--disable-embed ') . + ($enable_micro ? '--enable-micro=all-static ' : '--disable-micro ') . $disable_jit . $json_74 . $zts . @@ -200,21 +172,21 @@ class LinuxBuilder extends UnixBuilderBase $this->cleanMake(); - if ($enableCli) { + if ($enable_cli) { logger()->info('building cli'); $this->buildCli(); } - if ($enableFpm) { + if ($enable_fpm) { logger()->info('building fpm'); $this->buildFpm(); } - if ($enableMicro) { + if ($enable_micro) { logger()->info('building micro'); $this->buildMicro(); } - if ($enableEmbed) { + if ($enable_embed) { logger()->info('building embed'); - if ($enableMicro) { + if ($enable_micro) { FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'OVERALL_TARGET =', 'OVERALL_TARGET = libphp.la'); } $this->buildEmbed(); @@ -330,4 +302,48 @@ class LinuxBuilder extends UnixBuilderBase 'EXTRA_LDFLAGS_PROGRAM' => getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS_PROGRAM'), ]; } + + /** + * Apply option --no-strip and --with-upx-pack for micro sapi. + * + * @throws FileSystemException + */ + private function processMicroUPX(): void + { + // upx pack and strip for micro + // but always restore Makefile.frag.bak first + if (file_exists(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak')) { + copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'); + } + if ($this->getOption('with-upx-pack', false)) { + // judge $(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)` count + // if 2, replace src/globals/extra/micro-triple-Makefile.frag file content + if (substr_count(FileSystem::readFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag'), '$(MAKE) micro_2s_objs SFX_FILESIZE=`$(STAT_SIZE) $(SAPI_MICRO_PATH)`') === 2) { + // bak first + copy(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.bak'); + // replace Makefile.frag content + FileSystem::writeFile(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', FileSystem::readFile(ROOT_DIR . '/src/globals/extra/micro-triple-Makefile.frag')); + } + // with upx pack always need strip + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', + '/POST_MICRO_BUILD_COMMANDS=.*/', + 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH) && ' . getenv('UPX_EXEC') . ' --best \$(SAPI_MICRO_PATH)', + ); + } elseif (!$this->getOption('no-strip', false)) { + // not-no-strip means strip (default behavior) + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', + '/POST_MICRO_BUILD_COMMANDS=.*/', + 'POST_MICRO_BUILD_COMMANDS=\$(STRIP) \$(MICRO_STRIP_FLAGS) \$(SAPI_MICRO_PATH)', + ); + } else { + // just no strip + FileSystem::replaceFileRegex( + SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag', + '/POST_MICRO_BUILD_COMMANDS=.*/', + 'POST_MICRO_BUILD_COMMANDS=true', + ); + } + } } diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index 31064123..96ccc784 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -132,4 +132,14 @@ abstract class BaseCommand extends Command { return true; } + + protected function logWithResult(bool $result, string $success_msg, string $fail_msg): int + { + if ($result) { + logger()->info($success_msg); + return static::SUCCESS; + } + logger()->error($fail_msg); + return static::FAILURE; + } } diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 478cc883..e6d0d0ae 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -17,7 +17,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use ZM\Logger\ConsoleColor; -#[AsCommand('build', 'build PHP')] +#[AsCommand('build', 'build PHP', ['build:php'])] class BuildCliCommand extends BuildCommand { public function configure(): void diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index f4d3b26c..8edaacf6 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -61,6 +61,8 @@ class BuildLibsCommand extends BuildCommand $builder->setLibsOnly(); // 编译和检查库完整 $libraries = DependencyUtil::getLibs($libraries); + logger()->info('Building libraries: ' . implode(',', $libraries)); + sleep(2); $builder->buildLibs($libraries); $time = round(microtime(true) - START_TIME, 3); diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index 2d01a692..66047567 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -57,8 +57,11 @@ class DumpLicenseCommand extends BaseCommand $libraries = DependencyUtil::getLibs($libraries); $dumper->addLibs($libraries); $dumper->dump($this->getOption('dump-dir')); - $this->output->writeln('Dump target dir: ' . $this->getOption('dump-dir')); - return static::SUCCESS; + return $this->logWithResult( + $dumper->dump($this->getOption('dump-dir')), + 'Dump target dir: ' . $this->getOption('dump-dir'), + 'Dump failed!' + ); } if ($this->getOption('for-sources') !== null) { $sources = array_map('trim', array_filter(explode(',', $this->getOption('for-sources')))); diff --git a/src/SPC/util/GlobalEnvManager.php b/src/SPC/util/GlobalEnvManager.php index 0c5a0c1a..b44cf3b5 100644 --- a/src/SPC/util/GlobalEnvManager.php +++ b/src/SPC/util/GlobalEnvManager.php @@ -51,7 +51,7 @@ class GlobalEnvManager // Init system-specific env match (PHP_OS_FAMILY) { - 'Windows' => self::initWindowsEnv($builder), + 'Windows' => self::initWindowsEnv(), 'Darwin' => self::initDarwinEnv($builder), 'Linux' => self::initLinuxEnv($builder), 'BSD' => 'TODO', @@ -59,7 +59,7 @@ class GlobalEnvManager }; } - private static function initWindowsEnv(BuilderBase $builder): void + private static function initWindowsEnv(): void { // Windows need php-sdk binary tools self::initIfNotExists('PHP_SDK_PATH', WORKING_DIR . DIRECTORY_SEPARATOR . 'php-sdk-binary-tools'); @@ -69,7 +69,7 @@ class GlobalEnvManager private static function initLinuxEnv(BuilderBase $builder): void { // Init C Compiler and C++ Compiler (alpine) - if (\SPC\builder\linux\SystemUtil::isMuslDist()) { + if (LinuxSystemUtil::isMuslDist()) { self::initIfNotExists('CC', 'gcc'); self::initIfNotExists('CXX', 'g++'); self::initIfNotExists('AR', 'ar'); diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index 196ca365..61a6dc06 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -10,6 +10,9 @@ use SPC\exception\WrongUsageException; use SPC\store\Config; use SPC\store\FileSystem; +/** + * License dumper, dump source license files to target directory + */ class LicenseDumper { private array $exts = []; @@ -37,6 +40,10 @@ class LicenseDumper } /** + * Dump source licenses to target directory + * + * @param string $target_dir Target directory + * @return bool Success or not * @throws WrongUsageException * @throws FileSystemException * @throws RuntimeException @@ -55,20 +62,29 @@ class LicenseDumper $source_name = Config::getExt($ext, 'source'); foreach ($this->getSourceLicenses($source_name) as $index => $license) { - file_put_contents("{$target_dir}/ext_{$ext}_{$index}.txt", $license); + $result = file_put_contents("{$target_dir}/ext_{$ext}_{$index}.txt", $license); + if ($result === false) { + return false; + } } } foreach ($this->libs as $lib) { $source_name = Config::getLib($lib, 'source'); foreach ($this->getSourceLicenses($source_name) as $index => $license) { - file_put_contents("{$target_dir}/lib_{$lib}_{$index}.txt", $license); + $result = file_put_contents("{$target_dir}/lib_{$lib}_{$index}.txt", $license); + if ($result === false) { + return false; + } } } foreach ($this->sources as $source) { foreach ($this->getSourceLicenses($source) as $index => $license) { - file_put_contents("{$target_dir}/src_{$source}_{$index}.txt", $license); + $result = file_put_contents("{$target_dir}/src_{$source}_{$index}.txt", $license); + if ($result === false) { + return false; + } } } return true; diff --git a/src/SPC/util/Patcher.php b/src/SPC/util/Patcher.php deleted file mode 100644 index 1419606e..00000000 --- a/src/SPC/util/Patcher.php +++ /dev/null @@ -1,38 +0,0 @@ -getPatchPoint(); +} + +// ------- function f_* part ------- +// f_ means standard function wrapper + /** * Execute the shell command, and the output will be directly printed in the terminal. If there is an error, an exception will be thrown * @@ -126,33 +173,3 @@ function f_putenv(string $env): bool logger()->debug('Setting env: ' . $env); return putenv($env); } - -function shell(?bool $debug = null): UnixShell -{ - return new UnixShell($debug); -} - -function cmd(?bool $debug = null): WindowsCmd -{ - return new WindowsCmd($debug); -} - -/** - * Get current builder. - * - * @throws WrongUsageException - */ -function builder(): BuilderBase -{ - return BuilderProvider::getBuilder(); -} - -/** - * Get current patch point. - * - * @throws WrongUsageException - */ -function patch_point(): string -{ - return BuilderProvider::getBuilder()->getPatchPoint(); -} From 3136d6edc1485a053485bf1f8f213cbe83c54479 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 16 May 2024 13:01:11 +0800 Subject: [PATCH 290/415] Put extension and library compatibility checks before compilation (#451) --- src/SPC/builder/BuilderBase.php | 37 ++++++++++++++++++- src/SPC/builder/Extension.php | 5 +++ src/SPC/builder/LibraryBase.php | 5 +++ src/SPC/builder/extension/imap.php | 6 ++- src/SPC/builder/extension/opcache.php | 6 ++- src/SPC/builder/extension/parallel.php | 3 +- .../builder/extension/swoole_hook_pgsql.php | 6 ++- .../builder/extension/swoole_hook_sqlite.php | 6 ++- src/SPC/builder/freebsd/BSDBuilder.php | 3 +- src/SPC/builder/unix/UnixBuilderBase.php | 12 +----- src/SPC/builder/windows/WindowsBuilder.php | 12 +----- src/SPC/command/BuildCliCommand.php | 17 +++++++-- src/SPC/command/BuildLibsCommand.php | 4 +- 13 files changed, 86 insertions(+), 36 deletions(-) diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index ee4d9d61..fb3fd70f 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -33,7 +33,7 @@ abstract class BuilderBase protected string $patch_point = ''; /** - * Build libraries + * Convert libraries to class * * @param array $sorted_libraries Libraries to build (if not empty, must sort first) * @throws FileSystemException @@ -41,7 +41,27 @@ abstract class BuilderBase * @throws WrongUsageException * @internal */ - abstract public function buildLibs(array $sorted_libraries); + abstract public function proveLibs(array $sorted_libraries); + + /** + * Build libraries + * + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException + */ + public function buildLibs(): void + { + // build all libs + foreach ($this->libs as $lib) { + match ($lib->tryBuild($this->getOption('rebuild', false))) { + BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), + BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), + BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), + default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), + }; + } + } /** * Add library to build. @@ -335,6 +355,19 @@ abstract class BuilderBase return $this->patch_point; } + /** + * Validate libs and exts can be compiled successfully in current environment + */ + public function validateLibsAndExts(): void + { + foreach ($this->libs as $lib) { + $lib->validate(); + } + foreach ($this->exts as $ext) { + $ext->validate(); + } + } + public function emitPatchPoint(string $point_name): void { $this->patch_point = $point_name; diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index ea875a78..5a317184 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -223,6 +223,11 @@ class Extension } } + public function validate(): void + { + // do nothing, just throw wrong usage exception if not valid + } + /** * @throws RuntimeException */ diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index cff8ff2b..ef6ea79d 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -177,6 +177,11 @@ abstract class LibraryBase return false; } + public function validate(): void + { + // do nothing, just throw wrong usage exception if not valid + } + /** * Get current builder object. */ diff --git a/src/SPC/builder/extension/imap.php b/src/SPC/builder/extension/imap.php index 389223ec..bdb1cd8c 100644 --- a/src/SPC/builder/extension/imap.php +++ b/src/SPC/builder/extension/imap.php @@ -14,11 +14,15 @@ class imap extends Extension /** * @throws WrongUsageException */ - public function getUnixConfigureArg(): string + public function validate(): void { if ($this->builder->getOption('enable-zts')) { throw new WrongUsageException('ext-imap is not thread safe, do not build it with ZTS builds'); } + } + + public function getUnixConfigureArg(): string + { $arg = '--with-imap=' . BUILD_ROOT_PATH; if ($this->builder->getLib('openssl') !== null) { $arg .= ' --with-imap-ssl=' . BUILD_ROOT_PATH; diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 82efc853..0bd972d6 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -16,11 +16,15 @@ class opcache extends Extension * @throws WrongUsageException * @throws RuntimeException */ - public function getUnixConfigureArg(): string + public function validate(): void { if ($this->builder->getPHPVersionID() < 80000) { throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !'); } + } + + public function getUnixConfigureArg(): string + { return '--enable-opcache'; } diff --git a/src/SPC/builder/extension/parallel.php b/src/SPC/builder/extension/parallel.php index 8fdf1824..f50dffb2 100644 --- a/src/SPC/builder/extension/parallel.php +++ b/src/SPC/builder/extension/parallel.php @@ -11,11 +11,10 @@ use SPC\util\CustomExt; #[CustomExt('parallel')] class parallel extends Extension { - public function getConfigureArg(): string + public function validate(): void { if (!$this->builder->getOption('enable-zts')) { throw new WrongUsageException('ext-parallel must be built with ZTS builds. Use "--enable-zts" option!'); } - return parent::getConfigureArg(); // TODO: Change the autogenerated stub } } diff --git a/src/SPC/builder/extension/swoole_hook_pgsql.php b/src/SPC/builder/extension/swoole_hook_pgsql.php index dd77db18..a1c58f9f 100644 --- a/src/SPC/builder/extension/swoole_hook_pgsql.php +++ b/src/SPC/builder/extension/swoole_hook_pgsql.php @@ -17,12 +17,16 @@ class swoole_hook_pgsql extends Extension return 'swoole'; } - public function getUnixConfigureArg(): string + public function validate(): void { // pdo_pgsql need to be disabled if ($this->builder->getExt('pdo_pgsql') !== null) { throw new WrongUsageException('swoole-hook-pgsql provides pdo_pgsql, if you enable pgsql hook for swoole, you must remove pdo_pgsql extension.'); } + } + + public function getUnixConfigureArg(): string + { // enable swoole pgsql hook return '--enable-swoole-pgsql'; } diff --git a/src/SPC/builder/extension/swoole_hook_sqlite.php b/src/SPC/builder/extension/swoole_hook_sqlite.php index 4dbfd0df..60ffe5d2 100644 --- a/src/SPC/builder/extension/swoole_hook_sqlite.php +++ b/src/SPC/builder/extension/swoole_hook_sqlite.php @@ -17,12 +17,16 @@ class swoole_hook_sqlite extends Extension return 'swoole'; } - public function getUnixConfigureArg(): string + public function validate(): void { // pdo_pgsql need to be disabled if ($this->builder->getExt('pdo_sqlite') !== null) { throw new WrongUsageException('swoole-hook-sqlite provides pdo_sqlite, if you enable sqlite hook for swoole, you must remove pdo_sqlite extension.'); } + } + + public function getUnixConfigureArg(): string + { // enable swoole pgsql hook return '--enable-swoole-sqlite'; } diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index 2317bccb..ffb44316 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -86,7 +86,8 @@ class BSDBuilder extends UnixBuilderBase SourcePatcher::patchBeforeConfigure($this); $json_74 = $this->getPHPVersionID() < 80000 ? '--enable-json ' : ''; - $zts = $this->getOption('enable-zts', false) ? '--enable-zts --disable-zend-signals ' : ''; + $zts_enable = $this->getPHPVersionID() < 80000 ? '--enable-maintainer-zts --disable-zend-signals' : '--enable-zts --disable-zend-signals'; + $zts = $this->getOption('enable-zts', false) ? $zts_enable : ''; $enableCli = ($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI; $enableFpm = ($build_target & BUILD_TARGET_FPM) === BUILD_TARGET_FPM; diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 934ddaad..7b17698a 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -90,7 +90,7 @@ abstract class UnixBuilderBase extends BuilderBase return $extra; } - public function buildLibs(array $sorted_libraries): void + public function proveLibs(array $sorted_libraries): void { // search all supported libs $support_lib_list = []; @@ -137,16 +137,6 @@ abstract class UnixBuilderBase extends BuilderBase SourceManager::initSource(libs: $sorted_libraries); $this->emitPatchPoint('after-libs-extract'); - - // build all libs - foreach ($this->libs as $lib) { - match ($lib->tryBuild($this->getOption('rebuild', false))) { - BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), - BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), - BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), - default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), - }; - } } /** diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index dff8b746..f2026055 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -205,7 +205,7 @@ class WindowsBuilder extends BuilderBase $this->deployBinary(BUILD_TARGET_MICRO); } - public function buildLibs(array $sorted_libraries): void + public function proveLibs(array $sorted_libraries): void { // search all supported libs $support_lib_list = []; @@ -242,16 +242,6 @@ class WindowsBuilder extends BuilderBase // extract sources SourceManager::initSource(libs: $sorted_libraries); - - // build all libs - foreach ($this->libs as $lib) { - match ($lib->tryBuild($this->getOption('rebuild', false))) { - BUILD_STATUS_OK => logger()->info('lib [' . $lib::NAME . '] build success'), - BUILD_STATUS_ALREADY => logger()->notice('lib [' . $lib::NAME . '] already built'), - BUILD_STATUS_FAILED => logger()->error('lib [' . $lib::NAME . '] build failed'), - default => logger()->warning('lib [' . $lib::NAME . '] build status unknown'), - }; - } } /** diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index e6d0d0ae..d196b455 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -93,6 +93,9 @@ class BuildCliCommand extends BuildCommand if ($this->getOption('no-strip')) { logger()->warning('--with-upx-pack conflicts with --no-strip, --no-strip won\'t work!'); } + if (($rule & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { + logger()->warning('Some cases micro.sfx cannot be packed via UPX due to dynamic size bug, be aware!'); + } } try { // create builder @@ -133,17 +136,23 @@ class BuildCliCommand extends BuildCommand } $this->printFormatInfo($this->getDefinedEnvs(), true); $this->printFormatInfo($indent_texts); + logger()->notice('Build will start after 2s ...'); sleep(2); + // compile libraries + $builder->proveLibs($libraries); + // check extensions + $builder->proveExts($extensions); + // validate libs and exts + $builder->validateLibsAndExts(); + // build libraries + $builder->buildLibs(); + if ($this->input->getOption('with-clean')) { logger()->info('Cleaning source dir...'); FileSystem::removeDir(SOURCE_PATH); } - // compile libraries - $builder->buildLibs($libraries); - // check extensions - $builder->proveExts($extensions); // Process -I option $custom_ini = []; diff --git a/src/SPC/command/BuildLibsCommand.php b/src/SPC/command/BuildLibsCommand.php index 8edaacf6..8bb08f61 100644 --- a/src/SPC/command/BuildLibsCommand.php +++ b/src/SPC/command/BuildLibsCommand.php @@ -63,7 +63,9 @@ class BuildLibsCommand extends BuildCommand $libraries = DependencyUtil::getLibs($libraries); logger()->info('Building libraries: ' . implode(',', $libraries)); sleep(2); - $builder->buildLibs($libraries); + $builder->proveLibs($libraries); + $builder->validateLibsAndExts(); + $builder->buildLibs(); $time = round(microtime(true) - START_TIME, 3); logger()->info('Build libs complete, used ' . $time . ' s !'); From 1fdb6b439e5d79e1ab2a1dc21139785a7cff7e7e Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 17 May 2024 16:34:59 +0800 Subject: [PATCH 291/415] Add compression for spc.phar and spc.exe (#452) --- box.json | 1 + 1 file changed, 1 insertion(+) diff --git a/box.json b/box.json index 6626fa2f..f6eecf1c 100644 --- a/box.json +++ b/box.json @@ -4,6 +4,7 @@ "blacklist": [ ".github" ], + "compression": "GZ", "directories": [ "config", "src", From 98d3766fe83e9b85fe4c5a4831e8336731927a18 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 17 May 2024 16:42:26 +0800 Subject: [PATCH 292/415] Add xattr command to prevent macOS GateKeeper block --- .github/workflows/release-build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 62099e08..d21f069d 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -76,6 +76,9 @@ jobs: else chmod +x spc fi + if [ "${{ matrix.operating-system }}" = "macos-aarch64" ] || [ "${{ matrix.operating-system }}" = "macos-x86_64" ]; then + xattr -cr spc + fi - name: "Archive Executable" run: | From 71770a0a5f89aca60bdcd5b7cb7d6d1ac6192e9c Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 17 May 2024 19:41:02 +0800 Subject: [PATCH 293/415] Add xattr command to prevent macOS GateKeeper block (#453) * Add xattr command to prevent macOS GateKeeper block * test * test * test: disable build tests * test * test * test * update * update --- .github/workflows/release-build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index d21f069d..211e52bc 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -11,7 +11,7 @@ on: jobs: build-release-artifacts: name: "Build SPC Binary" - runs-on: ubuntu-latest + runs-on: macos-14 strategy: matrix: php-version: @@ -45,7 +45,7 @@ jobs: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: "Cache Composer dependencies" - uses: "actions/cache@v3" + uses: "actions/cache@v4" with: path: "${{ steps.composer-cache.outputs.dir }}" key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" @@ -77,7 +77,7 @@ jobs: chmod +x spc fi if [ "${{ matrix.operating-system }}" = "macos-aarch64" ] || [ "${{ matrix.operating-system }}" = "macos-x86_64" ]; then - xattr -cr spc + sudo xattr -cr ./spc fi - name: "Archive Executable" @@ -86,7 +86,7 @@ jobs: tar -czf spc-${{ matrix.operating-system }}.tar.gz spc echo "filename=spc-${{ matrix.operating-system }}.tar.gz" >> $GITHUB_ENV echo "OS=${{ matrix.operating-system }}" >> $GITHUB_ENV - if [ "${{ matrix.operating-system }}" == "linux-x86_64" ]; then + if [ "${{ matrix.operating-system }}" == "macos-aarch64" ]; then ./spc dev:extensions fi else @@ -122,7 +122,7 @@ jobs: TARGET: ${{ secrets.DEPLOY_SERVER_TARGET_SPC_NIGHTLY }} - name: "Upload Artifact" - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: path: spc${{ env.SUFFIX }} name: spc-${{ matrix.operating-system }}${{ env.SUFFIX }} From 11076b13551498bbfe807fc56e48fdf6a9309cd7 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 21 May 2024 14:54:08 +0800 Subject: [PATCH 294/415] Add comomand: `switch-php-version` (#457) * add switch-php-version command * update README direct download description --- README-zh.md | 9 ++- README.md | 9 ++- src/SPC/command/SwitchPhpVersionCommand.php | 67 +++++++++++++++++++++ 3 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 src/SPC/command/SwitchPhpVersionCommand.php diff --git a/README-zh.md b/README-zh.md index 2a26b156..11fbe4e6 100755 --- a/README-zh.md +++ b/README-zh.md @@ -43,9 +43,12 @@ static-php-cli(简称 `spc`)有许多特性: 如果你不想自行编译 PHP,可以从本项目现有的示例 Action 下载 Artifact,也可以从自托管的服务器下载。 -- [扩展组合 - common](https://dl.static-php.dev/static-php-cli/common/):common 组合包含了约 [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) 个常用扩展,体积为 22MB 左右。 -- [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 70MB 左右。 -- [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/):minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 6MB 左右。 +- [扩展组合 - common](https://dl.static-php.dev/static-php-cli/common/):common 组合包含了约 [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) 个常用扩展,体积为 7.5MB 左右。 +- [扩展组合 - bulk](https://dl.static-php.dev/static-php-cli/bulk/):bulk 组合包含了 [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) 个扩展,体积为 25MB 左右。 +- [扩展组合 - minimal](https://dl.static-php.dev/static-php-cli/minimal/):minimal 组合包含了 [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) 个扩展,体积为 3MB 左右。 + +> Linux 和 Windows 默认启用了 UPX 压缩,可减小 30~50% 的 PHP 二进制体积。 +> macOS 当前不支持 UPX,所以上述预编译的 macOS 版本体积可能较大。 对于 Windows 系统,目前支持的扩展较少,故仅提供 SPC 自身运行的最小扩展组合的 `cli` 和 `micro`:[扩展组合 - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/)。 diff --git a/README.md b/README.md index 7d423681..91e8953c 100755 --- a/README.md +++ b/README.md @@ -49,9 +49,12 @@ If you don't want to build or want to test first, you can download example pre-c Below are several precompiled static-php binaries with different extension combinations, which can be downloaded directly according to your needs. -- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 22MB. -- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 70MB in size. -- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 6MB in size. +- [Extension-Combination - common](https://dl.static-php.dev/static-php-cli/common/): `common` contains about [30+](https://dl.static-php.dev/static-php-cli/common/README.txt) commonly used extensions, and the size is about 7.5MB. +- [Extension-Combination - bulk](https://dl.static-php.dev/static-php-cli/bulk/): `bulk` contains [50+](https://dl.static-php.dev/static-php-cli/bulk/README.txt) extensions and is about 25MB in size. +- [Extension-Combination - minimal](https://dl.static-php.dev/static-php-cli/minimal/): `minimal` contains [5](https://dl.static-php.dev/static-php-cli/minimal/README.txt) extensions and is about 3MB in size. + +> Linux and Windows supports UPX compression for binaries, which can reduce the size of the binary by 30% to 50%. +> macOS does not support UPX compression, so the size of the pre-built binaries for mac is larger. For Windows systems, there are currently fewer extensions supported, so only `cli` and `micro` that run the minimum extension combination of SPC itself are provided: [Extension-Combination - spc-min](https://dl.static-php.dev/static-php-cli/windows/spc-min/). diff --git a/src/SPC/command/SwitchPhpVersionCommand.php b/src/SPC/command/SwitchPhpVersionCommand.php new file mode 100644 index 00000000..ac5ae01f --- /dev/null +++ b/src/SPC/command/SwitchPhpVersionCommand.php @@ -0,0 +1,67 @@ +addArgument( + 'php-major-version', + InputArgument::REQUIRED, + 'PHP major version (supported: 7.4, 8.0, 8.1, 8.2, 8.3)', + null, + fn () => ['7.4', '8.0', '8.1', '8.2', '8.3'] + ); + $this->no_motd = true; + + $this->addOption('retry', 'R', InputOption::VALUE_REQUIRED, 'Set retry time when downloading failed (default: 0)', '0'); + } + + public function handle(): int + { + $php_ver = $this->input->getArgument('php-major-version'); + if (!in_array($php_ver, ['7.4', '8.0', '8.1', '8.2', '8.3'])) { + $this->output->writeln('Invalid PHP major version ' . $php_ver . ' !'); + return static::FAILURE; + } + + // 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)) { + $this->output->writeln('Removing old PHP source...'); + unlink($file); + } + + // Download new PHP source + $this->output->writeln('Downloading PHP source...'); + define('SPC_BUILD_PHP_VERSION', $php_ver); + + // retry + $retry = intval($this->getOption('retry')); + f_putenv('SPC_RETRY_TIME=' . $retry); + + Downloader::downloadSource('php-src', Config::getSource('php-src')); + + // Remove source/php-src dir + FileSystem::removeDir(SOURCE_PATH . '/php-src'); + + $this->output->writeln('Switched to PHP ' . $php_ver . ' successfully!'); + return static::SUCCESS; + } +} From 4ba92b08cac34839681c713fa05740f952556372 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 21 May 2024 14:56:54 +0800 Subject: [PATCH 295/415] Add extension version and env check method (#458) --- src/SPC/ConsoleApplication.php | 9 ++------- src/SPC/builder/extension/opcache.php | 2 +- src/SPC/builder/extension/protobuf.php | 19 +++++++++++++++++++ src/SPC/builder/extension/swow.php | 7 +++++++ 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/SPC/builder/extension/protobuf.php diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 22a89ed1..c18856f5 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -16,9 +16,8 @@ use SPC\command\DumpLicenseCommand; use SPC\command\ExtractCommand; use SPC\command\InstallPkgCommand; use SPC\command\MicroCombineCommand; +use SPC\command\SwitchPhpVersionCommand; use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\HelpCommand; -use Symfony\Component\Console\Command\ListCommand; /** * static-php-cli console app entry @@ -43,6 +42,7 @@ final class ConsoleApplication extends Application new DumpLicenseCommand(), new ExtractCommand(), new MicroCombineCommand(), + new SwitchPhpVersionCommand(), // Dev commands new AllExtCommand(), @@ -51,9 +51,4 @@ final class ConsoleApplication extends Application ] ); } - - protected function getDefaultCommands(): array - { - return [new HelpCommand(), new ListCommand()]; - } } diff --git a/src/SPC/builder/extension/opcache.php b/src/SPC/builder/extension/opcache.php index 0bd972d6..a0af4a8f 100644 --- a/src/SPC/builder/extension/opcache.php +++ b/src/SPC/builder/extension/opcache.php @@ -18,7 +18,7 @@ class opcache extends Extension */ public function validate(): void { - if ($this->builder->getPHPVersionID() < 80000) { + if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { throw new WrongUsageException('Statically compiled PHP with Zend Opcache only available for PHP >= 8.0 !'); } } diff --git a/src/SPC/builder/extension/protobuf.php b/src/SPC/builder/extension/protobuf.php new file mode 100644 index 00000000..9bab1a32 --- /dev/null +++ b/src/SPC/builder/extension/protobuf.php @@ -0,0 +1,19 @@ +builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { + throw new \RuntimeException('The latest protobuf extension requires PHP 8.0 or later'); + } + } +} diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index a43fdc1d..3b2f91d9 100644 --- a/src/SPC/builder/extension/swow.php +++ b/src/SPC/builder/extension/swow.php @@ -11,6 +11,13 @@ use SPC\util\CustomExt; #[CustomExt('swow')] class swow extends Extension { + public function validate(): void + { + if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { + throw new RuntimeException('The latest swow extension requires PHP 8.0 or later'); + } + } + public function getUnixConfigureArg(): string { $arg = '--enable-swow'; From 5d2bd93bd7adc6898dc230d40d11a137510b8344 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 21 May 2024 18:09:41 +0800 Subject: [PATCH 296/415] Remove dll before sanity check (#459) --- src/SPC/builder/windows/WindowsBuilder.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index f2026055..6da09257 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -261,6 +261,12 @@ class WindowsBuilder extends BuilderBase */ public function sanityCheck(mixed $build_target): void { + // remove all .dll from `buildroot/bin/` + logger()->debug('Removing all .dll files from buildroot/bin/'); + $dlls = glob(BUILD_BIN_PATH . '\*.dll'); + foreach ($dlls as $dll) { + @unlink($dll); + } // sanity check for php-cli if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) { logger()->info('running cli sanity check'); From 968b3acbceeed16e1b25e005874b7e1722fc9863 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 29 May 2024 13:53:08 +0800 Subject: [PATCH 297/415] Add gen-ext-docs command (#462) --- .github/workflows/update-docs-config.yml | 33 +- config/ext.json | 283 ++++++++++++++++++ src/SPC/ConsoleApplication.php | 4 +- src/SPC/command/dev/GenerateExtDocCommand.php | 80 +++++ 4 files changed, 395 insertions(+), 5 deletions(-) create mode 100644 src/SPC/command/dev/GenerateExtDocCommand.php diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/update-docs-config.yml index d29b7960..d3687b42 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/update-docs-config.yml @@ -15,9 +15,6 @@ jobs: steps: - name: "Checkout static-php-cli" uses: actions/checkout@v4 - with: - ref: main - path: static-php-cli - name: "Checkout static-php-cli-docs" uses: actions/checkout@v4 @@ -33,7 +30,35 @@ jobs: git config --global user.name "GitHub Actions" - name: "Copy Config Files" - run: cp -r static-php-cli/config/* static-php-cli-docs/docs/.vitepress/config/ + run: cp -r config/* static-php-cli-docs/docs/.vitepress/config/ + + - name: "Install PHP for official runners" + uses: "shivammathur/setup-php@v2" + with: + coverage: none + tools: composer:v2 + php-version: 8.2 + ini-values: memory_limit=-1 + + - name: "Get Composer Cache Directory" + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: "actions/cache@v4" + with: + path: "${{ steps.composer-cache.outputs.dir }}" + key: "php-8.2-locked-composer-${{ hashFiles('**/composer.lock') }}" + restore-keys: | + php-8.2-locked-composer + + - name: "Install Locked Dependencies" + run: "composer install --no-interaction --no-progress" + + - name: "Generate Extension Support List" + run: | + bin/spc dev:gen-ext-docs > static-php-cli-docs/docs/extensions.md - name: "Commit and Push Changes" run: | diff --git a/config/ext.json b/config/ext.json index f3529fc2..2ac53d09 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1,5 +1,8 @@ { "amqp": { + "support": { + "BSD": "wip" + }, "type": "external", "arg-type": "custom", "source": "amqp", @@ -18,6 +21,9 @@ "type": "builtin" }, "bz2": { + "support": { + "Windows": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -31,6 +37,7 @@ "type": "builtin" }, "curl": { + "notes": true, "type": "builtin", "arg-type": "with", "lib-depends": [ @@ -49,6 +56,9 @@ ] }, "dom": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -64,7 +74,21 @@ "type": "external", "source": "ext-ds" }, + "enchant": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Darwin": "wip", + "Linux": "wip" + }, + "type": "wip" + }, "event": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "ext-event", "arg-type": "custom", @@ -82,6 +106,11 @@ "type": "builtin" }, "ffi": { + "support": { + "Linux": "no", + "BSD": "wip" + }, + "notes": true, "arg-type": "custom", "type": "builtin", "lib-depends-unix": [ @@ -104,6 +133,11 @@ ] }, "gd": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -122,6 +156,10 @@ ] }, "gettext": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -129,6 +167,12 @@ ] }, "glfw": { + "support": { + "Windows": "wip", + "BSD": "no", + "Linux": "no" + }, + "notes": true, "type": "external", "arg-type": "custom", "source": "ext-glfw", @@ -138,6 +182,10 @@ "lib-depends-windows": [] }, "gmp": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -145,6 +193,9 @@ ] }, "iconv": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "with", @@ -156,10 +207,18 @@ ] }, "igbinary": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "igbinary" }, "imagick": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-imagick", "arg-type": "custom", @@ -168,6 +227,11 @@ ] }, "imap": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -178,16 +242,29 @@ ] }, "inotify": { + "support": { + "Windows": "no", + "BSD": "wip", + "Darwin": "no" + }, "type": "external", "source": "inotify" }, "intl": { + "support": { + "Windows": "no", + "BSD": "wip" + }, "type": "builtin", "lib-depends": [ "icu" ] }, "ldap": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -215,7 +292,21 @@ "type": "builtin", "arg-type": "custom" }, + "mcrypt": { + "type": "wip", + "support": { + "Windows": "no", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, "memcache": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-memcache", "arg-type": "custom", @@ -227,6 +318,11 @@ ] }, "memcached": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Linux": "no" + }, "type": "external", "source": "memcached", "arg-type": "custom", @@ -240,6 +336,12 @@ ] }, "mongodb": { + "support": { + "Darwin": "no", + "BSD": "wip", + "Windows": "wip" + }, + "notes": true, "type": "external", "source": "mongodb", "arg-type": "custom", @@ -264,11 +366,22 @@ "zlib" ] }, + "oci8": { + "type": "wip", + "support": { + "Windows": "wip", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, "opcache": { "type": "builtin", "arg-type": "custom" }, "openssl": { + "notes": true, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -281,6 +394,10 @@ ] }, "parallel": { + "support": { + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "parallel", "arg-type-windows": "with", @@ -289,6 +406,11 @@ ] }, "password-argon2": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -296,6 +418,9 @@ ] }, "pcntl": { + "support": { + "Windows": "no" + }, "type": "builtin", "unix-only": true }, @@ -311,6 +436,10 @@ ] }, "pdo_pgsql": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "ext-depends": [ @@ -322,6 +451,9 @@ ] }, "pdo_sqlite": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "with", "ext-depends": [ @@ -333,6 +465,10 @@ ] }, "pdo_sqlsrv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "pdo_sqlsrv", "arg-type": "with", @@ -342,6 +478,11 @@ ] }, "pgsql": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -355,19 +496,36 @@ ] }, "posix": { + "support": { + "Windows": "no" + }, "type": "builtin", "unix-only": true }, "protobuf": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "protobuf" }, "rar": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Darwin": "partial" + }, + "notes": true, "type": "external", "source": "rar", "cpp-extension": true }, "readline": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -375,6 +533,10 @@ ] }, "redis": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "redis", "arg-type": "custom", @@ -399,6 +561,9 @@ "cpp-extension": true }, "simplexml": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -409,6 +574,10 @@ ] }, "snappy": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-snappy", "cpp-extension": true, @@ -421,6 +590,9 @@ ] }, "soap": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -434,6 +606,10 @@ "type": "builtin" }, "sodium": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with", "lib-depends": [ @@ -441,6 +617,9 @@ ] }, "sqlite3": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "with", @@ -449,6 +628,10 @@ ] }, "sqlsrv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "sqlsrv", "lib-depends": [ @@ -460,6 +643,9 @@ "cpp-extension": true }, "ssh2": { + "support": { + "BSD": "wip" + }, "type": "external", "source": "ext-ssh2", "arg-type": "with-prefix", @@ -473,6 +659,11 @@ ] }, "swoole": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "swoole", "arg-type": "custom", @@ -495,6 +686,11 @@ ] }, "swoole-hook-mysql": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, "type": "addon", "arg-type": "custom", "ext-depends": [ @@ -507,6 +703,12 @@ ] }, "swoole-hook-pgsql": { + "support": { + "Windows": "no", + "BSD": "wip", + "Darwin": "partial" + }, + "notes": true, "type": "addon", "arg-type": "custom", "ext-depends": [ @@ -515,6 +717,11 @@ ] }, "swoole-hook-sqlite": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, "type": "addon", "arg-type": "custom", "ext-depends": [ @@ -523,6 +730,11 @@ ] }, "swow": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "swow", "arg-type": "custom", @@ -536,17 +748,32 @@ ] }, "sysvmsg": { + "support": { + "Windows": "no", + "BSD": "wip" + }, "type": "builtin", "unix-only": true }, "sysvsem": { + "support": { + "Windows": "no", + "BSD": "wip" + }, "type": "builtin", "unix-only": true }, "sysvshm": { + "support": { + "BSD": "wip" + }, "type": "builtin" }, "tidy": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -557,6 +784,10 @@ "type": "builtin" }, "uuid": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-uuid", "arg-type": "with-prefix", @@ -565,6 +796,10 @@ ] }, "uv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-uv", "arg-type": "with-prefix", @@ -575,7 +810,22 @@ "sockets" ] }, + "xdebug": { + "type": "builtin", + "support": { + "Windows": "wip", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, "xhprof": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, "type": "external", "source": "xhprof", "ext-depends": [ @@ -583,6 +833,10 @@ ] }, "xlswriter": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "xlswriter", "arg-type": "custom", @@ -592,6 +846,10 @@ ] }, "xml": { + "support": { + "BSD": "wip" + }, + "notes": true, "type": "builtin", "arg-type": "custom", "arg-type-windows": "with", @@ -603,6 +861,9 @@ ] }, "xmlreader": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -614,6 +875,9 @@ ] }, "xmlwriter": { + "support": { + "BSD": "wip" + }, "type": "builtin", "arg-type": "custom", "lib-depends": [ @@ -624,6 +888,10 @@ ] }, "xsl": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "lib-depends": [ @@ -635,6 +903,9 @@ ] }, "yac": { + "support": { + "BSD": "wip" + }, "type": "external", "source": "yac", "arg-type-unix": "custom", @@ -643,6 +914,10 @@ ] }, "yaml": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "yaml", "arg-type": "with-prefix", @@ -651,6 +926,10 @@ ] }, "zip": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "enable", @@ -667,6 +946,10 @@ ] }, "zstd": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, "type": "external", "source": "ext-zstd", "arg-type": "custom", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index c18856f5..fca4015e 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -8,6 +8,7 @@ use SPC\command\BuildCliCommand; use SPC\command\BuildLibsCommand; use SPC\command\DeleteDownloadCommand; use SPC\command\dev\AllExtCommand; +use SPC\command\dev\GenerateExtDocCommand; use SPC\command\dev\PhpVerCommand; use SPC\command\dev\SortConfigCommand; use SPC\command\DoctorCommand; @@ -24,7 +25,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.2.1'; + public const VERSION = '2.2.2'; public function __construct() { @@ -48,6 +49,7 @@ final class ConsoleApplication extends Application new AllExtCommand(), new PhpVerCommand(), new SortConfigCommand(), + new GenerateExtDocCommand(), ] ); } diff --git a/src/SPC/command/dev/GenerateExtDocCommand.php b/src/SPC/command/dev/GenerateExtDocCommand.php new file mode 100644 index 00000000..c53e529d --- /dev/null +++ b/src/SPC/command/dev/GenerateExtDocCommand.php @@ -0,0 +1,80 @@ + $ext) { + // notes is optional + $name = ($ext['notes'] ?? false) === true ? "[{$ext_name}](./extension-notes#{$ext_name})" : $ext_name; + // calculate max length + $max_name = max($max_name, strlen($name)); + + // linux + $linux = match ($ext['support']['Linux'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['Linux'] ?? 'yes', + }; + $max_linux = max($max_linux, strlen($linux)); + + // macos + $macos = match ($ext['support']['Darwin'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['Darwin'] ?? 'yes', + }; + $max_macos = max($max_macos, strlen($macos)); + + // freebsd + $freebsd = match ($ext['support']['BSD'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['BSD'] ?? 'yes', + }; + $max_freebsd = max($max_freebsd, strlen($freebsd)); + + // windows + $windows = match ($ext['support']['Windows'] ?? 'yes') { + 'wip' => '', + default => $ext['support']['Windows'] ?? 'yes', + }; + $max_windows = max($max_windows, strlen($windows)); + $md_lines[] = [ + $name, + $linux, + $macos, + $freebsd, + $windows, + ]; + } + + // generate markdown + $md = '| ' . str_pad('Extension Name', $max_name) . ' | ' . str_pad('Linux', $max_linux) . ' | ' . str_pad('macOS', $max_macos) . ' | ' . str_pad('FreeBSD', $max_freebsd) . ' | ' . str_pad('Windows', $max_windows) . ' |' . PHP_EOL; + $md .= '| ' . str_repeat('-', $max_name) . ' | ' . str_repeat('-', $max_linux) . ' | ' . str_repeat('-', $max_macos) . ' | ' . str_repeat('-', $max_freebsd) . ' | ' . str_repeat('-', $max_windows) . ' |' . PHP_EOL; + foreach ($md_lines as $line) { + $md .= '| ' . str_pad($line[0], $max_name) . ' | ' . str_pad($line[1], $max_linux) . ' | ' . str_pad($line[2], $max_macos) . ' | ' . str_pad($line[3], $max_freebsd) . ' | ' . str_pad($line[4], $max_windows) . ' |' . PHP_EOL; + } + $this->output->writeln($md); + return static::SUCCESS; + } +} From af8204fbf05f186f2ce0e9f71123e1b1b109010b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 29 May 2024 14:30:31 +0800 Subject: [PATCH 298/415] Add libxml extension wrapper for composer compatibility (#463) * Add libxml extension wrapper for compatibility * Add tests --- config/ext.json | 10 ++++++++++ src/globals/test-extensions.php | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/ext.json b/config/ext.json index 2ac53d09..45c71986 100644 --- a/config/ext.json +++ b/config/ext.json @@ -278,6 +278,16 @@ "openssl" ] }, + "libxml": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "none", + "ext-depends": [ + "xml" + ] + }, "mbregex": { "type": "builtin", "arg-type": "custom", diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 0dfc8312..f2ccda99 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -11,12 +11,12 @@ declare(strict_types=1); // --------------------------------- edit area --------------------------------- -$zts = true; +$zts = 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' => 'parallel', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,parallel', + 'Linux', 'Darwin' => 'libxml', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,libxml', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From 3057d02e3724043564e07a6c75c05a261e65157b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 30 May 2024 22:01:40 +0800 Subject: [PATCH 299/415] Fix macOS --no-strip opposite bug --- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 522c12d3..a6769cee 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -241,7 +241,7 @@ class MacOSBuilder extends UnixBuilderBase // patch fake cli for micro $vars['EXTRA_CFLAGS'] .= $enable_fake_cli; - if (!$this->getOption('no-strip', false)) { + if ($this->getOption('no-strip', false)) { $vars['STRIP'] = 'dsymutil -f '; } $vars = SystemUtil::makeEnvVarString($vars); From d258417afbed101feba6f5869a43043716f0b61a Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 3 Jun 2024 23:16:15 +0800 Subject: [PATCH 300/415] Fix several patches & newer phpmicro support (#470) * use upstream phpmicro * move src/global/tests to src/global/ext-tests * move src/global/tests to src/global/ext-tests * prevent file_get_contents memory insufficience * update README * fix libxml >= 2.12 with older PHP (<=8.1) build bug * cleanup code, support newer phpmicro * add --no-strip and --with-upx-pack tests * fix windows sanity check for newer phpmicro * fix windows sanity check for newer phpmicro * test * test * test * update deps for ci --- .github/workflows/tests.yml | 24 +- README-zh.md | 4 +- README.md | 4 +- config/source.json | 2 +- phpstan.neon | 4 +- src/SPC/builder/BuilderBase.php | 41 ++ src/SPC/builder/BuilderProvider.php | 2 + src/SPC/builder/Extension.php | 12 +- src/SPC/builder/freebsd/BSDBuilder.php | 4 +- src/SPC/builder/linux/LinuxBuilder.php | 38 +- src/SPC/builder/macos/MacOSBuilder.php | 4 +- src/SPC/builder/unix/UnixBuilderBase.php | 30 +- src/SPC/builder/windows/WindowsBuilder.php | 62 +-- src/SPC/command/BaseCommand.php | 2 + src/SPC/store/FileSystem.php | 15 + src/SPC/store/SourcePatcher.php | 54 +++ .../micro_zend_mm_heap_corrupted.txt | 361 ++++++++++++++++++ src/globals/{tests => ext-tests}/bcmath.php | 0 src/globals/{tests => ext-tests}/bz2.php | 0 src/globals/{tests => ext-tests}/calendar.php | 0 src/globals/{tests => ext-tests}/curl.php | 0 src/globals/{tests => ext-tests}/dom.php | 0 src/globals/{tests => ext-tests}/filter.php | 0 src/globals/{tests => ext-tests}/gd.php | 0 src/globals/{tests => ext-tests}/gettext.php | 0 src/globals/{tests => ext-tests}/intl.php | 0 src/globals/{tests => ext-tests}/openssl.php | 0 src/globals/{tests => ext-tests}/parallel.php | 0 src/globals/{tests => ext-tests}/redis.php | 0 src/globals/{tests => ext-tests}/swoole.php | 0 src/globals/{tests => ext-tests}/uuid.php | 0 src/globals/{tests => ext-tests}/zip.php | 0 src/globals/{tests => ext-tests}/zlib.php | 0 .../patch/spc_fix_libxml2_12_php80.patch | 89 +++++ .../patch/spc_fix_libxml2_12_php81.patch | 55 +++ src/globals/test-extensions.php | 6 + 36 files changed, 742 insertions(+), 71 deletions(-) create mode 100644 src/globals/common-tests/micro_zend_mm_heap_corrupted.txt rename src/globals/{tests => ext-tests}/bcmath.php (100%) rename src/globals/{tests => ext-tests}/bz2.php (100%) rename src/globals/{tests => ext-tests}/calendar.php (100%) rename src/globals/{tests => ext-tests}/curl.php (100%) rename src/globals/{tests => ext-tests}/dom.php (100%) rename src/globals/{tests => ext-tests}/filter.php (100%) rename src/globals/{tests => ext-tests}/gd.php (100%) rename src/globals/{tests => ext-tests}/gettext.php (100%) rename src/globals/{tests => ext-tests}/intl.php (100%) rename src/globals/{tests => ext-tests}/openssl.php (100%) rename src/globals/{tests => ext-tests}/parallel.php (100%) rename src/globals/{tests => ext-tests}/redis.php (100%) rename src/globals/{tests => ext-tests}/swoole.php (100%) rename src/globals/{tests => ext-tests}/uuid.php (100%) rename src/globals/{tests => ext-tests}/zip.php (100%) rename src/globals/{tests => ext-tests}/zlib.php (100%) create mode 100644 src/globals/patch/spc_fix_libxml2_12_php80.patch create mode 100644 src/globals/patch/spc_fix_libxml2_12_php81.patch diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3f688d8..ab5aa4a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -147,7 +147,7 @@ jobs: # Cache downloaded source - id: cache-download - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: downloads key: php-${{ matrix.php }}-dependencies @@ -158,6 +158,19 @@ jobs: - name: "Run Build Tests (doctor)" run: bin/spc doctor --auto-fix + - name: "Prepare UPX for Windows" + if: matrix.os == 'windows-latest' + run: | + bin/spc install-pkg upx + echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $env:GITHUB_ENV + + - name: "Prepare UPX for Linux" + if: matrix.os == 'ubunut-latest' + run: | + bin/spc install-pkg upx + echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV + + - name: "Run Build Tests (download)" uses: nick-fields/retry@v3 with: @@ -167,5 +180,10 @@ jobs: command: | bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3 - - name: "Run Build Tests (build)" - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug + - name: "Run Build Tests (build, *nix)" + if: matrix.os != 'windows-latest' + run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug + + - name: "Run Build Tests (build, windows)" + if: matrix.os == 'windows-latest' + run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $env:UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug \ No newline at end of file diff --git a/README-zh.md b/README-zh.md index 11fbe4e6..8b64a65c 100755 --- a/README-zh.md +++ b/README-zh.md @@ -74,7 +74,7 @@ static-php-cli(简称 `spc`)有许多特性: 当前支持编译的 PHP 版本: -> :warning: 支持,但可能不再提供修复 +> :warning: 支持,但 static-php-cli 作者可能不再提供补丁修复 > > :heavy_check_mark: 支持 > @@ -86,7 +86,7 @@ static-php-cli(简称 `spc`)有许多特性: | 7.3 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | | 7.4 | :warning: | phpmicro 和许多扩展不支持 7.3、7.4 版本 | | 8.0 | :heavy_check_mark: | PHP 官方已停止 8.0 的维护 | -| 8.1 | :heavy_check_mark: | | +| 8.1 | :heavy_check_mark: | PHP 官方仅对 8.1 提供安全更新 | | 8.2 | :heavy_check_mark: | | | 8.3 | :heavy_check_mark: | | diff --git a/README.md b/README.md index 91e8953c..c61cb7d7 100755 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Here is the supported OS and arch, where :octocat: represents support for GitHub Currently supported PHP versions for compilation: -> :warning: supported but not maintained +> :warning: supported but not maintained by static-php-cli authors > > :heavy_check_mark: supported > @@ -94,7 +94,7 @@ Currently supported PHP versions for compilation: | 7.3 | :warning: | phpmicro and some extensions not supported on 7.x | | 7.4 | :warning: | phpmicro and some extensions not supported on 7.x | | 8.0 | :heavy_check_mark: | PHP official has stopped maintenance of 8.0 | -| 8.1 | :heavy_check_mark: | | +| 8.1 | :heavy_check_mark: | PHP official has security fixes only | | 8.2 | :heavy_check_mark: | | | 8.3 | :heavy_check_mark: | | diff --git a/config/source.json b/config/source.json index b666ca6c..789f4e31 100644 --- a/config/source.json +++ b/config/source.json @@ -463,7 +463,7 @@ "type": "git", "path": "php-src/sapi/micro", "rev": "master", - "url": "https://github.com/static-php/phpmicro", + "url": "https://github.com/easysoft/phpmicro", "license": { "type": "file", "path": "LICENSE" diff --git a/phpstan.neon b/phpstan.neon index 56d8183c..241a8dbb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,6 +13,6 @@ parameters: - PHP_OS_FAMILY excludePaths: analyseAndScan: - - ./src/globals/tests/swoole.php - - ./src/globals/tests/swoole.phpt + - ./src/globals/ext-tests/swoole.php + - ./src/globals/ext-tests/swoole.phpt - ./src/globals/test-extensions.php \ No newline at end of file diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index fb3fd70f..f2ab2dd8 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -9,6 +9,7 @@ use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; use SPC\exception\WrongUsageException; use SPC\store\Config; +use SPC\store\FileSystem; use SPC\store\SourceManager; use SPC\util\CustomExt; @@ -275,6 +276,24 @@ abstract class BuilderBase return false; } + public function getMicroVersion(): false|string + { + $file = FileSystem::convertPath(SOURCE_PATH . '/php-src/sapi/micro/php_micro.h'); + if (!file_exists($file)) { + return false; + } + + $content = file_get_contents($file); + $ver = ''; + preg_match('/#define PHP_MICRO_VER_MAJ (\d)/m', $content, $match); + $ver .= $match[1] . '.'; + preg_match('/#define PHP_MICRO_VER_MIN (\d)/m', $content, $match); + $ver .= $match[1] . '.'; + preg_match('/#define PHP_MICRO_VER_PAT (\d)/m', $content, $match); + $ver .= $match[1]; + return $ver; + } + /** * Get build type name string to display. * @@ -434,4 +453,26 @@ abstract class BuilderBase $php .= "echo '[micro-test-end]';\n"; return $php; } + + protected function getMicroTestTasks(): array + { + return [ + 'micro_ext_test' => [ + 'content' => ($this->getOption('without-micro-ext-test') ? 'generateMicroExtTests()), + 'conditions' => [ + function ($ret) { return $ret === 0; }, + function ($ret, $out) { + $raw_out = trim(implode('', $out)); + return str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); + }, + ], + ], + 'micro_zend_bug_test' => [ + 'content' => ($this->getOption('without-micro-ext-test') ? ' [ + function ($ret) { return $ret === 0; }, + ], + ], + ]; + } } diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index fb6d3cef..fd52a217 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -27,6 +27,8 @@ class BuilderProvider */ public static function makeBuilderByInput(InputInterface $input): BuilderBase { + ini_set('memory_limit', '2G'); + self::$builder = match (PHP_OS_FAMILY) { 'Windows' => new WindowsBuilder($input->getOptions()), 'Darwin' => new MacOSBuilder($input->getOptions()), diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 5a317184..562db372 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -170,19 +170,19 @@ class Extension public function runCliCheckUnix(): void { // Run compile check if build target is cli - // If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php + // 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 --ri "' . $this->getDistName() . '"', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); } - if (file_exists(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php')) { + if (file_exists(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php')) { // Trim additional content & escape special characters to allow inline usage $test = str_replace( ['getName() . '.php') + file_get_contents(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php') ); [$ret, $out] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "' . trim($test) . '"'); @@ -201,19 +201,19 @@ class Extension public function runCliCheckWindows(): void { // Run compile check if build target is cli - // If you need to run some check, overwrite this or add your assert in src/globals/tests/{extension_name}.php + // 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] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe --ri "' . $this->getDistName() . '"', false); if ($ret !== 0) { throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret); } - if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/tests/' . $this->getName() . '.php'))) { + if (file_exists(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))) { // Trim additional content & escape special characters to allow inline usage $test = str_replace( ['getName() . '.php')) + file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php')) ); [$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"'); diff --git a/src/SPC/builder/freebsd/BSDBuilder.php b/src/SPC/builder/freebsd/BSDBuilder.php index ffb44316..fad4a830 100644 --- a/src/SPC/builder/freebsd/BSDBuilder.php +++ b/src/SPC/builder/freebsd/BSDBuilder.php @@ -181,7 +181,7 @@ class BSDBuilder extends UnixBuilderBase } if ($this->getExt('phar')) { $this->phar_patched = true; - SourcePatcher::patchMicro(['phar']); + SourcePatcher::patchMicroPhar($this->getPHPVersionID()); } $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; @@ -202,7 +202,7 @@ class BSDBuilder extends UnixBuilderBase $this->deployBinary(BUILD_TARGET_MICRO); if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); + SourcePatcher::unpatchMicroPhar(); } } diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index c921ff69..14a1b987 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -149,7 +149,11 @@ class LinuxBuilder extends UnixBuilderBase // process micro upx patch if micro sapi enabled if ($enable_micro) { - $this->processMicroUPX(); + if (version_compare($this->getMicroVersion(), '0.2.0') < 0) { + // for phpmicro 0.1.x + $this->processMicroUPXLegacy(); + } + // micro latest needs do strip and upx pack later (strip, upx, cut binary manually supported) } shell()->cd(SOURCE_PATH . '/php-src') @@ -236,7 +240,7 @@ class LinuxBuilder extends UnixBuilderBase } if ($this->getExt('phar')) { $this->phar_patched = true; - SourcePatcher::patchMicro(['phar']); + SourcePatcher::patchMicroPhar($this->getPHPVersionID()); } $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; @@ -250,10 +254,12 @@ class LinuxBuilder extends UnixBuilderBase ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec("\$SPC_CMD_PREFIX_PHP_MAKE {$vars} micro"); + $this->processMicroUPX(); + $this->deployBinary(BUILD_TARGET_MICRO); if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); + SourcePatcher::unpatchMicroPhar(); } } @@ -304,11 +310,11 @@ class LinuxBuilder extends UnixBuilderBase } /** - * Apply option --no-strip and --with-upx-pack for micro sapi. + * Apply option --no-strip and --with-upx-pack for micro sapi (only for phpmicro 0.1.x) * * @throws FileSystemException */ - private function processMicroUPX(): void + private function processMicroUPXLegacy(): void { // upx pack and strip for micro // but always restore Makefile.frag.bak first @@ -346,4 +352,26 @@ class LinuxBuilder extends UnixBuilderBase ); } } + + private function processMicroUPX(): void + { + if (version_compare($this->getMicroVersion(), '0.2.0') >= 0 && !$this->getOption('no-strip', false)) { + shell()->exec('strip --strip-all ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx'); + + if ($this->getOption('with-upx-pack')) { + // strip first + shell()->exec(getenv('UPX_EXEC') . ' --best ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx'); + // cut binary with readelf + [$ret, $out] = shell()->execWithResult('readelf -l ' . SOURCE_PATH . '/php-src/sapi/micro/micro.sfx | awk \'/LOAD|GNU_STACK/ {getline; print $1, $2, $3, $4, $6, $7}\''); + $out[1] = explode(' ', $out[1]); + $offset = $out[1][0]; + if ($ret !== 0 || !str_starts_with($offset, '0x')) { + throw new RuntimeException('Cannot find offset in readelf output'); + } + $offset = hexdec($offset); + // remove upx extra wastes + file_put_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx', substr(file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx'), 0, $offset)); + } + } + } } diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index a6769cee..ddcfcb64 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -233,7 +233,7 @@ class MacOSBuilder extends UnixBuilderBase } if ($this->getExt('phar')) { $this->phar_patched = true; - SourcePatcher::patchMicro(['phar']); + SourcePatcher::patchMicroPhar($this->getPHPVersionID()); } $enable_fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' -DPHP_MICRO_FAKE_CLI' : ''; @@ -251,7 +251,7 @@ class MacOSBuilder extends UnixBuilderBase $this->deployBinary(BUILD_TARGET_MICRO); if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); + SourcePatcher::unpatchMicroPhar(); } } diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 7b17698a..76d6768a 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -162,22 +162,20 @@ abstract class UnixBuilderBase extends BuilderBase // sanity check for phpmicro if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { - if (file_exists(SOURCE_PATH . '/hello.exe')) { - @unlink(SOURCE_PATH . '/hello.exe'); - } - file_put_contents( - SOURCE_PATH . '/hello.exe', - file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') . - ($this->getOption('without-micro-ext-test') ? 'generateMicroExtTests()) - ); - chmod(SOURCE_PATH . '/hello.exe', 0755); - [$ret, $output2] = shell()->execWithResult(SOURCE_PATH . '/hello.exe'); - $raw_out = trim(implode('', $output2)); - $condition[0] = $ret === 0; - $condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); - foreach ($condition as $k => $v) { - if (!$v) { - throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]"); + $test_task = $this->getMicroTestTasks(); + foreach ($test_task as $task_name => $task) { + $test_file = SOURCE_PATH . '/' . $task_name . '.exe'; + if (file_exists($test_file)) { + @unlink($test_file); + } + file_put_contents($test_file, file_get_contents(SOURCE_PATH . '/php-src/sapi/micro/micro.sfx') . $task['content']); + chmod($test_file, 0755); + [$ret, $out] = shell()->execWithResult($test_file); + foreach ($task['conditions'] as $condition => $closure) { + if (!$closure($ret, $out)) { + $raw_out = trim(implode('', $out)); + throw new RuntimeException("micro failed sanity check: {$task_name}, condition [{$condition}], ret[{$ret}], out[{$raw_out}]"); + } } } } diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 6da09257..7c1f9ff7 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -80,16 +80,18 @@ class WindowsBuilder extends BuilderBase $zts = $this->zts ? '--enable-zts=yes ' : '--enable-zts=no '; // with-upx-pack for phpmicro - $makefile = FileSystem::convertPath(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.w32'); - if ($this->getOption('with-upx-pack', false)) { - if (!file_exists($makefile . '.originfile')) { - copy($makefile, $makefile . '.originfile'); - FileSystem::replaceFileStr($makefile, '$(MICRO_SFX):', '_MICRO_UPX = ' . getenv('UPX_EXEC') . " --best $(MICRO_SFX)\n$(MICRO_SFX):"); - FileSystem::replaceFileStr($makefile, '@$(_MICRO_MT)', "@$(_MICRO_MT)\n\t@$(_MICRO_UPX)"); + if ($enableMicro && version_compare($this->getMicroVersion(), '0.2.0') < 0) { + $makefile = FileSystem::convertPath(SOURCE_PATH . '/php-src/sapi/micro/Makefile.frag.w32'); + if ($this->getOption('with-upx-pack', false)) { + if (!file_exists($makefile . '.originfile')) { + copy($makefile, $makefile . '.originfile'); + FileSystem::replaceFileStr($makefile, '$(MICRO_SFX):', '_MICRO_UPX = ' . getenv('UPX_EXEC') . " --best $(MICRO_SFX)\n$(MICRO_SFX):"); + FileSystem::replaceFileStr($makefile, '@$(_MICRO_MT)', "@$(_MICRO_MT)\n\t@$(_MICRO_UPX)"); + } + } elseif (file_exists($makefile . '.originfile')) { + copy($makefile . '.originfile', $makefile); + unlink($makefile . '.originfile'); } - } elseif (file_exists($makefile . '.originfile')) { - copy($makefile . '.originfile', $makefile); - unlink($makefile . '.originfile'); } if (($logo = $this->getOption('with-micro-logo')) !== null) { @@ -191,14 +193,14 @@ class WindowsBuilder extends BuilderBase // phar patch for micro if ($this->getExt('phar')) { $this->phar_patched = true; - SourcePatcher::patchMicro(['phar']); + SourcePatcher::patchMicroPhar($this->getPHPVersionID()); } try { cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_micro_wrapper.bat --task-args micro"); } finally { if ($this->phar_patched) { - SourcePatcher::patchMicro(['phar'], true); + SourcePatcher::unpatchMicroPhar(); } } @@ -283,22 +285,20 @@ class WindowsBuilder extends BuilderBase // sanity check for phpmicro if (($build_target & BUILD_TARGET_MICRO) === BUILD_TARGET_MICRO) { - if (file_exists(SOURCE_PATH . '\hello.exe')) { - @unlink(SOURCE_PATH . '\hello.exe'); - } - file_put_contents( - SOURCE_PATH . '\hello.exe', - file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') . - ($this->getOption('without-micro-ext-test') ? 'generateMicroExtTests()) - ); - chmod(SOURCE_PATH . '\hello.exe', 0755); - [$ret, $output2] = cmd()->execWithResult(SOURCE_PATH . '\hello.exe'); - $raw_out = trim(implode('', $output2)); - $condition[0] = $ret === 0; - $condition[1] = str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); - foreach ($condition as $k => $v) { - if (!$v) { - throw new RuntimeException("micro failed sanity check with condition[{$k}], ret[{$ret}], out[{$raw_out}]"); + $test_task = $this->getMicroTestTasks(); + foreach ($test_task as $task_name => $task) { + $test_file = SOURCE_PATH . '/' . $task_name . '.exe'; + if (file_exists($test_file)) { + @unlink($test_file); + } + file_put_contents($test_file, file_get_contents(BUILD_ROOT_PATH . '\bin\micro.sfx') . $task['content']); + chmod($test_file, 0755); + [$ret, $out] = cmd()->execWithResult($test_file); + foreach ($task['conditions'] as $condition => $closure) { + if (!$closure($ret, $out)) { + $raw_out = trim(implode('', $out)); + throw new RuntimeException("micro failed sanity check: {$task_name}, condition [{$condition}], ret[{$ret}], out[{$raw_out}]"); + } } } } @@ -320,9 +320,11 @@ class WindowsBuilder extends BuilderBase default => throw new RuntimeException('Deployment does not accept type ' . $type), }; - // with-upx-pack for cli - if ($this->getOption('with-upx-pack', false) && $type === BUILD_TARGET_CLI) { - cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($src)); + // with-upx-pack for cli and micro + if ($this->getOption('with-upx-pack', false)) { + if ($type === BUILD_TARGET_CLI || ($type === BUILD_TARGET_MICRO && version_compare($this->getMicroVersion(), '0.2.0') >= 0)) { + cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($src)); + } } logger()->info('Deploying ' . $this->getBuildTypeName($type) . ' file'); diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index 96ccc784..041b53a5 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -96,6 +96,8 @@ abstract class BaseCommand extends Command }); if ($this->shouldExecute()) { try { + // show raw argv list for logger()->debug + logger()->debug('argv: ' . implode(' ', $_SERVER['argv'])); return $this->handle(); } catch (WrongUsageException $e) { $msg = explode("\n", $e->getMessage()); diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 732c5b3c..6295a889 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -436,6 +436,21 @@ class FileSystem return str_replace(array_keys($replacement), array_values($replacement), $path); } + public static function backupFile(string $path): string + { + copy($path, $path . '.bak'); + return $path . '.bak'; + } + + public static function restoreBackupFile(string $path): void + { + if (!file_exists($path . '.bak')) { + throw new RuntimeException('Cannot find bak file for ' . $path); + } + copy($path . '.bak', $path); + unlink($path . '.bak'); + } + /** * @throws RuntimeException * @throws FileSystemException diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 53f74ddc..4bae1f5a 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -18,6 +18,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('micro', [SourcePatcher::class, 'patchMicro']); FileSystem::addSourceExtractHook('openssl', [SourcePatcher::class, 'patchOpenssl11Darwin']); FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']); + FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchPhpLibxml212']); } /** @@ -200,6 +201,11 @@ class SourcePatcher FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'install-micro', ''); } + // no asan + // if (strpos(file_get_contents(SOURCE_PATH . '/php-src/Makefile'), 'CFLAGS_CLEAN = -g') === false) { + // FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/Makefile', 'CFLAGS_CLEAN = ', 'CFLAGS_CLEAN = -g -fsanitize=address '); + // } + // call extension patch before make foreach ($builder->getExts() as $ext) { if ($ext->patchBeforeMake() === true) { @@ -268,6 +274,36 @@ class SourcePatcher return $result; } + public static function patchMicroPhar(int $version_id): void + { + FileSystem::backupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/phar/phar.c', + 'static zend_op_array *phar_compile_file', + "char *micro_get_filename(void);\n\nstatic zend_op_array *phar_compile_file" + ); + if ($version_id < 80100) { + // PHP 8.0.x + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/phar/phar.c', + 'if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) {', + 'if ((strstr(file_handle->filename, micro_get_filename()) || strstr(file_handle->filename, ".phar")) && !strstr(file_handle->filename, "://")) {' + ); + } else { + // PHP >= 8.1 + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/phar/phar.c', + 'if (strstr(ZSTR_VAL(file_handle->filename), ".phar") && !strstr(ZSTR_VAL(file_handle->filename), "://")) {', + 'if ((strstr(ZSTR_VAL(file_handle->filename), micro_get_filename()) || strstr(ZSTR_VAL(file_handle->filename), ".phar")) && !strstr(ZSTR_VAL(file_handle->filename), "://")) {' + ); + } + } + + public static function unpatchMicroPhar(): void + { + FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); + } + /** * Patch cli SAPI Makefile for Windows. * @@ -296,6 +332,24 @@ class SourcePatcher FileSystem::writeFile(SOURCE_PATH . '/php-src/Makefile', implode("\r\n", $lines)); } + public static function patchPhpLibxml212(): bool + { + $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); + if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) { + $ver_id = intval($match[1]); + if ($ver_id < 80100) { + self::patchFile('spc_fix_libxml2_12_php80.patch', SOURCE_PATH . '/php-src'); + return true; + } + if ($ver_id < 80200) { + self::patchFile('spc_fix_libxml2_12_php81.patch', SOURCE_PATH . '/php-src'); + return true; + } + return false; + } + return false; + } + /** * Add additional `static-php-cli.version` ini value for PHP source. * diff --git a/src/globals/common-tests/micro_zend_mm_heap_corrupted.txt b/src/globals/common-tests/micro_zend_mm_heap_corrupted.txt new file mode 100644 index 00000000..cd0272a2 --- /dev/null +++ b/src/globals/common-tests/micro_zend_mm_heap_corrupted.txt @@ -0,0 +1,361 @@ +'); +define('K_question', '?'); +define('K_at', '@'); +define('K_A', 'A'); +define('K_B', 'B'); +define('K_C', 'C'); +define('K_D', 'D'); +define('K_E', 'E'); +define('K_F', 'F'); +define('K_G', 'G'); +define('K_H', 'H'); +define('K_I', 'I'); +define('K_J', 'J'); +define('K_K', 'K'); +define('K_L', 'L'); +define('K_M', 'M'); +define('K_N', 'N'); +define('K_O', 'O'); +define('K_P', 'P'); +define('K_Q', 'Q'); +define('K_R', 'R'); +define('K_S', 'S'); +define('K_T', 'T'); +define('K_U', 'U'); +define('K_V', 'V'); +define('K_W', 'W'); +define('K_X', 'X'); +define('K_Y', 'Y'); +define('K_Z', 'Z'); +define('K_bracketleft', '['); +define('K_bracketright', ']'); +define('K_circum', '^'); +define('K_underscore', '_'); +define('K_grave', '`'); +define('K_a', 'a'); +define('K_b', 'b'); +define('K_c', 'c'); +define('K_d', 'd'); +define('K_e', 'e'); +define('K_f', 'f'); +define('K_g', 'g'); +define('K_h', 'h'); +define('K_i', 'i'); +define('K_j', 'j'); +define('K_k', 'k'); +define('K_l', 'l'); +define('K_m', 'm'); +define('K_n', 'n'); +define('K_o', 'o'); +define('K_p', 'p'); +define('K_q', 'q'); +define('K_r', 'r'); +define('K_s', 's'); +define('K_t', 't'); +define('K_u', 'u'); +define('K_v', 'v'); +define('K_w', 'w'); +define('K_x', 'x'); +define('K_y', 'y'); +define('K_z', 'z'); +define('K_braceleft', '{'); +define('K_bar', '|'); +define('K_braceright', '}'); +define('K_tilde', '~'); +define('K_BS', '\\b'); +define('K_TAB', "\t"); +define('K_LF', "\n"); +define('K_CR', "\r"); +define('K_quoteleft', '`'); +define('K_quoteright', "'"); +define('K_PAUSE', 65299); +define('K_ESC', 65307); +define('K_HOME', 65360); +define('K_LEFT', 65361); +define('K_UP', 65362); +define('K_RIGHT', 65363); +define('K_DOWN', 65364); +define('K_PGUP', 65365); +define('K_PGDN', 65366); +define('K_END', 65367); +define('K_MIDDLE', 65291); +define('K_Print', 65377); +define('K_INS', 65379); +define('K_Menu', 65383); +define('K_DEL', 65535); +define('K_F1', 65470); +define('K_F2', 65471); +define('K_F3', 65472); +define('K_F4', 65473); +define('K_F5', 65474); +define('K_F6', 65475); +define('K_F7', 65476); +define('K_F8', 65477); +define('K_F9', 65478); +define('K_F10', 65479); +define('K_F11', 65480); +define('K_F12', 65481); +define('K_F13', 65482); +define('K_F14', 65483); +define('K_F15', 65484); +define('K_F16', 65485); +define('K_F17', 65486); +define('K_F18', 65487); +define('K_F19', 65488); +define('K_F20', 65489); +define('K_LSHIFT', 65505); +define('K_RSHIFT', 65506); +define('K_LCTRL', 65507); +define('K_RCTRL', 65508); +define('K_LALT', 65513); +define('K_RALT', 65514); +define('K_NUM', 65407); +define('K_SCROLL', 65300); +define('K_CAPS', 65509); +define('K_CLEAR', 65490); +define('K_HELP', 65491); +define('K_ccedilla', 231); +define('K_Ccedilla', 199); +define('K_acute', 180); +define('K_diaeresis', 168); +define('IUP_RUN', 'RUN'); +define('IUP_ENGLISH', 'ENGLISH'); +define('IUP_PORTUGUESE', 'PORTUGUESE'); +define('IUP_SBH', 'SBH'); +define('IUP_SBV', 'SBV'); +define('IUP_IDLE_ACTION', 'IDLE_ACTION'); +define('IUP_ACTION', 'ACTION'); +define('IUP_GETFOCUS_CB', 'GETFOCUS_CB'); +define('IUP_KILLFOCUS_CB', 'KILLFOCUS_CB'); +define('IUP_K_ANY', 'K_ANY'); +define('IUP_KEYPRESS_CB', 'KEYPRESS_CB'); +define('IUP_HELP_CB', 'HELP_CB'); +define('IUP_SCROLL_CB', 'SCROLL_CB'); +define('IUP_RESIZE_CB', 'RESIZE_CB'); +define('IUP_MOTION_CB', 'MOTION_CB'); +define('IUP_BUTTON_CB', 'BUTTON_CB'); +define('IUP_ENTERWINDOW_CB', 'ENTERWINDOW_CB'); +define('IUP_LEAVEWINDOW_CB', 'LEAVEWINDOW_CB'); +define('IUP_WHEEL_CB', 'WHEEL_CB'); +define('IUP_MASK_CB', 'MASK_CB'); +define('IUP_OPEN_CB', 'OPEN_CB'); +define('IUP_HIGHLIGHT_CB', 'HIGHLIGHT_CB'); +define('IUP_MENUCLOSE_CB', 'MENUCLOSE_CB'); +define('IUP_MAP_CB', 'MAP_CB'); +define('IUP_CLOSE_CB', 'CLOSE_CB'); +define('IUP_SHOW_CB', 'SHOW_CB'); +define('IUP_DROPFILES_CB', 'DROPFILES_CB'); +define('IUP_WOM_CB', 'WOM_CB'); +define('IUP_DIRECTION', 'DIRECTION'); +define('IUP_ACTIVE', 'ACTIVE'); +define('IUP_BGCOLOR', 'BGCOLOR'); +define('IUP_FRAMECOLOR', 'FRAMECOLOR'); +define('IUP_FGCOLOR', 'FGCOLOR'); +define('IUP_COLOR', 'COLOR'); +define('IUP_WID', 'WID'); +define('IUP_SIZE', 'SIZE'); +define('IUP_RASTERSIZE', 'RASTERSIZE'); +define('IUP_TITLE', 'TITLE'); +define('IUP_VALUE', 'VALUE'); +define('IUP_VISIBLE', 'VISIBLE'); +define('IUP_FONT', 'FONT'); +define('IUP_TIP', 'TIP'); +define('IUP_EXPAND', 'EXPAND'); +define('IUP_SEPARATOR', 'SEPARATOR'); +define('IUP_HOTSPOT', 'HOTSPOT'); +define('IUP_HEIGHT', 'HEIGHT'); +define('IUP_WIDTH', 'WIDTH'); +define('IUP_KEY', 'KEY'); +define('IUP_MULTIPLE', 'MULTIPLE'); +define('IUP_DROPDOWN', 'DROPDOWN'); +define('IUP_VISIBLE_ITEMS', 'VISIBLE_ITEMS'); +define('IUP_MARGIN', 'MARGIN'); +define('IUP_GAP', 'GAP'); +define('IUP_ALIGNMENT', 'ALIGNMENT'); +define('IUP_IMAGE', 'IMAGE'); +define('IUP_IMINACTIVE', 'IMINACTIVE'); +define('IUP_IMPRESS', 'IMPRESS'); +define('IUP_WIN_SAVEBITS', 'WIN_SAVEBITS'); +define('IUP_NC', 'NC'); +define('IUP_MASK', 'MASK'); +define('IUP_APPEND', 'APPEND'); +define('IUP_BORDER', 'BORDER'); +define('IUP_CARET', 'CARET'); +define('IUP_SELECTION', 'SELECTION'); +define('IUP_SELECTEDTEXT', 'SELECTEDTEXT'); +define('IUP_INSERT', 'INSERT'); +define('IUP_CONID', 'CONID'); +define('IUP_CURSOR', 'CURSOR'); +define('IUP_ICON', 'ICON'); +define('IUP_MENUBOX', 'MENUBOX'); +define('IUP_MINBOX', 'MINBOX'); +define('IUP_MAXBOX', 'MAXBOX'); +define('IUP_RESIZE', 'RESIZE'); +define('IUP_MENU', 'MENU'); +define('IUP_STARTFOCUS', 'STARTFOCUS'); +define('IUP_PARENTDIALOG', 'PARENTDIALOG'); +define('IUP_SHRINK', 'SHRINK'); +define('IUP_DEFAULTENTER', 'DEFAULTENTER'); +define('IUP_DEFAULTESC', 'DEFAULTESC'); +define('IUP_X', 'X'); +define('IUP_Y', 'Y'); +define('IUP_TOOLBOX', 'TOOLBOX'); +define('IUP_CONTROL', 'CONTROL'); +define('IUP_READONLY', 'READONLY'); +define('IUP_SCROLLBAR', 'SCROLLBAR'); +define('IUP_POSY', 'POSY'); +define('IUP_POSX', 'POSX'); +define('IUP_DX', 'DX'); +define('IUP_DY', 'DY'); +define('IUP_XMAX', 'XMAX'); +define('IUP_XMIN', 'XMIN'); +define('IUP_YMAX', 'YMAX'); +define('IUP_YMIN', 'YMIN'); +define('IUP_RED', '255 0 0'); +define('IUP_GREEN', '0 255 0'); +define('IUP_BLUE', '0 0 255'); +define('IUP_MIN', 'MIN'); +define('IUP_MAX', 'MAX'); +define('IUP_TIME', 'TIME'); +define('IUP_DRAG', 'DRAG'); +define('IUP_DROP', 'DROP'); +define('IUP_REPAINT', 'REPAINT'); +define('IUP_TOPMOST', 'TOPMOST'); +define('IUP_CLIPCHILDREN', 'CLIPCHILDREN'); +define('IUP_DIALOGTYPE', 'DIALOGTYPE'); +define('IUP_FILE', 'FILE'); +define('IUP_MULTIPLEFILES', 'MULTIPLEFILES'); +define('IUP_FILTER', 'FILTER'); +define('IUP_FILTERUSED', 'FILTERUSED'); +define('IUP_FILTERINFO', 'FILTERINFO'); +define('IUP_EXTFILTER', 'EXTFILTER'); +define('IUP_DIRECTORY', 'DIRECTORY'); +define('IUP_ALLOWNEW', 'ALLOWNEW'); +define('IUP_NOOVERWRITEPROMPT', 'NOOVERWRITEPROMPT'); +define('IUP_NOCHANGEDIR', 'NOCHANGEDIR'); +define('IUP_FILEEXIST', 'FILEEXIST'); +define('IUP_STATUS', 'STATUS'); +define('IUP_LOCKLOOP', 'LOCKLOOP'); +define('IUP_SYSTEM', 'SYSTEM'); +define('IUP_DRIVER', 'DRIVER'); +define('IUP_SCREENSIZE', 'SCREENSIZE'); +define('IUP_SYSTEMLANGUAGE', 'SYSTEMLANGUAGE'); +define('IUP_COMPUTERNAME', 'COMPUTERNAME'); +define('IUP_USERNAME', 'USERNAME'); +define('IUP_OPEN', 'OPEN'); +define('IUP_SAVE', 'SAVE'); +define('IUP_DIR', 'DIR'); +define('IUP_HORIZONTAL', 'HORIZONTAL'); +define('IUP_VERTICAL', 'VERTICAL'); +define('IUP_YES', 'YES'); +define('IUP_NO', 'NO'); +define('IUP_ON', 'ON'); +define('IUP_OFF', 'OFF'); +define('IUP_ACENTER', 'ACENTER'); +define('IUP_ALEFT', 'ALEFT'); +define('IUP_ARIGHT', 'ARIGHT'); +define('IUP_ATOP', 'ATOP'); +define('IUP_ABOTTOM', 'ABOTTOM'); +define('IUP_NORTH', 'NORTH'); +define('IUP_SOUTH', 'SOUTH'); +define('IUP_WEST', 'WEST'); +define('IUP_EAST', 'EAST'); +define('IUP_NE', 'NE'); +define('IUP_SE', 'SE'); +define('IUP_NW', 'NW'); +define('IUP_SW', 'SW'); +define('IUP_FULLSCREEN', 'FULLSCREEN'); +define('IUP_FULL', 'FULL'); +define('IUP_HALF', 'HALF'); +define('IUP_THIRD', 'THIRD'); +define('IUP_QUARTER', 'QUARTER'); +define('IUP_EIGHTH', 'EIGHTH'); +define('IUP_ARROW', 'ARROW'); +define('IUP_BUSY', 'BUSY'); +define('IUP_RESIZE_N', 'RESIZE_N'); +define('IUP_RESIZE_S', 'RESIZE_S'); +define('IUP_RESIZE_E', 'RESIZE_E'); +define('IUP_RESIZE_W', 'RESIZE_W'); +define('IUP_RESIZE_NE', 'RESIZE_NE'); +define('IUP_RESIZE_NW', 'RESIZE_NW'); +define('IUP_RESIZE_SE', 'RESIZE_SE'); +define('IUP_RESIZE_SW', 'RESIZE_SW'); +define('IUP_MOVE', 'MOVE'); +define('IUP_HAND', 'HAND'); +define('IUP_NONE', 'NONE'); +define('IUP_IUP', 'IUP'); +define('IUP_CROSS', 'CROSS'); +define('IUP_PEN', 'PEN'); +define('IUP_TEXT', 'TEXT'); +define('IUP_RESIZE_C', 'RESIZE_C'); +define('IUP_OPENHAND', 'OPENHAND'); +define('IUP_K_exclam', 'K_exclam'); +define('IUP_K_quotedbl', 'K_quotedbl'); +define('IUP_K_numbersign', 'K_numbersign'); +define('IUP_K_dollar', 'K_dollar'); +define('IUP_K_percent', 'K_percent'); +define('IUP_K_ampersand', 'K_ampersand'); +define('IUP_K_quoteright', 'K_quoteright'); +define('IUP_K_parentleft', 'K_parentleft'); +define('IUP_K_parentright', 'K_parentright'); +define('IUP_K_asterisk', 'K_asterisk'); +define('IUP_K_plus', 'K_plus'); +define('IUP_K_comma', 'K_comma'); +define('IUP_K_minus', 'K_minus'); +define('IUP_K_period', 'K_period'); +define('IUP_K_slash', 'K_slash'); +define('IUP_K_0', 'K_0'); +define('IUP_K_1', 'K_1'); +define('IUP_K_2', 'K_2'); +define('IUP_K_3', 'K_3'); +define('IUP_K_4', 'K_4'); +define('IUP_K_5', 'K_5'); +define('IUP_K_6', 'K_6'); +define('IUP_K_7', 'K_7'); +define('IUP_K_8', 'K_8'); +define('IUP_K_9', 'K_9'); +define('IUP_K_colon', 'K_colon'); +define('IUP_K_semicolon', 'K_semicolon '); +define('IUP_K_less', 'K_less'); +define('IUP_K_equal', 'K_equal'); +define('IUP_K_greater', 'K_greater'); +define('IUP_K_question', 'K_question'); +define('IUP_K_at', 'K_at'); +define('IUP_K_A', 'K_A'); +define('IUP_K_B', 'K_B'); +define('IUP_K_C', 'K_C'); +define('IUP_K_D', 'K_D'); +define('IUP_K_E', 'K_E'); +define('IUP_K_F', 'K_F'); +define('IUP_K_G', 'K_G'); \ No newline at end of file diff --git a/src/globals/tests/bcmath.php b/src/globals/ext-tests/bcmath.php similarity index 100% rename from src/globals/tests/bcmath.php rename to src/globals/ext-tests/bcmath.php diff --git a/src/globals/tests/bz2.php b/src/globals/ext-tests/bz2.php similarity index 100% rename from src/globals/tests/bz2.php rename to src/globals/ext-tests/bz2.php diff --git a/src/globals/tests/calendar.php b/src/globals/ext-tests/calendar.php similarity index 100% rename from src/globals/tests/calendar.php rename to src/globals/ext-tests/calendar.php diff --git a/src/globals/tests/curl.php b/src/globals/ext-tests/curl.php similarity index 100% rename from src/globals/tests/curl.php rename to src/globals/ext-tests/curl.php diff --git a/src/globals/tests/dom.php b/src/globals/ext-tests/dom.php similarity index 100% rename from src/globals/tests/dom.php rename to src/globals/ext-tests/dom.php diff --git a/src/globals/tests/filter.php b/src/globals/ext-tests/filter.php similarity index 100% rename from src/globals/tests/filter.php rename to src/globals/ext-tests/filter.php diff --git a/src/globals/tests/gd.php b/src/globals/ext-tests/gd.php similarity index 100% rename from src/globals/tests/gd.php rename to src/globals/ext-tests/gd.php diff --git a/src/globals/tests/gettext.php b/src/globals/ext-tests/gettext.php similarity index 100% rename from src/globals/tests/gettext.php rename to src/globals/ext-tests/gettext.php diff --git a/src/globals/tests/intl.php b/src/globals/ext-tests/intl.php similarity index 100% rename from src/globals/tests/intl.php rename to src/globals/ext-tests/intl.php diff --git a/src/globals/tests/openssl.php b/src/globals/ext-tests/openssl.php similarity index 100% rename from src/globals/tests/openssl.php rename to src/globals/ext-tests/openssl.php diff --git a/src/globals/tests/parallel.php b/src/globals/ext-tests/parallel.php similarity index 100% rename from src/globals/tests/parallel.php rename to src/globals/ext-tests/parallel.php diff --git a/src/globals/tests/redis.php b/src/globals/ext-tests/redis.php similarity index 100% rename from src/globals/tests/redis.php rename to src/globals/ext-tests/redis.php diff --git a/src/globals/tests/swoole.php b/src/globals/ext-tests/swoole.php similarity index 100% rename from src/globals/tests/swoole.php rename to src/globals/ext-tests/swoole.php diff --git a/src/globals/tests/uuid.php b/src/globals/ext-tests/uuid.php similarity index 100% rename from src/globals/tests/uuid.php rename to src/globals/ext-tests/uuid.php diff --git a/src/globals/tests/zip.php b/src/globals/ext-tests/zip.php similarity index 100% rename from src/globals/tests/zip.php rename to src/globals/ext-tests/zip.php diff --git a/src/globals/tests/zlib.php b/src/globals/ext-tests/zlib.php similarity index 100% rename from src/globals/tests/zlib.php rename to src/globals/ext-tests/zlib.php diff --git a/src/globals/patch/spc_fix_libxml2_12_php80.patch b/src/globals/patch/spc_fix_libxml2_12_php80.patch new file mode 100644 index 00000000..608c1ec0 --- /dev/null +++ b/src/globals/patch/spc_fix_libxml2_12_php80.patch @@ -0,0 +1,89 @@ +diff --git a/ext/dom/document.c b/ext/dom/document.c +index 02522b50..6d1b0740 100644 +--- a/ext/dom/document.c ++++ b/ext/dom/document.c +@@ -23,6 +23,7 @@ + #if defined(HAVE_LIBXML) && defined(HAVE_DOM) + #include "php_dom.h" + #include ++#include + #ifdef LIBXML_SCHEMAS_ENABLED + #include + #include +diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c +index 73486ae2..59bd3d20 100644 +--- a/ext/libxml/libxml.c ++++ b/ext/libxml/libxml.c +@@ -382,7 +382,7 @@ php_libxml_input_buffer_create_filename(const char *URI, xmlCharEncoding enc) + + if (encoding) { + char *end; +- ++ + encoding += sizeof("charset=")-1; + if (*encoding == '"') { + encoding++; +@@ -481,7 +481,11 @@ static void _php_libxml_free_error(void *ptr) + xmlResetError((xmlErrorPtr) ptr); + } + +-static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg) ++#if LIBXML_VERSION >= 21200 ++static void _php_list_set_error_structure(const xmlError *error, const char *msg) ++#else ++static void _php_list_set_error_structure(xmlError *error, const char *msg) ++#endif + { + xmlError error_copy; + int ret; +@@ -732,7 +736,11 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...) + va_end(args); + } + ++#if LIBXML_VERSION >= 21200 ++PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, const xmlError *error) ++#else + PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error) ++#endif + { + _php_list_set_error_structure(error, NULL); + +@@ -1035,11 +1043,9 @@ PHP_FUNCTION(libxml_use_internal_errors) + /* {{{ Retrieve last error from libxml */ + PHP_FUNCTION(libxml_get_last_error) + { +- xmlErrorPtr error; +- + ZEND_PARSE_PARAMETERS_NONE(); + +- error = xmlGetLastError(); ++ const xmlError *error = xmlGetLastError(); + + if (error) { + object_init_ex(return_value, libxmlerror_class_entry); +diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h +index d0ce7cec..02717417 100644 +--- a/ext/libxml/php_libxml.h ++++ b/ext/libxml/php_libxml.h +@@ -35,6 +35,7 @@ extern zend_module_entry libxml_module_entry; + + #include "zend_smart_str.h" + #include ++#include + + #define LIBXML_SAVE_NOEMPTYTAG 1<<2 + +diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c +index e5e7f2f9..00b58b87 100644 +--- a/ext/soap/php_sdl.c ++++ b/ext/soap/php_sdl.c +@@ -331,8 +331,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include) + sdl_restore_uri_credentials(ctx); + + if (!wsdl) { +- xmlErrorPtr xmlErrorPtr = xmlGetLastError(); +- ++ const xmlError *xmlErrorPtr = xmlGetLastError(); + if (xmlErrorPtr) { + soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message); + } else { diff --git a/src/globals/patch/spc_fix_libxml2_12_php81.patch b/src/globals/patch/spc_fix_libxml2_12_php81.patch new file mode 100644 index 00000000..bd9a616c --- /dev/null +++ b/src/globals/patch/spc_fix_libxml2_12_php81.patch @@ -0,0 +1,55 @@ +diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c +index 3959b362..6cdfbd39 100644 +--- a/ext/libxml/libxml.c ++++ b/ext/libxml/libxml.c +@@ -483,7 +483,11 @@ static void _php_libxml_free_error(void *ptr) + xmlResetError((xmlErrorPtr) ptr); + } + +-static void _php_list_set_error_structure(xmlErrorPtr error, const char *msg) ++#if LIBXML_VERSION >= 21200 ++static void _php_list_set_error_structure(const xmlError *error, const char *msg) ++#else ++static void _php_list_set_error_structure(xmlError *error, const char *msg) ++#endif + { + xmlError error_copy; + int ret; +@@ -736,7 +740,11 @@ PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...) + va_end(args); + } + ++#if LIBXML_VERSION >= 21200 ++PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, const xmlError *error) ++#else + PHP_LIBXML_API void php_libxml_structured_error_handler(void *userData, xmlErrorPtr error) ++#endif + { + _php_list_set_error_structure(error, NULL); + +@@ -1009,11 +1017,9 @@ PHP_FUNCTION(libxml_use_internal_errors) + /* {{{ Retrieve last error from libxml */ + PHP_FUNCTION(libxml_get_last_error) + { +- xmlErrorPtr error; +- + ZEND_PARSE_PARAMETERS_NONE(); + +- error = xmlGetLastError(); ++ const xmlError *error = xmlGetLastError(); + + if (error) { + object_init_ex(return_value, libxmlerror_class_entry); +diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c +index 651eab23..7a7ce304 100644 +--- a/ext/soap/php_sdl.c ++++ b/ext/soap/php_sdl.c +@@ -332,7 +332,7 @@ static void load_wsdl_ex(zval *this_ptr, char *struri, sdlCtx *ctx, int include) + sdl_restore_uri_credentials(ctx); + + if (!wsdl) { +- xmlErrorPtr xmlErrorPtr = xmlGetLastError(); ++ const xmlError *xmlErrorPtr = xmlGetLastError(); + + if (xmlErrorPtr) { + soap_error2(E_ERROR, "Parsing WSDL: Couldn't load from '%s' : %s", struri, xmlErrorPtr->message); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index f2ccda99..22a42e07 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,6 +13,10 @@ declare(strict_types=1); $zts = false; +$no_strip = false; + +$upx = true; + // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'libxml', @@ -74,5 +78,7 @@ echo match ($argv[1]) { 'libs_cmd' => ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), 'cmd' => $final_extensions_cmd . ($final_libs === '' ? '' : (' --with-libs=' . $final_libs)), 'zts' => $zts ? '--enable-zts' : '', + 'no_strip' => $no_strip ? '--no-strip' : '', + 'upx' => $upx ? '--with-upx-pack' : '', default => '', }; From 036e4f52b70386c3810d6138ac6465cae4c52945 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 4 Jun 2024 12:24:52 +0800 Subject: [PATCH 301/415] Prevent use building uv on 7.4 (#471) * Prevent use building uv on 7.4 * Add swoole test * Use github source for libcares * Add libcares missing file patch * Add libcares missing file patch --- .github/workflows/tests.yml | 2 +- config/source.json | 11 +- src/SPC/builder/extension/uv.php | 19 ++++ src/SPC/builder/unix/library/libcares.php | 11 ++ src/globals/extra/libcares_dnsinfo.h | 128 ++++++++++++++++++++++ src/globals/test-extensions.php | 2 +- 6 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 src/SPC/builder/extension/uv.php create mode 100644 src/globals/extra/libcares_dnsinfo.h diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ab5aa4a2..71d4dfb7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -178,7 +178,7 @@ jobs: max_attempts: 3 retry_on: error command: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3 + bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src,libcares --debug --retry=3 - name: "Run Build Tests (build, *nix)" if: matrix.os != 'windows-latest' diff --git a/config/source.json b/config/source.json index 789f4e31..8fdfc85c 100644 --- a/config/source.json +++ b/config/source.json @@ -259,9 +259,14 @@ } }, "libcares": { - "type": "filelist", - "url": "https://c-ares.org/download/", - "regex": "/href=\"\\/download\\/(?c-ares-(?[^\"]+)\\.tar\\.gz)\"/", + "type": "ghrel", + "repo": "c-ares/c-ares", + "match": "c-ares-.+\\.tar\\.gz", + "alt": { + "type": "filelist", + "url": "https://c-ares.org/download/", + "regex": "/href=\"\\/download\\/(?c-ares-(?[^\"]+)\\.tar\\.gz)\"/" + }, "license": { "type": "file", "path": "LICENSE.md" diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php new file mode 100644 index 00000000..af879882 --- /dev/null +++ b/src/SPC/builder/extension/uv.php @@ -0,0 +1,19 @@ +builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { + throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later'); + } + } +} diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php index c57ef375..ea56d8cd 100644 --- a/src/SPC/builder/unix/library/libcares.php +++ b/src/SPC/builder/unix/library/libcares.php @@ -5,9 +5,20 @@ declare(strict_types=1); namespace SPC\builder\unix\library; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; trait libcares { + public function patchBeforeBuild(): bool + { + if (!file_exists($this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h')) { + FileSystem::createDir($this->source_dir . '/src/lib/thirdparty/apple'); + copy(ROOT_DIR . '/src/globals/extra/libcares_dnsinfo.h', $this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h'); + return true; + } + return false; + } + /** * @throws RuntimeException */ diff --git a/src/globals/extra/libcares_dnsinfo.h b/src/globals/extra/libcares_dnsinfo.h new file mode 100644 index 00000000..e6a9ed11 --- /dev/null +++ b/src/globals/extra/libcares_dnsinfo.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015-2018 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef __DNSINFO_H__ +#define __DNSINFO_H__ + +/* + * These routines provide access to the systems DNS configuration + */ + +#include +#include +#include +#include +#include +#include + +#define DNSINFO_VERSION 20170629 + +#define DEFAULT_SEARCH_ORDER 200000 /* search order for the "default" resolver domain name */ + +#define DNS_PTR(type, name) \ + union { \ + type name; \ + uint64_t _ ## name ## _p; \ + } + +#define DNS_VAR(type, name) \ + type name + + +#pragma pack(4) +typedef struct { + struct in_addr address; + struct in_addr mask; +} dns_sortaddr_t; +#pragma pack() + + +#pragma pack(4) +typedef struct { + DNS_PTR(char *, domain); /* domain */ + DNS_VAR(int32_t, n_nameserver); /* # nameserver */ + DNS_PTR(struct sockaddr **, nameserver); + DNS_VAR(uint16_t, port); /* port (in host byte order) */ + DNS_VAR(int32_t, n_search); /* # search */ + DNS_PTR(char **, search); + DNS_VAR(int32_t, n_sortaddr); /* # sortaddr */ + DNS_PTR(dns_sortaddr_t **, sortaddr); + DNS_PTR(char *, options); /* options */ + DNS_VAR(uint32_t, timeout); /* timeout */ + DNS_VAR(uint32_t, search_order); /* search_order */ + DNS_VAR(uint32_t, if_index); + DNS_VAR(uint32_t, flags); + DNS_VAR(uint32_t, reach_flags); /* SCNetworkReachabilityFlags */ + DNS_VAR(uint32_t, service_identifier); + DNS_PTR(char *, cid); /* configuration identifer */ + DNS_PTR(char *, if_name); /* if_index interface name */ +} dns_resolver_t; +#pragma pack() + + +#define DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS 0x0002 /* always requesting for A dns records in queries */ +#define DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS 0x0004 /* always requesting for AAAA dns records in queries */ + +#define DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS \ + (DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS | DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) + +#define DNS_RESOLVER_FLAGS_SCOPED 0x1000 /* configuration is for scoped questions */ +#define DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC 0x2000 /* configuration is service-specific */ +#define DNS_RESOLVER_FLAGS_SUPPLEMENTAL 0x4000 /* supplemental match configuration */ + + +#pragma pack(4) +typedef struct { + DNS_VAR(int32_t, n_resolver); /* resolver configurations */ + DNS_PTR(dns_resolver_t **, resolver); + DNS_VAR(int32_t, n_scoped_resolver); /* "scoped" resolver configurations */ + DNS_PTR(dns_resolver_t **, scoped_resolver); + DNS_VAR(uint64_t, generation); + DNS_VAR(int32_t, n_service_specific_resolver); + DNS_PTR(dns_resolver_t **, service_specific_resolver); + DNS_VAR(uint32_t, version); +} dns_config_t; +#pragma pack() + + +__BEGIN_DECLS + +/* + * DNS configuration access APIs + */ +const char * +dns_configuration_notify_key (void) API_AVAILABLE(macos(10.4), ios(2.0)); + +dns_config_t * +dns_configuration_copy (void) API_AVAILABLE(macos(10.4), ios(2.0)); + +void +dns_configuration_free (dns_config_t *config) API_AVAILABLE(macos(10.4), ios(2.0)); + +void +_dns_configuration_ack (dns_config_t *config, + const char *bundle_id) API_AVAILABLE(macos(10.8), ios(6.0)); + +__END_DECLS + +#endif /* __DNSINFO_H__ */ \ No newline at end of file diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 22a42e07..f8f2e763 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,7 +19,7 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libxml', + 'Linux', 'Darwin' => 'libxml,swoole', 'Windows' => 'mbstring,pdo_sqlite,mbregex,libxml', }; From eff698cbe8ab8fc1fe1094612e912c8297387d9b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 4 Jun 2024 12:30:46 +0800 Subject: [PATCH 302/415] fix libxml2 patch for older php (limit only to 80, 81) --- 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 4bae1f5a..c3fbbfcf 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -337,7 +337,7 @@ class SourcePatcher $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) { $ver_id = intval($match[1]); - if ($ver_id < 80100) { + if ($ver_id < 80100 && $ver_id >= 80000) { self::patchFile('spc_fix_libxml2_12_php80.patch', SOURCE_PATH . '/php-src'); return true; } From 1ae1c81f9c056f469fdf77fc40b349f0e88c2419 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 4 Jun 2024 12:40:21 +0800 Subject: [PATCH 303/415] fix libxml2 patch for older php (limit only to 80, 81) --- src/SPC/store/SourcePatcher.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index c3fbbfcf..824c80f6 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -337,7 +337,10 @@ class SourcePatcher $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) { $ver_id = intval($match[1]); - if ($ver_id < 80100 && $ver_id >= 80000) { + if ($ver_id < 80000) { + return false; + } + if ($ver_id < 80100) { self::patchFile('spc_fix_libxml2_12_php80.patch', SOURCE_PATH . '/php-src'); return true; } From 7e6c2b4432847e84a20737ce0232824efff6a409 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 4 Jun 2024 19:31:13 +0800 Subject: [PATCH 304/415] Fix xlswriter with openssl conflict bug (#472) * Fix xlswriter with openssl conflict bug * bump version to 2.2.3 --- config/ext.json | 3 +++ src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/extension/xlswriter.php | 6 +++++- src/globals/test-extensions.php | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index 45c71986..f6dadaef 100644 --- a/config/ext.json +++ b/config/ext.json @@ -853,6 +853,9 @@ "ext-depends": [ "zlib", "zip" + ], + "lib-suggests": [ + "openssl" ] }, "xml": { diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index fca4015e..ae27245a 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.2.2'; + public const VERSION = '2.2.3'; public function __construct() { diff --git a/src/SPC/builder/extension/xlswriter.php b/src/SPC/builder/extension/xlswriter.php index 37fbf970..475a6c07 100644 --- a/src/SPC/builder/extension/xlswriter.php +++ b/src/SPC/builder/extension/xlswriter.php @@ -12,6 +12,10 @@ class xlswriter extends Extension { public function getUnixConfigureArg(): string { - return '--with-xlswriter --enable-reader'; + $arg = '--with-xlswriter --enable-reader'; + if ($this->builder->getLib('openssl')) { + $arg .= ' --with-openssl=' . BUILD_ROOT_PATH; + } + return $arg; } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index f8f2e763..cfde3b3b 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,8 +19,8 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libxml,swoole', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,libxml', + 'Linux', 'Darwin' => 'libxml,xlswriter,openssl', + 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From b3018af61cbb16eaf812a7c1e1922c1b4303671b Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 5 Jun 2024 13:12:25 +0800 Subject: [PATCH 305/415] Fix mongodb support on macOS --- config/ext.json | 1 - src/SPC/builder/extension/mongodb.php | 9 --------- 2 files changed, 10 deletions(-) diff --git a/config/ext.json b/config/ext.json index f6dadaef..7ac3014e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -347,7 +347,6 @@ }, "mongodb": { "support": { - "Darwin": "no", "BSD": "wip", "Windows": "wip" }, diff --git a/src/SPC/builder/extension/mongodb.php b/src/SPC/builder/extension/mongodb.php index e6f12d54..2096de05 100644 --- a/src/SPC/builder/extension/mongodb.php +++ b/src/SPC/builder/extension/mongodb.php @@ -5,20 +5,11 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; -use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('mongodb')] class mongodb extends Extension { - public function patchBeforeBuildconf(): bool - { - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'if test -z "$PHP_CONFIG"; then', 'if false; then'); - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION=`${PHP_CONFIG} --version`', 'PHP_MONGODB_PHP_VERSION=' . $this->builder->getPHPVersion()); - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/mongodb/config.m4', 'PHP_MONGODB_PHP_VERSION_ID=`${PHP_CONFIG} --vernum`', 'PHP_MONGODB_PHP_VERSION_ID=' . $this->builder->getPHPVersionID()); - return true; - } - public function getUnixConfigureArg(): string { $arg = ' --enable-mongodb '; From db9645641f621d91c0e1a31da3e735bba3a98c95 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 5 Jun 2024 23:20:21 +0800 Subject: [PATCH 306/415] Ignore passed internal extensions (#473) * Ignore passed internal extensions * Add tests * Add tests --- src/SPC/command/BaseCommand.php | 20 ++++++++++++++++++++ src/SPC/command/BuildCliCommand.php | 2 +- src/SPC/command/DownloadCommand.php | 2 +- src/SPC/command/DumpLicenseCommand.php | 2 +- src/globals/test-extensions.php | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index 041b53a5..cfb72e26 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -144,4 +144,24 @@ abstract class BaseCommand extends Command logger()->error($fail_msg); return static::FAILURE; } + + protected function parseExtensionList(string $ext_list): array + { + $a = array_map('trim', explode(',', $ext_list)); + return array_values(array_filter($a, function ($x) { + $filter_internals = [ + 'core', + 'hash', + 'json', + 'reflection', + 'spl', + 'standard', + ]; + if (in_array(strtolower($x), $filter_internals)) { + logger()->warning("Extension [{$x}] is an builtin extension, it will be ignored."); + return false; + } + return true; + })); + } } diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index d196b455..3c6fb59f 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -47,7 +47,7 @@ class BuildCliCommand extends BuildCommand // transform string to array $libraries = array_map('trim', array_filter(explode(',', $this->getOption('with-libs')))); // transform string to array - $extensions = array_map('trim', array_filter(explode(',', $this->getArgument('extensions')))); + $extensions = $this->parseExtensionList($this->getArgument('extensions')); // parse rule with options $rule = $this->parseRules(); diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 36f5cea2..5ce1a06a 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -68,7 +68,7 @@ class DownloadCommand extends BaseCommand } // mode: --for-extensions if ($for_ext = $input->getOption('for-extensions')) { - $ext = array_map('trim', array_filter(explode(',', $for_ext))); + $ext = $this->parseExtensionList($for_ext); $sources = $this->calculateSourcesByExt($ext, !$input->getOption('without-suggestions')); if (PHP_OS_FAMILY !== 'Windows') { array_unshift($sources, 'pkg-config'); diff --git a/src/SPC/command/DumpLicenseCommand.php b/src/SPC/command/DumpLicenseCommand.php index 66047567..0e9147da 100644 --- a/src/SPC/command/DumpLicenseCommand.php +++ b/src/SPC/command/DumpLicenseCommand.php @@ -37,7 +37,7 @@ class DumpLicenseCommand extends BaseCommand $dumper = new LicenseDumper(); if ($this->getOption('for-extensions') !== null) { // 从参数中获取要编译的 extensions,并转换为数组 - $extensions = array_map('trim', array_filter(explode(',', $this->getOption('for-extensions')))); + $extensions = $this->parseExtensionList($this->getOption('for-extensions')); // 根据提供的扩展列表获取依赖库列表并编译 [$extensions, $libraries] = DependencyUtil::getExtsAndLibs($extensions); $dumper->addExts($extensions); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index cfde3b3b..6a3cf7ba 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,7 +19,7 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libxml,xlswriter,openssl', + 'Linux', 'Darwin' => 'libxml,xlswriter,openssl,core,hash,json,standard,SPL,HASH,REFLECTION', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; From d80406b8e083af9bc30a16de897288616809768b Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 6 Jun 2024 01:17:23 +0800 Subject: [PATCH 307/415] Remove mongodb notes (#474) * Ignore passed internal extensions * Add tests * Add tests * Remove mongodb notes * Remove mongodb notes --- config/ext.json | 1 - 1 file changed, 1 deletion(-) diff --git a/config/ext.json b/config/ext.json index 7ac3014e..502058fd 100644 --- a/config/ext.json +++ b/config/ext.json @@ -350,7 +350,6 @@ "BSD": "wip", "Windows": "wip" }, - "notes": true, "type": "external", "source": "mongodb", "arg-type": "custom", From 2d2607cd7f24dc161bafe90e4c665ceb61eee4a8 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Sun, 9 Jun 2024 13:38:50 +0200 Subject: [PATCH 308/415] replace ext-zend-opcache with ext-opcache for spc extension list (#475) * replace ext-zend-opcache with ext-opcache for spc extension list * Use constant to set internal and filter extensions --------- Co-authored-by: Marc Henderkes Co-authored-by: crazywhalecc --- src/SPC/command/BaseCommand.php | 29 ++++++++++++++++++----------- src/globals/defines.php | 17 +++++++++++++++++ src/globals/test-extensions.php | 2 +- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/SPC/command/BaseCommand.php b/src/SPC/command/BaseCommand.php index cfb72e26..d67b133a 100644 --- a/src/SPC/command/BaseCommand.php +++ b/src/SPC/command/BaseCommand.php @@ -145,19 +145,26 @@ abstract class BaseCommand extends Command return static::FAILURE; } + /** + * Parse extension list from string, replace alias and filter internal extensions. + * + * @param string $ext_list Extension string list, e.g. "mbstring,posix,sockets" + */ protected function parseExtensionList(string $ext_list): array { - $a = array_map('trim', explode(',', $ext_list)); - return array_values(array_filter($a, function ($x) { - $filter_internals = [ - 'core', - 'hash', - 'json', - 'reflection', - 'spl', - 'standard', - ]; - if (in_array(strtolower($x), $filter_internals)) { + // replace alias + $ls = array_map(function ($x) { + $lower = strtolower(trim($x)); + if (isset(SPC_EXTENSION_ALIAS[$lower])) { + logger()->notice("Extension [{$lower}] is an alias of [" . SPC_EXTENSION_ALIAS[$lower] . '], it will be replaced.'); + return SPC_EXTENSION_ALIAS[$lower]; + } + return $lower; + }, explode(',', $ext_list)); + + // filter internals + return array_values(array_filter($ls, function ($x) { + if (in_array($x, SPC_INTERNAL_EXTENSIONS)) { logger()->warning("Extension [{$x}] is an builtin extension, it will be ignored."); return false; } diff --git a/src/globals/defines.php b/src/globals/defines.php index 94a9ff9e..b1868756 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -38,6 +38,23 @@ const DANGER_CMD = [ 'rmdir', ]; +// spc internal extensions +const SPC_INTERNAL_EXTENSIONS = [ + 'core', + 'hash', + 'json', + 'reflection', + 'spl', + 'standard', +]; + +// spc extension alias +const SPC_EXTENSION_ALIAS = [ + 'zend opcache' => 'opcache', + 'zend-opcache' => 'opcache', + 'zendopcache' => 'opcache', +]; + // file replace strategy const REPLACE_FILE_STR = 1; const REPLACE_FILE_PREG = 2; diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 6a3cf7ba..16aff9e9 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,7 +19,7 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libxml,xlswriter,openssl,core,hash,json,standard,SPL,HASH,REFLECTION', + 'Linux', 'Darwin' => 'libxml,xlswriter,openssl,core,hash,json,standard,SPL,HASH,REFLECTION,zend-opcache', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; From 93cb7e9fbbab2307e439b0fcc21429535529af11 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 20 Jun 2024 14:46:08 +0800 Subject: [PATCH 309/415] Add phpmicro win32 mode support (#478) * Add phpmicro win32 mode support * Bump version to 2.2.4 * Add micro win32 build tests for actions * cs-fix and update deps --- .github/workflows/tests.yml | 2 +- composer.lock | 358 +++++++++++---------- src/SPC/ConsoleApplication.php | 2 +- src/SPC/builder/BuilderBase.php | 3 + src/SPC/builder/unix/UnixBuilderBase.php | 2 +- src/SPC/builder/windows/WindowsBuilder.php | 10 +- src/SPC/command/BuildCliCommand.php | 1 + src/SPC/doctor/CheckListHandler.php | 2 +- src/SPC/store/Downloader.php | 4 +- src/SPC/store/SourcePatcher.php | 22 ++ src/SPC/util/CustomExt.php | 2 +- src/globals/ext-tests/dom.php | 2 +- src/globals/ext-tests/redis.php | 2 +- src/globals/ext-tests/zip.php | 2 +- src/globals/functions.php | 2 +- tests/SPC/store/FileSystemTest.php | 6 +- 16 files changed, 229 insertions(+), 193 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71d4dfb7..d90752c7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -186,4 +186,4 @@ jobs: - name: "Run Build Tests (build, windows)" if: matrix.os == 'windows-latest' - run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $env:UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug \ No newline at end of file + run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php zts) $(php src/globals/test-extensions.php no_strip) $env:UPX_CMD --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --debug --enable-micro-win32 \ No newline at end of file diff --git a/composer.lock b/composer.lock index 37203606..fbdcb19e 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "illuminate/collections", - "version": "v10.48.10", + "version": "v10.48.13", "source": { "type": "git", "url": "https://github.com/illuminate/collections.git", - "reference": "f9589f1063a449111dcaa1d68285b507d9483a95" + "reference": "994cedcd2060b65918efe46da805ac31b0563034" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/collections/zipball/f9589f1063a449111dcaa1d68285b507d9483a95", - "reference": "f9589f1063a449111dcaa1d68285b507d9483a95", + "url": "https://api.github.com/repos/illuminate/collections/zipball/994cedcd2060b65918efe46da805ac31b0563034", + "reference": "994cedcd2060b65918efe46da805ac31b0563034", "shasum": "" }, "require": { @@ -59,11 +59,11 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2024-03-20T20:09:13+00:00" + "time": "2024-06-04T13:31:47+00:00" }, { "name": "illuminate/conditionable", - "version": "v10.48.10", + "version": "v10.48.13", "source": { "type": "git", "url": "https://github.com/illuminate/conditionable.git", @@ -109,7 +109,7 @@ }, { "name": "illuminate/contracts", - "version": "v10.48.10", + "version": "v10.48.13", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", @@ -157,7 +157,7 @@ }, { "name": "illuminate/macroable", - "version": "v10.48.10", + "version": "v10.48.13", "source": { "type": "git", "url": "https://github.com/illuminate/macroable.git", @@ -203,16 +203,16 @@ }, { "name": "laravel/prompts", - "version": "v0.1.21", + "version": "v0.1.24", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "23ea808e8a145653e0ab29e30d4385e49f40a920" + "reference": "409b0b4305273472f3754826e68f4edbd0150149" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/23ea808e8a145653e0ab29e30d4385e49f40a920", - "reference": "23ea808e8a145653e0ab29e30d4385e49f40a920", + "url": "https://api.github.com/repos/laravel/prompts/zipball/409b0b4305273472f3754826e68f4edbd0150149", + "reference": "409b0b4305273472f3754826e68f4edbd0150149", "shasum": "" }, "require": { @@ -255,9 +255,9 @@ "description": "Add beautiful and user-friendly forms to your command-line applications.", "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.21" + "source": "https://github.com/laravel/prompts/tree/v0.1.24" }, - "time": "2024-04-30T12:46:16+00:00" + "time": "2024-06-17T13:58:22+00:00" }, { "name": "psr/container", @@ -415,16 +415,16 @@ }, { "name": "symfony/console", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "a170e64ae10d00ba89e2acbb590dc2e54da8ad8f" + "reference": "be5854cee0e8c7b110f00d695d11debdfa1a2a91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/a170e64ae10d00ba89e2acbb590dc2e54da8ad8f", - "reference": "a170e64ae10d00ba89e2acbb590dc2e54da8ad8f", + "url": "https://api.github.com/repos/symfony/console/zipball/be5854cee0e8c7b110f00d695d11debdfa1a2a91", + "reference": "be5854cee0e8c7b110f00d695d11debdfa1a2a91", "shasum": "" }, "require": { @@ -489,7 +489,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.7" + "source": "https://github.com/symfony/console/tree/v6.4.8" }, "funding": [ { @@ -505,7 +505,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/deprecation-contracts", @@ -576,16 +576,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + "reference": "0424dff1c58f028c451efff2045f5d92410bd540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", - "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", + "reference": "0424dff1c58f028c451efff2045f5d92410bd540", "shasum": "" }, "require": { @@ -635,7 +635,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" }, "funding": [ { @@ -651,20 +651,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", + "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", "shasum": "" }, "require": { @@ -713,7 +713,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" }, "funding": [ { @@ -729,20 +729,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", "shasum": "" }, "require": { @@ -794,7 +794,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" }, "funding": [ { @@ -810,20 +810,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", "shasum": "" }, "require": { @@ -874,7 +874,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" }, "funding": [ { @@ -890,7 +890,7 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-06-19T12:30:46+00:00" }, { "name": "symfony/service-contracts", @@ -977,16 +977,16 @@ }, { "name": "symfony/string", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "ffeb9591c61f65a68d47f77d12b83fa530227a69" + "reference": "a147c0f826c4a1f3afb763ab8e009e37c877a44d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/ffeb9591c61f65a68d47f77d12b83fa530227a69", - "reference": "ffeb9591c61f65a68d47f77d12b83fa530227a69", + "url": "https://api.github.com/repos/symfony/string/zipball/a147c0f826c4a1f3afb763ab8e009e37c877a44d", + "reference": "a147c0f826c4a1f3afb763ab8e009e37c877a44d", "shasum": "" }, "require": { @@ -1043,7 +1043,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.7" + "source": "https://github.com/symfony/string/tree/v6.4.8" }, "funding": [ { @@ -1059,7 +1059,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "zhamao/logger", @@ -1679,7 +1679,7 @@ }, { "name": "captainhook/captainhook-phar", - "version": "5.23.0", + "version": "5.23.1", "source": { "type": "git", "url": "https://github.com/captainhookphp/captainhook-phar.git", @@ -1733,7 +1733,7 @@ ], "support": { "issues": "https://github.com/captainhookphp/captainhook/issues", - "source": "https://github.com/captainhookphp/captainhook-phar/tree/5.23.0" + "source": "https://github.com/captainhookphp/captainhook-phar/tree/5.23.1" }, "funding": [ { @@ -1856,16 +1856,16 @@ }, { "name": "composer/pcre", - "version": "3.1.3", + "version": "3.1.4", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8" + "reference": "04229f163664973f68f38f6f73d917799168ef24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", - "reference": "5b16e25a5355f1f3afdfc2f954a0a80aec4826a8", + "url": "https://api.github.com/repos/composer/pcre/zipball/04229f163664973f68f38f6f73d917799168ef24", + "reference": "04229f163664973f68f38f6f73d917799168ef24", "shasum": "" }, "require": { @@ -1907,7 +1907,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.3" + "source": "https://github.com/composer/pcre/tree/3.1.4" }, "funding": [ { @@ -1923,7 +1923,7 @@ "type": "tidelift" } ], - "time": "2024-03-19T10:26:25+00:00" + "time": "2024-05-27T13:40:54+00:00" }, { "name": "composer/semver", @@ -2521,16 +2521,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.57.1", + "version": "v3.59.3", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "3f7efe667a8c9818aacceee478add7c0fc24cb21" + "reference": "30ba9ecc2b0e5205e578fe29973c15653d9bfd29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/3f7efe667a8c9818aacceee478add7c0fc24cb21", - "reference": "3f7efe667a8c9818aacceee478add7c0fc24cb21", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/30ba9ecc2b0e5205e578fe29973c15653d9bfd29", + "reference": "30ba9ecc2b0e5205e578fe29973c15653d9bfd29", "shasum": "" }, "require": { @@ -2560,16 +2560,16 @@ "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" }, "require-dev": { - "facile-it/paraunit": "^1.3 || ^2.0", - "infection/infection": "^0.27.11", + "facile-it/paraunit": "^1.3 || ^2.3", + "infection/infection": "^0.29.5", "justinrainbow/json-schema": "^5.2", "keradus/cli-executor": "^2.1", "mikey179/vfsstream": "^1.6.11", "php-coveralls/php-coveralls": "^2.7", "php-cs-fixer/accessible-object": "^1.1", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", - "phpunit/phpunit": "^9.6 || ^10.5.5 || ^11.0.2", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.5", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.5", + "phpunit/phpunit": "^9.6.19 || ^10.5.21 || ^11.2", "symfony/var-dumper": "^5.4 || ^6.0 || ^7.0", "symfony/yaml": "^5.4 || ^6.0 || ^7.0" }, @@ -2584,7 +2584,10 @@ "autoload": { "psr-4": { "PhpCsFixer\\": "src/" - } + }, + "exclude-from-classmap": [ + "src/Fixer/Internal/*" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2609,7 +2612,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.57.1" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.59.3" }, "funding": [ { @@ -2617,7 +2620,7 @@ "type": "github" } ], - "time": "2024-05-15T22:01:07+00:00" + "time": "2024-06-16T14:17:03+00:00" }, { "name": "humbug/box", @@ -2872,12 +2875,12 @@ "version": "v5.2.13", "source": { "type": "git", - "url": "https://github.com/justinrainbow/json-schema.git", + "url": "https://github.com/jsonrainbow/json-schema.git", "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", "shasum": "" }, @@ -2932,8 +2935,8 @@ "schema" ], "support": { - "issues": "https://github.com/justinrainbow/json-schema/issues", - "source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13" + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/v5.2.13" }, "time": "2023-09-26T02:20:38+00:00" }, @@ -2999,16 +3002,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.11.1", + "version": "1.12.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", - "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", "shasum": "" }, "require": { @@ -3016,11 +3019,12 @@ }, "conflict": { "doctrine/collections": "<1.6.8", - "doctrine/common": "<2.13.3 || >=3,<3.2.2" + "doctrine/common": "<2.13.3 || >=3 <3.2.2" }, "require-dev": { "doctrine/collections": "^1.6.8", "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" }, "type": "library", @@ -3046,7 +3050,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" }, "funding": [ { @@ -3054,20 +3058,20 @@ "type": "tidelift" } ], - "time": "2023-03-08T13:26:56+00:00" + "time": "2024-06-12T14:39:25+00:00" }, { "name": "nikic/iter", - "version": "v2.4.0", + "version": "v2.4.1", "source": { "type": "git", "url": "https://github.com/nikic/iter.git", - "reference": "09cd930fa9ff55747f34c7184532a5a1bd2385b1" + "reference": "3f031ae08d82c4394410e76b88b441331a6fa15f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/iter/zipball/09cd930fa9ff55747f34c7184532a5a1bd2385b1", - "reference": "09cd930fa9ff55747f34c7184532a5a1bd2385b1", + "url": "https://api.github.com/repos/nikic/iter/zipball/3f031ae08d82c4394410e76b88b441331a6fa15f", + "reference": "3f031ae08d82c4394410e76b88b441331a6fa15f", "shasum": "" }, "require": { @@ -3104,9 +3108,9 @@ ], "support": { "issues": "https://github.com/nikic/iter/issues", - "source": "https://github.com/nikic/iter/tree/v2.4.0" + "source": "https://github.com/nikic/iter/tree/v2.4.1" }, - "time": "2023-12-10T20:43:19+00:00" + "time": "2024-03-19T20:45:05+00:00" }, { "name": "nikic/php-parser", @@ -3800,16 +3804,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.4.0", + "version": "5.4.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", "shasum": "" }, "require": { @@ -3858,9 +3862,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" }, - "time": "2024-04-09T21:13:58+00:00" + "time": "2024-05-21T05:55:05+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3922,16 +3926,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.29.0", + "version": "1.29.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc" + "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/536889f2b340489d328f5ffb7b02bb6b183ddedc", - "reference": "536889f2b340489d328f5ffb7b02bb6b183ddedc", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/fcaefacf2d5c417e928405b71b400d4ce10daaf4", + "reference": "fcaefacf2d5c417e928405b71b400d4ce10daaf4", "shasum": "" }, "require": { @@ -3963,22 +3967,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.29.1" }, - "time": "2024-05-06T12:04:23+00:00" + "time": "2024-05-31T08:52:43+00:00" }, { "name": "phpstan/phpstan", - "version": "1.11.1", + "version": "1.11.5", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b" + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e524358f930e41a2b4cca1320e3b04fc26b39e0b", - "reference": "e524358f930e41a2b4cca1320e3b04fc26b39e0b", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/490f0ae1c92b082f154681d7849aee776a7c1443", + "reference": "490f0ae1c92b082f154681d7849aee776a7c1443", "shasum": "" }, "require": { @@ -4023,7 +4027,7 @@ "type": "github" } ], - "time": "2024-05-15T08:00:59+00:00" + "time": "2024-06-17T15:10:54+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4650,28 +4654,28 @@ }, { "name": "react/dns", - "version": "v1.12.0", + "version": "v1.13.0", "source": { "type": "git", "url": "https://github.com/reactphp/dns.git", - "reference": "c134600642fa615b46b41237ef243daa65bb64ec" + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/dns/zipball/c134600642fa615b46b41237ef243daa65bb64ec", - "reference": "c134600642fa615b46b41237ef243daa65bb64ec", + "url": "https://api.github.com/repos/reactphp/dns/zipball/eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", + "reference": "eb8ae001b5a455665c89c1df97f6fb682f8fb0f5", "shasum": "" }, "require": { "php": ">=5.3.0", "react/cache": "^1.0 || ^0.6 || ^0.5", "react/event-loop": "^1.2", - "react/promise": "^3.0 || ^2.7 || ^1.2.1" + "react/promise": "^3.2 || ^2.7 || ^1.2.1" }, "require-dev": { "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36", - "react/async": "^4 || ^3 || ^2", - "react/promise-timer": "^1.9" + "react/async": "^4.3 || ^3 || ^2", + "react/promise-timer": "^1.11" }, "type": "library", "autoload": { @@ -4714,7 +4718,7 @@ ], "support": { "issues": "https://github.com/reactphp/dns/issues", - "source": "https://github.com/reactphp/dns/tree/v1.12.0" + "source": "https://github.com/reactphp/dns/tree/v1.13.0" }, "funding": [ { @@ -4722,7 +4726,7 @@ "type": "open_collective" } ], - "time": "2023-11-29T12:41:06+00:00" + "time": "2024-06-13T14:18:03+00:00" }, { "name": "react/event-loop", @@ -4798,16 +4802,16 @@ }, { "name": "react/promise", - "version": "v3.1.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c" + "reference": "8a164643313c71354582dc850b42b33fa12a4b63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/e563d55d1641de1dea9f5e84f3cccc66d2bfe02c", - "reference": "e563d55d1641de1dea9f5e84f3cccc66d2bfe02c", + "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63", "shasum": "" }, "require": { @@ -4859,7 +4863,7 @@ ], "support": { "issues": "https://github.com/reactphp/promise/issues", - "source": "https://github.com/reactphp/promise/tree/v3.1.0" + "source": "https://github.com/reactphp/promise/tree/v3.2.0" }, "funding": [ { @@ -4867,7 +4871,7 @@ "type": "open_collective" } ], - "time": "2023-11-16T16:21:57+00:00" + "time": "2024-05-24T10:39:05+00:00" }, { "name": "react/socket", @@ -4951,16 +4955,16 @@ }, { "name": "react/stream", - "version": "v1.3.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/reactphp/stream.git", - "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66" + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/stream/zipball/6fbc9672905c7d5a885f2da2fc696f65840f4a66", - "reference": "6fbc9672905c7d5a885f2da2fc696f65840f4a66", + "url": "https://api.github.com/repos/reactphp/stream/zipball/1e5b0acb8fe55143b5b426817155190eb6f5b18d", + "reference": "1e5b0acb8fe55143b5b426817155190eb6f5b18d", "shasum": "" }, "require": { @@ -4970,7 +4974,7 @@ }, "require-dev": { "clue/stream-filter": "~1.2", - "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" }, "type": "library", "autoload": { @@ -5017,7 +5021,7 @@ ], "support": { "issues": "https://github.com/reactphp/stream/issues", - "source": "https://github.com/reactphp/stream/tree/v1.3.0" + "source": "https://github.com/reactphp/stream/tree/v1.4.0" }, "funding": [ { @@ -5025,7 +5029,7 @@ "type": "open_collective" } ], - "time": "2023-06-16T10:52:11+00:00" + "time": "2024-06-11T12:45:25+00:00" }, { "name": "sebastian/cli-parser", @@ -6056,16 +6060,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d84384f3f67de3cb650db64d685d70395dacfc3f" + "reference": "8d7507f02b06e06815e56bb39aa0128e3806208b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d84384f3f67de3cb650db64d685d70395dacfc3f", - "reference": "d84384f3f67de3cb650db64d685d70395dacfc3f", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/8d7507f02b06e06815e56bb39aa0128e3806208b", + "reference": "8d7507f02b06e06815e56bb39aa0128e3806208b", "shasum": "" }, "require": { @@ -6116,7 +6120,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.7" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.4.8" }, "funding": [ { @@ -6132,7 +6136,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -6212,23 +6216,25 @@ }, { "name": "symfony/filesystem", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4" + "reference": "4d37529150e7081c51b3c5d5718c55a04a9503f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/78dde75f8f6dbbca4ec436a4b0087f7af02076d4", - "reference": "78dde75f8f6dbbca4ec436a4b0087f7af02076d4", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/4d37529150e7081c51b3c5d5718c55a04a9503f3", + "reference": "4d37529150e7081c51b3c5d5718c55a04a9503f3", "shasum": "" }, "require": { "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/process": "^5.4|^6.4" + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^5.4|^6.4|^7.0" }, "type": "library", "autoload": { @@ -6256,7 +6262,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.4.7" + "source": "https://github.com/symfony/filesystem/tree/v6.4.8" }, "funding": [ { @@ -6272,20 +6278,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/finder", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "511c48990be17358c23bf45c5d71ab85d40fb764" + "reference": "3ef977a43883215d560a2cecb82ec8e62131471c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/511c48990be17358c23bf45c5d71ab85d40fb764", - "reference": "511c48990be17358c23bf45c5d71ab85d40fb764", + "url": "https://api.github.com/repos/symfony/finder/zipball/3ef977a43883215d560a2cecb82ec8e62131471c", + "reference": "3ef977a43883215d560a2cecb82ec8e62131471c", "shasum": "" }, "require": { @@ -6320,7 +6326,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v6.4.7" + "source": "https://github.com/symfony/finder/tree/v6.4.8" }, "funding": [ { @@ -6336,20 +6342,20 @@ "type": "tidelift" } ], - "time": "2024-04-23T10:36:43+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/options-resolver", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "9a3c92b490716ba6771f5beced13c6eda7183eed" + "reference": "22ab9e9101ab18de37839074f8a1197f55590c1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9a3c92b490716ba6771f5beced13c6eda7183eed", - "reference": "9a3c92b490716ba6771f5beced13c6eda7183eed", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/22ab9e9101ab18de37839074f8a1197f55590c1b", + "reference": "22ab9e9101ab18de37839074f8a1197f55590c1b", "shasum": "" }, "require": { @@ -6387,7 +6393,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v6.4.7" + "source": "https://github.com/symfony/options-resolver/tree/v6.4.8" }, "funding": [ { @@ -6403,20 +6409,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.29.0", + "version": "v1.30.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f" + "reference": "c027e6a3c6aee334663ec21f5852e89738abc805" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f", - "reference": "cd4226d140ecd3d0f13d32ed0a4a095ffe871d2f", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/c027e6a3c6aee334663ec21f5852e89738abc805", + "reference": "c027e6a3c6aee334663ec21f5852e89738abc805", "shasum": "" }, "require": { @@ -6467,7 +6473,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-iconv/tree/v1.29.0" + "source": "https://github.com/symfony/polyfill-iconv/tree/v1.30.0" }, "funding": [ { @@ -6483,20 +6489,20 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" + "time": "2024-05-31T15:07:36+00:00" }, { "name": "symfony/process", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "cdb1c81c145fd5aa9b0038bab694035020943381" + "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/cdb1c81c145fd5aa9b0038bab694035020943381", - "reference": "cdb1c81c145fd5aa9b0038bab694035020943381", + "url": "https://api.github.com/repos/symfony/process/zipball/8d92dd79149f29e89ee0f480254db595f6a6a2c5", + "reference": "8d92dd79149f29e89ee0f480254db595f6a6a2c5", "shasum": "" }, "require": { @@ -6528,7 +6534,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v6.4.7" + "source": "https://github.com/symfony/process/tree/v6.4.8" }, "funding": [ { @@ -6544,20 +6550,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/stopwatch", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "ffec95ba269e541eb2232126c0c20f83086b5c68" + "reference": "63e069eb616049632cde9674c46957819454b8aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/ffec95ba269e541eb2232126c0c20f83086b5c68", - "reference": "ffec95ba269e541eb2232126c0c20f83086b5c68", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/63e069eb616049632cde9674c46957819454b8aa", + "reference": "63e069eb616049632cde9674c46957819454b8aa", "shasum": "" }, "require": { @@ -6590,7 +6596,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v6.4.7" + "source": "https://github.com/symfony/stopwatch/tree/v6.4.8" }, "funding": [ { @@ -6606,20 +6612,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "symfony/var-dumper", - "version": "v6.4.7", + "version": "v6.4.8", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "7a9cd977cd1c5fed3694bee52990866432af07d7" + "reference": "ad23ca4312395f0a8a8633c831ef4c4ee542ed25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/7a9cd977cd1c5fed3694bee52990866432af07d7", - "reference": "7a9cd977cd1c5fed3694bee52990866432af07d7", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ad23ca4312395f0a8a8633c831ef4c4ee542ed25", + "reference": "ad23ca4312395f0a8a8633c831ef4c4ee542ed25", "shasum": "" }, "require": { @@ -6675,7 +6681,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.4.7" + "source": "https://github.com/symfony/var-dumper/tree/v6.4.8" }, "funding": [ { @@ -6691,7 +6697,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:22:46+00:00" + "time": "2024-05-31T14:49:08+00:00" }, { "name": "thecodingmachine/safe", diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index ae27245a..4b50e6f2 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.2.3'; + public const VERSION = '2.2.4'; public function __construct() { diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index f2ab2dd8..4f4a72f8 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -460,7 +460,9 @@ abstract class BuilderBase 'micro_ext_test' => [ 'content' => ($this->getOption('without-micro-ext-test') ? 'generateMicroExtTests()), 'conditions' => [ + // program success function ($ret) { return $ret === 0; }, + // program returns expected output function ($ret, $out) { $raw_out = trim(implode('', $out)); return str_starts_with($raw_out, '[micro-test-start]') && str_ends_with($raw_out, '[micro-test-end]'); @@ -470,6 +472,7 @@ abstract class BuilderBase 'micro_zend_bug_test' => [ 'content' => ($this->getOption('without-micro-ext-test') ? ' [ + // program success function ($ret) { return $ret === 0; }, ], ], diff --git a/src/SPC/builder/unix/UnixBuilderBase.php b/src/SPC/builder/unix/UnixBuilderBase.php index 76d6768a..18fb6eb0 100644 --- a/src/SPC/builder/unix/UnixBuilderBase.php +++ b/src/SPC/builder/unix/UnixBuilderBase.php @@ -96,7 +96,7 @@ abstract class UnixBuilderBase extends BuilderBase $support_lib_list = []; $classes = FileSystem::getClassesPsr4( ROOT_DIR . '/src/SPC/builder/' . osfamily2dir() . '/library', - 'SPC\\builder\\' . osfamily2dir() . '\\library' + 'SPC\builder\\' . osfamily2dir() . '\library' ); foreach ($classes as $class) { if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) { diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 7c1f9ff7..1c644488 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -102,6 +102,8 @@ class WindowsBuilder extends BuilderBase $micro_logo = ''; } + $micro_w32 = $this->getOption('enable-micro-win32') ? ' --enable-micro-win32=yes' : ''; + cmd()->cd(SOURCE_PATH . '\php-src') ->exec( "{$this->sdk_prefix} configure.bat --task-args \"" . @@ -111,7 +113,7 @@ class WindowsBuilder extends BuilderBase '--with-extra-includes=' . BUILD_INCLUDE_PATH . ' ' . '--with-extra-libs=' . BUILD_LIB_PATH . ' ' . ($enableCli ? '--enable-cli=yes ' : '--enable-cli=no ') . - ($enableMicro ? ('--enable-micro=yes ' . $micro_logo) : '--enable-micro=no ') . + ($enableMicro ? ('--enable-micro=yes ' . $micro_logo . $micro_w32) : '--enable-micro=no ') . ($enableEmbed ? '--enable-embed=yes ' : '--enable-embed=no ') . "{$this->makeExtensionArgs()} " . $zts . @@ -132,6 +134,8 @@ class WindowsBuilder extends BuilderBase if ($enableMicro) { logger()->info('building micro'); $this->buildMicro(); + + SourcePatcher::unpatchMicroWin32(); } if ($enableEmbed) { logger()->warning('Windows does not currently support embed SAPI.'); @@ -212,8 +216,8 @@ class WindowsBuilder extends BuilderBase // search all supported libs $support_lib_list = []; $classes = FileSystem::getClassesPsr4( - ROOT_DIR . '\src\SPC\builder\\' . osfamily2dir() . '\\library', - 'SPC\\builder\\' . osfamily2dir() . '\\library' + ROOT_DIR . '\src\SPC\builder\\' . osfamily2dir() . '\library', + 'SPC\builder\\' . osfamily2dir() . '\library' ); foreach ($classes as $class) { if (defined($class . '::NAME') && $class::NAME !== 'unknown' && Config::getLib($class::NAME) !== null) { diff --git a/src/SPC/command/BuildCliCommand.php b/src/SPC/command/BuildCliCommand.php index 3c6fb59f..ca689641 100644 --- a/src/SPC/command/BuildCliCommand.php +++ b/src/SPC/command/BuildCliCommand.php @@ -40,6 +40,7 @@ class BuildCliCommand extends BuildCommand $this->addOption('without-micro-ext-test', null, null, 'Disable phpmicro with extension test code'); $this->addOption('with-upx-pack', null, null, 'Compress / pack binary using UPX tool (linux/windows only)'); $this->addOption('with-micro-logo', null, InputOption::VALUE_REQUIRED, 'Use custom .ico for micro.sfx (windows only)'); + $this->addOption('enable-micro-win32', null, null, 'Enable win32 mode for phpmicro (Windows only)'); } public function handle(): int diff --git a/src/SPC/doctor/CheckListHandler.php b/src/SPC/doctor/CheckListHandler.php index de5733df..23005dfd 100644 --- a/src/SPC/doctor/CheckListHandler.php +++ b/src/SPC/doctor/CheckListHandler.php @@ -70,7 +70,7 @@ final class CheckListHandler */ private function loadCheckList(bool $include_manual = false): array { - foreach (FileSystem::getClassesPsr4(__DIR__ . '/item', 'SPC\\doctor\\item') as $class) { + foreach (FileSystem::getClassesPsr4(__DIR__ . '/item', 'SPC\doctor\item') as $class) { $ref = new \ReflectionClass($class); foreach ($ref->getMethods() as $method) { foreach ($method->getAttributes() as $a) { diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 1665ff66..00d8881d 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -337,7 +337,7 @@ 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/source', 'SPC\store\source'); foreach ($classes as $class) { if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { (new $class())->fetch($force); @@ -437,7 +437,7 @@ 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/source', 'SPC\store\source'); foreach ($classes as $class) { if (is_a($class, CustomSourceBase::class, true) && $class::NAME === $name) { (new $class())->fetch($force); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 824c80f6..6750f899 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -47,6 +47,12 @@ class SourcePatcher '' ); } + + if ($builder->getOption('enable-micro-win32')) { + SourcePatcher::patchMicroWin32(); + } else { + SourcePatcher::unpatchMicroWin32(); + } } /** @@ -368,4 +374,20 @@ class SourcePatcher FileSystem::writeFile(SOURCE_PATH . '/php-src/main/main.c', $file); } } + + public static function patchMicroWin32(): void + { + // patch micro win32 + if (!file_exists(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak')) { + copy(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak'); + FileSystem::replaceFileStr(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c', '#include "php_variables.h"', '#include "php_variables.h"' . "\n#define PHP_MICRO_WIN32_NO_CONSOLE 1"); + } + } + + public static function unpatchMicroWin32(): void + { + if (file_exists(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak')) { + rename(SOURCE_PATH . '\php-src\sapi\micro\php_micro.c.win32bak', SOURCE_PATH . '\php-src\sapi\micro\php_micro.c'); + } + } } diff --git a/src/SPC/util/CustomExt.php b/src/SPC/util/CustomExt.php index db312007..bbd4adf7 100644 --- a/src/SPC/util/CustomExt.php +++ b/src/SPC/util/CustomExt.php @@ -23,7 +23,7 @@ class CustomExt */ public static function loadCustomExt(): void { - $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\\builder\\extension'); + $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\builder\extension'); foreach ($classes as $class) { $reflection = new \ReflectionClass($class); foreach ($reflection->getAttributes(CustomExt::class) as $attribute) { diff --git a/src/globals/ext-tests/dom.php b/src/globals/ext-tests/dom.php index 65e3617f..a6b44f78 100644 --- a/src/globals/ext-tests/dom.php +++ b/src/globals/ext-tests/dom.php @@ -2,7 +2,7 @@ declare(strict_types=1); -assert(class_exists('\\DOMDocument')); +assert(class_exists('\DOMDocument')); $doc = new DOMDocument(); $doc->loadHtml('Hello'); assert($doc->getElementById('app')->nodeValue === 'Hello'); diff --git a/src/globals/ext-tests/redis.php b/src/globals/ext-tests/redis.php index 76a971b2..e14ff631 100644 --- a/src/globals/ext-tests/redis.php +++ b/src/globals/ext-tests/redis.php @@ -2,4 +2,4 @@ declare(strict_types=1); -assert(class_exists('\\Redis')); +assert(class_exists('\Redis')); diff --git a/src/globals/ext-tests/zip.php b/src/globals/ext-tests/zip.php index 3c5bf3da..1cc9e20e 100644 --- a/src/globals/ext-tests/zip.php +++ b/src/globals/ext-tests/zip.php @@ -2,4 +2,4 @@ declare(strict_types=1); -assert(class_exists('\\ZipArchive')); +assert(class_exists('\ZipArchive')); diff --git a/src/globals/functions.php b/src/globals/functions.php index 691f73e7..e61a8d6e 100644 --- a/src/globals/functions.php +++ b/src/globals/functions.php @@ -56,7 +56,7 @@ function arch2gnu(string $arch): string */ function match_pattern(string $pattern, string $subject): bool { - $pattern = str_replace(['\*', '\\\\.*'], ['.*', '\*'], preg_quote($pattern, '/')); + $pattern = str_replace(['\*', '\\\.*'], ['.*', '\*'], preg_quote($pattern, '/')); $pattern = '/^' . $pattern . '$/i'; return preg_match($pattern, $subject) === 1; } diff --git a/tests/SPC/store/FileSystemTest.php b/tests/SPC/store/FileSystemTest.php index aae36d8b..e2d18f73 100644 --- a/tests/SPC/store/FileSystemTest.php +++ b/tests/SPC/store/FileSystemTest.php @@ -94,7 +94,7 @@ class FileSystemTest extends TestCase */ public function testGetClassesPsr4() { - $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\\builder\\extension'); + $classes = FileSystem::getClassesPsr4(ROOT_DIR . '/src/SPC/builder/extension', 'SPC\builder\extension'); foreach ($classes as $class) { $this->assertIsString($class); new \ReflectionClass($class); @@ -185,9 +185,9 @@ class FileSystemTest extends TestCase public function testIsRelativePath() { $this->assertTrue(FileSystem::isRelativePath('.')); - $this->assertTrue(FileSystem::isRelativePath('.\\sdf')); + $this->assertTrue(FileSystem::isRelativePath('.\sdf')); if (DIRECTORY_SEPARATOR === '\\') { - $this->assertFalse(FileSystem::isRelativePath('C:\\asdasd/fwe\asd')); + $this->assertFalse(FileSystem::isRelativePath('C:\asdasd/fwe\asd')); } else { $this->assertFalse(FileSystem::isRelativePath('/fwefwefewf')); } From e9aff8f1d85c7c4de19a86de7a219102a28d8f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Tue, 25 Jun 2024 06:38:38 +0200 Subject: [PATCH 310/415] fix: error when building libtiff (#481) * fix: error when building libtiff * Update test-extensions.php * Add test token * Fix windows builds * Fix token * Fix token * Test token * Test token * Test token --------- Co-authored-by: Jerry Ma --- .github/workflows/tests.yml | 20 +++++--------------- src/SPC/builder/unix/library/libtiff.php | 12 +++++++++--- src/globals/test-extensions.php | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d90752c7..86b14e61 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,6 +12,9 @@ on: permissions: contents: read +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: php-cs-fixer: runs-on: ubuntu-latest @@ -129,13 +132,6 @@ jobs: extensions: curl, openssl, mbstring ini-values: memory_limit=-1 - - name: "Use test token if exists" - if: matrix.os != 'windows-latest' - run: | - if [ "${{ secrets.TEST_GH_TOKEN }}" != "" ]; then - echo "GITHUB_TOKEN=${{ secrets.TEST_GH_TOKEN }}" >> $GITHUB_ENV - fi - - name: "Cache composer packages" id: composer-cache uses: actions/cache@v4 @@ -170,15 +166,9 @@ jobs: bin/spc install-pkg upx echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV - - name: "Run Build Tests (download)" - uses: nick-fields/retry@v3 - with: - timeout_minutes: 10 - max_attempts: 3 - retry_on: error - command: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src,libcares --debug --retry=3 + run: | + bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=5 - name: "Run Build Tests (build, *nix)" if: matrix.os != 'windows-latest' diff --git a/src/SPC/builder/unix/library/libtiff.php b/src/SPC/builder/unix/library/libtiff.php index 08e6e7eb..4c93acea 100644 --- a/src/SPC/builder/unix/library/libtiff.php +++ b/src/SPC/builder/unix/library/libtiff.php @@ -15,14 +15,20 @@ trait libtiff */ protected function build(): void { - shell()->cd($this->source_dir) + $shell = shell()->cd($this->source_dir) ->exec( './configure ' . '--enable-static --disable-shared ' . '--disable-cxx ' . '--prefix=' - ) - ->exec('make clean') + ); + + // TODO: Remove this check when https://gitlab.com/libtiff/libtiff/-/merge_requests/635 will be merged and released + if (file_exists($this->source_dir . '/html')) { + $shell->exec('make clean'); + } + + $shell ->exec("make -j{$this->builder->concurrency}") ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); $this->patchPkgconfPrefix(['libtiff-4.pc']); diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 16aff9e9..ec97f329 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,13 +19,13 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libxml,xlswriter,openssl,core,hash,json,standard,SPL,HASH,REFLECTION,zend-opcache', + 'Linux', 'Darwin' => 'imagick', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // 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' => 'libtiff', 'Windows' => '', }; From 0b8a0504a21c7d784392c31d448ecc614259ee66 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 26 Jun 2024 11:30:19 +0800 Subject: [PATCH 311/415] Update GMP ver, using official 6.3.0 version (#483) * Update GMP ver, using official 6.3.0 version * Add GMP test --- config/source.json | 8 ++++++-- src/globals/test-extensions.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/source.json b/config/source.json index 8fdfc85c..5dadd944 100644 --- a/config/source.json +++ b/config/source.json @@ -179,8 +179,12 @@ } }, "gmp": { - "type": "ghtagtar", - "repo": "alisw/GMP", + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/gmp/gmp-6.3.0.tar.xz", + "alt": { + "type": "ghtagtar", + "repo": "alisw/GMP" + }, "license": { "type": "text", "text": "Since version 6, GMP is distributed under the dual licenses, GNU LGPL v3 and GNU GPL v2. These licenses make the library free to use, share, and improve, and allow you to pass on the result. The GNU licenses give freedoms, but also set firm restrictions on the use with non-free programs." diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ec97f329..69260524 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,7 +19,7 @@ $upx = true; // 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' => 'imagick,gmp', 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; From 2a03c32bc090d017f6bf1cb2b3f7e08796643ad9 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Wed, 26 Jun 2024 20:35:11 +0800 Subject: [PATCH 312/415] Add full gd support on Windows (#484) * Add full gd support (libjpeg, libpng, libwebp, libavif, freetype), and related patches * cs fix * Fix PHP 8.0 gd build --- config/ext.json | 1941 +++++++++--------- config/lib.json | 1337 ++++++------ src/SPC/builder/windows/SystemUtil.php | 1 + src/SPC/builder/windows/library/freetype.php | 36 + src/SPC/builder/windows/library/libavif.php | 37 + src/SPC/builder/windows/library/libjpeg.php | 41 + src/SPC/builder/windows/library/libpng.php | 40 + src/SPC/builder/windows/library/libwebp.php | 45 + src/SPC/store/SourcePatcher.php | 18 + src/globals/extra/gd_config_80.w32 | 86 + src/globals/extra/gd_config_81.w32 | 94 + src/globals/test-extensions.php | 8 +- 12 files changed, 2050 insertions(+), 1634 deletions(-) create mode 100644 src/SPC/builder/windows/library/freetype.php create mode 100644 src/SPC/builder/windows/library/libavif.php create mode 100644 src/SPC/builder/windows/library/libjpeg.php create mode 100644 src/SPC/builder/windows/library/libpng.php create mode 100644 src/SPC/builder/windows/library/libwebp.php create mode 100644 src/globals/extra/gd_config_80.w32 create mode 100644 src/globals/extra/gd_config_81.w32 diff --git a/config/ext.json b/config/ext.json index 502058fd..a3ec8041 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1,971 +1,970 @@ -{ - "amqp": { - "support": { - "BSD": "wip" - }, - "type": "external", - "arg-type": "custom", - "source": "amqp", - "lib-depends": [ - "librabbitmq" - ], - "ext-depends-windows": [ - "openssl" - ] - }, - "apcu": { - "type": "external", - "source": "apcu" - }, - "bcmath": { - "type": "builtin" - }, - "bz2": { - "support": { - "Windows": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "bzip2" - ] - }, - "calendar": { - "type": "builtin" - }, - "ctype": { - "type": "builtin" - }, - "curl": { - "notes": true, - "type": "builtin", - "arg-type": "with", - "lib-depends": [ - "curl" - ], - "ext-depends-windows": [ - "zlib", - "openssl" - ] - }, - "dba": { - "type": "builtin", - "arg-type": "custom", - "lib-suggests": [ - "qdbm" - ] - }, - "dom": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "custom", - "arg-type-windows": "with", - "lib-depends": [ - "libxml2", - "zlib" - ], - "ext-depends-windows": [ - "xml" - ] - }, - "ds": { - "type": "external", - "source": "ext-ds" - }, - "enchant": { - "support": { - "Windows": "wip", - "BSD": "wip", - "Darwin": "wip", - "Linux": "wip" - }, - "type": "wip" - }, - "event": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "external", - "source": "ext-event", - "arg-type": "custom", - "lib-depends": [ - "libevent" - ], - "ext-depends": [ - "openssl" - ], - "ext-suggests": [ - "sockets" - ] - }, - "exif": { - "type": "builtin" - }, - "ffi": { - "support": { - "Linux": "no", - "BSD": "wip" - }, - "notes": true, - "arg-type": "custom", - "type": "builtin", - "lib-depends-unix": [ - "libffi" - ], - "lib-depends-windows": [ - "libffi-win" - ] - }, - "fileinfo": { - "type": "builtin" - }, - "filter": { - "type": "builtin" - }, - "ftp": { - "type": "builtin", - "lib-suggests": [ - "openssl" - ] - }, - "gd": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "builtin", - "arg-type": "custom", - "arg-type-windows": "with", - "lib-depends": [ - "zlib", - "libpng" - ], - "ext-depends": [ - "zlib" - ], - "lib-suggests": [ - "libavif", - "libwebp", - "libjpeg", - "freetype" - ] - }, - "gettext": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "gettext" - ] - }, - "glfw": { - "support": { - "Windows": "wip", - "BSD": "no", - "Linux": "no" - }, - "notes": true, - "type": "external", - "arg-type": "custom", - "source": "ext-glfw", - "lib-depends": [ - "glfw" - ], - "lib-depends-windows": [] - }, - "gmp": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "gmp" - ] - }, - "iconv": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "arg-type-windows": "with", - "lib-depends-unix": [ - "libiconv" - ], - "lib-depends-windows": [ - "libiconv-win" - ] - }, - "igbinary": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "igbinary" - }, - "imagick": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "ext-imagick", - "arg-type": "custom", - "lib-depends": [ - "imagemagick" - ] - }, - "imap": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "builtin", - "arg-type": "custom", - "lib-depends": [ - "imap" - ], - "ext-suggests": [ - "openssl" - ] - }, - "inotify": { - "support": { - "Windows": "no", - "BSD": "wip", - "Darwin": "no" - }, - "type": "external", - "source": "inotify" - }, - "intl": { - "support": { - "Windows": "no", - "BSD": "wip" - }, - "type": "builtin", - "lib-depends": [ - "icu" - ] - }, - "ldap": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "ldap" - ], - "lib-suggests": [ - "gmp", - "libsodium" - ], - "ext-suggests": [ - "openssl" - ] - }, - "libxml": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "none", - "ext-depends": [ - "xml" - ] - }, - "mbregex": { - "type": "builtin", - "arg-type": "custom", - "ext-depends": [ - "mbstring" - ], - "lib-depends": [ - "onig" - ] - }, - "mbstring": { - "type": "builtin", - "arg-type": "custom" - }, - "mcrypt": { - "type": "wip", - "support": { - "Windows": "no", - "BSD": "no", - "Darwin": "no", - "Linux": "no" - }, - "notes": true - }, - "memcache": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "ext-memcache", - "arg-type": "custom", - "lib-depends": [ - "zlib" - ], - "ext-depends": [ - "session" - ] - }, - "memcached": { - "support": { - "Windows": "wip", - "BSD": "wip", - "Linux": "no" - }, - "type": "external", - "source": "memcached", - "arg-type": "custom", - "cpp-extension": true, - "lib-depends": [ - "libmemcached" - ], - "ext-depends": [ - "session", - "zlib" - ] - }, - "mongodb": { - "support": { - "BSD": "wip", - "Windows": "wip" - }, - "type": "external", - "source": "mongodb", - "arg-type": "custom", - "lib-suggests": [ - "icu", - "openssl", - "zstd", - "zlib" - ] - }, - "mysqli": { - "type": "builtin", - "arg-type": "with", - "ext-depends": [ - "mysqlnd" - ] - }, - "mysqlnd": { - "type": "builtin", - "arg-type-windows": "with", - "lib-depends": [ - "zlib" - ] - }, - "oci8": { - "type": "wip", - "support": { - "Windows": "wip", - "BSD": "no", - "Darwin": "no", - "Linux": "no" - }, - "notes": true - }, - "opcache": { - "type": "builtin", - "arg-type": "custom" - }, - "openssl": { - "notes": true, - "type": "builtin", - "arg-type": "custom", - "arg-type-windows": "with", - "lib-depends": [ - "openssl", - "zlib" - ], - "ext-depends": [ - "zlib" - ] - }, - "parallel": { - "support": { - "BSD": "wip" - }, - "notes": true, - "type": "external", - "source": "parallel", - "arg-type-windows": "with", - "lib-depends-windows": [ - "pthreads4w" - ] - }, - "password-argon2": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "libargon2" - ] - }, - "pcntl": { - "support": { - "Windows": "no" - }, - "type": "builtin", - "unix-only": true - }, - "pdo": { - "type": "builtin" - }, - "pdo_mysql": { - "type": "builtin", - "arg-type": "with", - "ext-depends": [ - "pdo", - "mysqlnd" - ] - }, - "pdo_pgsql": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "ext-depends": [ - "pdo", - "pgsql" - ], - "lib-depends": [ - "postgresql" - ] - }, - "pdo_sqlite": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with", - "ext-depends": [ - "pdo", - "sqlite3" - ], - "lib-depends": [ - "sqlite" - ] - }, - "pdo_sqlsrv": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "pdo_sqlsrv", - "arg-type": "with", - "ext-depends": [ - "pdo", - "sqlsrv" - ] - }, - "pgsql": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "postgresql" - ] - }, - "phar": { - "type": "builtin", - "ext-depends": [ - "zlib" - ] - }, - "posix": { - "support": { - "Windows": "no" - }, - "type": "builtin", - "unix-only": true - }, - "protobuf": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "protobuf" - }, - "rar": { - "support": { - "Windows": "wip", - "BSD": "wip", - "Darwin": "partial" - }, - "notes": true, - "type": "external", - "source": "rar", - "cpp-extension": true - }, - "readline": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "readline" - ] - }, - "redis": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "redis", - "arg-type": "custom", - "ext-suggests": [ - "session", - "igbinary" - ], - "lib-suggests": [ - "zstd", - "liblz4" - ] - }, - "session": { - "type": "builtin" - }, - "shmop": { - "type": "builtin" - }, - "simdjson": { - "type": "external", - "source": "ext-simdjson", - "cpp-extension": true - }, - "simplexml": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "custom", - "lib-depends": [ - "libxml2" - ], - "ext-depends-windows": [ - "xml" - ] - }, - "snappy": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "ext-snappy", - "cpp-extension": true, - "arg-type": "custom", - "lib-depends": [ - "snappy" - ], - "ext-suggest": [ - "apcu" - ] - }, - "soap": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "custom", - "lib-depends": [ - "libxml2" - ], - "ext-depends-windows": [ - "xml" - ] - }, - "sockets": { - "type": "builtin" - }, - "sodium": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with", - "lib-depends": [ - "libsodium" - ] - }, - "sqlite3": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "arg-type-windows": "with", - "lib-depends": [ - "sqlite" - ] - }, - "sqlsrv": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "sqlsrv", - "lib-depends": [ - "unixodbc" - ], - "ext-depends-linux": [ - "pcntl" - ], - "cpp-extension": true - }, - "ssh2": { - "support": { - "BSD": "wip" - }, - "type": "external", - "source": "ext-ssh2", - "arg-type": "with-prefix", - "arg-type-windows": "with", - "lib-depends": [ - "libssh2" - ], - "ext-depends-windows": [ - "openssl", - "zlib" - ] - }, - "swoole": { - "support": { - "Windows": "no", - "BSD": "wip" - }, - "notes": true, - "type": "external", - "source": "swoole", - "arg-type": "custom", - "cpp-extension": true, - "unix-only": true, - "lib-depends": [ - "libcares", - "brotli", - "nghttp2", - "zlib" - ], - "ext-depends": [ - "openssl", - "curl" - ], - "ext-suggests": [ - "swoole-hook-pgsql", - "swoole-hook-mysql", - "swoole-hook-sqlite" - ] - }, - "swoole-hook-mysql": { - "support": { - "Windows": "no", - "BSD": "wip" - }, - "notes": true, - "type": "addon", - "arg-type": "custom", - "ext-depends": [ - "mysqlnd", - "pdo", - "pdo_mysql" - ], - "ext-suggests": [ - "mysqli" - ] - }, - "swoole-hook-pgsql": { - "support": { - "Windows": "no", - "BSD": "wip", - "Darwin": "partial" - }, - "notes": true, - "type": "addon", - "arg-type": "custom", - "ext-depends": [ - "pgsql", - "pdo" - ] - }, - "swoole-hook-sqlite": { - "support": { - "Windows": "no", - "BSD": "wip" - }, - "notes": true, - "type": "addon", - "arg-type": "custom", - "ext-depends": [ - "sqlite3", - "pdo" - ] - }, - "swow": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "external", - "source": "swow", - "arg-type": "custom", - "lib-suggests": [ - "openssl", - "curl" - ], - "ext-suggests": [ - "openssl", - "curl" - ] - }, - "sysvmsg": { - "support": { - "Windows": "no", - "BSD": "wip" - }, - "type": "builtin", - "unix-only": true - }, - "sysvsem": { - "support": { - "Windows": "no", - "BSD": "wip" - }, - "type": "builtin", - "unix-only": true - }, - "sysvshm": { - "support": { - "BSD": "wip" - }, - "type": "builtin" - }, - "tidy": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "tidy" - ] - }, - "tokenizer": { - "type": "builtin" - }, - "uuid": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "ext-uuid", - "arg-type": "with-prefix", - "lib-depends": [ - "libuuid" - ] - }, - "uv": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "ext-uv", - "arg-type": "with-prefix", - "lib-depends": [ - "libuv" - ], - "ext-depends": [ - "sockets" - ] - }, - "xdebug": { - "type": "builtin", - "support": { - "Windows": "wip", - "BSD": "no", - "Darwin": "no", - "Linux": "no" - }, - "notes": true - }, - "xhprof": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "notes": true, - "type": "external", - "source": "xhprof", - "ext-depends": [ - "ctype" - ] - }, - "xlswriter": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "xlswriter", - "arg-type": "custom", - "ext-depends": [ - "zlib", - "zip" - ], - "lib-suggests": [ - "openssl" - ] - }, - "xml": { - "support": { - "BSD": "wip" - }, - "notes": true, - "type": "builtin", - "arg-type": "custom", - "arg-type-windows": "with", - "lib-depends": [ - "libxml2" - ], - "ext-depends-windows": [ - "iconv" - ] - }, - "xmlreader": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "custom", - "lib-depends": [ - "libxml2" - ], - "ext-depends-windows": [ - "xml", - "dom" - ] - }, - "xmlwriter": { - "support": { - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "custom", - "lib-depends": [ - "libxml2" - ], - "ext-depends-windows": [ - "xml" - ] - }, - "xsl": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "lib-depends": [ - "libxslt" - ], - "ext-depends": [ - "xml", - "dom" - ] - }, - "yac": { - "support": { - "BSD": "wip" - }, - "type": "external", - "source": "yac", - "arg-type-unix": "custom", - "ext-depends-unix": [ - "igbinary" - ] - }, - "yaml": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "yaml", - "arg-type": "with-prefix", - "lib-depends": [ - "libyaml" - ] - }, - "zip": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "builtin", - "arg-type": "with-prefix", - "arg-type-windows": "enable", - "lib-depends": [ - "libzip" - ] - }, - "zlib": { - "type": "builtin", - "arg-type": "custom", - "arg-type-windows": "enable", - "lib-depends": [ - "zlib" - ] - }, - "zstd": { - "support": { - "Windows": "wip", - "BSD": "wip" - }, - "type": "external", - "source": "ext-zstd", - "arg-type": "custom", - "lib-depends": [ - "zstd" - ] - } -} +{ + "amqp": { + "support": { + "BSD": "wip" + }, + "type": "external", + "arg-type": "custom", + "source": "amqp", + "lib-depends": [ + "librabbitmq" + ], + "ext-depends-windows": [ + "openssl" + ] + }, + "apcu": { + "type": "external", + "source": "apcu" + }, + "bcmath": { + "type": "builtin" + }, + "bz2": { + "support": { + "Windows": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "bzip2" + ] + }, + "calendar": { + "type": "builtin" + }, + "ctype": { + "type": "builtin" + }, + "curl": { + "notes": true, + "type": "builtin", + "arg-type": "with", + "lib-depends": [ + "curl" + ], + "ext-depends-windows": [ + "zlib", + "openssl" + ] + }, + "dba": { + "type": "builtin", + "arg-type": "custom", + "lib-suggests": [ + "qdbm" + ] + }, + "dom": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "custom", + "arg-type-windows": "with", + "lib-depends": [ + "libxml2", + "zlib" + ], + "ext-depends-windows": [ + "xml" + ] + }, + "ds": { + "type": "external", + "source": "ext-ds" + }, + "enchant": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Darwin": "wip", + "Linux": "wip" + }, + "type": "wip" + }, + "event": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, + "type": "external", + "source": "ext-event", + "arg-type": "custom", + "lib-depends": [ + "libevent" + ], + "ext-depends": [ + "openssl" + ], + "ext-suggests": [ + "sockets" + ] + }, + "exif": { + "type": "builtin" + }, + "ffi": { + "support": { + "Linux": "no", + "BSD": "wip" + }, + "notes": true, + "arg-type": "custom", + "type": "builtin", + "lib-depends-unix": [ + "libffi" + ], + "lib-depends-windows": [ + "libffi-win" + ] + }, + "fileinfo": { + "type": "builtin" + }, + "filter": { + "type": "builtin" + }, + "ftp": { + "type": "builtin", + "lib-suggests": [ + "openssl" + ] + }, + "gd": { + "support": { + "BSD": "wip" + }, + "notes": true, + "type": "builtin", + "arg-type": "custom", + "arg-type-windows": "with", + "lib-depends": [ + "zlib", + "libpng" + ], + "ext-depends": [ + "zlib" + ], + "lib-suggests": [ + "libavif", + "libwebp", + "libjpeg", + "freetype" + ] + }, + "gettext": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "gettext" + ] + }, + "glfw": { + "support": { + "Windows": "wip", + "BSD": "no", + "Linux": "no" + }, + "notes": true, + "type": "external", + "arg-type": "custom", + "source": "ext-glfw", + "lib-depends": [ + "glfw" + ], + "lib-depends-windows": [] + }, + "gmp": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "gmp" + ] + }, + "iconv": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "arg-type-windows": "with", + "lib-depends-unix": [ + "libiconv" + ], + "lib-depends-windows": [ + "libiconv-win" + ] + }, + "igbinary": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "igbinary" + }, + "imagick": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "ext-imagick", + "arg-type": "custom", + "lib-depends": [ + "imagemagick" + ] + }, + "imap": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, + "type": "builtin", + "arg-type": "custom", + "lib-depends": [ + "imap" + ], + "ext-suggests": [ + "openssl" + ] + }, + "inotify": { + "support": { + "Windows": "no", + "BSD": "wip", + "Darwin": "no" + }, + "type": "external", + "source": "inotify" + }, + "intl": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "type": "builtin", + "lib-depends": [ + "icu" + ] + }, + "ldap": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "ldap" + ], + "lib-suggests": [ + "gmp", + "libsodium" + ], + "ext-suggests": [ + "openssl" + ] + }, + "libxml": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "none", + "ext-depends": [ + "xml" + ] + }, + "mbregex": { + "type": "builtin", + "arg-type": "custom", + "ext-depends": [ + "mbstring" + ], + "lib-depends": [ + "onig" + ] + }, + "mbstring": { + "type": "builtin", + "arg-type": "custom" + }, + "mcrypt": { + "type": "wip", + "support": { + "Windows": "no", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, + "memcache": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "ext-memcache", + "arg-type": "custom", + "lib-depends": [ + "zlib" + ], + "ext-depends": [ + "session" + ] + }, + "memcached": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Linux": "no" + }, + "type": "external", + "source": "memcached", + "arg-type": "custom", + "cpp-extension": true, + "lib-depends": [ + "libmemcached" + ], + "ext-depends": [ + "session", + "zlib" + ] + }, + "mongodb": { + "support": { + "BSD": "wip", + "Windows": "wip" + }, + "type": "external", + "source": "mongodb", + "arg-type": "custom", + "lib-suggests": [ + "icu", + "openssl", + "zstd", + "zlib" + ] + }, + "mysqli": { + "type": "builtin", + "arg-type": "with", + "ext-depends": [ + "mysqlnd" + ] + }, + "mysqlnd": { + "type": "builtin", + "arg-type-windows": "with", + "lib-depends": [ + "zlib" + ] + }, + "oci8": { + "type": "wip", + "support": { + "Windows": "wip", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, + "opcache": { + "type": "builtin", + "arg-type": "custom" + }, + "openssl": { + "notes": true, + "type": "builtin", + "arg-type": "custom", + "arg-type-windows": "with", + "lib-depends": [ + "openssl", + "zlib" + ], + "ext-depends": [ + "zlib" + ] + }, + "parallel": { + "support": { + "BSD": "wip" + }, + "notes": true, + "type": "external", + "source": "parallel", + "arg-type-windows": "with", + "lib-depends-windows": [ + "pthreads4w" + ] + }, + "password-argon2": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "libargon2" + ] + }, + "pcntl": { + "support": { + "Windows": "no" + }, + "type": "builtin", + "unix-only": true + }, + "pdo": { + "type": "builtin" + }, + "pdo_mysql": { + "type": "builtin", + "arg-type": "with", + "ext-depends": [ + "pdo", + "mysqlnd" + ] + }, + "pdo_pgsql": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "ext-depends": [ + "pdo", + "pgsql" + ], + "lib-depends": [ + "postgresql" + ] + }, + "pdo_sqlite": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with", + "ext-depends": [ + "pdo", + "sqlite3" + ], + "lib-depends": [ + "sqlite" + ] + }, + "pdo_sqlsrv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "pdo_sqlsrv", + "arg-type": "with", + "ext-depends": [ + "pdo", + "sqlsrv" + ] + }, + "pgsql": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "postgresql" + ] + }, + "phar": { + "type": "builtin", + "ext-depends": [ + "zlib" + ] + }, + "posix": { + "support": { + "Windows": "no" + }, + "type": "builtin", + "unix-only": true + }, + "protobuf": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "protobuf" + }, + "rar": { + "support": { + "Windows": "wip", + "BSD": "wip", + "Darwin": "partial" + }, + "notes": true, + "type": "external", + "source": "rar", + "cpp-extension": true + }, + "readline": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "readline" + ] + }, + "redis": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "redis", + "arg-type": "custom", + "ext-suggests": [ + "session", + "igbinary" + ], + "lib-suggests": [ + "zstd", + "liblz4" + ] + }, + "session": { + "type": "builtin" + }, + "shmop": { + "type": "builtin" + }, + "simdjson": { + "type": "external", + "source": "ext-simdjson", + "cpp-extension": true + }, + "simplexml": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "custom", + "lib-depends": [ + "libxml2" + ], + "ext-depends-windows": [ + "xml" + ] + }, + "snappy": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "ext-snappy", + "cpp-extension": true, + "arg-type": "custom", + "lib-depends": [ + "snappy" + ], + "ext-suggest": [ + "apcu" + ] + }, + "soap": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "custom", + "lib-depends": [ + "libxml2" + ], + "ext-depends-windows": [ + "xml" + ] + }, + "sockets": { + "type": "builtin" + }, + "sodium": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with", + "lib-depends": [ + "libsodium" + ] + }, + "sqlite3": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "arg-type-windows": "with", + "lib-depends": [ + "sqlite" + ] + }, + "sqlsrv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "sqlsrv", + "lib-depends": [ + "unixodbc" + ], + "ext-depends-linux": [ + "pcntl" + ], + "cpp-extension": true + }, + "ssh2": { + "support": { + "BSD": "wip" + }, + "type": "external", + "source": "ext-ssh2", + "arg-type": "with-prefix", + "arg-type-windows": "with", + "lib-depends": [ + "libssh2" + ], + "ext-depends-windows": [ + "openssl", + "zlib" + ] + }, + "swoole": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, + "type": "external", + "source": "swoole", + "arg-type": "custom", + "cpp-extension": true, + "unix-only": true, + "lib-depends": [ + "libcares", + "brotli", + "nghttp2", + "zlib" + ], + "ext-depends": [ + "openssl", + "curl" + ], + "ext-suggests": [ + "swoole-hook-pgsql", + "swoole-hook-mysql", + "swoole-hook-sqlite" + ] + }, + "swoole-hook-mysql": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, + "type": "addon", + "arg-type": "custom", + "ext-depends": [ + "mysqlnd", + "pdo", + "pdo_mysql" + ], + "ext-suggests": [ + "mysqli" + ] + }, + "swoole-hook-pgsql": { + "support": { + "Windows": "no", + "BSD": "wip", + "Darwin": "partial" + }, + "notes": true, + "type": "addon", + "arg-type": "custom", + "ext-depends": [ + "pgsql", + "pdo" + ] + }, + "swoole-hook-sqlite": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "notes": true, + "type": "addon", + "arg-type": "custom", + "ext-depends": [ + "sqlite3", + "pdo" + ] + }, + "swow": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, + "type": "external", + "source": "swow", + "arg-type": "custom", + "lib-suggests": [ + "openssl", + "curl" + ], + "ext-suggests": [ + "openssl", + "curl" + ] + }, + "sysvmsg": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "type": "builtin", + "unix-only": true + }, + "sysvsem": { + "support": { + "Windows": "no", + "BSD": "wip" + }, + "type": "builtin", + "unix-only": true + }, + "sysvshm": { + "support": { + "BSD": "wip" + }, + "type": "builtin" + }, + "tidy": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "tidy" + ] + }, + "tokenizer": { + "type": "builtin" + }, + "uuid": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "ext-uuid", + "arg-type": "with-prefix", + "lib-depends": [ + "libuuid" + ] + }, + "uv": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "ext-uv", + "arg-type": "with-prefix", + "lib-depends": [ + "libuv" + ], + "ext-depends": [ + "sockets" + ] + }, + "xdebug": { + "type": "builtin", + "support": { + "Windows": "wip", + "BSD": "no", + "Darwin": "no", + "Linux": "no" + }, + "notes": true + }, + "xhprof": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "notes": true, + "type": "external", + "source": "xhprof", + "ext-depends": [ + "ctype" + ] + }, + "xlswriter": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "xlswriter", + "arg-type": "custom", + "ext-depends": [ + "zlib", + "zip" + ], + "lib-suggests": [ + "openssl" + ] + }, + "xml": { + "support": { + "BSD": "wip" + }, + "notes": true, + "type": "builtin", + "arg-type": "custom", + "arg-type-windows": "with", + "lib-depends": [ + "libxml2" + ], + "ext-depends-windows": [ + "iconv" + ] + }, + "xmlreader": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "custom", + "lib-depends": [ + "libxml2" + ], + "ext-depends-windows": [ + "xml", + "dom" + ] + }, + "xmlwriter": { + "support": { + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "custom", + "lib-depends": [ + "libxml2" + ], + "ext-depends-windows": [ + "xml" + ] + }, + "xsl": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "libxslt" + ], + "ext-depends": [ + "xml", + "dom" + ] + }, + "yac": { + "support": { + "BSD": "wip" + }, + "type": "external", + "source": "yac", + "arg-type-unix": "custom", + "ext-depends-unix": [ + "igbinary" + ] + }, + "yaml": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "yaml", + "arg-type": "with-prefix", + "lib-depends": [ + "libyaml" + ] + }, + "zip": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "builtin", + "arg-type": "with-prefix", + "arg-type-windows": "enable", + "lib-depends": [ + "libzip" + ] + }, + "zlib": { + "type": "builtin", + "arg-type": "custom", + "arg-type-windows": "enable", + "lib-depends": [ + "zlib" + ] + }, + "zstd": { + "support": { + "Windows": "wip", + "BSD": "wip" + }, + "type": "external", + "source": "ext-zstd", + "arg-type": "custom", + "lib-depends": [ + "zstd" + ] + } +} diff --git a/config/lib.json b/config/lib.json index d2364a3a..d57ba0df 100644 --- a/config/lib.json +++ b/config/lib.json @@ -1,659 +1,678 @@ -{ - "brotli": { - "source": "brotli", - "static-libs-unix": [ - "libbrotlidec.a", - "libbrotlienc.a", - "libbrotlicommon.a" - ], - "static-libs-windows": [ - "brotlicommon.lib", - "brotlienc.lib", - "brotlidec.lib" - ], - "headers": [ - "brotli" - ] - }, - "bzip2": { - "source": "bzip2", - "static-libs-unix": [ - "libbz2.a" - ], - "static-libs-windows": [ - [ - "libbz2.lib", - "libbz2_a.lib" - ] - ], - "headers": [ - "bzlib.h" - ] - }, - "curl": { - "source": "curl", - "static-libs-unix": [ - "libcurl.a" - ], - "static-libs-windows": [ - "libcurl_a.lib" - ], - "headers": [ - "curl" - ], - "lib-depends-unix": [ - "openssl", - "zlib" - ], - "lib-depends-windows": [ - "openssl", - "zlib", - "libssh2", - "nghttp2" - ], - "lib-suggests-unix": [ - "libssh2", - "brotli", - "nghttp2", - "zstd" - ], - "lib-suggests-windows": [ - "brotli", - "zstd" - ], - "frameworks": [ - "CoreFoundation", - "CoreServices", - "SystemConfiguration" - ] - }, - "freetype": { - "source": "freetype", - "static-libs-unix": [ - "libfreetype.a" - ], - "headers-unix": [ - "freetype2/freetype/freetype.h", - "freetype2/ft2build.h" - ], - "lib-depends": [ - "zlib" - ], - "lib-suggests": [ - "libpng", - "bzip2", - "brotli" - ] - }, - "gettext": { - "source": "gettext", - "static-libs-unix": [ - "libintl.a" - ], - "lib-depends": [ - "libiconv" - ], - "lib-suggests": [ - "ncurses", - "libxml2" - ], - "frameworks": [ - "CoreFoundation" - ] - }, - "glfw": { - "source": "ext-glfw", - "static-libs-unix": [ - "libglfw3.a" - ], - "frameworks": [ - "CoreVideo", - "OpenGL", - "Cocoa", - "IOKit" - ] - }, - "gmp": { - "source": "gmp", - "static-libs-unix": [ - "libgmp.a" - ], - "static-libs-windows": [ - "libgmp.lib" - ], - "headers": [ - "gmp.h" - ] - }, - "icu": { - "source": "icu", - "cpp-library": true, - "static-libs-unix": [ - "libicui18n.a", - "libicuio.a", - "libicuuc.a", - "libicudata.a" - ] - }, - "imagemagick": { - "source": "imagemagick", - "static-libs-unix": [ - "libMagick++-7.Q16HDRI.a", - "libMagickWand-7.Q16HDRI.a", - "libMagickCore-7.Q16HDRI.a" - ], - "lib-depends": [ - "zlib", - "libpng", - "libjpeg", - "libwebp", - "freetype", - "libtiff" - ], - "lib-suggests": [ - "zstd", - "xz", - "bzip2", - "libzip", - "libxml2" - ] - }, - "imap": { - "source": "imap", - "static-libs-unix": [ - "libc-client.a" - ], - "lib-suggests": [ - "openssl" - ] - }, - "ldap": { - "source": "ldap", - "static-libs-unix": [ - "liblber.a", - "libldap.a" - ], - "lib-depends": [ - "openssl", - "zlib", - "gmp", - "libsodium" - ] - }, - "libargon2": { - "source": "libargon2", - "static-libs-unix": [ - "libargon2.a" - ] - }, - "libavif": { - "source": "libavif", - "static-libs-unix": [ - "libavif.a" - ] - }, - "libcares": { - "source": "libcares", - "static-libs-unix": [ - "libcares.a" - ], - "headers-unix": [ - "ares.h", - "ares_dns.h", - "ares_nameser.h", - "ares_rules.h" - ] - }, - "libevent": { - "source": "libevent", - "static-libs-unix": [ - "libevent.a", - "libevent_core.a", - "libevent_extra.a", - "libevent_openssl.a" - ], - "lib-depends": [ - "openssl" - ] - }, - "libffi": { - "source": "libffi", - "static-libs-unix": [ - "libffi.a" - ], - "static-libs-windows": [ - "libffi.lib" - ], - "headers-unix": [ - "ffi.h", - "ffitarget.h" - ], - "headers-windows": [ - "ffi.h", - "fficonfig.h", - "ffitarget.h" - ] - }, - "libffi-win": { - "source": "libffi-win", - "static-libs-windows": [ - "libffi.lib" - ], - "headers-windows": [ - "ffi.h", - "ffitarget.h", - "fficonfig.h" - ] - }, - "libiconv": { - "source": "libiconv", - "static-libs-unix": [ - "libiconv.a", - "libcharset.a" - ], - "headers": [ - "iconv.h", - "libcharset.h", - "localcharset.h" - ] - }, - "libiconv-win": { - "source": "libiconv-win", - "static-libs-windows": [ - "libiconv.lib", - "libiconv_a.lib" - ] - }, - "libjpeg": { - "source": "libjpeg", - "static-libs-unix": [ - "libjpeg.a", - "libturbojpeg.a" - ] - }, - "liblz4": { - "source": "liblz4", - "static-libs-unix": [ - "liblz4.a" - ] - }, - "libmemcached": { - "source": "libmemcached", - "static-libs-unix": [ - "libmemcached.a", - "libmemcachedutil.a" - ] - }, - "libpng": { - "source": "libpng", - "static-libs-unix": [ - "libpng16.a" - ], - "static-libs-windows": [ - "libpng16_static.lib" - ], - "headers-unix": [ - "png.h", - "pngconf.h", - "pnglibconf.h" - ], - "headers-windows": [ - "png.h", - "pngconf.h" - ], - "lib-depends": [ - "zlib" - ] - }, - "librabbitmq": { - "source": "librabbitmq", - "static-libs-unix": [ - "librabbitmq.a" - ], - "static-libs-windows": [ - "rabbitmq.4.lib" - ], - "lib-depends": [ - "openssl" - ] - }, - "libsodium": { - "source": "libsodium", - "static-libs-unix": [ - "libsodium.a" - ] - }, - "libssh2": { - "source": "libssh2", - "static-libs-unix": [ - "libssh2.a" - ], - "static-libs-windows": [ - "libssh2.lib" - ], - "headers": [ - "libssh2.h", - "libssh2_publickey.h", - "libssh2_sftp.h" - ], - "lib-depends": [ - "openssl" - ], - "lib-suggests": [ - "zlib" - ] - }, - "libtiff": { - "source": "libtiff", - "static-libs-unix": [ - "libtiff.a" - ] - }, - "libuuid": { - "source": "libuuid", - "static-libs-unix": [ - "libuuid.a" - ], - "headers": [ - "uuid/uuid.h" - ] - }, - "libuv": { - "source": "libuv", - "static-libs-unix": [ - "libuv.a" - ] - }, - "libwebp": { - "source": "libwebp", - "static-libs-unix": [ - "libwebp.a", - "libwebpdecoder.a", - "libwebpdemux.a", - "libwebpmux.a", - "libsharpyuv.a" - ] - }, - "libxml2": { - "source": "libxml2", - "static-libs-unix": [ - "libxml2.a" - ], - "static-libs-windows": [ - "libxml2s.lib", - "libxml2_a.lib" - ], - "headers": [ - "libxml2" - ], - "lib-depends-unix": [ - "libiconv" - ], - "lib-suggests-unix": [ - "xz", - "icu", - "zlib" - ], - "lib-depends-windows": [ - "libiconv-win" - ], - "lib-suggests-windows": [ - "zlib" - ] - }, - "libxslt": { - "source": "libxslt", - "static-libs-unix": [ - "libxslt.a", - "libexslt.a" - ], - "lib-depends": [ - "libxml2" - ] - }, - "libyaml": { - "source": "libyaml", - "static-libs-unix": [ - "libyaml.a" - ], - "static-libs-windows": [ - "yaml.lib" - ], - "headers": [ - "yaml.h" - ] - }, - "libzip": { - "source": "libzip", - "static-libs-unix": [ - "libzip.a" - ], - "static-libs-windows": [ - [ - "zip.lib", - "libzip_a.lib" - ] - ], - "headers": [ - "zip.h", - "zipconf.h" - ], - "lib-depends": [ - "zlib" - ], - "lib-suggests": [ - "bzip2", - "xz", - "zstd", - "openssl" - ] - }, - "ncurses": { - "source": "ncurses", - "static-libs-unix": [ - "libncurses.a" - ] - }, - "nghttp2": { - "source": "nghttp2", - "static-libs-unix": [ - "libnghttp2.a" - ], - "static-libs-windows": [ - "nghttp2.lib" - ], - "headers": [ - "nghttp2" - ], - "lib-depends": [ - "zlib", - "openssl" - ], - "lib-suggests": [ - "libxml2" - ] - }, - "onig": { - "source": "onig", - "static-libs-unix": [ - "libonig.a" - ], - "static-libs-windows": [ - "onig.lib", - "onig_a.lib" - ], - "headers": [ - "oniggnu.h", - "oniguruma.h" - ] - }, - "openssl": { - "source": "openssl", - "static-libs-unix": [ - "libssl.a", - "libcrypto.a" - ], - "static-libs-windows": [ - "libssl.lib", - "libcrypto.lib" - ], - "headers": [ - "openssl" - ], - "lib-depends": [ - "zlib" - ] - }, - "pkg-config": { - "source": "pkg-config" - }, - "postgresql": { - "source": "postgresql", - "static-libs-unix": [ - "libpq.a", - "libpgport.a", - "libpgcommon.a" - ], - "lib-depends": [ - "libiconv", - "libxml2", - "openssl", - "zlib", - "readline" - ], - "lib-suggests": [ - "icu", - "libxslt", - "ldap", - "zstd" - ] - }, - "pthreads4w": { - "source": "pthreads4w", - "static-libs-windows": [ - "libpthreadVC3.lib" - ] - }, - "qdbm": { - "source": "qdbm", - "static-libs-unix": [ - "libqdbm.a" - ], - "static-libs-windows": [ - "qdbm_a.lib" - ], - "headers-windows": [ - "depot.h" - ] - }, - "readline": { - "source": "readline", - "static-libs-unix": [ - "libreadline.a" - ], - "lib-depends": [ - "ncurses" - ] - }, - "snappy": { - "source": "snappy", - "static-libs-unix": [ - "libsnappy.a" - ], - "headers-unix": [ - "snappy.h", - "snappy-c.h", - "snappy-sinksource.h", - "snappy-stubs-public.h" - ], - "lib-depends": [ - "zlib" - ] - }, - "sqlite": { - "source": "sqlite", - "static-libs-unix": [ - "libsqlite3.a" - ], - "static-libs-windows": [ - "libsqlite3_a.lib" - ], - "headers": [ - "sqlite3.h", - "sqlite3ext.h" - ] - }, - "tidy": { - "source": "tidy", - "static-libs-unix": [ - "libtidy.a" - ] - }, - "unixodbc": { - "source": "unixodbc", - "static-libs-unix": [ - "libodbc.a", - "libodbccr.a", - "libodbcinst.a" - ], - "lib-depends": [ - "libiconv" - ] - }, - "xz": { - "source": "xz", - "static-libs-unix": [ - "liblzma.a" - ], - "static-libs-windows": [ - [ - "liblzma.lib", - "liblzma_a.lib" - ] - ], - "headers-unix": [ - "lzma" - ], - "headers-windows": [ - "lzma", - "lzma.h" - ], - "lib-depends": [ - "libiconv" - ] - }, - "zlib": { - "source": "zlib", - "static-libs-unix": [ - "libz.a" - ], - "static-libs-windows": [ - "zlib_a.lib" - ], - "headers": [ - "zlib.h", - "zconf.h" - ] - }, - "zstd": { - "source": "zstd", - "static-libs-unix": [ - "libzstd.a" - ], - "static-libs-windows": [ - [ - "zstd.lib", - "zstd_static.lib" - ] - ], - "headers-unix": [ - "zdict.h", - "zstd.h", - "zstd_errors.h" - ], - "headers-windows": [ - "zstd.h", - "zstd_errors.h" - ] - } -} +{ + "brotli": { + "source": "brotli", + "static-libs-unix": [ + "libbrotlidec.a", + "libbrotlienc.a", + "libbrotlicommon.a" + ], + "static-libs-windows": [ + "brotlicommon.lib", + "brotlienc.lib", + "brotlidec.lib" + ], + "headers": [ + "brotli" + ] + }, + "bzip2": { + "source": "bzip2", + "static-libs-unix": [ + "libbz2.a" + ], + "static-libs-windows": [ + [ + "libbz2.lib", + "libbz2_a.lib" + ] + ], + "headers": [ + "bzlib.h" + ] + }, + "curl": { + "source": "curl", + "static-libs-unix": [ + "libcurl.a" + ], + "static-libs-windows": [ + "libcurl_a.lib" + ], + "headers": [ + "curl" + ], + "lib-depends-unix": [ + "openssl", + "zlib" + ], + "lib-depends-windows": [ + "openssl", + "zlib", + "libssh2", + "nghttp2" + ], + "lib-suggests-unix": [ + "libssh2", + "brotli", + "nghttp2", + "zstd" + ], + "lib-suggests-windows": [ + "brotli", + "zstd" + ], + "frameworks": [ + "CoreFoundation", + "CoreServices", + "SystemConfiguration" + ] + }, + "freetype": { + "source": "freetype", + "static-libs-unix": [ + "libfreetype.a" + ], + "static-libs-windows": [ + "libfreetype_a.lib" + ], + "headers-unix": [ + "freetype2/freetype/freetype.h", + "freetype2/ft2build.h" + ], + "lib-depends": [ + "zlib" + ], + "lib-suggests": [ + "libpng", + "bzip2", + "brotli" + ] + }, + "gettext": { + "source": "gettext", + "static-libs-unix": [ + "libintl.a" + ], + "lib-depends": [ + "libiconv" + ], + "lib-suggests": [ + "ncurses", + "libxml2" + ], + "frameworks": [ + "CoreFoundation" + ] + }, + "glfw": { + "source": "ext-glfw", + "static-libs-unix": [ + "libglfw3.a" + ], + "frameworks": [ + "CoreVideo", + "OpenGL", + "Cocoa", + "IOKit" + ] + }, + "gmp": { + "source": "gmp", + "static-libs-unix": [ + "libgmp.a" + ], + "static-libs-windows": [ + "libgmp.lib" + ], + "headers": [ + "gmp.h" + ] + }, + "icu": { + "source": "icu", + "cpp-library": true, + "static-libs-unix": [ + "libicui18n.a", + "libicuio.a", + "libicuuc.a", + "libicudata.a" + ] + }, + "imagemagick": { + "source": "imagemagick", + "static-libs-unix": [ + "libMagick++-7.Q16HDRI.a", + "libMagickWand-7.Q16HDRI.a", + "libMagickCore-7.Q16HDRI.a" + ], + "lib-depends": [ + "zlib", + "libpng", + "libjpeg", + "libwebp", + "freetype", + "libtiff" + ], + "lib-suggests": [ + "zstd", + "xz", + "bzip2", + "libzip", + "libxml2" + ] + }, + "imap": { + "source": "imap", + "static-libs-unix": [ + "libc-client.a" + ], + "lib-suggests": [ + "openssl" + ] + }, + "ldap": { + "source": "ldap", + "static-libs-unix": [ + "liblber.a", + "libldap.a" + ], + "lib-depends": [ + "openssl", + "zlib", + "gmp", + "libsodium" + ] + }, + "libargon2": { + "source": "libargon2", + "static-libs-unix": [ + "libargon2.a" + ] + }, + "libavif": { + "source": "libavif", + "static-libs-unix": [ + "libavif.a" + ], + "static-libs-windows": [ + "avif.lib" + ] + }, + "libcares": { + "source": "libcares", + "static-libs-unix": [ + "libcares.a" + ], + "headers-unix": [ + "ares.h", + "ares_dns.h", + "ares_nameser.h", + "ares_rules.h" + ] + }, + "libevent": { + "source": "libevent", + "static-libs-unix": [ + "libevent.a", + "libevent_core.a", + "libevent_extra.a", + "libevent_openssl.a" + ], + "lib-depends": [ + "openssl" + ] + }, + "libffi": { + "source": "libffi", + "static-libs-unix": [ + "libffi.a" + ], + "static-libs-windows": [ + "libffi.lib" + ], + "headers-unix": [ + "ffi.h", + "ffitarget.h" + ], + "headers-windows": [ + "ffi.h", + "fficonfig.h", + "ffitarget.h" + ] + }, + "libffi-win": { + "source": "libffi-win", + "static-libs-windows": [ + "libffi.lib" + ], + "headers-windows": [ + "ffi.h", + "ffitarget.h", + "fficonfig.h" + ] + }, + "libiconv": { + "source": "libiconv", + "static-libs-unix": [ + "libiconv.a", + "libcharset.a" + ], + "headers": [ + "iconv.h", + "libcharset.h", + "localcharset.h" + ] + }, + "libiconv-win": { + "source": "libiconv-win", + "static-libs-windows": [ + "libiconv.lib", + "libiconv_a.lib" + ] + }, + "libjpeg": { + "source": "libjpeg", + "static-libs-unix": [ + "libjpeg.a", + "libturbojpeg.a" + ], + "static-libs-windows": [ + "libjpeg_a.lib" + ], + "lib-suggests-windows": [ + "zlib" + ] + }, + "liblz4": { + "source": "liblz4", + "static-libs-unix": [ + "liblz4.a" + ] + }, + "libmemcached": { + "source": "libmemcached", + "static-libs-unix": [ + "libmemcached.a", + "libmemcachedutil.a" + ] + }, + "libpng": { + "source": "libpng", + "static-libs-unix": [ + "libpng16.a" + ], + "static-libs-windows": [ + "libpng16_static.lib", + "libpng_a.lib" + ], + "headers-unix": [ + "png.h", + "pngconf.h", + "pnglibconf.h" + ], + "headers-windows": [ + "png.h", + "pngconf.h" + ], + "lib-depends": [ + "zlib" + ] + }, + "librabbitmq": { + "source": "librabbitmq", + "static-libs-unix": [ + "librabbitmq.a" + ], + "static-libs-windows": [ + "rabbitmq.4.lib" + ], + "lib-depends": [ + "openssl" + ] + }, + "libsodium": { + "source": "libsodium", + "static-libs-unix": [ + "libsodium.a" + ] + }, + "libssh2": { + "source": "libssh2", + "static-libs-unix": [ + "libssh2.a" + ], + "static-libs-windows": [ + "libssh2.lib" + ], + "headers": [ + "libssh2.h", + "libssh2_publickey.h", + "libssh2_sftp.h" + ], + "lib-depends": [ + "openssl" + ], + "lib-suggests": [ + "zlib" + ] + }, + "libtiff": { + "source": "libtiff", + "static-libs-unix": [ + "libtiff.a" + ] + }, + "libuuid": { + "source": "libuuid", + "static-libs-unix": [ + "libuuid.a" + ], + "headers": [ + "uuid/uuid.h" + ] + }, + "libuv": { + "source": "libuv", + "static-libs-unix": [ + "libuv.a" + ] + }, + "libwebp": { + "source": "libwebp", + "static-libs-unix": [ + "libwebp.a", + "libwebpdecoder.a", + "libwebpdemux.a", + "libwebpmux.a", + "libsharpyuv.a" + ], + "static-libs-windows": [ + "libwebp.lib", + "libwebpdecoder.lib", + "libwebpdemux.lib", + "libsharpyuv.lib" + ] + }, + "libxml2": { + "source": "libxml2", + "static-libs-unix": [ + "libxml2.a" + ], + "static-libs-windows": [ + "libxml2s.lib", + "libxml2_a.lib" + ], + "headers": [ + "libxml2" + ], + "lib-depends-unix": [ + "libiconv" + ], + "lib-suggests-unix": [ + "xz", + "icu", + "zlib" + ], + "lib-depends-windows": [ + "libiconv-win" + ], + "lib-suggests-windows": [ + "zlib" + ] + }, + "libxslt": { + "source": "libxslt", + "static-libs-unix": [ + "libxslt.a", + "libexslt.a" + ], + "lib-depends": [ + "libxml2" + ] + }, + "libyaml": { + "source": "libyaml", + "static-libs-unix": [ + "libyaml.a" + ], + "static-libs-windows": [ + "yaml.lib" + ], + "headers": [ + "yaml.h" + ] + }, + "libzip": { + "source": "libzip", + "static-libs-unix": [ + "libzip.a" + ], + "static-libs-windows": [ + [ + "zip.lib", + "libzip_a.lib" + ] + ], + "headers": [ + "zip.h", + "zipconf.h" + ], + "lib-depends": [ + "zlib" + ], + "lib-suggests": [ + "bzip2", + "xz", + "zstd", + "openssl" + ] + }, + "ncurses": { + "source": "ncurses", + "static-libs-unix": [ + "libncurses.a" + ] + }, + "nghttp2": { + "source": "nghttp2", + "static-libs-unix": [ + "libnghttp2.a" + ], + "static-libs-windows": [ + "nghttp2.lib" + ], + "headers": [ + "nghttp2" + ], + "lib-depends": [ + "zlib", + "openssl" + ], + "lib-suggests": [ + "libxml2" + ] + }, + "onig": { + "source": "onig", + "static-libs-unix": [ + "libonig.a" + ], + "static-libs-windows": [ + "onig.lib", + "onig_a.lib" + ], + "headers": [ + "oniggnu.h", + "oniguruma.h" + ] + }, + "openssl": { + "source": "openssl", + "static-libs-unix": [ + "libssl.a", + "libcrypto.a" + ], + "static-libs-windows": [ + "libssl.lib", + "libcrypto.lib" + ], + "headers": [ + "openssl" + ], + "lib-depends": [ + "zlib" + ] + }, + "pkg-config": { + "source": "pkg-config" + }, + "postgresql": { + "source": "postgresql", + "static-libs-unix": [ + "libpq.a", + "libpgport.a", + "libpgcommon.a" + ], + "lib-depends": [ + "libiconv", + "libxml2", + "openssl", + "zlib", + "readline" + ], + "lib-suggests": [ + "icu", + "libxslt", + "ldap", + "zstd" + ] + }, + "pthreads4w": { + "source": "pthreads4w", + "static-libs-windows": [ + "libpthreadVC3.lib" + ] + }, + "qdbm": { + "source": "qdbm", + "static-libs-unix": [ + "libqdbm.a" + ], + "static-libs-windows": [ + "qdbm_a.lib" + ], + "headers-windows": [ + "depot.h" + ] + }, + "readline": { + "source": "readline", + "static-libs-unix": [ + "libreadline.a" + ], + "lib-depends": [ + "ncurses" + ] + }, + "snappy": { + "source": "snappy", + "static-libs-unix": [ + "libsnappy.a" + ], + "headers-unix": [ + "snappy.h", + "snappy-c.h", + "snappy-sinksource.h", + "snappy-stubs-public.h" + ], + "lib-depends": [ + "zlib" + ] + }, + "sqlite": { + "source": "sqlite", + "static-libs-unix": [ + "libsqlite3.a" + ], + "static-libs-windows": [ + "libsqlite3_a.lib" + ], + "headers": [ + "sqlite3.h", + "sqlite3ext.h" + ] + }, + "tidy": { + "source": "tidy", + "static-libs-unix": [ + "libtidy.a" + ] + }, + "unixodbc": { + "source": "unixodbc", + "static-libs-unix": [ + "libodbc.a", + "libodbccr.a", + "libodbcinst.a" + ], + "lib-depends": [ + "libiconv" + ] + }, + "xz": { + "source": "xz", + "static-libs-unix": [ + "liblzma.a" + ], + "static-libs-windows": [ + [ + "liblzma.lib", + "liblzma_a.lib" + ] + ], + "headers-unix": [ + "lzma" + ], + "headers-windows": [ + "lzma", + "lzma.h" + ], + "lib-depends": [ + "libiconv" + ] + }, + "zlib": { + "source": "zlib", + "static-libs-unix": [ + "libz.a" + ], + "static-libs-windows": [ + "zlib_a.lib" + ], + "headers": [ + "zlib.h", + "zconf.h" + ] + }, + "zstd": { + "source": "zstd", + "static-libs-unix": [ + "libzstd.a" + ], + "static-libs-windows": [ + [ + "zstd.lib", + "zstd_static.lib" + ] + ], + "headers-unix": [ + "zdict.h", + "zstd.h", + "zstd_errors.h" + ], + "headers-windows": [ + "zstd.h", + "zstd_errors.h" + ] + } +} diff --git a/src/SPC/builder/windows/SystemUtil.php b/src/SPC/builder/windows/SystemUtil.php index 668e60b1..e1794f94 100644 --- a/src/SPC/builder/windows/SystemUtil.php +++ b/src/SPC/builder/windows/SystemUtil.php @@ -90,6 +90,7 @@ class SystemUtil $buildroot = str_replace('\\', '\\\\', BUILD_ROOT_PATH); $toolchain = <<source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + // freetype.lib to libfreetype_a.lib + copy(BUILD_LIB_PATH . '\freetype.lib', BUILD_LIB_PATH . '\libfreetype_a.lib'); + } +} diff --git a/src/SPC/builder/windows/library/libavif.php b/src/SPC/builder/windows/library/libavif.php new file mode 100644 index 00000000..0b839074 --- /dev/null +++ b/src/SPC/builder/windows/library/libavif.php @@ -0,0 +1,37 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DAVIF_BUILD_APPS=OFF ' . + '-DAVIF_BUILD_TESTS=OFF ' . + '-DAVID_ENABLE_GTEST=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/builder/windows/library/libjpeg.php b/src/SPC/builder/windows/library/libjpeg.php new file mode 100644 index 00000000..d7ac718c --- /dev/null +++ b/src/SPC/builder/windows/library/libjpeg.php @@ -0,0 +1,41 @@ +builder->getLib('zlib') ? 'ON' : 'OFF'; + // reset cmake + FileSystem::resetDir($this->source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DENABLE_SHARED=OFF ' . + '-DENABLE_STATIC=ON ' . + '-DBUILD_TESTING=OFF ' . + '-DWITH_JAVA=OFF ' . + '-DWITH_CRT_DLL=OFF ' . + "-DENABLE_ZLIB_COMPRESSION={$zlib} " . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + copy(BUILD_LIB_PATH . '\jpeg-static.lib', BUILD_LIB_PATH . '\libjpeg_a.lib'); + } +} diff --git a/src/SPC/builder/windows/library/libpng.php b/src/SPC/builder/windows/library/libpng.php new file mode 100644 index 00000000..a722fa79 --- /dev/null +++ b/src/SPC/builder/windows/library/libpng.php @@ -0,0 +1,40 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DSKIP_INSTALL_PROGRAM=ON ' . + '-DSKIP_INSTALL_FILES=ON ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DPNG_STATIC=ON ' . + '-DPNG_SHARED=OFF ' . + '-DPNG_TESTS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + copy(BUILD_LIB_PATH . '\libpng16_static.lib', BUILD_LIB_PATH . '\libpng_a.lib'); + } +} diff --git a/src/SPC/builder/windows/library/libwebp.php b/src/SPC/builder/windows/library/libwebp.php new file mode 100644 index 00000000..c09b76d6 --- /dev/null +++ b/src/SPC/builder/windows/library/libwebp.php @@ -0,0 +1,45 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DWEBP_LINK_STATIC=ON ' . + '-DWEBP_BUILD_ANIM_UTILS=OFF ' . + '-DWEBP_BUILD_CWEBP=OFF ' . + '-DWEBP_BUILD_DWEBP=OFF ' . + '-DWEBP_BUILD_GIF2WEBP=OFF ' . + '-DWEBP_BUILD_IMG2WEBP=OFF ' . + '-DWEBP_BUILD_VWEBP=OFF ' . + '-DWEBP_BUILD_WEBPINFO=OFF ' . + '-DWEBP_BUILD_LIBWEBPMUX=OFF ' . + '-DWEBP_BUILD_WEBPMUX=OFF ' . + '-DWEBP_BUILD_EXTRAS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 6750f899..96238619 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -19,6 +19,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('openssl', [SourcePatcher::class, 'patchOpenssl11Darwin']); FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']); FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchPhpLibxml212']); + FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchGDWin32']); } /** @@ -359,6 +360,23 @@ class SourcePatcher return false; } + public static function patchGDWin32(): bool + { + $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); + if (preg_match('/PHP_VERSION_ID (\d+)/', $file, $match) !== 0) { + $ver_id = intval($match[1]); + if ($ver_id < 80200) { + // see: https://github.com/php/php-src/commit/243966177e39eb71822935042c3f13fa6c5b9eed + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gd/libgd/gdft.c', '#ifndef MSWIN32', '#ifndef _WIN32'); + } + // custom config.w32, because official config.w32 is hard-coded many things + $origin = $ver_id >= 80100 ? file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32') : file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32'); + file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32.bak', file_get_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32')); + return file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32', $origin) !== false; + } + return false; + } + /** * Add additional `static-php-cli.version` ini value for PHP source. * diff --git a/src/globals/extra/gd_config_80.w32 b/src/globals/extra/gd_config_80.w32 new file mode 100644 index 00000000..ea7582b8 --- /dev/null +++ b/src/globals/extra/gd_config_80.w32 @@ -0,0 +1,86 @@ +// vim:ft=javascript + +ARG_WITH("gd", "Bundled GD support", "yes"); + +if (PHP_GD != "no") { + // check for gd.h (required) + if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) { + ERROR("gd not enabled; libraries and headers not found"); + } + + // zlib ext support (required) + if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) { + ERROR("gd not enabled; zlib not enabled"); + } + + // libjpeg lib support + if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) { + AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support"); + AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support"); + } + + // libpng16 lib support + if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) { + AC_DEFINE("HAVE_LIBPNG", 1, "PNG support"); + AC_DEFINE("HAVE_GD_PNG", 1, "PNG support"); + } + + // freetype lib support + if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) { + AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support"); + AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support"); + } + + // xpm lib support + if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) { + AC_DEFINE("HAVE_LIBXPM", 1, "XPM support"); + AC_DEFINE("HAVE_GD_XPM", 1, "XPM support"); + } + + // iconv lib support + if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) && + CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) { + AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support"); + } + + // libwebp lib support + if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) && + CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") && + CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) { + AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support"); + AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support"); + } + + // libavif lib is not supported on php <= 8.0 + + CHECK_LIB("User32.lib", "gd", PHP_GD); + CHECK_LIB("Gdi32.lib", "gd", PHP_GD); + + EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd"); + ADD_SOURCES("ext/gd/libgd", "gd.c \ + gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \ + gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \ + gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \ + gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \ + gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c \ + gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd"); + + AC_DEFINE('HAVE_LIBGD', 1, 'GD support'); + AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD"); + AC_DEFINE('HAVE_GD_BMP', 1, "BMP support"); + AC_DEFINE('HAVE_GD_TGA', 1, "TGA support"); + ADD_FLAG("CFLAGS_GD", " \ +/D PHP_GD_EXPORTS=1 \ +/D HAVE_GD_GET_INTERPOLATION \ + "); + if (ICC_TOOLSET) { + ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt"); + } + + PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd"); +} diff --git a/src/globals/extra/gd_config_81.w32 b/src/globals/extra/gd_config_81.w32 new file mode 100644 index 00000000..528de319 --- /dev/null +++ b/src/globals/extra/gd_config_81.w32 @@ -0,0 +1,94 @@ +// vim:ft=javascript + +ARG_WITH("gd", "Bundled GD support", "yes"); + +if (PHP_GD != "no") { + // check for gd.h (required) + if (!CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd")) { + ERROR("gd not enabled; libraries and headers not found"); + } + + // zlib ext support (required) + if (!CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD)) { + ERROR("gd not enabled; zlib not enabled"); + } + + // libjpeg lib support + if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("jpeglib.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include")) { + AC_DEFINE("HAVE_LIBJPEG", 1, "JPEG support"); + AC_DEFINE("HAVE_GD_JPG", 1, "JPEG support"); + } + + // libpng16 lib support + if (CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng16")) { + AC_DEFINE("HAVE_LIBPNG", 1, "PNG support"); + AC_DEFINE("HAVE_GD_PNG", 1, "PNG support"); + } + + // freetype lib support + if (CHECK_LIB("libfreetype_a.lib;libfreetype.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("ft2build.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\freetype2;" + PHP_PHP_BUILD + "\\include\\freetype")) { + AC_DEFINE("HAVE_LIBFREETYPE", 1, "FreeType support"); + AC_DEFINE("HAVE_GD_FREETYPE", 1, "FreeType support"); + } + + // xpm lib support + if (CHECK_LIB("libXpm_a.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("xpm.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\X11")) { + AC_DEFINE("HAVE_LIBXPM", 1, "XPM support"); + AC_DEFINE("HAVE_GD_XPM", 1, "XPM support"); + } + + // iconv lib support + if ((CHECK_LIB("libiconv_a.lib;libiconv.lib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) && + CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD)) { + AC_DEFINE("HAVE_LIBICONV", 1, "Iconv support"); + } + + // libwebp lib support + if ((CHECK_LIB("libwebp_a.lib", "gd", PHP_GD) || CHECK_LIB("libwebp.lib", "gd", PHP_GD)) && + CHECK_LIB("libsharpyuv.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("decode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp") && + CHECK_HEADER_ADD_INCLUDE("encode.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\webp")) { + AC_DEFINE("HAVE_LIBWEBP", 1, "WebP support"); + AC_DEFINE("HAVE_GD_WEBP", 1, "WebP support"); + } + + // libavif lib support + if (CHECK_LIB("avif_a.lib", "gd", PHP_GD) && + CHECK_LIB("aom_a.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) { + ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF"); + } else if (CHECK_LIB("avif.lib", "gd", PHP_GD) && + CHECK_HEADER_ADD_INCLUDE("avif.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\avif")) { + ADD_FLAG("CFLAGS_GD", "/D HAVE_LIBAVIF /D HAVE_GD_AVIF"); + } + + CHECK_LIB("User32.lib", "gd", PHP_GD); + CHECK_LIB("Gdi32.lib", "gd", PHP_GD); + + EXTENSION("gd", "gd.c", null, "-Iext/gd/libgd"); + ADD_SOURCES("ext/gd/libgd", "gd.c \ + gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \ + gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \ + gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \ + gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \ + gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \ + gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd"); + + AC_DEFINE('HAVE_LIBGD', 1, 'GD support'); + AC_DEFINE('HAVE_GD_BUNDLED', 1, "Bundled GD"); + AC_DEFINE('HAVE_GD_BMP', 1, "BMP support"); + AC_DEFINE('HAVE_GD_TGA', 1, "TGA support"); + ADD_FLAG("CFLAGS_GD", " \ +/D PHP_GD_EXPORTS=1 \ +/D HAVE_GD_GET_INTERPOLATION \ + "); + if (ICC_TOOLSET) { + ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt"); + } + + PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd"); +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 69260524..d49365ba 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,14 +19,14 @@ $upx = true; // 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,gmp', - 'Windows' => 'mbstring,pdo_sqlite,mbregex', + 'Linux', 'Darwin' => 'sockets', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,gd', }; // 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' => 'libtiff', - 'Windows' => '', + 'Linux', 'Darwin' => '', + 'Windows' => 'libjpeg,libwebp,libavif,freetype', }; // Please change your test base combination. We recommend testing with `common`. From 0857a19c3c61443a3dd1b45e85cd94a8ad5a1262 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Fri, 28 Jun 2024 12:14:36 +0800 Subject: [PATCH 313/415] Increase memory_limit size (#485) --- src/SPC/builder/BuilderProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/BuilderProvider.php b/src/SPC/builder/BuilderProvider.php index fd52a217..18636952 100644 --- a/src/SPC/builder/BuilderProvider.php +++ b/src/SPC/builder/BuilderProvider.php @@ -27,7 +27,7 @@ class BuilderProvider */ public static function makeBuilderByInput(InputInterface $input): BuilderBase { - ini_set('memory_limit', '2G'); + ini_set('memory_limit', '4G'); self::$builder = match (PHP_OS_FAMILY) { 'Windows' => new WindowsBuilder($input->getOptions()), From c22488ec575bb874f7bb053a7e845ce2095250c4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 00:08:11 +0800 Subject: [PATCH 314/415] Add pcre as internal extension --- src/globals/defines.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/globals/defines.php b/src/globals/defines.php index b1868756..bcd59a16 100644 --- a/src/globals/defines.php +++ b/src/globals/defines.php @@ -43,6 +43,7 @@ const SPC_INTERNAL_EXTENSIONS = [ 'core', 'hash', 'json', + 'pcre', 'reflection', 'spl', 'standard', From a6236eb98c3f82610c001ab07d4d1cdbdbd9abe5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 00:08:20 +0800 Subject: [PATCH 315/415] Bump version --- 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 4b50e6f2..1131ef12 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -25,7 +25,7 @@ use Symfony\Component\Console\Application; */ final class ConsoleApplication extends Application { - public const VERSION = '2.2.4'; + public const VERSION = '2.3.0'; public function __construct() { From 310091180270218af54e684be3bfb0ba9bedd920 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 00:12:39 +0800 Subject: [PATCH 316/415] Add several extensions and libs for windows exts: bz2, sqlsrv, pdo_sqlsrv, yaml, zip, rar libs: bzip2, libyaml, libzip, xz --- config/ext.json | 27 +++++---- config/lib.json | 33 ++++++----- src/SPC/builder/extension/sqlsrv.php | 36 ++++++++++++ src/SPC/builder/windows/library/bzip2.php | 21 +++++++ src/SPC/builder/windows/library/libyaml.php | 44 +++++++++++++++ src/SPC/builder/windows/library/libzip.php | 46 +++++++++++++++ src/SPC/builder/windows/library/xz.php | 39 +++++++++++++ src/SPC/store/FileSystem.php | 2 +- src/SPC/store/SourcePatcher.php | 56 +++++++++++++++++-- src/globals/extra/libyaml_YamlConfig.cmake.in | 10 ++++ src/globals/extra/libyaml_config.h.in | 4 ++ 11 files changed, 286 insertions(+), 32 deletions(-) create mode 100644 src/SPC/builder/extension/sqlsrv.php create mode 100644 src/SPC/builder/windows/library/bzip2.php create mode 100644 src/SPC/builder/windows/library/libyaml.php create mode 100644 src/SPC/builder/windows/library/libzip.php create mode 100644 src/SPC/builder/windows/library/xz.php create mode 100644 src/globals/extra/libyaml_YamlConfig.cmake.in create mode 100644 src/globals/extra/libyaml_config.h.in diff --git a/config/ext.json b/config/ext.json index a3ec8041..9e0c3f3e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -21,11 +21,9 @@ "type": "builtin" }, "bz2": { - "support": { - "Windows": "wip" - }, "type": "builtin", - "arg-type": "with-prefix", + "arg-type-unix": "with-prefix", + "arg-type-windows": "with", "lib-depends": [ "bzip2" ] @@ -473,7 +471,6 @@ }, "pdo_sqlsrv": { "support": { - "Windows": "wip", "BSD": "wip" }, "type": "external", @@ -519,7 +516,6 @@ }, "rar": { "support": { - "Windows": "wip", "BSD": "wip", "Darwin": "partial" }, @@ -636,12 +632,11 @@ }, "sqlsrv": { "support": { - "Windows": "wip", "BSD": "wip" }, "type": "external", "source": "sqlsrv", - "lib-depends": [ + "lib-depends-unix": [ "unixodbc" ], "ext-depends-linux": [ @@ -925,12 +920,12 @@ }, "yaml": { "support": { - "Windows": "wip", "BSD": "wip" }, "type": "external", "source": "yaml", - "arg-type": "with-prefix", + "arg-type-unix": "with-prefix", + "arg-type-windows": "with", "lib-depends": [ "libyaml" ] @@ -943,8 +938,18 @@ "type": "builtin", "arg-type": "with-prefix", "arg-type-windows": "enable", - "lib-depends": [ + "lib-depends-unix": [ "libzip" + ], + "ext-depends-windows": [ + "zlib", + "bz2" + ], + "lib-depends-windows": [ + "libzip", + "zlib", + "bzip2", + "xz" ] }, "zlib": { diff --git a/config/lib.json b/config/lib.json index d57ba0df..faaef865 100644 --- a/config/lib.json +++ b/config/lib.json @@ -21,10 +21,8 @@ "libbz2.a" ], "static-libs-windows": [ - [ - "libbz2.lib", - "libbz2_a.lib" - ] + "libbz2.lib", + "libbz2_a.lib" ], "headers": [ "bzlib.h" @@ -448,23 +446,30 @@ "libzip.a" ], "static-libs-windows": [ - [ - "zip.lib", - "libzip_a.lib" - ] + "zip.lib", + "libzip_a.lib" ], "headers": [ "zip.h", "zipconf.h" ], - "lib-depends": [ + "lib-depends-unix": [ "zlib" ], - "lib-suggests": [ + "lib-suggests-unix": [ "bzip2", "xz", "zstd", "openssl" + ], + "lib-depends-windows": [ + "zlib", + "bzip2", + "xz" + ], + "lib-suggests-windows": [ + "zstd", + "openssl" ] }, "ncurses": { @@ -625,10 +630,8 @@ "liblzma.a" ], "static-libs-windows": [ - [ - "liblzma.lib", - "liblzma_a.lib" - ] + "liblzma.lib", + "liblzma_a.lib" ], "headers-unix": [ "lzma" @@ -637,7 +640,7 @@ "lzma", "lzma.h" ], - "lib-depends": [ + "lib-depends-unix": [ "libiconv" ] }, diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php new file mode 100644 index 00000000..edf5d919 --- /dev/null +++ b/src/SPC/builder/extension/sqlsrv.php @@ -0,0 +1,36 @@ +builder->getExt('pdo_sqlsrv') === null) { + // support sqlsrv without pdo_sqlsrv + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/sqlsrv/config.w32', 'PHP_PDO_SQLSRV', '"no"'); + $this->pdo_sqlsrv_patched = true; + return true; + } + return false; + } + + public function patchBeforeConfigure(): bool + { + if ($this->pdo_sqlsrv_patched) { + // revert pdo_sqlsrv patch + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/sqlsrv/config.w32', '"no" == "no"', 'PHP_PDO_SQLSRV == "no"'); + return true; + } + return false; + } +} diff --git a/src/SPC/builder/windows/library/bzip2.php b/src/SPC/builder/windows/library/bzip2.php new file mode 100644 index 00000000..81a74b0a --- /dev/null +++ b/src/SPC/builder/windows/library/bzip2.php @@ -0,0 +1,21 @@ +builder->makeSimpleWrapper('nmake /nologo /f Makefile.msc CFLAGS="-DWIN32 -MT -Ox -D_FILE_OFFSET_BITS=64 -nologo"'); + cmd()->cd($this->source_dir) + ->execWithWrapper($nmake, 'clean') + ->execWithWrapper($nmake, 'lib'); + copy($this->source_dir . '\libbz2.lib', BUILD_LIB_PATH . '\libbz2.lib'); + copy($this->source_dir . '\libbz2.lib', BUILD_LIB_PATH . '\libbz2_a.lib'); + copy($this->source_dir . '\bzlib.h', BUILD_INCLUDE_PATH . '\bzlib.h'); + } +} diff --git a/src/SPC/builder/windows/library/libyaml.php b/src/SPC/builder/windows/library/libyaml.php new file mode 100644 index 00000000..5d4026c5 --- /dev/null +++ b/src/SPC/builder/windows/library/libyaml.php @@ -0,0 +1,44 @@ +source_dir . '\build'); + + // check missing files: cmake\config.h.in and .\YamlConfig.cmake.in + if (!file_exists($this->source_dir . '\cmake\config.h.in')) { + FileSystem::createDir($this->source_dir . '\cmake'); + copy(ROOT_DIR . '\src\globals\extra\libyaml_config.h.in', $this->source_dir . '\cmake\config.h.in'); + } + if (!file_exists($this->source_dir . '\YamlConfig.cmake.in')) { + copy(ROOT_DIR . '\src\globals\extra\libyaml_YamlConfig.cmake.in', $this->source_dir . '\YamlConfig.cmake.in'); + } + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DBUILD_TESTING=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + } +} diff --git a/src/SPC/builder/windows/library/libzip.php b/src/SPC/builder/windows/library/libzip.php new file mode 100644 index 00000000..9a8206af --- /dev/null +++ b/src/SPC/builder/windows/library/libzip.php @@ -0,0 +1,46 @@ +source_dir . '\build'); + + $openssl = $this->builder->getLib('openssl') ? 'ON' : 'OFF'; + $zstd = $this->builder->getLib('zstd') ? 'ON' : 'OFF'; + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DENABLE_BZIP2=ON ' . + '-DENABLE_LZMA=ON ' . + "-DENABLE_ZSTD={$zstd} " . + "-DENABLE_OPENSSL={$openssl} " . + '-DBUILD_TOOLS=OFF ' . + '-DBUILD_DOC=OFF ' . + '-DBUILD_EXAMPLES=OFF ' . + '-DBUILD_REGRESS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + copy(BUILD_LIB_PATH . '\zip.lib', BUILD_LIB_PATH . '\libzip_a.lib'); + } +} diff --git a/src/SPC/builder/windows/library/xz.php b/src/SPC/builder/windows/library/xz.php new file mode 100644 index 00000000..cf5b7234 --- /dev/null +++ b/src/SPC/builder/windows/library/xz.php @@ -0,0 +1,39 @@ +source_dir . '\build'); + + // start build + cmd()->cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + '-B build ' . + '-A x64 ' . + "-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . + '-DCMAKE_BUILD_TYPE=Release ' . + '-DBUILD_SHARED_LIBS=OFF ' . + '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' + ) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('cmake'), + "--build build --config Release --target install -j{$this->builder->concurrency}" + ); + + // copy liblzma.lib to liblzma_a.lib + copy(BUILD_LIB_PATH . '/liblzma.lib', BUILD_LIB_PATH . '/liblzma_a.lib'); + // patch lzma.h + FileSystem::replaceFileStr(BUILD_INCLUDE_PATH . '/lzma.h', 'defined(LZMA_API_STATIC)', 'defined(_WIN32)'); + } +} diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 6295a889..6d192bce 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -521,7 +521,7 @@ class FileSystem private static function emitSourceExtractHook(string $name): void { foreach ((self::$_extract_hook[$name] ?? []) as $hook) { - if ($hook() === true) { + if ($hook($name) === true) { logger()->info('Patched source [' . $name . '] after extracted'); } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 96238619..dc114fe2 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -9,6 +9,7 @@ use SPC\builder\linux\LinuxBuilder; use SPC\builder\unix\UnixBuilderBase; use SPC\exception\FileSystemException; use SPC\exception\RuntimeException; +use SPC\exception\WrongUsageException; class SourcePatcher { @@ -20,12 +21,18 @@ class SourcePatcher FileSystem::addSourceExtractHook('swoole', [SourcePatcher::class, 'patchSwoole']); FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchPhpLibxml212']); FileSystem::addSourceExtractHook('php-src', [SourcePatcher::class, 'patchGDWin32']); + FileSystem::addSourceExtractHook('sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); + FileSystem::addSourceExtractHook('pdo_sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); + FileSystem::addSourceExtractHook('yaml', [SourcePatcher::class, 'patchYamlWin32']); } /** * Source patcher runner before buildconf * - * @param BuilderBase $builder Builder + * @param BuilderBase $builder Builder + * @throws FileSystemException + * @throws RuntimeException + * @throws WrongUsageException */ public static function patchBeforeBuildconf(BuilderBase $builder): void { @@ -77,7 +84,7 @@ class SourcePatcher * @throws RuntimeException * @throws FileSystemException */ - public static function patchMicro(?array $list = null, bool $reverse = false): bool + public static function patchMicro(): bool { if (!file_exists(SOURCE_PATH . '/php-src/sapi/micro/php_micro.c')) { return false; @@ -112,7 +119,7 @@ class SourcePatcher if (PHP_OS_FAMILY === 'Darwin') { $default[] = 'macos_iconv'; } - $patch_list = $list ?? $default; + $patch_list = $default; $patches = []; $serial = ['80', '81', '82', '83', '84']; foreach ($patch_list as $patchName) { @@ -135,7 +142,7 @@ class SourcePatcher f_passthru( 'cd ' . SOURCE_PATH . '/php-src && ' . - (PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patchesStr . ' | patch -p1 ' . ($reverse ? '-R' : '') + (PHP_OS_FAMILY === 'Windows' ? 'type' : 'cat') . ' ' . $patchesStr . ' | patch -p1 ' ); return true; @@ -183,6 +190,9 @@ class SourcePatcher return false; } + /** + * @throws FileSystemException + */ public static function patchSwoole(): bool { // swoole hook needs pdo/pdo.h @@ -281,6 +291,9 @@ class SourcePatcher return $result; } + /** + * @throws FileSystemException + */ public static function patchMicroPhar(int $version_id): void { FileSystem::backupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); @@ -306,11 +319,35 @@ class SourcePatcher } } + /** + * @throws RuntimeException + */ public static function unpatchMicroPhar(): void { FileSystem::restoreBackupFile(SOURCE_PATH . '/php-src/ext/phar/phar.c'); } + /** + * Fix the compilation issue of sqlsrv and pdo_sqlsrv on Windows (/sdl check is too strict and will cause Zend compilation to fail) + * + * @throws FileSystemException + */ + public static function patchSQLSRVWin32(string $source_name): bool + { + $source_name = preg_replace('/[^a-z_]/', '', $source_name); + if (file_exists(SOURCE_PATH . '/php-src/ext/' . $source_name . '/config.w32')) { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/' . $source_name . '/config.w32', '/sdl', ''); + return true; + } + return false; + } + + public static function patchYamlWin32(): bool + { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/yaml/config.w32', "lib.substr(lib.length - 6, 6) == '_a.lib'", "lib.substr(lib.length - 6, 6) == '_a.lib' || 'yes' == 'yes'"); + return true; + } + /** * Patch cli SAPI Makefile for Windows. * @@ -325,7 +362,7 @@ class SourcePatcher $line_num = 0; $found = false; foreach ($lines as $v) { - if (strpos($v, '$(BUILD_DIR)\php.exe:') !== false) { + if (str_contains($v, '$(BUILD_DIR)\php.exe:')) { $found = $line_num; break; } @@ -339,6 +376,9 @@ class SourcePatcher FileSystem::writeFile(SOURCE_PATH . '/php-src/Makefile', implode("\r\n", $lines)); } + /** + * @throws RuntimeException + */ public static function patchPhpLibxml212(): bool { $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); @@ -360,6 +400,9 @@ class SourcePatcher return false; } + /** + * @throws FileSystemException + */ public static function patchGDWin32(): bool { $file = file_get_contents(SOURCE_PATH . '/php-src/main/php_version.h'); @@ -393,6 +436,9 @@ class SourcePatcher } } + /** + * @throws FileSystemException + */ public static function patchMicroWin32(): void { // patch micro win32 diff --git a/src/globals/extra/libyaml_YamlConfig.cmake.in b/src/globals/extra/libyaml_YamlConfig.cmake.in new file mode 100644 index 00000000..839f3aba --- /dev/null +++ b/src/globals/extra/libyaml_YamlConfig.cmake.in @@ -0,0 +1,10 @@ +@PACKAGE_INIT@ + +set_and_check(yaml_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/yamlTargets.cmake") + +if(NOT yaml_TARGETS_IMPORTED) + set(yaml_TARGETS_IMPORTED 1) + include(${yaml_TARGETS}) +endif() + +set(yaml_LIBRARIES yaml) \ No newline at end of file diff --git a/src/globals/extra/libyaml_config.h.in b/src/globals/extra/libyaml_config.h.in new file mode 100644 index 00000000..c92894bb --- /dev/null +++ b/src/globals/extra/libyaml_config.h.in @@ -0,0 +1,4 @@ +#define YAML_VERSION_MAJOR @YAML_VERSION_MAJOR@ +#define YAML_VERSION_MINOR @YAML_VERSION_MINOR@ +#define YAML_VERSION_PATCH @YAML_VERSION_PATCH@ +#define YAML_VERSION_STRING "@YAML_VERSION_STRING@" \ No newline at end of file From 3445a2cd58c10ee02e56fe1c4faf305c4a226df4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 00:13:40 +0800 Subject: [PATCH 317/415] Add extension 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 d49365ba..3f237007 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -20,13 +20,13 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'sockets', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,gd', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,bz2,sqlsrv,pdo_sqlsrv,yaml,zip,rar', }; // 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' => '', - 'Windows' => 'libjpeg,libwebp,libavif,freetype', + 'Windows' => '', }; // Please change your test base combination. We recommend testing with `common`. From a1f632e8c95e942edb32430c343c10308cba3d9d Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 00:24:05 +0800 Subject: [PATCH 318/415] Add apcu 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 3f237007..ff3993c0 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -20,7 +20,7 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'sockets', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,bz2,sqlsrv,pdo_sqlsrv,yaml,zip,rar', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,bz2,sqlsrv,pdo_sqlsrv,yaml,zip,rar,apcu', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From 334a3bdf5db7af32f6aeb4c5e96637cc288af344 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 00:55:43 +0800 Subject: [PATCH 319/415] Add extension swow for Windows --- config/ext.json | 2 -- src/SPC/builder/extension/swow.php | 2 +- src/globals/test-extensions.php | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/config/ext.json b/config/ext.json index 9e0c3f3e..5b2e8eb8 100644 --- a/config/ext.json +++ b/config/ext.json @@ -733,7 +733,6 @@ }, "swow": { "support": { - "Windows": "wip", "BSD": "wip" }, "notes": true, @@ -932,7 +931,6 @@ }, "zip": { "support": { - "Windows": "wip", "BSD": "wip" }, "type": "builtin", diff --git a/src/SPC/builder/extension/swow.php b/src/SPC/builder/extension/swow.php index 3b2f91d9..27576635 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 getUnixConfigureArg(): string + public function getConfigureArg(): string { $arg = '--enable-swow'; $arg .= $this->builder->getLib('openssl') ? ' --enable-swow-ssl' : ' --disable-swow-ssl'; diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index ff3993c0..5b2c5007 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -20,7 +20,7 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { 'Linux', 'Darwin' => 'sockets', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,bz2,sqlsrv,pdo_sqlsrv,yaml,zip,rar,apcu', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,bz2,sqlsrv,pdo_sqlsrv,yaml,zip,rar,apcu,swow', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). From d4da18e869b254d564b37aa1f984ac4f7ef679fa Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:32:17 +0800 Subject: [PATCH 320/415] Disable getCpuCount log --- src/SPC/builder/macos/SystemUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/SystemUtil.php b/src/SPC/builder/macos/SystemUtil.php index 22d7847e..0c2d4560 100644 --- a/src/SPC/builder/macos/SystemUtil.php +++ b/src/SPC/builder/macos/SystemUtil.php @@ -20,7 +20,7 @@ class SystemUtil */ public static function getCpuCount(): int { - [$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu'); + [$ret, $output] = shell()->execWithResult('sysctl -n hw.ncpu', false); if ($ret !== 0) { throw new RuntimeException('Failed to get cpu count'); } From ba127f4e009daeff5a2631216cf5e468c2a0dcdf Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:33:03 +0800 Subject: [PATCH 321/415] Use extra files instead of internal patch block for libyaml --- src/SPC/builder/unix/library/libyaml.php | 54 +++++++----------------- src/SPC/store/SourcePatcher.php | 13 ++++++ 2 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/SPC/builder/unix/library/libyaml.php b/src/SPC/builder/unix/library/libyaml.php index b1b545cf..53962e9b 100644 --- a/src/SPC/builder/unix/library/libyaml.php +++ b/src/SPC/builder/unix/library/libyaml.php @@ -10,51 +10,27 @@ use SPC\store\FileSystem; trait libyaml { + public function getLibVersion(): ?string + { + // Match version from CMakeLists.txt: + // Format: set (YAML_VERSION_MAJOR 0) + // set (YAML_VERSION_MINOR 2) + // set (YAML_VERSION_PATCH 5) + $content = FileSystem::readFile($this->source_dir . '/CMakeLists.txt'); + if (preg_match('/set \(YAML_VERSION_MAJOR (\d+)\)/', $content, $major) + && preg_match('/set \(YAML_VERSION_MINOR (\d+)\)/', $content, $minor) + && preg_match('/set \(YAML_VERSION_PATCH (\d+)\)/', $content, $patch)) { + return "{$major[1]}.{$minor[1]}.{$patch[1]}"; + } + return null; + } + /** * @throws RuntimeException * @throws FileSystemException */ protected function build(): void { - // prepare cmake/config.h.in - if (!is_file(SOURCE_PATH . '/libyaml/cmake/config.h.in')) { - f_mkdir(SOURCE_PATH . '/libyaml/cmake'); - file_put_contents( - SOURCE_PATH . '/libyaml/cmake/config.h.in', - <<<'EOF' -#define YAML_VERSION_MAJOR @YAML_VERSION_MAJOR@ -#define YAML_VERSION_MINOR @YAML_VERSION_MINOR@ -#define YAML_VERSION_PATCH @YAML_VERSION_PATCH@ -#define YAML_VERSION_STRING "@YAML_VERSION_STRING@" -EOF - ); - } - - // prepare yamlConfig.cmake.in - if (!is_file(SOURCE_PATH . '/libyaml/yamlConfig.cmake.in')) { - file_put_contents( - SOURCE_PATH . '/libyaml/yamlConfig.cmake.in', - <<<'EOF' -# Config file for the yaml library. -# -# It defines the following variables: -# yaml_LIBRARIES - libraries to link against - -@PACKAGE_INIT@ - -set_and_check(yaml_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/yamlTargets.cmake") - -if(NOT yaml_TARGETS_IMPORTED) - set(yaml_TARGETS_IMPORTED 1) - include(${yaml_TARGETS}) -endif() - -set(yaml_LIBRARIES yaml) - -EOF - ); - } - [$lib, $include, $destdir] = SEPARATED_PATH; FileSystem::resetDir($this->source_dir . '/build'); diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index dc114fe2..0eb530c4 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -24,6 +24,7 @@ class SourcePatcher FileSystem::addSourceExtractHook('sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('pdo_sqlsrv', [SourcePatcher::class, 'patchSQLSRVWin32']); FileSystem::addSourceExtractHook('yaml', [SourcePatcher::class, 'patchYamlWin32']); + FileSystem::addSourceExtractHook('libyaml', [SourcePatcher::class, 'patchLibYaml']); } /** @@ -348,6 +349,18 @@ class SourcePatcher return true; } + public static function patchLibYaml(string $name, string $target): bool + { + if (!file_exists("{$target}\\cmake\\config.h.in")) { + FileSystem::createDir("{$target}\\cmake"); + copy(ROOT_DIR . '\src\globals\extra\libyaml_config.h.in', "{$target}\\cmake\\config.h.in"); + } + if (!file_exists("{$target}\\YamlConfig.cmake.in")) { + copy(ROOT_DIR . '\src\globals\extra\libyaml_YamlConfig.cmake.in', "{$target}\\YamlConfig.cmake.in"); + } + return true; + } + /** * Patch cli SAPI Makefile for Windows. * From 9463cf94ca1920c6e4000a4a94cb279bb4c1a870 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:33:53 +0800 Subject: [PATCH 322/415] Prevent constructing builder without --arch options error --- src/SPC/builder/macos/MacOSBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index ddcfcb64..a29e9954 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -37,7 +37,7 @@ class MacOSBuilder extends UnixBuilderBase $this->arch_c_flags = getenv('SPC_DEFAULT_C_FLAGS'); $this->arch_cxx_flags = getenv('SPC_DEFAULT_CXX_FLAGS'); // cmake toolchain - $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch'), $this->arch_c_flags); + $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile('Darwin', $this->getOption('arch', php_uname('m')), $this->arch_c_flags); // create pkgconfig and include dir (some libs cannot create them automatically) f_mkdir(BUILD_LIB_PATH . '/pkgconfig', recursive: true); From 1d78a231db62a5489a302e35fbd1c634c62995e6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:34:27 +0800 Subject: [PATCH 323/415] Add target dir to extract hook --- src/SPC/store/FileSystem.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SPC/store/FileSystem.php b/src/SPC/store/FileSystem.php index 6d192bce..0d1aee72 100644 --- a/src/SPC/store/FileSystem.php +++ b/src/SPC/store/FileSystem.php @@ -195,7 +195,7 @@ class FileSystem } try { self::extractArchive($filename, $target); - self::emitSourceExtractHook($name); + self::emitSourceExtractHook($name, $target); } catch (RuntimeException $e) { if (PHP_OS_FAMILY === 'Windows') { f_passthru('rmdir /s /q ' . $target); @@ -518,10 +518,10 @@ class FileSystem return file_put_contents($filename, $file); } - private static function emitSourceExtractHook(string $name): void + private static function emitSourceExtractHook(string $name, string $target): void { foreach ((self::$_extract_hook[$name] ?? []) as $hook) { - if ($hook($name) === true) { + if ($hook($name, $target) === true) { logger()->info('Patched source [' . $name . '] after extracted'); } } From 351e3912214af911cb81718c27783de080db94dd Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:35:22 +0800 Subject: [PATCH 324/415] `--ignore-cache-sources` now support empty values (force all download) --- src/SPC/command/DownloadCommand.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index 5ce1a06a..48fa5e7a 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -38,7 +38,7 @@ class DownloadCommand extends BaseCommand $this->addOption('for-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"'); $this->addOption('for-libs', 'l', InputOption::VALUE_REQUIRED, 'Fetch by libraries, e.g "libcares,openssl,onig"'); $this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions'); - $this->addOption('ignore-cache-sources', null, InputOption::VALUE_REQUIRED, 'Ignore some source caches, comma separated, e.g "php-src,curl,openssl"', ''); + $this->addOption('ignore-cache-sources', null, InputOption::VALUE_OPTIONAL, 'Ignore some source caches, comma separated, e.g "php-src,curl,openssl"', ''); $this->addOption('retry', 'R', InputOption::VALUE_REQUIRED, 'Set retry time when downloading failed (default: 0)', '0'); } @@ -147,8 +147,12 @@ class DownloadCommand extends BaseCommand } $chosen_sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources')))); - $force_list = array_map('trim', array_filter(explode(',', $this->getOption('ignore-cache-sources')))); - + $force_all = empty($this->getOption('ignore-cache-sources')); + if (!$force_all) { + $force_list = array_map('trim', array_filter(explode(',', $this->getOption('ignore-cache-sources')))); + } else { + $force_list = []; + } if ($this->getOption('all')) { logger()->notice('Downloading with --all option will take more times to download, we recommend you to download with --for-extensions option !'); } @@ -182,7 +186,7 @@ class DownloadCommand extends BaseCommand Downloader::downloadSource($source, $new_config, true); } else { logger()->info("Fetching source {$source} [{$ni}/{$cnt}]"); - Downloader::downloadSource($source, Config::getSource($source), in_array($source, $force_list)); + Downloader::downloadSource($source, Config::getSource($source), $force_all || in_array($source, $force_list)); } } $time = round(microtime(true) - START_TIME, 3); From f645c8869a7e14897549e7f39162190c22bf0246 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:36:22 +0800 Subject: [PATCH 325/415] Add prefer-stable option for ghrel, ghtar, ghtagtar --- config/source.json | 16 ++++++++++++++++ src/SPC/store/Downloader.php | 17 +++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/config/source.json b/config/source.json index 5dadd944..ba518e28 100644 --- a/config/source.json +++ b/config/source.json @@ -47,6 +47,7 @@ "type": "ghrel", "repo": "curl/curl", "match": "curl.+\\.tar\\.xz", + "prefer-stable": true, "license": { "type": "file", "path": "COPYING" @@ -194,6 +195,7 @@ "type": "ghrel", "repo": "unicode-org/icu", "match": "icu4c.+-src\\.tgz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -266,6 +268,7 @@ "type": "ghrel", "repo": "c-ares/c-ares", "match": "c-ares-.+\\.tar\\.gz", + "prefer-stable": true, "alt": { "type": "filelist", "url": "https://c-ares.org/download/", @@ -280,6 +283,7 @@ "type": "ghrel", "repo": "libevent/libevent", "match": "libevent.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -289,6 +293,7 @@ "type": "ghrel", "repo": "libffi/libffi", "match": "libffi.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -333,6 +338,7 @@ "type": "ghrel", "repo": "lz4/lz4", "match": "lz4-.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -369,6 +375,7 @@ "type": "ghrel", "repo": "jedisct1/libsodium", "match": "libsodium-\\d+(\\.\\d+)*\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -378,6 +385,7 @@ "type": "ghrel", "repo": "libssh2/libssh2", "match": "libssh2.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "COPYING" @@ -444,6 +452,7 @@ "type": "ghrel", "repo": "yaml/libyaml", "match": "yaml-.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "License" @@ -453,6 +462,7 @@ "type": "ghrel", "repo": "nih-at/libzip", "match": "libzip.+\\.tar\\.xz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -483,6 +493,7 @@ "repo": "mongodb/mongo-php-driver", "path": "php-src/ext/mongodb", "match": "mongodb.+\\.tgz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -501,6 +512,7 @@ "type": "ghrel", "repo": "nghttp2/nghttp2", "match": "nghttp2.+\\.tar\\.xz", + "prefer-stable": true, "license": { "type": "file", "path": "COPYING" @@ -510,6 +522,7 @@ "type": "ghrel", "repo": "kkos/oniguruma", "match": "onig-.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "COPYING" @@ -649,6 +662,7 @@ "type": "ghtar", "path": "php-src/ext/swoole", "repo": "swoole/swoole-src", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" @@ -734,6 +748,7 @@ "type": "ghrel", "repo": "madler/zlib", "match": "zlib.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "text", "text": "(C) 1995-2022 Jean-loup Gailly and Mark Adler\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must not\n claim that you wrote the original software. If you use this software\n in a product, an acknowledgment in the product documentation would be\n appreciated but is not required.\n2. Altered source versions must be plainly marked as such, and must not be\n misrepresented as being the original software.\n3. This notice may not be removed or altered from any source distribution.\n\nJean-loup Gailly Mark Adler\njloup@gzip.org madler@alumni.caltech.edu" @@ -743,6 +758,7 @@ "type": "ghrel", "repo": "facebook/zstd", "match": "zstd.+\\.tar\\.gz", + "prefer-stable": true, "license": { "type": "file", "path": "LICENSE" diff --git a/src/SPC/store/Downloader.php b/src/SPC/store/Downloader.php index 00d8881d..312a459c 100644 --- a/src/SPC/store/Downloader.php +++ b/src/SPC/store/Downloader.php @@ -16,7 +16,7 @@ use SPC\store\source\CustomSourceBase; class Downloader { /** - * Get latest version from BitBucket tag + * Get latest version from BitBucket tag (type = bitbuckettag) * * @param string $name source name * @param array $source source meta info: [repo] @@ -51,7 +51,7 @@ class Downloader } /** - * Get latest version from GitHub tarball + * Get latest version from GitHub tarball (type = ghtar / ghtagtar) * * @param string $name source name * @param array $source source meta info: [repo] @@ -68,7 +68,16 @@ class Downloader hooks: [[CurlHook::class, 'setupGithubToken']], retry: intval(getenv('SPC_RETRY_TIME') ? getenv('SPC_RETRY_TIME') : 0) ), true); - $url = $data[0]['tarball_url']; + + if (($source['prefer-stable'] ?? false) === true) { + $url = $data[0]['tarball_url']; + } else { + $id = 0; + while ($data[$id]['prerelease'] === true) { + ++$id; + } + $url = $data[$id]['tarball_url'] ?? null; + } if (!$url) { throw new DownloaderException("failed to find {$name} source"); } @@ -106,7 +115,7 @@ class Downloader ), true); $url = null; foreach ($data as $release) { - if ($release['prerelease'] === true) { + if (($source['prefer-stable'] ?? false) === true && $release['prerelease'] === true) { continue; } foreach ($release['assets'] as $asset) { From eb00e0012f943a9e0317dcdfbaee6764d279aeaa Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 30 Jun 2024 22:37:01 +0800 Subject: [PATCH 326/415] Add getLibVersion and getExtVersion method for extensions and libs --- config/pre-built.json | 5 +++ src/SPC/ConsoleApplication.php | 4 ++ src/SPC/builder/BuilderBase.php | 6 ++- src/SPC/builder/Extension.php | 10 +++++ src/SPC/builder/LibraryBase.php | 10 +++++ src/SPC/builder/extension/swoole.php | 12 ++++++ src/SPC/command/dev/ExtVerCommand.php | 51 +++++++++++++++++++++++ src/SPC/command/dev/LibVerCommand.php | 60 +++++++++++++++++++++++++++ 8 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 config/pre-built.json create mode 100644 src/SPC/command/dev/ExtVerCommand.php create mode 100644 src/SPC/command/dev/LibVerCommand.php diff --git a/config/pre-built.json b/config/pre-built.json new file mode 100644 index 00000000..8b5811e2 --- /dev/null +++ b/config/pre-built.json @@ -0,0 +1,5 @@ +{ + "repo": "static-php/static-php-cli-hosted", + "match-pattern": "{name}-{arch}-{os}.tgz", + "pack-config": {} +} \ No newline at end of file diff --git a/src/SPC/ConsoleApplication.php b/src/SPC/ConsoleApplication.php index 1131ef12..f0a357fc 100644 --- a/src/SPC/ConsoleApplication.php +++ b/src/SPC/ConsoleApplication.php @@ -8,7 +8,9 @@ use SPC\command\BuildCliCommand; use SPC\command\BuildLibsCommand; use SPC\command\DeleteDownloadCommand; use SPC\command\dev\AllExtCommand; +use SPC\command\dev\ExtVerCommand; use SPC\command\dev\GenerateExtDocCommand; +use SPC\command\dev\LibVerCommand; use SPC\command\dev\PhpVerCommand; use SPC\command\dev\SortConfigCommand; use SPC\command\DoctorCommand; @@ -48,6 +50,8 @@ final class ConsoleApplication extends Application // Dev commands new AllExtCommand(), new PhpVerCommand(), + new LibVerCommand(), + new ExtVerCommand(), new SortConfigCommand(), new GenerateExtDocCommand(), ] diff --git a/src/SPC/builder/BuilderBase.php b/src/SPC/builder/BuilderBase.php index 4f4a72f8..de529165 100644 --- a/src/SPC/builder/BuilderBase.php +++ b/src/SPC/builder/BuilderBase.php @@ -161,7 +161,7 @@ abstract class BuilderBase * @throws WrongUsageException * @internal */ - public function proveExts(array $extensions): void + public function proveExts(array $extensions, bool $skip_check_deps = false): void { CustomExt::loadCustomExt(); $this->emitPatchPoint('before-php-extract'); @@ -181,6 +181,10 @@ abstract class BuilderBase $this->addExt($ext); } + if ($skip_check_deps) { + return; + } + foreach ($this->exts as $ext) { $ext->checkDependency(); } diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 562db372..ff280a15 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -228,6 +228,16 @@ class Extension // do nothing, just throw wrong usage exception if not valid } + /** + * Get current extension version + * + * @return null|string Version string or null + */ + public function getExtVersion(): ?string + { + return null; + } + /** * @throws RuntimeException */ diff --git a/src/SPC/builder/LibraryBase.php b/src/SPC/builder/LibraryBase.php index ef6ea79d..fb0a4591 100644 --- a/src/SPC/builder/LibraryBase.php +++ b/src/SPC/builder/LibraryBase.php @@ -182,6 +182,16 @@ abstract class LibraryBase // do nothing, just throw wrong usage exception if not valid } + /** + * Get current lib version + * + * @return null|string Version string or null + */ + public function getLibVersion(): ?string + { + return null; + } + /** * Get current builder object. */ diff --git a/src/SPC/builder/extension/swoole.php b/src/SPC/builder/extension/swoole.php index 1e892ee5..e95969e3 100644 --- a/src/SPC/builder/extension/swoole.php +++ b/src/SPC/builder/extension/swoole.php @@ -10,6 +10,18 @@ use SPC\util\CustomExt; #[CustomExt('swoole')] class swoole extends Extension { + public function getExtVersion(): ?string + { + // Get version from source directory + $file = SOURCE_PATH . '/php-src/ext/swoole/include/swoole_version.h'; + // Match #define SWOOLE_VERSION "5.1.3" + $pattern = '/#define SWOOLE_VERSION "(.+)"/'; + if (preg_match($pattern, file_get_contents($file), $matches)) { + return $matches[1]; + } + return null; + } + public function getUnixConfigureArg(): string { // enable swoole diff --git a/src/SPC/command/dev/ExtVerCommand.php b/src/SPC/command/dev/ExtVerCommand.php new file mode 100644 index 00000000..0f08fa9a --- /dev/null +++ b/src/SPC/command/dev/ExtVerCommand.php @@ -0,0 +1,51 @@ +addArgument('extension', InputArgument::REQUIRED, 'The library name'); + } + + public function initialize(InputInterface $input, OutputInterface $output): void + { + $this->no_motd = true; + parent::initialize($input, $output); + } + + public function handle(): int + { + // Get lib object + $builder = BuilderProvider::makeBuilderByInput($this->input); + + $ext_conf = Config::getExt($this->getArgument('extension')); + $builder->proveExts([$this->getArgument('extension')], true); + + // Check whether lib is extracted + // if (!is_dir(SOURCE_PATH . '/' . $this->getArgument('library'))) { + // $this->output->writeln("Library {$this->getArgument('library')} is not extracted"); + // return static::FAILURE; + // } + + $version = $builder->getExt($this->getArgument('extension'))->getExtVersion(); + if ($version === null) { + $this->output->writeln("Failed to get version of extension {$this->getArgument('extension')}"); + return static::FAILURE; + } + $this->output->writeln("{$version}"); + return static::SUCCESS; + } +} diff --git a/src/SPC/command/dev/LibVerCommand.php b/src/SPC/command/dev/LibVerCommand.php new file mode 100644 index 00000000..717fd155 --- /dev/null +++ b/src/SPC/command/dev/LibVerCommand.php @@ -0,0 +1,60 @@ +addArgument('library', InputArgument::REQUIRED, 'The library name'); + } + + public function initialize(InputInterface $input, OutputInterface $output): void + { + $this->no_motd = true; + parent::initialize($input, $output); + } + + public function handle(): int + { + // Get lib object + $builder = BuilderProvider::makeBuilderByInput($this->input); + $builder->setLibsOnly(); + + // check lib name exist in lib.json + try { + Config::getLib($this->getArgument('library')); + } catch (WrongUsageException $e) { + $this->output->writeln("Library {$this->getArgument('library')} is not supported yet"); + return static::FAILURE; + } + + $builder->proveLibs([$this->getArgument('library')]); + + // Check whether lib is extracted + if (!is_dir(SOURCE_PATH . '/' . $this->getArgument('library'))) { + $this->output->writeln("Library {$this->getArgument('library')} is not extracted"); + return static::FAILURE; + } + + $version = $builder->getLib($this->getArgument('library'))->getLibVersion(); + if ($version === null) { + $this->output->writeln("Failed to get version of library {$this->getArgument('library')}"); + return static::FAILURE; + } + $this->output->writeln("{$version}"); + return static::SUCCESS; + } +} From b31539f0f4ceac2c4acf25271934ec5c23d9ab60 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 1 Jul 2024 10:29:31 +0800 Subject: [PATCH 327/415] Merge docs into static-php-cli repo (#492) * Move docs to here * Move docs to here * Modify old docs links --- .github/pull_request_template.md | 6 +- ...e-docs-config.yml => vitepress-deploy.yml} | 43 +- .gitignore | 8 + README-zh.md | 2 +- README.md | 2 +- docs/.vitepress/components/CliGenerator.vue | 556 ++++++++++++++++++ docs/.vitepress/components/DependencyUtil.js | 193 ++++++ docs/.vitepress/config.ts | 52 ++ docs/.vitepress/sidebar.en.ts | 52 ++ docs/.vitepress/sidebar.zh.ts | 52 ++ docs/.vitepress/theme/index.ts | 16 + docs/en/contributing/index.md | 63 ++ docs/en/develop/doctor-module.md | 70 +++ docs/en/develop/index.md | 35 ++ docs/en/develop/source-module.md | 316 ++++++++++ docs/en/develop/structure.md | 180 ++++++ docs/en/develop/system-build-tools.md | 242 ++++++++ docs/en/faq/index.md | 74 +++ docs/en/guide/action-build.md | 29 + docs/en/guide/build-on-windows.md | 221 +++++++ docs/en/guide/cli-generator.md | 12 + docs/en/guide/env-vars.md | 173 ++++++ docs/en/guide/extension-notes.md | 146 +++++ docs/en/guide/extensions.md | 27 + docs/en/guide/index.md | 43 ++ docs/en/guide/manual-build.md | 525 +++++++++++++++++ docs/en/guide/troubleshooting.md | 33 ++ docs/en/index.md | 21 + docs/extension-notes.md | 0 docs/extensions.md | 1 + docs/index.md | 23 + docs/public/CNAME | 1 + docs/zh/contributing/index.md | 48 ++ docs/zh/develop/doctor-module.md | 60 ++ docs/zh/develop/index.md | 27 + docs/zh/develop/source-module.md | 297 ++++++++++ docs/zh/develop/structure.md | 163 +++++ docs/zh/develop/system-build-tools.md | 204 +++++++ docs/zh/faq/index.md | 61 ++ docs/zh/guide/action-build.md | 25 + docs/zh/guide/build-on-windows.md | 203 +++++++ docs/zh/guide/cli-generator.md | 11 + docs/zh/guide/env-vars.md | 165 ++++++ docs/zh/guide/extension-notes.md | 133 +++++ docs/zh/guide/extensions.md | 24 + docs/zh/guide/index.md | 34 ++ docs/zh/guide/manual-build.md | 468 +++++++++++++++ docs/zh/guide/troubleshooting.md | 20 + docs/zh/index.md | 20 + package.json | 11 + src/SPC/builder/LibraryBase.php | 9 + 51 files changed, 5172 insertions(+), 28 deletions(-) rename .github/workflows/{update-docs-config.yml => vitepress-deploy.yml} (56%) create mode 100644 docs/.vitepress/components/CliGenerator.vue create mode 100644 docs/.vitepress/components/DependencyUtil.js create mode 100644 docs/.vitepress/config.ts create mode 100644 docs/.vitepress/sidebar.en.ts create mode 100644 docs/.vitepress/sidebar.zh.ts create mode 100644 docs/.vitepress/theme/index.ts create mode 100644 docs/en/contributing/index.md create mode 100644 docs/en/develop/doctor-module.md create mode 100644 docs/en/develop/index.md create mode 100644 docs/en/develop/source-module.md create mode 100644 docs/en/develop/structure.md create mode 100644 docs/en/develop/system-build-tools.md create mode 100644 docs/en/faq/index.md create mode 100644 docs/en/guide/action-build.md create mode 100644 docs/en/guide/build-on-windows.md create mode 100644 docs/en/guide/cli-generator.md create mode 100644 docs/en/guide/env-vars.md create mode 100644 docs/en/guide/extension-notes.md create mode 100644 docs/en/guide/extensions.md create mode 100644 docs/en/guide/index.md create mode 100644 docs/en/guide/manual-build.md create mode 100644 docs/en/guide/troubleshooting.md create mode 100644 docs/en/index.md create mode 100644 docs/extension-notes.md create mode 100644 docs/extensions.md create mode 100644 docs/index.md create mode 100644 docs/public/CNAME create mode 100644 docs/zh/contributing/index.md create mode 100644 docs/zh/develop/doctor-module.md create mode 100644 docs/zh/develop/index.md create mode 100644 docs/zh/develop/source-module.md create mode 100644 docs/zh/develop/structure.md create mode 100644 docs/zh/develop/system-build-tools.md create mode 100644 docs/zh/faq/index.md create mode 100644 docs/zh/guide/action-build.md create mode 100644 docs/zh/guide/build-on-windows.md create mode 100644 docs/zh/guide/cli-generator.md create mode 100644 docs/zh/guide/env-vars.md create mode 100644 docs/zh/guide/extension-notes.md create mode 100644 docs/zh/guide/extensions.md create mode 100644 docs/zh/guide/index.md create mode 100644 docs/zh/guide/manual-build.md create mode 100644 docs/zh/guide/troubleshooting.md create mode 100644 docs/zh/index.md create mode 100644 package.json diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 6a441788..8cf1f448 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,6 +7,6 @@ > 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 it's a extension or dependency update, make sure adding related extensions in `src/global/test-extensions.php`. -- [ ] If you changed the behavior of static-php-cli, add docs in [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) . -- [ ] If you updated `config/xxxx.json` content, run `bin/spc dev:sort-config xxx`. +- [ ] 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`. diff --git a/.github/workflows/update-docs-config.yml b/.github/workflows/vitepress-deploy.yml similarity index 56% rename from .github/workflows/update-docs-config.yml rename to .github/workflows/vitepress-deploy.yml index d3687b42..8ad3baee 100644 --- a/.github/workflows/update-docs-config.yml +++ b/.github/workflows/vitepress-deploy.yml @@ -1,36 +1,31 @@ -name: Update Docs Config - +name: Docs Auto Deploy on: push: branches: - main paths: - 'config/**.json' + - 'docs/**' + - 'package.json' jobs: - update-docs-config: - name: "Update Docs Config" + build: + name: Deploy docs runs-on: ubuntu-latest if: github.repository == 'crazywhalecc/static-php-cli' steps: - - name: "Checkout static-php-cli" + - name: Checkout master uses: actions/checkout@v4 - - name: "Checkout static-php-cli-docs" - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 with: - repository: static-php/static-php-cli-docs - ref: master - token: ${{ secrets.DOCS_REPO_TOKEN }} - path: static-php-cli-docs + node-version: 18 + cache: yarn - - name: "Set up Git" - run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" + - run: yarn install --frozen-lockfile - name: "Copy Config Files" - run: cp -r config/* static-php-cli-docs/docs/.vitepress/config/ + run: cp -r config/* docs/.vitepress/config/ - name: "Install PHP for official runners" uses: "shivammathur/setup-php@v2" @@ -58,11 +53,13 @@ jobs: - name: "Generate Extension Support List" run: | - bin/spc dev:gen-ext-docs > static-php-cli-docs/docs/extensions.md + bin/spc dev:gen-ext-docs > docs/extensions.md - - name: "Commit and Push Changes" - run: | - cd static-php-cli-docs - git add -A - git commit -m "Sync config files from main" - git push origin master + - name: Build + run: yarn docs:build + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/.vitepress/dist diff --git a/.gitignore b/.gitignore index 269a267e..ab857ea9 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,11 @@ docker/source/ # default test directory /tests/var/ + +# VitePress +/node_modules/ +/docs/.vitepress/dist/ +/docs/.vitepress/cache/ +package-lock.json +pnpm-lock.yaml +yarn.lock diff --git a/README-zh.md b/README-zh.md index 8b64a65c..c68d52f8 100755 --- a/README-zh.md +++ b/README-zh.md @@ -274,7 +274,7 @@ bin/spc micro:combine my-app.phar -I "memory_limit=4G" -I "disable_functions=sys 另外,添加新扩展的贡献方式,可以参考下方 `进阶`。 -如果你想贡献文档内容,请到项目仓库 [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs) 贡献。 +如果你想贡献文档内容,请直接修改 `docs/` 目录。 ## 赞助本项目 diff --git a/README.md b/README.md index c61cb7d7..4b000aa8 100755 --- a/README.md +++ b/README.md @@ -297,7 +297,7 @@ For an advanced example of how to use this feature, take a look at [how to use i If the extension you need is missing, you can create an issue. If you are familiar with this project, you are also welcome to initiate a pull request. -If you want to contribute documentation, please go to [static-php/static-php-cli-docs](https://github.com/static-php/static-php-cli-docs). +If you want to contribute documentation, please just edit in `docs/`. Now there is a [static-php](https://github.com/static-php) organization, which is used to store the repo related to the project. diff --git a/docs/.vitepress/components/CliGenerator.vue b/docs/.vitepress/components/CliGenerator.vue new file mode 100644 index 00000000..5ef34495 --- /dev/null +++ b/docs/.vitepress/components/CliGenerator.vue @@ -0,0 +1,556 @@ +