From 4537bfb247e48292d0ffe378ce39930e1f686f9c Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 31 May 2023 10:03:40 +0200 Subject: [PATCH 01/56] 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 02/56] 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 03/56] 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 04/56] 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 05/56] 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 672a4102cdce711be89ec52fb328f92dbbe5948c Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 5 Nov 2023 17:53:48 +0800 Subject: [PATCH 06/56] 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 07/56] 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 1c307d0d594a0b3139446d0bcd5e1a28c805ddaa Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 13:30:12 +0800 Subject: [PATCH 08/56] 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 09/56] 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 10/56] 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 11/56] 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 12/56] 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 13/56] 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 6b23c90bba480d8643f8a2a8bdb101be8bfd68af Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Wed, 29 Nov 2023 16:52:53 +0800 Subject: [PATCH 14/56] 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 15/56] 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 16/56] 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 17/56] 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 18/56] 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 19/56] 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 20/56] 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 21/56] 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 22/56] 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 23/56] 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 24/56] 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 25/56] 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 26/56] 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 27/56] 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 28/56] 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 29/56] 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 30/56] 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 31/56] 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 32/56] 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 33/56] 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 34/56] 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 35/56] 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 36/56] 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 37/56] 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 38/56] 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 39/56] 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 40/56] 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 41/56] 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 42/56] 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 43/56] 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 44/56] 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 45/56] 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 46/56] 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 47/56] 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 48/56] 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 49/56] 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 50/56] 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 51/56] 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 52/56] 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 53/56] 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 54/56] 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 55/56] 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 56/56] 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=' )