You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.2 KiB
63 lines
2.2 KiB
const std = @import("std"); |
|
const builtin = @import("builtin"); |
|
|
|
fn check_version() void { |
|
const required_zig_version = "0.16.0"; |
|
const current_zig_version = builtin.zig_version_string; |
|
if (std.SemanticVersion.order(try std.SemanticVersion.parse(required_zig_version), try std.SemanticVersion.parse(current_zig_version)) == .gt) { |
|
@compileError("punkres requires zig version: " ++ required_zig_version ++ " to build. Your zig version is: " ++ current_zig_version); |
|
} |
|
} |
|
comptime { |
|
check_version(); |
|
} |
|
|
|
pub fn build(b: *std.Build) void { |
|
const target = b.standardTargetOptions(.{}); |
|
const mode = b.standardOptimizeOption(.{}); |
|
|
|
const exe_mod = b.createModule(.{ |
|
.root_source_file = b.path("./src/punkres.zig"), |
|
.target = target, |
|
.optimize = mode, |
|
}); |
|
const exe = b.addExecutable(.{ |
|
.name = "punkres", |
|
.root_module = exe_mod, |
|
}); |
|
|
|
const install_exe = b.addInstallArtifact(exe, .{}); |
|
b.getInstallStep().dependOn(&install_exe.step); |
|
|
|
const run_cmd = b.addRunArtifact(exe); |
|
run_cmd.step.dependOn(b.getInstallStep()); |
|
if (b.args) |args| { |
|
run_cmd.addArgs(args); |
|
} |
|
const run_step = b.step("run", "Run punkres"); |
|
run_step.dependOn(&run_cmd.step); |
|
|
|
const test_names = [_][]const u8{ "pe", "rsrc", "ico", "overlay", "punkres" }; |
|
const test_step = b.step("test", "Run punkres tests"); |
|
test_step.dependOn(b.getInstallStep()); |
|
inline for (test_names) |tn| { |
|
const mod = b.createModule(.{ |
|
.root_source_file = b.path("./src/" ++ tn ++ "_test.zig"), |
|
.target = target, |
|
.optimize = mode, |
|
}); |
|
const t = b.addTest(.{ |
|
.name = "test_" ++ tn, |
|
.root_module = mod, |
|
}); |
|
const run_t = b.addRunArtifact(t); |
|
//the CLI suite drives the installed binary from zig-out/bin - the run |
|
//itself must wait for install (a step's own install dependency does |
|
//NOT order sibling runs; punkzip build-graph race, 2026-07-27) |
|
if (std.mem.eql(u8, tn, "punkres")) { |
|
run_t.step.dependOn(b.getInstallStep()); |
|
} |
|
test_step.dependOn(&t.step); |
|
test_step.dependOn(&run_t.step); |
|
} |
|
}
|
|
|