diff --git a/config/ext.json b/config/ext.json index 89f17dc7..290a079b 100644 --- a/config/ext.json +++ b/config/ext.json @@ -77,12 +77,6 @@ ], "ext-depends-windows": [ "xml" - ], - "shared-ext-depends": [ - "libxml", - "xmlreader", - "xmlwriter", - "xml" ] }, "ds": { @@ -331,13 +325,16 @@ }, "type": "builtin", "arg-type": "none", - "ext-depends": [ - "xml" + "target": [ + "static" ] }, "mbregex": { "type": "builtin", "arg-type": "custom", + "target": [ + "static" + ], "ext-depends": [ "mbstring" ], @@ -1083,6 +1080,9 @@ "arg-type-windows": "enable", "lib-depends": [ "zlib" + ], + "target": [ + "static" ] }, "zstd": { diff --git a/src/SPC/builder/Extension.php b/src/SPC/builder/Extension.php index 6b00bfae..3152dd3e 100644 --- a/src/SPC/builder/Extension.php +++ b/src/SPC/builder/Extension.php @@ -80,7 +80,7 @@ class Extension { $_name = str_replace('_', '-', $this->name); return match ($arg_type = Config::getExt($this->name, 'arg-type', 'enable')) { - 'enable' => '--enable-' . $_name . ' ', + 'enable' => '--enable-' . $_name . ($shared ? '=shared' : '') . ' ', 'with' => '--with-' . $_name . ($shared ? '=shared' : '') . ' ', 'with-prefix' => '--with-' . $_name . '=' . ($shared ? 'shared,' : '') . '"' . BUILD_ROOT_PATH . '" ', 'none', 'custom' => '', diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php index 4a69c0a5..abda5651 100644 --- a/src/SPC/builder/extension/dba.php +++ b/src/SPC/builder/extension/dba.php @@ -13,7 +13,7 @@ class dba extends Extension public function getUnixConfigureArg(bool $shared = false): string { $qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH) : ''; - return '--enable-dba' . $qdbm; + return '--enable-dba' . ($shared ? '=shared' : '') . $qdbm; } public function getWindowsConfigureArg(bool $shared = false): string diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php index 46dae9e2..fb1a4e15 100644 --- a/src/SPC/builder/extension/dom.php +++ b/src/SPC/builder/extension/dom.php @@ -18,9 +18,7 @@ class dom extends Extension public function getUnixConfigureArg(bool $shared = false): string { $arg = '--enable-dom' . ($shared ? '=shared' : ''); - if (!$shared) { - $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; - } + $arg .= ' --with-libxml="' . BUILD_ROOT_PATH . '"'; return $arg; } diff --git a/src/SPC/builder/extension/mbstring.php b/src/SPC/builder/extension/mbstring.php index 697ad3fe..3576877f 100644 --- a/src/SPC/builder/extension/mbstring.php +++ b/src/SPC/builder/extension/mbstring.php @@ -12,7 +12,7 @@ class mbstring extends Extension { public function getConfigureArg(bool $shared = false): string { - $arg = '--enable-mbstring'; + $arg = '--enable-mbstring' . ($shared ? '=shared' : ''); if ($this->builder->getExt('mbregex') === null) { $arg .= ' --disable-mbregex'; } else { diff --git a/src/SPC/builder/extension/odbc.php b/src/SPC/builder/extension/odbc.php index ac5c3e8f..278b5865 100644 --- a/src/SPC/builder/extension/odbc.php +++ b/src/SPC/builder/extension/odbc.php @@ -12,6 +12,6 @@ class odbc extends Extension { public function getUnixConfigureArg(bool $shared = false): string { - return '--with-unixODBC=' . BUILD_ROOT_PATH; + return '--with-unixODBC=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } } diff --git a/src/SPC/builder/extension/pdo_odbc.php b/src/SPC/builder/extension/pdo_odbc.php index ac1b7456..c47144fe 100644 --- a/src/SPC/builder/extension/pdo_odbc.php +++ b/src/SPC/builder/extension/pdo_odbc.php @@ -19,7 +19,7 @@ class pdo_odbc extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--with-pdo-odbc=unixODBC,' . BUILD_ROOT_PATH; + return '--with-pdo-odbc=' . ($shared ? 'shared,' : '') . 'unixODBC,' . BUILD_ROOT_PATH; } public function getWindowsConfigureArg(bool $shared = false): string diff --git a/src/SPC/builder/extension/pgsql.php b/src/SPC/builder/extension/pgsql.php index e4ac8ebb..b45ba667 100644 --- a/src/SPC/builder/extension/pgsql.php +++ b/src/SPC/builder/extension/pgsql.php @@ -36,9 +36,9 @@ class pgsql extends Extension public function getUnixConfigureArg(bool $shared = false): string { if ($this->builder->getPHPVersionID() >= 80400) { - return '--with-pgsql PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"'; + return '--with-pgsql' . ($shared ? '=shared' : '') . ' PGSQL_CFLAGS=-I' . BUILD_INCLUDE_PATH . ' PGSQL_LIBS="-L' . BUILD_LIB_PATH . ' -lpq -lpgport -lpgcommon"'; } - return '--with-pgsql=' . BUILD_ROOT_PATH; + return '--with-pgsql=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } /** diff --git a/src/SPC/builder/extension/readline.php b/src/SPC/builder/extension/readline.php index dc4d15f7..5cb5eff3 100644 --- a/src/SPC/builder/extension/readline.php +++ b/src/SPC/builder/extension/readline.php @@ -27,7 +27,7 @@ class readline extends Extension public function getUnixConfigureArg(bool $shared = false): string { - return '--without-libedit --with-readline=' . BUILD_ROOT_PATH; + return '--without-libedit --with-readline=' . ($shared ? 'shared,' : '') . BUILD_ROOT_PATH; } public function buildUnixShared(): void diff --git a/src/SPC/builder/extension/sqlsrv.php b/src/SPC/builder/extension/sqlsrv.php index edf5d919..22aef95b 100644 --- a/src/SPC/builder/extension/sqlsrv.php +++ b/src/SPC/builder/extension/sqlsrv.php @@ -7,6 +7,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('sqlsrv')] class sqlsrv extends Extension @@ -33,4 +34,35 @@ class sqlsrv extends Extension } return false; } + + public function buildUnixShared(): void + { + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'], + 'CXXFLAGS' => $config['cflags'], + 'LDFLAGS' => $config['ldflags'], + 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, + ]; + // prepare configure args + shell()->cd($this->source_dir) + ->setEnv($env) + ->execWithEnv(BUILD_BIN_PATH . '/phpize'); + + if ($this->patchBeforeSharedConfigure()) { + logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); + } + + shell()->cd($this->source_dir) + ->setEnv($env) + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency) + ->execWithEnv('make install'); + + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } } } diff --git a/src/SPC/builder/extension/xhprof.php b/src/SPC/builder/extension/xhprof.php index c3d98aac..118a34cd 100644 --- a/src/SPC/builder/extension/xhprof.php +++ b/src/SPC/builder/extension/xhprof.php @@ -7,6 +7,7 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\store\FileSystem; use SPC\util\CustomExt; +use SPC\util\SPCConfigUtil; #[CustomExt('xhprof')] class xhprof extends Extension @@ -30,4 +31,35 @@ class xhprof extends Extension } return false; } + + public function buildUnixShared(): void + { + $config = (new SPCConfigUtil($this->builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'], + 'LDFLAGS' => $config['ldflags'], + 'LIBS' => $config['libs'], + 'LD_LIBRARY_PATH' => BUILD_LIB_PATH, + ]; + // prepare configure args + shell()->cd($this->source_dir . '/extension') + ->setEnv($env) + ->execWithEnv(BUILD_BIN_PATH . '/phpize'); + + if ($this->patchBeforeSharedConfigure()) { + logger()->info('ext [ . ' . $this->getName() . '] patching before shared configure'); + } + + shell()->cd($this->source_dir . '/extension') + ->setEnv($env) + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --with-pic') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency) + ->execWithEnv('make install'); + + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } + } } diff --git a/src/SPC/command/BuildPHPCommand.php b/src/SPC/command/BuildPHPCommand.php index edeb7c47..cd83c1c8 100644 --- a/src/SPC/command/BuildPHPCommand.php +++ b/src/SPC/command/BuildPHPCommand.php @@ -249,7 +249,11 @@ class BuildPHPCommand extends BuildCommand if (!empty($shared_extensions)) { foreach ($shared_extensions as $ext) { $path = FileSystem::convertPath("{$build_root_path}/modules/{$ext}.so"); - logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); + if (file_exists("{$build_root_path}/modules/{$ext}.so")) { + logger()->info("Shared extension [{$ext}] path{$fixed}: {$path}"); + } else { + logger()->warning("Shared extension [{$ext}] not found, please check!"); + } } }