Add php-src/config.log for SPCException

This commit is contained in:
crazywhalecc 2025-09-07 10:57:44 +08:00 committed by Jerry Ma
parent 8d303348d9
commit 4bc30b0b6f
4 changed files with 24 additions and 9 deletions

View File

@ -34,7 +34,7 @@ use Symfony\Component\Console\Application;
*/ */
final class ConsoleApplication extends Application final class ConsoleApplication extends Application
{ {
public const string VERSION = '2.7.3'; public const string VERSION = '2.7.4';
public function __construct() public function __construct()
{ {

View File

@ -103,8 +103,7 @@ class LinuxBuilder extends UnixBuilderBase
); );
} }
shell()->cd(SOURCE_PATH . '/php-src') $this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
->exec(
$php_configure_env . ' ' . $php_configure_env . ' ' .
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableCli ? '--enable-cli ' : '--disable-cli ') .
@ -118,7 +117,7 @@ class LinuxBuilder extends UnixBuilderBase
$zts . $zts .
$maxExecutionTimers . $maxExecutionTimers .
$this->makeStaticExtensionArgs() . ' ' $this->makeStaticExtensionArgs() . ' '
); ));
$this->emitPatchPoint('before-php-make'); $this->emitPatchPoint('before-php-make');
SourcePatcher::patchBeforeMake($this); SourcePatcher::patchBeforeMake($this);

View File

@ -118,8 +118,7 @@ class MacOSBuilder extends UnixBuilderBase
} }
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static'; $embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
shell()->cd(SOURCE_PATH . '/php-src') $this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
->exec(
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' . getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
($enableCli ? '--enable-cli ' : '--disable-cli ') . ($enableCli ? '--enable-cli ' : '--disable-cli ') .
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') . ($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
@ -132,7 +131,7 @@ class MacOSBuilder extends UnixBuilderBase
$zts . $zts .
$this->makeStaticExtensionArgs() . ' ' . $this->makeStaticExtensionArgs() . ' ' .
$envs_build_php $envs_build_php
); ));
$this->emitPatchPoint('before-php-make'); $this->emitPatchPoint('before-php-make');
SourcePatcher::patchBeforeMake($this); SourcePatcher::patchBeforeMake($this);

View File

@ -6,6 +6,7 @@ namespace SPC\builder\unix;
use SPC\builder\BuilderBase; use SPC\builder\BuilderBase;
use SPC\builder\linux\SystemUtil as LinuxSystemUtil; use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
use SPC\exception\SPCException;
use SPC\exception\SPCInternalException; use SPC\exception\SPCInternalException;
use SPC\exception\ValidationException; use SPC\exception\ValidationException;
use SPC\exception\WrongUsageException; use SPC\exception\WrongUsageException;
@ -338,4 +339,20 @@ abstract class UnixBuilderBase extends BuilderBase
} }
} }
} }
/**
* Seek php-src/config.log when building PHP, add it to exception.
*/
protected function seekPhpSrcLogFileOnException(callable $callback): void
{
try {
$callback();
} catch (SPCException $e) {
if (file_exists(SOURCE_PATH . '/php-src/config.log')) {
$e->addExtraLogFile('php-src config.log', 'php-src.config.log');
copy(SOURCE_PATH . '/php-src/config.log', SPC_LOGS_DIR . '/php-src.config.log');
}
throw $e;
}
}
} }