adjust craft command for zig

This commit is contained in:
DubbleClick 2025-06-28 22:55:30 +07:00
parent 9e9474a026
commit 02f2837f86
2 changed files with 18 additions and 9 deletions

View File

@ -71,7 +71,16 @@ class CraftCommand extends BaseCommand
$retcode = $this->runCommand('install-pkg', 'go-xcaddy');
if ($retcode !== 0) {
$this->output->writeln('<error>craft go-xcaddy failed</error>');
$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('<error>craft zig failed</error>');
$this->log("craft: spc install-pkg zig failed with code: {$retcode}", true);
return static::FAILURE;
}
}

View File

@ -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;
}