authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-25 17:42:27-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-11-25 17:43:27-07:00
log7b78b4fff02e5f59da3034ee739c0eae99a01de5
tree22d29adc7469faae3c7c119aad0acc1e0b136657
parent2006add8496c47804ee3b6c562f420871cb4ea0a

stage2: better error message when copying artifacts fails


1 files changed, 11 insertions(+), 4 deletions(-)

src/Compilation.zig+11-4
......@@ -1885,7 +1885,7 @@ pub fn update(self: *Compilation) !void {
18851885
18861886 // Flush takes care of -femit-bin, but we still have -femit-llvm-ir, -femit-llvm-bc, and
18871887 // -femit-asm to handle, in the case of C objects.
1888 try self.emitOthers();
1888 self.emitOthers();
18891889
18901890 // If there are any errors, we anticipate the source files being loaded
18911891 // to report error messages. Otherwise we unload all source files to save memory.
......@@ -1902,7 +1902,7 @@ pub fn update(self: *Compilation) !void {
19021902 }
19031903}
19041904
1905fn emitOthers(comp: *Compilation) !void {
1905fn emitOthers(comp: *Compilation) void {
19061906 if (comp.bin_file.options.output_mode != .Obj or comp.bin_file.options.module != null or
19071907 comp.c_object_table.count() == 0)
19081908 {
......@@ -1925,9 +1925,16 @@ fn emitOthers(comp: *Compilation) !void {
19251925 for (outs) |out| {
19261926 if (out.emit) |loc| {
19271927 if (loc.directory) |directory| {
1928 const src_path = try std.fmt.allocPrint(comp.gpa, "{s}{s}", .{ basename, out.ext });
1928 const src_path = std.fmt.allocPrint(comp.gpa, "{s}{s}", .{
1929 basename, out.ext,
1930 }) catch |err| {
1931 log.err("unable to copy {s}{s}: {s}", .{ basename, out.ext, @errorName(err) });
1932 continue;
1933 };
19291934 defer comp.gpa.free(src_path);
1930 try cwd.copyFile(src_path, directory.handle, loc.basename, .{});
1935 cwd.copyFile(src_path, directory.handle, loc.basename, .{}) catch |err| {
1936 log.err("unable to copy {s}: {s}", .{ src_path, @errorName(err) });
1937 };
19311938 }
19321939 }
19331940 }