authorgravatar for mogud@qq.commogud <mogud@qq.com> 2019-12-19 11:10:17+08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-31 02:25:57-05:00
logd972d1c9428f7ee762462dd0f074b6db6896790f
tree7c494d0324e76711d52280832d4e653bda19e89d
parent86ba8c06bff84ac4865cef18080fa64fe946cb11

generate header in separate folder


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

lib/std/build.zig+16-2
......@@ -45,6 +45,7 @@ pub const Builder = struct {
4545 dest_dir: ?[]const u8,
4646 lib_dir: []const u8,
4747 exe_dir: []const u8,
48 h_dir: []const u8,
4849 install_path: []const u8,
4950 search_prefixes: ArrayList([]const u8),
5051 installed_files: ArrayList(InstalledFile),
......@@ -145,6 +146,7 @@ pub const Builder = struct {
145146 .install_prefix = null,
146147 .lib_dir = undefined,
147148 .exe_dir = undefined,
149 .h_dir = undefined,
148150 .dest_dir = env_map.get("DESTDIR"),
149151 .installed_files = ArrayList(InstalledFile).init(allocator),
150152 .install_tls = TopLevelStep{
......@@ -197,6 +199,7 @@ pub const Builder = struct {
197199 }
198200 self.lib_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "lib" }) catch unreachable;
199201 self.exe_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "bin" }) catch unreachable;
202 self.h_dir = fs.path.join(self.allocator, &[_][]const u8{ self.install_path, "include" }) catch unreachable;
200203 }
201204
202205 pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
......@@ -933,6 +936,7 @@ pub const Builder = struct {
933936 .Prefix => self.install_path,
934937 .Bin => self.exe_dir,
935938 .Lib => self.lib_dir,
939 .Header => self.h_dir,
936940 };
937941 return fs.path.resolve(
938942 self.allocator,
......@@ -2171,6 +2175,7 @@ const InstallArtifactStep = struct {
21712175 artifact: *LibExeObjStep,
21722176 dest_dir: InstallDir,
21732177 pdb_dir: ?InstallDir,
2178 h_dir: ?InstallDir,
21742179
21752180 const Self = @This();
21762181
......@@ -2185,8 +2190,8 @@ const InstallArtifactStep = struct {
21852190 .dest_dir = switch (artifact.kind) {
21862191 .Obj => unreachable,
21872192 .Test => unreachable,
2188 .Exe => InstallDir.Bin,
2189 .Lib => InstallDir.Lib,
2193 .Exe => .Bin,
2194 .Lib => .Lib,
21902195 },
21912196 .pdb_dir = if (artifact.producesPdbFile()) blk: {
21922197 if (artifact.kind == .Exe) {
......@@ -2195,6 +2200,7 @@ const InstallArtifactStep = struct {
21952200 break :blk InstallDir.Lib;
21962201 }
21972202 } else null,
2203 .h_dir = if (artifact.kind == .Lib and !artifact.disable_gen_h) .Header else null,
21982204 };
21992205 self.step.dependOn(&artifact.step);
22002206 artifact.install_step = self;
......@@ -2210,6 +2216,9 @@ const InstallArtifactStep = struct {
22102216 if (self.pdb_dir) |pdb_dir| {
22112217 builder.pushInstalledFile(pdb_dir, artifact.out_pdb_filename);
22122218 }
2219 if (self.h_dir) |h_dir| {
2220 builder.pushInstalledFile(h_dir, artifact.out_h_filename);
2221 }
22132222 return self;
22142223 }
22152224
......@@ -2226,6 +2235,10 @@ const InstallArtifactStep = struct {
22262235 const full_pdb_path = builder.getInstallPath(pdb_dir, self.artifact.out_pdb_filename);
22272236 try builder.updateFile(self.artifact.getOutputPdbPath(), full_pdb_path);
22282237 }
2238 if (self.h_dir) |h_dir| {
2239 const full_pdb_path = builder.getInstallPath(h_dir, self.artifact.out_h_filename);
2240 try builder.updateFile(self.artifact.getOutputHPath(), full_pdb_path);
2241 }
22292242 self.artifact.installed_path = full_dest_path;
22302243 }
22312244};
......@@ -2478,6 +2491,7 @@ pub const InstallDir = enum {
24782491 Prefix,
24792492 Lib,
24802493 Bin,
2494 Header,
24812495};
24822496
24832497pub const InstalledFile = struct {