From 05e9129a66f7f4208e73e7bffda3c2b17ebf879a Mon Sep 17 00:00:00 2001 From: henderkes Date: Sat, 17 May 2025 19:01:32 +0700 Subject: [PATCH] refactor dom out to its own extension, fails shared build --- src/SPC/builder/extension/dom.php | 72 +++++++++++++++++++++++++++++++ src/SPC/builder/extension/xml.php | 1 - 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/SPC/builder/extension/dom.php diff --git a/src/SPC/builder/extension/dom.php b/src/SPC/builder/extension/dom.php new file mode 100644 index 00000000..bb2f659f --- /dev/null +++ b/src/SPC/builder/extension/dom.php @@ -0,0 +1,72 @@ +builder))->config([$this->getName()]); + $env = [ + 'CFLAGS' => $config['cflags'] . ' -I' . SOURCE_PATH . '/php-src', + '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') + ->execWithEnv('./configure ' . $this->getUnixConfigureArg(true) . ' --with-php-config=' . BUILD_BIN_PATH . '/php-config --enable-shared --disable-static') + ->execWithEnv('make clean') + ->execWithEnv('make -j' . $this->builder->concurrency); + + // copy shared library + FileSystem::createDir(BUILD_MODULES_PATH); + $extensionDirFile = (getenv('EXTENSION_DIR') ?: $this->source_dir . '/modules') . '/' . $this->getName() . '.so'; + $sourceDirFile = $this->source_dir . '/modules/' . $this->getName() . '.so'; + if (file_exists($extensionDirFile)) { + copy($extensionDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); + } elseif (file_exists($sourceDirFile)) { + copy($sourceDirFile, BUILD_MODULES_PATH . '/' . $this->getName() . '.so'); + } else { + throw new RuntimeException('extension ' . $this->getName() . ' built successfully, but into an unexpected location.'); + } + // check shared extension with php-cli + if (file_exists(BUILD_BIN_PATH . '/php')) { + $this->runSharedExtensionCheckUnix(); + } + } +} diff --git a/src/SPC/builder/extension/xml.php b/src/SPC/builder/extension/xml.php index fc8bfc4d..544585ad 100644 --- a/src/SPC/builder/extension/xml.php +++ b/src/SPC/builder/extension/xml.php @@ -13,7 +13,6 @@ use SPC\util\CustomExt; #[CustomExt('soap')] #[CustomExt('xmlreader')] #[CustomExt('xmlwriter')] -#[CustomExt('dom')] #[CustomExt('simplexml')] class xml extends Extension {