From 27a0a2c3ef1694117b60c66c30d3cee9375568fd Mon Sep 17 00:00:00 2001 From: g-w1 Date: Wed, 30 Dec 2020 21:04:27 -0500 Subject: [PATCH] Fix #7296: * makes '$build_root/{install,debug}/' the default prefix. This makes it not '$pwd/zig-cache/'. --- lib/std/build.zig | 12 ++++++++---- lib/std/special/build_runner.zig | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/std/build.zig b/lib/std/build.zig index 43d7b8486dd8..a670d3e0b702 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -200,12 +200,16 @@ pub const Builder = struct { 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_path = self.install_prefix orelse blk: { + const p = if (self.release_mode) |mode| switch (mode) { + .Debug => "debug", + .ReleaseSafe => "release", + .ReleaseFast => "release", + .ReleaseSmall => "release", + } else "debug"; self.install_prefix = p; - break :blk p; + break :blk self.pathFromRoot(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; diff --git a/lib/std/special/build_runner.zig b/lib/std/special/build_runner.zig index 7d9ac1749966..6a10441facf8 100644 --- a/lib/std/special/build_runner.zig +++ b/lib/std/special/build_runner.zig @@ -134,8 +134,8 @@ pub fn main() !void { } } - builder.resolveInstallPrefix(); try runBuild(builder); + builder.resolveInstallPrefix(); if (builder.validateUserInputDidItFail()) return usageAndErr(builder, true, stderr_stream);