Skip to content

Commit eb50a06

Browse files
committed
Add no fail option
1 parent 304298d commit eb50a06

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

build.zig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ pub fn build(b: *std.Build) !void {
55
const target = b.standardTargetOptions(.{});
66
const optimize = b.standardOptimizeOption(.{});
77

8+
const no_fail = b.option(bool, "no_fail", "Ignore build panic") orelse false;
9+
10+
switch (target.result.os.tag) {
11+
.windows, .macos, .linux => {},
12+
else => if (no_fail) return else @panic("Unsupported OS"),
13+
}
14+
switch (target.result.cpu.arch) {
15+
.x86_64, .arm, .aarch64, .riscv64 => {},
16+
else => if (no_fail) return else @panic("Unsupported CPU architecture"),
17+
}
18+
819
const tcc_dep = b.dependency("tinycc", .{});
920

1021
const build_native_target: std.Build.ResolvedTarget = .{
@@ -91,7 +102,7 @@ pub fn build(b: *std.Build) !void {
91102
for (RISCV64_SOURCES) |file|
92103
try C_SOURCES.append(file);
93104
},
94-
else => @panic("Unsupported CPU architecture"),
105+
else => unreachable,
95106
}
96107

97108
switch (os_tag) {
@@ -104,7 +115,7 @@ pub fn build(b: *std.Build) !void {
104115
try C_SOURCES.append(file);
105116
},
106117
.linux => {},
107-
else => @panic("Unsupported OS"),
118+
else => unreachable,
108119
}
109120

110121
switch (cpu_arch) {

0 commit comments

Comments
 (0)