From 31fe8a49a0f8ada55c9953f9521db7683e7c6e88 Mon Sep 17 00:00:00 2001 From: Ultra-Code Date: Mon, 30 Sep 2024 12:11:12 +0000 Subject: [PATCH] [lmdb]: add a zig version check assert at comptime that zig version is greater or equal to 0.13.0 --- build.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.zig b/build.zig index 1da2042..ae4f0fd 100644 --- a/build.zig +++ b/build.zig @@ -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(.{}); @@ -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; +}