Skip to content

Commit a12b12f

Browse files
authored
feat: ensure correct zig version on compilation
Ensure library only compiles when the Zig compiler versions match.
2 parents c1685f6 + c7f5ed3 commit a12b12f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

build.zig

+20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
const std = @import("std");
2+
const builtin = @import("builtin");
3+
4+
const zig_version = std.SemanticVersion{
5+
.major = 0,
6+
.minor = 13,
7+
.patch = 0,
8+
};
9+
10+
comptime {
11+
// Compare versions while allowing different pre/patch metadata.
12+
const zig_version_eq = zig_version.major == builtin.zig_version.major and
13+
zig_version.minor == builtin.zig_version.minor and
14+
zig_version.patch == builtin.zig_version.patch;
15+
if (!zig_version_eq) {
16+
@compileError(std.fmt.comptimePrint(
17+
"unsupported zig version: expected {}, found {}",
18+
.{ zig_version, builtin.zig_version },
19+
));
20+
}
21+
}
222

323
pub fn build(b: *std.Build) void {
424
const target = b.standardTargetOptions(.{});

0 commit comments

Comments
 (0)