Skip to content

Commit 4bc30b0

Browse files
committed
Add php-src/config.log for SPCException
1 parent 8d30334 commit 4bc30b0

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

src/SPC/ConsoleApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
final class ConsoleApplication extends Application
3636
{
37-
public const string VERSION = '2.7.3';
37+
public const string VERSION = '2.7.4';
3838

3939
public function __construct()
4040
{

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
103103
);
104104
}
105105

106-
shell()->cd(SOURCE_PATH . '/php-src')
107-
->exec(
108-
$php_configure_env . ' ' .
106+
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
107+
$php_configure_env . ' ' .
109108
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
110109
($enableCli ? '--enable-cli ' : '--disable-cli ') .
111110
($enableFpm ? '--enable-fpm ' . ($this->getLib('libacl') !== null ? '--with-fpm-acl ' : '') : '--disable-fpm ') .
@@ -118,7 +117,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
118117
$zts .
119118
$maxExecutionTimers .
120119
$this->makeStaticExtensionArgs() . ' '
121-
);
120+
));
122121

123122
$this->emitPatchPoint('before-php-make');
124123
SourcePatcher::patchBeforeMake($this);

src/SPC/builder/macos/MacOSBuilder.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,8 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
118118
}
119119

120120
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
121-
shell()->cd(SOURCE_PATH . '/php-src')
122-
->exec(
123-
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
121+
$this->seekPhpSrcLogFileOnException(fn () => shell()->cd(SOURCE_PATH . '/php-src')->exec(
122+
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
124123
($enableCli ? '--enable-cli ' : '--disable-cli ') .
125124
($enableFpm ? '--enable-fpm ' : '--disable-fpm ') .
126125
($enableEmbed ? "--enable-embed={$embed_type} " : '--disable-embed ') .
@@ -132,7 +131,7 @@ public function buildPHP(int $build_target = BUILD_TARGET_NONE): void
132131
$zts .
133132
$this->makeStaticExtensionArgs() . ' ' .
134133
$envs_build_php
135-
);
134+
));
136135

137136
$this->emitPatchPoint('before-php-make');
138137
SourcePatcher::patchBeforeMake($this);

src/SPC/builder/unix/UnixBuilderBase.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use SPC\builder\BuilderBase;
88
use SPC\builder\linux\SystemUtil as LinuxSystemUtil;
9+
use SPC\exception\SPCException;
910
use SPC\exception\SPCInternalException;
1011
use SPC\exception\ValidationException;
1112
use SPC\exception\WrongUsageException;
@@ -338,4 +339,20 @@ protected function buildFrankenphp(): void
338339
}
339340
}
340341
}
342+
343+
/**
344+
* Seek php-src/config.log when building PHP, add it to exception.
345+
*/
346+
protected function seekPhpSrcLogFileOnException(callable $callback): void
347+
{
348+
try {
349+
$callback();
350+
} catch (SPCException $e) {
351+
if (file_exists(SOURCE_PATH . '/php-src/config.log')) {
352+
$e->addExtraLogFile('php-src config.log', 'php-src.config.log');
353+
copy(SOURCE_PATH . '/php-src/config.log', SPC_LOGS_DIR . '/php-src.config.log');
354+
}
355+
throw $e;
356+
}
357+
}
341358
}

0 commit comments

Comments
 (0)