From 8ab09898f0f5ccb125e9f4810dbd23cdfa671fa8 Mon Sep 17 00:00:00 2001 From: henderkes Date: Sun, 19 Oct 2025 10:41:14 +0200 Subject: [PATCH] conditional install-modules --- config/ext.json | 5 +++++ src/SPC/builder/linux/LinuxBuilder.php | 8 +++++++- src/SPC/builder/macos/MacOSBuilder.php | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/config/ext.json b/config/ext.json index 59ff4352..51924abf 100644 --- a/config/ext.json +++ b/config/ext.json @@ -341,6 +341,7 @@ "ext-depends": [ "xml" ], + "build-with-php": true, "target": [ "static" ] @@ -461,6 +462,7 @@ "mysqli": { "type": "builtin", "arg-type": "with", + "build-with-php": true, "ext-depends": [ "mysqlnd" ] @@ -468,6 +470,7 @@ "mysqlnd": { "type": "builtin", "arg-type-windows": "with", + "build-with-php": true, "lib-depends": [ "zlib" ] @@ -797,6 +800,7 @@ "type": "builtin", "arg-type": "with-path", "arg-type-windows": "with", + "build-with-php": true, "lib-depends": [ "sqlite" ] @@ -1177,6 +1181,7 @@ "lib-depends": [ "zlib" ], + "build-with-php": true, "target": [ "static" ] diff --git a/src/SPC/builder/linux/LinuxBuilder.php b/src/SPC/builder/linux/LinuxBuilder.php index bb40125a..3995c3a8 100644 --- a/src/SPC/builder/linux/LinuxBuilder.php +++ b/src/SPC/builder/linux/LinuxBuilder.php @@ -7,6 +7,7 @@ namespace SPC\builder\linux; use SPC\builder\unix\UnixBuilderBase; use SPC\exception\PatchException; use SPC\exception\WrongUsageException; +use SPC\store\Config; use SPC\store\FileSystem; use SPC\store\SourcePatcher; use SPC\util\GlobalEnvManager; @@ -283,12 +284,17 @@ class LinuxBuilder extends UnixBuilderBase */ protected function buildEmbed(): void { + $sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared()); + $sharedExts = array_filter($sharedExts, static function ($ext) { + return Config::getExt($ext->getName(), 'build-with-php') === true; + }); + $install_modules = $sharedExts ? 'install-modules' : ''; $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); $concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : ''; shell()->cd(SOURCE_PATH . '/php-src') ->exec('sed -i "s|//lib|/lib|g" Makefile') ->exec('sed -i "s|^EXTENSION_DIR = .*|EXTENSION_DIR = /' . basename(BUILD_MODULES_PATH) . '|" Makefile') - ->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi install-modules install-build install-headers install-programs"); + ->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi {$install_modules} install-build install-headers install-programs"); $ldflags = getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_LDFLAGS') ?: ''; $libDir = BUILD_LIB_PATH; diff --git a/src/SPC/builder/macos/MacOSBuilder.php b/src/SPC/builder/macos/MacOSBuilder.php index 119aa3b7..bcfaf6cf 100644 --- a/src/SPC/builder/macos/MacOSBuilder.php +++ b/src/SPC/builder/macos/MacOSBuilder.php @@ -7,6 +7,7 @@ namespace SPC\builder\macos; use SPC\builder\macos\library\MacOSLibraryBase; use SPC\builder\unix\UnixBuilderBase; use SPC\exception\WrongUsageException; +use SPC\store\Config; use SPC\store\FileSystem; use SPC\store\SourcePatcher; use SPC\util\GlobalEnvManager; @@ -264,10 +265,15 @@ class MacOSBuilder extends UnixBuilderBase */ protected function buildEmbed(): void { + $sharedExts = array_filter($this->exts, static fn ($ext) => $ext->isBuildShared()); + $sharedExts = array_filter($sharedExts, static function ($ext) { + return Config::getExt($ext->getName(), 'build-with-php') === true; + }); + $install_modules = $sharedExts ? 'install-modules' : ''; $vars = SystemUtil::makeEnvVarString($this->getMakeExtraVars()); $concurrency = getenv('SPC_CONCURRENCY') ? '-j' . getenv('SPC_CONCURRENCY') : ''; shell()->cd(SOURCE_PATH . '/php-src') - ->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi install-modules install-build install-headers install-programs"); + ->exec("make {$concurrency} INSTALL_ROOT=" . BUILD_ROOT_PATH . " {$vars} install-sapi {$install_modules} install-build install-headers install-programs"); if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'static') { $AR = getenv('AR') ?: 'ar';