From 2717b0fba19daba897f86dd6de4b8b590bfee516 Mon Sep 17 00:00:00 2001 From: Techatrix <19954306+Techatrix@users.noreply.github.com> Date: Fri, 6 Jan 2023 18:59:58 +0000 Subject: [PATCH] Verify minimum zig version at comptime (#885) * verify minimum zig version at comptime * run zig fmt --- build.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/build.zig b/build.zig index d96dd1f..039f5fe 100644 --- a/build.zig +++ b/build.zig @@ -5,10 +5,13 @@ const shared = @import("src/shared.zig"); const zls_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 }; pub fn build(b: *std.build.Builder) !void { - const current_zig = builtin.zig_version; - const min_zig = std.SemanticVersion.parse("0.11.0-dev.874+40ed6ae84") catch return; // Changes to builtin.Type API - if (current_zig.order(min_zig).compare(.lt)) @panic(b.fmt("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig })); - + comptime { + const current_zig = builtin.zig_version; + const min_zig = std.SemanticVersion.parse("0.11.0-dev.874+40ed6ae84") catch return; // Changes to builtin.Type API + if (current_zig.order(min_zig) == .lt) { + @compileError(std.fmt.comptimePrint("Your Zig version v{} does not meet the minimum build requirement of v{}", .{ current_zig, min_zig })); + } + } const target = b.standardTargetOptions(.{}); const mode = b.standardReleaseOptions(); @@ -49,7 +52,7 @@ pub fn build(b: *std.build.Builder) !void { "enable_tracy_callstack", b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse false, ); - + exe_options.addOption( bool, "enable_failing_allocator",