| ... | @@ -2062,14 +2062,28 @@ pub const RunStep = struct { | ... | @@ -2062,14 +2062,28 @@ pub const RunStep = struct { |
| 2062 | } | 2062 | } |
| 2063 | | 2063 | |
| 2064 | pub fn addPathDir(self: *RunStep, search_path: []const u8) void { | 2064 | pub fn addPathDir(self: *RunStep, search_path: []const u8) void { |
| 2065 | const PATH = if (builtin.os == .windows) "Path" else "PATH"; | | |
| 2066 | const env_map = self.getEnvMap(); | 2065 | const env_map = self.getEnvMap(); |
| 2067 | const prev_path = env_map.get(PATH) orelse { | 2066 | |
| 2068 | env_map.set(PATH, search_path) catch unreachable; | 2067 | var key: []const u8 = undefined; |
| 2069 | return; | 2068 | var prev_path: ?[]const u8 = undefined; |
| 2070 | }; | 2069 | if (builtin.os == .windows) { |
| 2071 | const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", prev_path, search_path); | 2070 | key = "Path"; |
| 2072 | env_map.set(PATH, new_path) catch unreachable; | 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 | } |
| 2073 | } | 2087 | } |
| 2074 | | 2088 | |
| 2075 | pub fn getEnvMap(self: *RunStep) *BufMap { | 2089 | pub fn getEnvMap(self: *RunStep) *BufMap { |