diff --git a/build.zig b/build.zig index 44d306b..34d07dc 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,9 @@ const std = @import("std"); +pub const min_zig_version = std.SemanticVersion{ .major = 0, .minor = 12, .patch = 0, .pre = "dev.2158" }; + pub fn build(b: *std.Build) void { + ensureZigVersion() catch return; const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); @@ -16,12 +19,35 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); - lib.addModule("vapoursynth", vapoursynth_dep.module("vapoursynth")); + lib.root_module.addImport("vapoursynth", vapoursynth_dep.module("vapoursynth")); lib.linkLibC(); - if (lib.optimize == .ReleaseFast) { - lib.strip = true; + if (lib.root_module.optimize == .ReleaseFast) { + lib.root_module.strip = true; } b.installArtifact(lib); } + +fn ensureZigVersion() !void { + var installed_ver = @import("builtin").zig_version; + installed_ver.build = null; + + if (installed_ver.order(min_zig_version) == .lt) { + std.log.err("\n" ++ + \\--------------------------------------------------------------------------- + \\ + \\Installed Zig compiler version is too old. + \\ + \\Min. required version: {any} + \\Installed version: {any} + \\ + \\Please install newer version and try again. + \\Latest version can be found here: https://ziglang.org/download/ + \\ + \\--------------------------------------------------------------------------- + \\ + , .{ min_zig_version, installed_ver }); + return error.ZigIsTooOld; + } +}