| ... | @@ -2112,12 +2112,37 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, hook: AfterUpdateHook) !voi | ... | @@ -2112,12 +2112,37 @@ fn updateModule(gpa: *Allocator, comp: *Compilation, hook: AfterUpdateHook) !voi |
| 2112 | } else switch (hook) { | 2112 | } else switch (hook) { |
| 2113 | .none => {}, | 2113 | .none => {}, |
| 2114 | .print => |bin_path| try io.getStdOut().writer().print("{s}\n", .{bin_path}), | 2114 | .print => |bin_path| try io.getStdOut().writer().print("{s}\n", .{bin_path}), |
| 2115 | .update => |full_path| _ = try comp.bin_file.options.emit.?.directory.handle.updateFile( | 2115 | .update => |full_path| { |
| 2116 | comp.bin_file.options.emit.?.sub_path, | 2116 | const bin_sub_path = comp.bin_file.options.emit.?.sub_path; |
| 2117 | fs.cwd(), | 2117 | const cwd = fs.cwd(); |
| 2118 | full_path, | 2118 | const cache_dir = comp.bin_file.options.emit.?.directory.handle; |
| 2119 | .{}, | 2119 | _ = try cache_dir.updateFile(bin_sub_path, cwd, full_path, .{}); |
| 2120 | ), | 2120 | |
| | 2121 | // If a .pdb file is part of the expected output, we must also copy |
| | 2122 | // it into place here. |
| | 2123 | const coff_or_pe = switch (comp.bin_file.options.object_format) { |
| | 2124 | .coff, .pe => true, |
| | 2125 | else => false, |
| | 2126 | }; |
| | 2127 | const have_pdb = coff_or_pe and !comp.bin_file.options.strip; |
| | 2128 | if (have_pdb) { |
| | 2129 | // Replace `.out` or `.exe` with `.pdb` on both the source and destination |
| | 2130 | const src_bin_ext = fs.path.extension(bin_sub_path); |
| | 2131 | const dst_bin_ext = fs.path.extension(full_path); |
| | 2132 | |
| | 2133 | const src_pdb_path = try std.fmt.allocPrint(gpa, "{s}.pdb", .{ |
| | 2134 | bin_sub_path[0 .. bin_sub_path.len - src_bin_ext.len], |
| | 2135 | }); |
| | 2136 | defer gpa.free(src_pdb_path); |
| | 2137 | |
| | 2138 | const dst_pdb_path = try std.fmt.allocPrint(gpa, "{s}.pdb", .{ |
| | 2139 | full_path[0 .. full_path.len - dst_bin_ext.len], |
| | 2140 | }); |
| | 2141 | defer gpa.free(dst_pdb_path); |
| | 2142 | |
| | 2143 | _ = try cache_dir.updateFile(src_pdb_path, cwd, dst_pdb_path, .{}); |
| | 2144 | } |
| | 2145 | }, |
| 2121 | } | 2146 | } |
| 2122 | } | 2147 | } |
| 2123 | | 2148 | |