From ed5f3f9b5e7d6edb3da979c17968d203832a2018 Mon Sep 17 00:00:00 2001 From: Techatrix Date: Thu, 11 Jul 2024 21:40:33 +0200 Subject: [PATCH] build: add Zig version check --- build.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.zig b/build.zig index cd52ffa..ef45632 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,21 @@ const std = @import("std"); +const builtin = @import("builtin"); + +const minimum_zig_version = std.SemanticVersion.parse("0.12.0") catch unreachable; pub fn build(b: *std.Build) void { + if (comptime (builtin.zig_version.order(minimum_zig_version) == .lt)) { + @compileError(std.fmt.comptimePrint( + \\Your Zig version does not meet the minimum build requirement: + \\ required Zig version: {[minimum_zig_version]} + \\ actual Zig version: {[current_version]} + \\ + , .{ + .current_version = builtin.zig_version, + .minimum_zig_version = minimum_zig_version, + })); + } + const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{});