build: Use the new b.addFail() for the update-mingw step.

This is precisely the kind of use case it was added for.
This commit is contained in:
Alex Rønne Petersen 2024-08-13 23:38:02 +02:00
parent 019c0fc184
commit 4a2b23c2be
No known key found for this signature in database

View file

@ -537,21 +537,20 @@ pub fn build(b: *std.Build) !void {
const update_mingw_step = b.step("update-mingw", "Update zig's bundled mingw");
const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory");
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.graph.host,
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(b.path("lib"));
if (opt_mingw_src_path) |mingw_src_path| {
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.graph.host,
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(b.path("lib"));
update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });
} else {
// Intentionally cause an error if this build step is requested.
update_mingw_run.addArg("--missing-mingw-source-directory");
}
update_mingw_step.dependOn(&update_mingw_run.step);
update_mingw_step.dependOn(&update_mingw_run.step);
} else {
update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step);
}
}
fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {