authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2020-09-11 01:59:06+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-11 04:32:36-04:00
log68bf29c31efb770d7e25d0922c9305673e606f36
tree22cbb3556041a928ac5e2f9981adf01bdaa1719c
parentc41cd3e13a51864728009ba73d9297259defb005

std: allow overriding install dir of artifacts

This is necessary when, for example, writing a PAM module which should be installed to lib/security/module_name.so.

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

lib/std/build.zig+16-10
...@@ -1048,6 +1048,7 @@ pub const Builder = struct {...@@ -1048,6 +1048,7 @@ pub const Builder = struct {
1048 .Bin => self.exe_dir,1048 .Bin => self.exe_dir,
1049 .Lib => self.lib_dir,1049 .Lib => self.lib_dir,
1050 .Header => self.h_dir,1050 .Header => self.h_dir,
1051 .Custom => |path| fs.path.join(self.allocator, &[_][]const u8{ self.install_path, path }) catch unreachable,
1051 };1052 };
1052 return fs.path.resolve(1053 return fs.path.resolve(
1053 self.allocator,1054 self.allocator,
...@@ -1212,6 +1213,8 @@ pub const LibExeObjStep = struct {...@@ -1212,6 +1213,8 @@ pub const LibExeObjStep = struct {
1212 is_linking_libc: bool = false,1213 is_linking_libc: bool = false,
1213 vcpkg_bin_path: ?[]const u8 = null,1214 vcpkg_bin_path: ?[]const u8 = null,
12141215
1216 /// This may be set in order to override the default install directory
1217 override_dest_dir: ?InstallDir,
1215 installed_path: ?[]const u8,1218 installed_path: ?[]const u8,
1216 install_step: ?*InstallArtifactStep,1219 install_step: ?*InstallArtifactStep,
12171220
...@@ -1348,6 +1351,7 @@ pub const LibExeObjStep = struct {...@@ -1348,6 +1351,7 @@ pub const LibExeObjStep = struct {
1348 .rdynamic = false,1351 .rdynamic = false,
1349 .output_dir = null,1352 .output_dir = null,
1350 .single_threaded = false,1353 .single_threaded = false,
1354 .override_dest_dir = null,
1351 .installed_path = null,1355 .installed_path = null,
1352 .install_step = null,1356 .install_step = null,
1353 };1357 };
...@@ -2309,17 +2313,17 @@ pub const InstallArtifactStep = struct {...@@ -2309,17 +2313,17 @@ pub const InstallArtifactStep = struct {
2309 .builder = builder,2313 .builder = builder,
2310 .step = Step.init(.InstallArtifact, builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make),2314 .step = Step.init(.InstallArtifact, builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make),
2311 .artifact = artifact,2315 .artifact = artifact,
2312 .dest_dir = switch (artifact.kind) {2316 .dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) {
2313 .Obj => unreachable,2317 .Obj => unreachable,
2314 .Test => unreachable,2318 .Test => unreachable,
2315 .Exe => .Bin,2319 .Exe => InstallDir{ .Bin = {} },
2316 .Lib => .Lib,2320 .Lib => InstallDir{ .Lib = {} },
2317 },2321 },
2318 .pdb_dir = if (artifact.producesPdbFile()) blk: {2322 .pdb_dir = if (artifact.producesPdbFile()) blk: {
2319 if (artifact.kind == .Exe) {2323 if (artifact.kind == .Exe) {
2320 break :blk InstallDir.Bin;2324 break :blk InstallDir{ .Bin = {} };
2321 } else {2325 } else {
2322 break :blk InstallDir.Lib;2326 break :blk InstallDir{ .Lib = {} };
2323 }2327 }
2324 } else null,2328 } else null,
2325 .h_dir = if (artifact.kind == .Lib and artifact.emit_h) .Header else null,2329 .h_dir = if (artifact.kind == .Lib and artifact.emit_h) .Header else null,
...@@ -2615,11 +2619,13 @@ const VcpkgRootStatus = enum {...@@ -2615,11 +2619,13 @@ const VcpkgRootStatus = enum {
26152619
2616pub const VcpkgLinkage = std.builtin.LinkMode;2620pub const VcpkgLinkage = std.builtin.LinkMode;
26172621
2618pub const InstallDir = enum {2622pub const InstallDir = union(enum) {
2619 Prefix,2623 Prefix: void,
2620 Lib,2624 Lib: void,
2621 Bin,2625 Bin: void,
2622 Header,2626 Header: void,
2627 /// A path relative to the prefix
2628 Custom: []const u8,
2623};2629};
26242630
2625pub const InstalledFile = struct {2631pub const InstalledFile = struct {