From bab330b64eae068d47f6bb67784ce0d768b2a7f6 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 25 Oct 2025 03:03:40 +0800 Subject: [PATCH] Unify CGI deploy functions --- src/SPC/builder/windows/WindowsBuilder.php | 9 +++------ src/SPC/store/SourcePatcher.php | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index bd218fb5..76489b02 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -176,11 +176,7 @@ class WindowsBuilder extends BuilderBase cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_cgi_wrapper.bat --task-args php-cgi.exe"); - // deploy cgi binary - logger()->info('Deploying cgi file'); - FileSystem::createDir(BUILD_BIN_PATH); - - cmd()->exec('copy ' . escapeshellarg(SOURCE_PATH . '\php-src\x64\Release' . ($this->zts ? '_TS' : '') . '\php-cgi.exe') . ' ' . escapeshellarg(BUILD_BIN_PATH . '\php-cgi.exe')); + $this->deployBinary(BUILD_TARGET_CGI); } public function buildEmbed(): void @@ -346,12 +342,13 @@ class WindowsBuilder extends BuilderBase $src = match ($type) { BUILD_TARGET_CLI => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\php.exe", BUILD_TARGET_MICRO => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\micro.sfx", + BUILD_TARGET_CGI => SOURCE_PATH . "\\php-src\\x64\\Release{$ts}\\php-cgi.exe", default => throw new SPCInternalException("Deployment does not accept type {$type}"), }; // with-upx-pack for cli and micro if ($this->getOption('with-upx-pack', false)) { - if ($type === BUILD_TARGET_CLI || ($type === BUILD_TARGET_MICRO && version_compare($this->getMicroVersion(), '0.2.0') >= 0)) { + if ($type === BUILD_TARGET_CLI || $type === BUILD_TARGET_CGI || ($type === BUILD_TARGET_MICRO && version_compare($this->getMicroVersion(), '0.2.0') >= 0)) { cmd()->exec(getenv('UPX_EXEC') . ' --best ' . escapeshellarg($src)); } } diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index d9bae08b..1ffe98ea 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -571,7 +571,7 @@ class SourcePatcher */ public static function patchWindowsCGITarget(): void { - // search Makefile code line contains "$(BUILD_DIR)\php.exe:" + // search Makefile code line contains "$(BUILD_DIR)\php-cgi.exe:" $content = FileSystem::readFile(SOURCE_PATH . '/php-src/Makefile'); $lines = explode("\r\n", $content); $line_num = 0;