authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-11-27 17:47:44-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2019-11-27 19:24:06-05:00
logca61a5f0b74fb420a21cdbb9e58f9d38ebe9dc0f
tree2d70e35cfa86ef77dd8af6aab9a1dc1202b5a2d6
parentf0d6447569e89a7b862da806a78da52d15160ef4

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

1 files changed, 21 insertions(+), 7 deletions(-)

lib/std/build.zig+21-7
......@@ -2062,14 +2062,28 @@ pub const RunStep = struct {
20622062 }
20632063
20642064 pub fn addPathDir(self: *RunStep, search_path: []const u8) void {
2065 const PATH = if (builtin.os == .windows) "Path" else "PATH";
20662065 const env_map = self.getEnvMap();
2067 const prev_path = env_map.get(PATH) orelse {
2068 env_map.set(PATH, search_path) catch unreachable;
2069 return;
2070 };
2071 const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", prev_path, search_path);
2072 env_map.set(PATH, new_path) catch unreachable;
2066
2067 var key: []const u8 = undefined;
2068 var prev_path: ?[]const u8 = undefined;
2069 if (builtin.os == .windows) {
2070 key = "Path";
2071 prev_path = env_map.get(key);
2072 if (prev_path == null) {
2073 key = "PATH";
2074 prev_path = env_map.get(key);
2075 }
2076 } else {
2077 key = "PATH";
2078 prev_path = env_map.get(key);
2079 }
2080
2081 if (prev_path) |pp| {
2082 const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", pp, search_path);
2083 env_map.set(key, new_path) catch unreachable;
2084 } else {
2085 env_map.set(key, search_path) catch unreachable;
2086 }
20732087 }
20742088
20752089 pub fn getEnvMap(self: *RunStep) *BufMap {