diff --git a/config/ext.json b/config/ext.json index 188aea58..7525b67e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1171,6 +1171,27 @@ "xz" ] }, + "zip-shared": { + "support": { + "BSD": "wip" + }, + "type": "external", + "source": "ext-zip", + "arg-type": "enable", + "lib-depends-unix": [ + "libzip" + ], + "ext-depends-windows": [ + "zlib", + "bz2" + ], + "lib-depends-windows": [ + "libzip", + "zlib", + "bzip2", + "xz" + ] + }, "zlib": { "type": "builtin", "arg-type": "custom", diff --git a/config/source.json b/config/source.json index 4a0e0fdb..ccda09c2 100644 --- a/config/source.json +++ b/config/source.json @@ -263,6 +263,16 @@ "path": "LICENSE" } }, + "ext-zip": { + "type": "url", + "url": "https://pecl.php.net/get/zip", + "path": "php-src/ext/zip-shared", + "filename": "ext-zip.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "ext-zstd": { "type": "git", "path": "php-src/ext/zstd", diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index ac7efd1e..5f834ff6 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -81,7 +81,7 @@ class Extension { $escapedPath = str_replace("'", '', escapeshellarg(BUILD_ROOT_PATH)) !== BUILD_ROOT_PATH || str_contains(BUILD_ROOT_PATH, ' ') ? escapeshellarg(BUILD_ROOT_PATH) : BUILD_ROOT_PATH; $_name = str_replace('_', '-', $this->name); - return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) { + $arg = match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) { 'enable' => '--enable-' . $_name . ($shared ? '=shared' : '') . ' ', 'enable-path' => '--enable-' . $_name . '=' . ($shared ? 'shared,' : '') . $escapedPath . ' ', 'with' => '--with-' . $_name . ($shared ? '=shared' : '') . ' ', @@ -89,6 +89,7 @@ class Extension 'none', 'custom' => '', default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-path] ."), }; + return str_replace('-shared', '', $arg); } /** @@ -130,7 +131,7 @@ class Extension public function getName(): string { - return $this->name; + return str_replace('-shared', '', $this->name); } /** @@ -138,7 +139,7 @@ class Extension */ public function getDistName(): string { - return $this->name; + return str_replace('-shared', '', $this->name); } public function getWindowsConfigureArg(bool $shared = false): string diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index 3ffc54ce..be788a65 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -56,6 +56,12 @@ class BuildPHPCommand extends BuildCommand $libraries = array_map('trim', array_filter(explode(',', $this->getOption('with-libs')))); // transform string to array $shared_extensions = array_map('trim', array_filter(explode(',', $this->getOption('build-shared')))); + foreach ($shared_extensions as &$ext) { + if (array_key_exists($ext . '-shared', Config::getExts())) { + $ext .= '-shared'; + } + } + unset($ext); // transform string to array $static_extensions = $this->parseExtensionList($this->getArgument('extensions')); @@ -205,7 +211,7 @@ class BuildPHPCommand extends BuildCommand } // add static-php-cli.version to main.c, in order to debug php failure more easily - SourcePatcher::patchSPCVersionToPHP($this->getApplication()->getVersion()); + SourcePatcher::patchSPCVersionToPHP($this->getApplication()?->getVersion()); // clean old modules that may conflict with the new php build FileSystem::removeDir(BUILD_MODULES_PATH); @@ -244,6 +250,7 @@ class BuildPHPCommand extends BuildCommand } if (!empty($shared_extensions)) { foreach ($shared_extensions as $ext) { + $ext = str_replace('-shared', '', $ext); $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); if (file_exists(BUILD_MODULES_PATH . "/{$ext}.so")) { logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); diff --git a/src/SPC/command/DownloadCommand.php b/src/SPC/command/DownloadCommand.php index b9bae6a5..e710af6e 100644 --- a/src/SPC/command/DownloadCommand.php +++ b/src/SPC/command/DownloadCommand.php @@ -295,6 +295,11 @@ class DownloadCommand extends BaseCommand */ private function calculateSourcesByExt(array $extensions, bool $include_suggests = true): array { + foreach ($extensions as $ext) { + if (array_key_exists($ext . '-shared', Config::getExts())) { + $extensions[] = $ext . '-shared'; + } + } [$extensions, $libraries] = $include_suggests ? DependencyUtil::getExtsAndLibs($extensions, [], true, true) : DependencyUtil::getExtsAndLibs($extensions); $sources = []; foreach ($extensions as $extension) { diff --git a/src/SPC/store/SourceManager.php b/src/SPC/store/SourceManager.php index 35728e22..adfa5a49 100644 --- a/src/SPC/store/SourceManager.php +++ b/src/SPC/store/SourceManager.php @@ -27,6 +27,11 @@ class SourceManager } // ext check source exist if (is_array($exts)) { + foreach ($exts as $ext) { + if (in_array($ext . '-shared', Config::getExts())) { + $exts[] = $ext . '-shared'; + } + } foreach ($exts as $ext) { // get source name for ext if (Config::getExt($ext, 'type') !== 'external') { diff --git a/src/SPC/util/LicenseDumper.php b/src/SPC/util/LicenseDumper.php index 6a40a73a..b877be37 100644 --- a/src/SPC/util/LicenseDumper.php +++ b/src/SPC/util/LicenseDumper.php @@ -50,7 +50,13 @@ class LicenseDumper logger()->warning('Target dump directory is not empty, be aware!'); } FileSystem::createDir($target_dir); + $exts = $this->exts; foreach ($this->exts as $ext) { + if (array_key_exists($ext . '-shared', Config::getExts())) { + $exts[] = $ext . '-shared'; + } + } + foreach ($exts as $ext) { if (Config::getExt($ext, 'type') !== 'external') { continue; }