Compare commits

...

2 Commits

Author SHA1 Message Date
Marc
ef3d4c22c0 Merge branch 'main' into feature/shared-exts 2025-10-02 16:21:11 +02:00
henderkes
9a37534fd3 add -shared suffix extension to allow building newest e.g. zip.so 2025-10-02 16:20:00 +02:00
7 changed files with 59 additions and 4 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -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

View File

@@ -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}");

View File

@@ -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) {

View File

@@ -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') {

View File

@@ -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;
}