Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions lib/std/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ pub const Builder = struct {
.Bin => self.exe_dir,
.Lib => self.lib_dir,
.Header => self.h_dir,
.Custom => |path| fs.path.join(self.allocator, &[_][]const u8{ self.install_path, path }) catch unreachable,
};
return fs.path.resolve(
self.allocator,
Expand Down Expand Up @@ -1212,6 +1213,8 @@ pub const LibExeObjStep = struct {
is_linking_libc: bool = false,
vcpkg_bin_path: ?[]const u8 = null,

/// This may be set in order to override the default install directory
override_dest_dir: ?InstallDir,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't really seem like a function to set this variable is necessary, users of the api can just set the field directly.

installed_path: ?[]const u8,
install_step: ?*InstallArtifactStep,

Expand Down Expand Up @@ -1348,6 +1351,7 @@ pub const LibExeObjStep = struct {
.rdynamic = false,
.output_dir = null,
.single_threaded = false,
.override_dest_dir = null,
.installed_path = null,
.install_step = null,
};
Expand Down Expand Up @@ -2309,17 +2313,17 @@ pub const InstallArtifactStep = struct {
.builder = builder,
.step = Step.init(.InstallArtifact, builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make),
.artifact = artifact,
.dest_dir = switch (artifact.kind) {
.dest_dir = artifact.override_dest_dir orelse switch (artifact.kind) {
.Obj => unreachable,
.Test => unreachable,
.Exe => .Bin,
.Lib => .Lib,
.Exe => InstallDir{ .Bin = {} },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're working around a stage1 issue here, but just to let you know it's planned for .Bin to coerce to the tagged union here, which would make these kind of code reworkings nicer in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that seems to be the case unfortunately, I played with it a bit but this was the cleanest it got.

.Lib => InstallDir{ .Lib = {} },
},
.pdb_dir = if (artifact.producesPdbFile()) blk: {
if (artifact.kind == .Exe) {
break :blk InstallDir.Bin;
break :blk InstallDir{ .Bin = {} };
} else {
break :blk InstallDir.Lib;
break :blk InstallDir{ .Lib = {} };
}
} else null,
.h_dir = if (artifact.kind == .Lib and artifact.emit_h) .Header else null,
Expand Down Expand Up @@ -2615,11 +2619,13 @@ const VcpkgRootStatus = enum {

pub const VcpkgLinkage = std.builtin.LinkMode;

pub const InstallDir = enum {
Prefix,
Lib,
Bin,
Header,
pub const InstallDir = union(enum) {
Prefix: void,
Lib: void,
Bin: void,
Header: void,
/// A path relative to the prefix
Custom: []const u8,
};

pub const InstalledFile = struct {
Expand Down