From 4a2b23c2beb043c1e5368d3737893494d61d4060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 13 Aug 2024 23:38:02 +0200 Subject: [PATCH] build: Use the new b.addFail() for the update-mingw step. This is precisely the kind of use case it was added for. --- build.zig | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/build.zig b/build.zig index 085201e9548600307b9edb3d81c7a4b14050479f..e67ba0a9d1796dfb7fbcb3c1e8b46d908c21bfa8 100644 --- a/build.zig +++ b/build.zig @@ -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 }); + + update_mingw_step.dependOn(&update_mingw_run.step); } else { - // Intentionally cause an error if this build step is requested. - update_mingw_run.addArg("--missing-mingw-source-directory"); + update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step); } - - update_mingw_step.dependOn(&update_mingw_run.step); } fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { -- 2.54.0