Skip to content

Commit

Permalink
[lmdb]: add a zig version check
Browse files Browse the repository at this point in the history
assert at comptime that zig version is greater or equal to 0.13.0
  • Loading branch information
Ultra-Code committed Sep 30, 2024
1 parent a12f111 commit 31fe8a4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const builtin = @import("builtin");
const mem = std.mem;

pub fn build(b: *std.Build) void {
if (comptime !checkVersion())
@compileError("Update your zig toolchain to >= 0.13.0");

const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

Expand Down Expand Up @@ -199,3 +202,15 @@ pub fn build(b: *std.Build) void {
}.make;
test_step.makeFn = create_testdb;
}

// ensures the currently in-use zig version is at least the minimum required
fn checkVersion() bool {
if (!@hasDecl(builtin, "zig_version")) {
return false;
}

const needed_version = std.SemanticVersion{ .major = 0, .minor = 13, .patch = 0 };
const version = builtin.zig_version;
const order = version.order(needed_version);
return order != .lt;
}

0 comments on commit 31fe8a4

Please sign in to comment.