aboutsummaryrefslogtreecommitdiff
path: root/std/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-07-22 14:37:08 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-07-22 14:37:08 -0400
commit317d1ecb2cf3234b0259daf6cc0baac7d86264e2 (patch)
tree17c8c50e096fd23e0f9b9194a8a6ac0b8a028711 /std/build.zig
parentfcadeb50c04199fce2d9675ba2976680c71c67ff (diff)
parent16be70cbbf8e6dc658b9fcacd3366df8f83fffa8 (diff)
downloadzig-317d1ecb2cf3234b0259daf6cc0baac7d86264e2.tar.gz
zig-317d1ecb2cf3234b0259daf6cc0baac7d86264e2.zip
Merge remote-tracking branch 'origin/master' into rewrite-coroutines
Diffstat (limited to 'std/build.zig')
-rw-r--r--std/build.zig31
1 files changed, 20 insertions, 11 deletions
diff --git a/std/build.zig b/std/build.zig
index fc0786094d..3a0c34c8d1 100644
--- a/std/build.zig
+++ b/std/build.zig
@@ -41,9 +41,11 @@ pub const Builder = struct {
env_map: *BufMap,
top_level_steps: ArrayList(*TopLevelStep),
install_prefix: ?[]const u8,
- search_prefixes: ArrayList([]const u8),
+ dest_dir: ?[]const u8,
lib_dir: ?[]const u8,
exe_dir: ?[]const u8,
+ install_path: []const u8,
+ search_prefixes: ArrayList([]const u8),
installed_files: ArrayList(InstalledFile),
build_root: []const u8,
cache_root: []const u8,
@@ -125,10 +127,11 @@ pub const Builder = struct {
.top_level_steps = ArrayList(*TopLevelStep).init(allocator),
.default_step = undefined,
.env_map = env_map,
- .install_prefix = null,
.search_prefixes = ArrayList([]const u8).init(allocator),
+ .install_prefix = null,
.lib_dir = null,
.exe_dir = null,
+ .dest_dir = env_map.get("DESTDIR"),
.installed_files = ArrayList(InstalledFile).init(allocator),
.install_tls = TopLevelStep{
.step = Step.initNoOp("install", allocator),
@@ -142,6 +145,7 @@ pub const Builder = struct {
.is_release = false,
.override_std_dir = null,
.override_lib_dir = null,
+ .install_path = undefined,
};
try self.top_level_steps.append(&self.install_tls);
try self.top_level_steps.append(&self.uninstall_tls);
@@ -164,14 +168,19 @@ pub const Builder = struct {
}
fn resolveInstallPrefix(self: *Builder) void {
- const prefix = if (self.install_prefix) |prefix| prefix else blk: {
- const prefix = self.cache_root;
- self.install_prefix = prefix;
- break :blk prefix;
- };
-
- self.lib_dir = fs.path.join(self.allocator, [_][]const u8{ prefix, "lib" }) catch unreachable;
- self.exe_dir = fs.path.join(self.allocator, [_][]const u8{ prefix, "bin" }) catch unreachable;
+ if (self.dest_dir) |dest_dir| {
+ const install_prefix = self.install_prefix orelse "/usr";
+ self.install_path = fs.path.join(self.allocator, [_][]const u8{ dest_dir, install_prefix }) catch unreachable;
+ } else {
+ const install_prefix = self.install_prefix orelse blk: {
+ const p = self.cache_root;
+ self.install_prefix = p;
+ break :blk p;
+ };
+ self.install_path = install_prefix;
+ }
+ self.lib_dir = fs.path.join(self.allocator, [_][]const u8{ self.install_path, "lib" }) catch unreachable;
+ self.exe_dir = fs.path.join(self.allocator, [_][]const u8{ self.install_path, "bin" }) catch unreachable;
}
pub fn addExecutable(self: *Builder, name: []const u8, root_src: ?[]const u8) *LibExeObjStep {
@@ -884,7 +893,7 @@ pub const Builder = struct {
fn getInstallPath(self: *Builder, dir: InstallDir, dest_rel_path: []const u8) []const u8 {
const base_dir = switch (dir) {
- .Prefix => self.install_prefix.?,
+ .Prefix => self.install_path,
.Bin => self.exe_dir.?,
.Lib => self.lib_dir.?,
};