Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions src/SPC/builder/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ public function getEnableArg(bool $shared = false): string
{
$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' : '') . ' ',
'with-path' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . $escapedPath . ' ',
'none', 'custom' => '',
default => throw new WrongUsageException("argType does not accept {$arg_type}, use [enable/with/with-path] ."),
};
return str_replace('-shared', '', $arg);
}

/**
Expand Down Expand Up @@ -130,15 +131,15 @@ public function getExtensionDependency(): array

public function getName(): string
{
return $this->name;
return str_replace('-shared', '', $this->name);
}

/**
* returns extension dist name
*/
public function getDistName(): string
{
return $this->name;
return str_replace('-shared', '', $this->name);
}

public function getWindowsConfigureArg(bool $shared = false): string
Expand Down
9 changes: 8 additions & 1 deletion src/SPC/command/BuildPHPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function handle(): int
$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'));

Expand Down Expand Up @@ -205,7 +211,7 @@ public function handle(): int
}

// 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);
Expand Down Expand Up @@ -244,6 +250,7 @@ public function handle(): int
}
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}");
Expand Down
5 changes: 5 additions & 0 deletions src/SPC/command/DownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ private function downloadFromZip(string $path): int
*/
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) {
Expand Down
5 changes: 5 additions & 0 deletions src/SPC/store/SourceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public static function initSource(?array $sources = null, ?array $libs = null, ?
}
// 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') {
Expand Down
6 changes: 6 additions & 0 deletions src/SPC/util/LicenseDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public function dump(string $target_dir): bool
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;
}
Expand Down
Loading