authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-08 18:48:03-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-07-08 18:48:03-04:00
logeebb00193d9e4531438b0f8c5dbcbea9a90e6a7e
treec46475c5da33c3d0e214683ca80db677e3041aca
parent1d2fc446bd1cf90fb93a1164538dcc4530a06d33
signaturelock-open Commit is signed but in an unrecognized format.

zig build: install .pdb files along with binaries

closes #2848

1 files changed, 27 insertions(+), 0 deletions(-)

std/build.zig+27
......@@ -1040,6 +1040,7 @@ pub const LibExeObjStep = struct {
10401040 root_src: ?[]const u8,
10411041 out_h_filename: []const u8,
10421042 out_lib_filename: []const u8,
1043 out_pdb_filename: []const u8,
10431044 packages: ArrayList(Pkg),
10441045 build_options_contents: std.Buffer,
10451046 system_linker_hack: bool,
......@@ -1125,6 +1126,7 @@ pub const LibExeObjStep = struct {
11251126 .out_filename = undefined,
11261127 .out_h_filename = builder.fmt("{}.h", name),
11271128 .out_lib_filename = undefined,
1129 .out_pdb_filename = builder.fmt("{}.pdb", name),
11281130 .major_only_filename = undefined,
11291131 .name_only_filename = undefined,
11301132 .packages = ArrayList(Pkg).init(builder.allocator),
......@@ -1367,6 +1369,16 @@ pub const LibExeObjStep = struct {
13671369 ) catch unreachable;
13681370 }
13691371
1372 /// Unless setOutputDir was called, this function must be called only in
1373 /// the make step, from a step that has declared a dependency on this one.
1374 pub fn getOutputPdbPath(self: *LibExeObjStep) []const u8 {
1375 assert(self.target.isWindows());
1376 return fs.path.join(
1377 self.builder.allocator,
1378 [_][]const u8{ self.output_dir.?, self.out_pdb_filename },
1379 ) catch unreachable;
1380 }
1381
13701382 pub fn addAssemblyFile(self: *LibExeObjStep, path: []const u8) void {
13711383 self.link_objects.append(LinkObject{ .AssemblyFile = self.builder.dupe(path) }) catch unreachable;
13721384 }
......@@ -1831,6 +1843,7 @@ const InstallArtifactStep = struct {
18311843 builder: *Builder,
18321844 artifact: *LibExeObjStep,
18331845 dest_dir: InstallDir,
1846 pdb_dir: ?InstallDir,
18341847
18351848 const Self = @This();
18361849
......@@ -1848,6 +1861,13 @@ const InstallArtifactStep = struct {
18481861 .Exe => InstallDir.Bin,
18491862 .Lib => InstallDir.Lib,
18501863 },
1864 .pdb_dir = if (artifact.target.isWindows() and !artifact.strip) blk: {
1865 if (artifact.kind == .Exe) {
1866 break :blk InstallDir.Bin;
1867 } else {
1868 break :blk InstallDir.Lib;
1869 }
1870 } else null,
18511871 };
18521872 self.step.dependOn(&artifact.step);
18531873 artifact.install_step = self;
......@@ -1857,6 +1877,9 @@ const InstallArtifactStep = struct {
18571877 builder.pushInstalledFile(.Lib, artifact.major_only_filename);
18581878 builder.pushInstalledFile(.Lib, artifact.name_only_filename);
18591879 }
1880 if (self.pdb_dir) |pdb_dir| {
1881 builder.pushInstalledFile(pdb_dir, artifact.out_pdb_filename);
1882 }
18601883 return self;
18611884 }
18621885
......@@ -1878,6 +1901,10 @@ const InstallArtifactStep = struct {
18781901 if (self.artifact.isDynamicLibrary()) {
18791902 try doAtomicSymLinks(builder.allocator, full_dest_path, self.artifact.major_only_filename, self.artifact.name_only_filename);
18801903 }
1904 if (self.pdb_dir) |pdb_dir| {
1905 const full_pdb_path = builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);
1906 try builder.copyFile(self.artifact.getOutputPdbPath(), full_pdb_path);
1907 }
18811908 self.artifact.installed_path = full_dest_path;
18821909 }
18831910};