Verify minimum zig version at comptime (#885)

* verify minimum zig version at comptime

* run zig fmt
This commit is contained in:
Techatrix 2023-01-06 18:59:58 +00:00 committed by GitHub
parent 3f2700eaa5
commit 2717b0fba1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,10 +5,13 @@ const shared = @import("src/shared.zig");
const zls_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 }; const zls_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 };
pub fn build(b: *std.build.Builder) !void { pub fn build(b: *std.build.Builder) !void {
const current_zig = builtin.zig_version; comptime {
const min_zig = std.SemanticVersion.parse("0.11.0-dev.874+40ed6ae84") catch return; // Changes to builtin.Type API const current_zig = builtin.zig_version;
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 })); 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 target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions(); const mode = b.standardReleaseOptions();
@ -49,7 +52,7 @@ pub fn build(b: *std.build.Builder) !void {
"enable_tracy_callstack", "enable_tracy_callstack",
b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse false, b.option(bool, "enable_tracy_callstack", "Enable callstack graphs.") orelse false,
); );
exe_options.addOption( exe_options.addOption(
bool, bool,
"enable_failing_allocator", "enable_failing_allocator",