authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-11 02:25:33+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-06-12 17:51:30+01:00
log1b27369acbb2009935d49c6906363e8fa425313a
tree2bc46951ce1e168c22ff21ac39cf4af849bd605b
parent7f2f107a1ed451c94da0db6ff559bfee3ce512a5
signaturelock-open Commit is signed but in an unrecognized format.

cli: correctly error for missing output directories


1 files changed, 20 insertions(+), 2 deletions(-)

src/main.zig+20-2
......@@ -712,7 +712,16 @@ const Emit = union(enum) {
712712 .{ @tagName(reason), path },
713713 ),
714714 }
715 } else .{ .yes_path = path },
715 } else e: {
716 // If there's a dirname, check that dir exists. This will give a more descriptive error than `Compilation` otherwise would.
717 if (fs.path.dirname(path)) |dir_path| {
718 var dir = fs.cwd().openDir(dir_path, .{}) catch |err| {
719 fatal("unable to open output directory '{s}': {s}", .{ dir_path, @errorName(err) });
720 };
721 dir.close();
722 }
723 break :e .{ .yes_path = path };
724 },
716725 };
717726 }
718727};
......@@ -3220,7 +3229,16 @@ fn buildOutputType(
32203229 .yes => |path| if (output_to_cache != null) {
32213230 assert(output_to_cache == .listen); // there was an explicit bin path
32223231 fatal("--listen incompatible with explicit output path '{s}'", .{path});
3223 } else .{ .yes_path = path },
3232 } else emit: {
3233 // If there's a dirname, check that dir exists. This will give a more descriptive error than `Compilation` otherwise would.
3234 if (fs.path.dirname(path)) |dir_path| {
3235 var dir = fs.cwd().openDir(dir_path, .{}) catch |err| {
3236 fatal("unable to open output directory '{s}': {s}", .{ dir_path, @errorName(err) });
3237 };
3238 dir.close();
3239 }
3240 break :emit .{ .yes_path = path };
3241 },
32243242 .yes_a_out => emit: {
32253243 assert(output_to_cache == null);
32263244 break :emit .{ .yes_path = switch (target.ofmt) {