diff --git a/src/SPC/command/CraftCommand.php b/src/SPC/command/CraftCommand.php index c8003a3e..7f6f506b 100644 --- a/src/SPC/command/CraftCommand.php +++ b/src/SPC/command/CraftCommand.php @@ -71,7 +71,16 @@ class CraftCommand extends BaseCommand $retcode = $this->runCommand('install-pkg', 'go-xcaddy'); if ($retcode !== 0) { $this->output->writeln('craft go-xcaddy failed'); - $this->log("craft go-xcaddy failed with code: {$retcode}", true); + $this->log("craft: spc install-pkg go-xcaddy failed with code: {$retcode}", true); + return static::FAILURE; + } + } + // install zig if requested + if (str_contains(getenv('CC'), 'zig')) { + $retcode = $this->runCommand('install-pkg', 'zig'); + if ($retcode !== 0) { + $this->output->writeln('craft zig failed'); + $this->log("craft: spc install-pkg zig failed with code: {$retcode}", true); return static::FAILURE; } } diff --git a/src/SPC/store/pkg/Zig.php b/src/SPC/store/pkg/Zig.php index 7b1f9fcd..ded55120 100644 --- a/src/SPC/store/pkg/Zig.php +++ b/src/SPC/store/pkg/Zig.php @@ -30,7 +30,11 @@ class Zig extends CustomPackage default => "{$pkgroot}/{$name}/bin/zig", }; - if (file_exists($zig_exec) && !$force) { + if ($force) { + FileSystem::removeDir($pkgroot . '/' . $name); + } + + if (file_exists($zig_exec)) { return; } @@ -73,13 +77,13 @@ class Zig extends CustomPackage $url = $download_info['tarball']; $filename = basename($url); - $config = [ + $pkg = [ 'type' => 'url', 'url' => $url, 'filename' => $filename, ]; - Downloader::downloadPackage($name, $config, $force); + Downloader::downloadPackage($name, $pkg, $force); } public function extract(string $name): void @@ -91,11 +95,7 @@ class Zig extends CustomPackage default => "{$zig_bin_dir}/zig", }; - if (file_exists($zig_exec)) { - if (!file_exists("{$zig_bin_dir}/zig-cc")) { - $this->createZigCcScript($zig_bin_dir); - return; - } + if (file_exists($zig_exec) && file_exists("{$zig_bin_dir}/zig-cc")) { return; }