make sure embed can only contain null, static, shared or false

This commit is contained in:
DubbleClick
2025-06-19 22:01:40 +07:00
parent 68c706ed79
commit 02a0b17deb

View File

@@ -295,14 +295,14 @@ class BuildPHPCommand extends BuildCommand
$rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE);
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
$embed = $this->getOption('build-embed');
$embed = $embed === null ? true : $embed;
if (!$embed && !empty($shared_extensions)) {
$embed = true;
}
$embed = match ($embed) {
null => getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static',
'static' => 'static',
'shared' => 'shared',
false => false,
default => throw new WrongUsageException('Invalid --build-embed option, please use --build-embed[=static|shared]'),
};
if ($embed) {
if ($embed === true) {
$embed = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
}
$rule |= BUILD_TARGET_EMBED;
f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared'));
}