Skip to content

Commit c551efb

Browse files
authored
Fix CraftCommand ignoring build-options during build (closes crazywhalecc#732) (crazywhalecc#733)
Unified option to parameter conversion
1 parent aae6c2c commit c551efb

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

src/SPC/command/CraftCommand.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,7 @@ public function handle(): int
7979
$craft['download-options']['ignore-cache-sources'] .= ',php-src';
8080
}
8181
}
82-
$download_options = $craft['download-options'];
83-
foreach ($download_options as $option => $val) {
84-
if (is_bool($val) && $val || is_null($val)) {
85-
$args[] = "--{$option}";
86-
} elseif (is_string($val)) {
87-
$args[] = "--{$option}={$val}";
88-
} elseif (is_array($val)) {
89-
foreach ($val as $v) {
90-
if (is_string($v)) {
91-
$args[] = "--{$option}={$v}";
92-
}
93-
}
94-
}
95-
}
82+
$this->optionsToArguments($craft['download-options'], $args);
9683
$retcode = $this->runCommand('download', ...$args);
9784
if ($retcode !== 0) {
9885
$this->output->writeln('<error>craft download failed</error>');
@@ -104,6 +91,7 @@ public function handle(): int
10491
// craft build
10592
if ($craft['craft-options']['build']) {
10693
$args = [$extensions, "--with-libs={$libs}", ...array_map(fn ($x) => "--build-{$x}", $craft['sapi'])];
94+
$this->optionsToArguments($craft['build-options'], $args);
10795
$retcode = $this->runCommand('build', ...$args);
10896
if ($retcode !== 0) {
10997
$this->output->writeln('<error>craft build failed</error>');
@@ -164,4 +152,27 @@ private function runCommand(string $cmd, ...$args): int
164152
$process->run([$this, 'processLogCallback']);
165153
return $process->getExitCode();
166154
}
155+
156+
private function optionsToArguments(array $options, array &$args): void
157+
{
158+
foreach ($options as $option => $val) {
159+
if ((is_bool($val) && $val) || $val === null) {
160+
$args[] = "--{$option}";
161+
162+
continue;
163+
}
164+
if (is_string($val)) {
165+
$args[] = "--{$option}={$val}";
166+
167+
continue;
168+
}
169+
if (is_array($val)) {
170+
foreach ($val as $v) {
171+
if (is_string($v)) {
172+
$args[] = "--{$option}={$v}";
173+
}
174+
}
175+
}
176+
}
177+
}
167178
}

0 commit comments

Comments
 (0)