Skip to content

Commit 02f2837

Browse files
committed
adjust craft command for zig
1 parent 9e9474a commit 02f2837

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

src/SPC/command/CraftCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ public function handle(): int
7171
$retcode = $this->runCommand('install-pkg', 'go-xcaddy');
7272
if ($retcode !== 0) {
7373
$this->output->writeln('<error>craft go-xcaddy failed</error>');
74-
$this->log("craft go-xcaddy failed with code: {$retcode}", true);
74+
$this->log("craft: spc install-pkg go-xcaddy failed with code: {$retcode}", true);
75+
return static::FAILURE;
76+
}
77+
}
78+
// install zig if requested
79+
if (str_contains(getenv('CC'), 'zig')) {
80+
$retcode = $this->runCommand('install-pkg', 'zig');
81+
if ($retcode !== 0) {
82+
$this->output->writeln('<error>craft zig failed</error>');
83+
$this->log("craft: spc install-pkg zig failed with code: {$retcode}", true);
7584
return static::FAILURE;
7685
}
7786
}

src/SPC/store/pkg/Zig.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ public function fetch(string $name, bool $force = false, ?array $config = null):
3030
default => "{$pkgroot}/{$name}/bin/zig",
3131
};
3232

33-
if (file_exists($zig_exec) && !$force) {
33+
if ($force) {
34+
FileSystem::removeDir($pkgroot . '/' . $name);
35+
}
36+
37+
if (file_exists($zig_exec)) {
3438
return;
3539
}
3640

@@ -73,13 +77,13 @@ public function fetch(string $name, bool $force = false, ?array $config = null):
7377
$url = $download_info['tarball'];
7478
$filename = basename($url);
7579

76-
$config = [
80+
$pkg = [
7781
'type' => 'url',
7882
'url' => $url,
7983
'filename' => $filename,
8084
];
8185

82-
Downloader::downloadPackage($name, $config, $force);
86+
Downloader::downloadPackage($name, $pkg, $force);
8387
}
8488

8589
public function extract(string $name): void
@@ -91,11 +95,7 @@ public function extract(string $name): void
9195
default => "{$zig_bin_dir}/zig",
9296
};
9397

94-
if (file_exists($zig_exec)) {
95-
if (!file_exists("{$zig_bin_dir}/zig-cc")) {
96-
$this->createZigCcScript($zig_bin_dir);
97-
return;
98-
}
98+
if (file_exists($zig_exec) && file_exists("{$zig_bin_dir}/zig-cc")) {
9999
return;
100100
}
101101

0 commit comments

Comments
 (0)