aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorMichael Dusan <michael.dusan@gmail.com>2019-11-27 17:47:44 -0500
committerMichael Dusan <michael.dusan@gmail.com>2019-11-27 19:24:06 -0500
commitca61a5f0b74fb420a21cdbb9e58f9d38ebe9dc0f (patch)
tree2d70e35cfa86ef77dd8af6aab9a1dc1202b5a2d6 /lib/std
parentf0d6447569e89a7b862da806a78da52d15160ef4 (diff)
downloadzig-ca61a5f0b74fb420a21cdbb9e58f9d38ebe9dc0f.tar.gz
zig-ca61a5f0b74fb420a21cdbb9e58f9d38ebe9dc0f.zip
Windows: fix test/standalone/shared_library
- on Windows use first found env var { "Path", "PATH" } Bug Description: `build test` results in the following error on in a msys64 shell with "PATH" env var instead of "Path": error while loading shared libraries: mathtest.dll: cannot open shared object file: No such file or directory
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/build.zig28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/std/build.zig b/lib/std/build.zig
index ea6ea929cf..38025b83bc 100644
--- a/lib/std/build.zig
+++ b/lib/std/build.zig
@@ -2062,14 +2062,28 @@ pub const RunStep = struct {
}
pub fn addPathDir(self: *RunStep, search_path: []const u8) void {
- const PATH = if (builtin.os == .windows) "Path" else "PATH";
const env_map = self.getEnvMap();
- const prev_path = env_map.get(PATH) orelse {
- env_map.set(PATH, search_path) catch unreachable;
- return;
- };
- const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", prev_path, search_path);
- env_map.set(PATH, new_path) catch unreachable;
+
+ var key: []const u8 = undefined;
+ var prev_path: ?[]const u8 = undefined;
+ if (builtin.os == .windows) {
+ key = "Path";
+ prev_path = env_map.get(key);
+ if (prev_path == null) {
+ key = "PATH";
+ prev_path = env_map.get(key);
+ }
+ } else {
+ key = "PATH";
+ prev_path = env_map.get(key);
+ }
+
+ if (prev_path) |pp| {
+ const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", pp, search_path);
+ env_map.set(key, new_path) catch unreachable;
+ } else {
+ env_map.set(key, search_path) catch unreachable;
+ }
}
pub fn getEnvMap(self: *RunStep) *BufMap {