Skip to content

Commit 8293160

Browse files
authored
fix bug with only --build-embed (#781)
* passing --build-embed sets the result to NULL, not true (and not false, like for options that are not passed) * prettify * make sure embed can only contain null, static, shared or false
1 parent c3b520c commit 8293160

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/SPC/command/BuildPHPCommand.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public function handle(): int
7474

7575
if ($rule === BUILD_TARGET_NONE) {
7676
$this->output->writeln('<error>Please add at least one build SAPI!</error>');
77-
$this->output->writeln("<comment>\t--build-cli\tBuild php-cli SAPI</comment>");
78-
$this->output->writeln("<comment>\t--build-micro\tBuild phpmicro SAPI</comment>");
79-
$this->output->writeln("<comment>\t--build-fpm\tBuild php-fpm SAPI</comment>");
80-
$this->output->writeln("<comment>\t--build-embed\tBuild embed SAPI/libphp</comment>");
77+
$this->output->writeln("<comment>\t--build-cli\t\tBuild php-cli SAPI</comment>");
78+
$this->output->writeln("<comment>\t--build-micro\t\tBuild phpmicro SAPI</comment>");
79+
$this->output->writeln("<comment>\t--build-fpm\t\tBuild php-fpm SAPI</comment>");
80+
$this->output->writeln("<comment>\t--build-embed\t\tBuild embed SAPI/libphp</comment>");
8181
$this->output->writeln("<comment>\t--build-frankenphp\tBuild FrankenPHP SAPI/libphp</comment>");
82-
$this->output->writeln("<comment>\t--build-all\tBuild all SAPI: cli, micro, fpm, embed, frankenphp</comment>");
82+
$this->output->writeln("<comment>\t--build-all\t\tBuild all SAPI: cli, micro, fpm, embed, frankenphp</comment>");
8383
return static::FAILURE;
8484
}
8585
if ($rule === BUILD_TARGET_ALL) {
@@ -290,13 +290,14 @@ private function parseRules(array $shared_extensions = []): int
290290
$rule |= ($this->getOption('build-micro') ? BUILD_TARGET_MICRO : BUILD_TARGET_NONE);
291291
$rule |= ($this->getOption('build-fpm') ? BUILD_TARGET_FPM : BUILD_TARGET_NONE);
292292
$embed = $this->getOption('build-embed');
293-
if (!$embed && !empty($shared_extensions)) {
294-
$embed = true;
295-
}
293+
$embed = match ($embed) {
294+
null => getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static',
295+
'static' => 'static',
296+
'shared' => 'shared',
297+
false => false,
298+
default => throw new WrongUsageException('Invalid --build-embed option, please use --build-embed[=static|shared]'),
299+
};
296300
if ($embed) {
297-
if ($embed === true) {
298-
$embed = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
299-
}
300301
$rule |= BUILD_TARGET_EMBED;
301302
f_putenv('SPC_CMD_VAR_PHP_EMBED_TYPE=' . ($embed === 'static' ? 'static' : 'shared'));
302303
}

0 commit comments

Comments
 (0)