| author | |
| committer | |
| log | 9e89000ffc92fd881ccb59d2571debe003a2f7b1 |
| tree | 0ada26a5978e82567dfe8f21fded83758142dbfd |
| parent | 15d5988e692c182892a118115fd7025048e06c29 |
# Conflicts:
#	lib/std/build/RunStep.zig5 files changed, 27 insertions(+), 38 deletions(-)
doc/docgen.zig+2-2| ... | @@ -1708,7 +1708,7 @@ fn genHtml( | ... | @@ -1708,7 +1708,7 @@ fn genHtml( |
| 1708 | } | 1708 | } |
| 1709 | } | 1709 | } |
| 1710 | 1710 | ||
| 1711 | fn exec(allocator: Allocator, env_map: *std.BufMap, args: []const []const u8) !ChildProcess.ExecResult { | 1711 | fn exec(allocator: Allocator, env_map: *process.EnvMap, args: []const []const u8) !ChildProcess.ExecResult { |
| 1712 | const result = try ChildProcess.exec(.{ | 1712 | const result = try ChildProcess.exec(.{ |
| 1713 | .allocator = allocator, | 1713 | .allocator = allocator, |
| 1714 | .argv = args, | 1714 | .argv = args, |
| ... | @@ -1732,7 +1732,7 @@ fn exec(allocator: Allocator, env_map: *std.BufMap, args: []const []const u8) !C | ... | @@ -1732,7 +1732,7 @@ fn exec(allocator: Allocator, env_map: *std.BufMap, args: []const []const u8) !C |
| 1732 | return result; | 1732 | return result; |
| 1733 | } | 1733 | } |
| 1734 | 1734 | ||
| 1735 | fn getBuiltinCode(allocator: Allocator, env_map: *std.BufMap, zig_exe: []const u8) ![]const u8 { | 1735 | fn getBuiltinCode(allocator: Allocator, env_map: *process.EnvMap, zig_exe: []const u8) ![]const u8 { |
| 1736 | const result = try exec(allocator, env_map, &[_][]const u8{ zig_exe, "build-obj", "--show-builtin" }); | 1736 | const result = try exec(allocator, env_map, &[_][]const u8{ zig_exe, "build-obj", "--show-builtin" }); |
| 1737 | return result.stdout; | 1737 | return result.stdout; |
| 1738 | } | 1738 | } |
lib/std/build.zig+4-4| ... | @@ -12,7 +12,7 @@ const StringHashMap = std.StringHashMap; | ... | @@ -12,7 +12,7 @@ const StringHashMap = std.StringHashMap; |
| 12 | const Allocator = mem.Allocator; | 12 | const Allocator = mem.Allocator; |
| 13 | const process = std.process; | 13 | const process = std.process; |
| 14 | const BufSet = std.BufSet; | 14 | const BufSet = std.BufSet; |
| 15 | const BufMap = std.BufMap; | 15 | const EnvMap = std.process.EnvMap; |
| 16 | const fmt_lib = std.fmt; | 16 | const fmt_lib = std.fmt; |
| 17 | const File = std.fs.File; | 17 | const File = std.fs.File; |
| 18 | const CrossTarget = std.zig.CrossTarget; | 18 | const CrossTarget = std.zig.CrossTarget; |
| ... | @@ -48,7 +48,7 @@ pub const Builder = struct { | ... | @@ -48,7 +48,7 @@ pub const Builder = struct { |
| 48 | invalid_user_input: bool, | 48 | invalid_user_input: bool, |
| 49 | zig_exe: []const u8, | 49 | zig_exe: []const u8, |
| 50 | default_step: *Step, | 50 | default_step: *Step, |
| 51 | env_map: *BufMap, | 51 | env_map: *EnvMap, |
| 52 | top_level_steps: ArrayList(*TopLevelStep), | 52 | top_level_steps: ArrayList(*TopLevelStep), |
| 53 | install_prefix: []const u8, | 53 | install_prefix: []const u8, |
| 54 | dest_dir: ?[]const u8, | 54 | dest_dir: ?[]const u8, |
| ... | @@ -167,7 +167,7 @@ pub const Builder = struct { | ... | @@ -167,7 +167,7 @@ pub const Builder = struct { |
| 167 | cache_root: []const u8, | 167 | cache_root: []const u8, |
| 168 | global_cache_root: []const u8, | 168 | global_cache_root: []const u8, |
| 169 | ) !*Builder { | 169 | ) !*Builder { |
| 170 | const env_map = try allocator.create(BufMap); | 170 | const env_map = try allocator.create(EnvMap); |
| 171 | env_map.* = try process.getEnvMap(allocator); | 171 | env_map.* = try process.getEnvMap(allocator); |
| 172 | 172 | ||
| 173 | const host = try NativeTargetInfo.detect(allocator, .{}); | 173 | const host = try NativeTargetInfo.detect(allocator, .{}); |
| ... | @@ -963,7 +963,7 @@ pub const Builder = struct { | ... | @@ -963,7 +963,7 @@ pub const Builder = struct { |
| 963 | warn("\n", .{}); | 963 | warn("\n", .{}); |
| 964 | } | 964 | } |
| 965 | 965 | ||
| 966 | pub fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) !void { | 966 | pub fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const EnvMap, argv: []const []const u8) !void { |
| 967 | if (self.verbose) { | 967 | if (self.verbose) { |
| 968 | printCmd(cwd, argv); | 968 | printCmd(cwd, argv); |
| 969 | } | 969 | } |
lib/std/build/RunStep.zig+7-18| ... | @@ -9,7 +9,7 @@ const fs = std.fs; | ... | @@ -9,7 +9,7 @@ const fs = std.fs; |
| 9 | const mem = std.mem; | 9 | const mem = std.mem; |
| 10 | const process = std.process; | 10 | const process = std.process; |
| 11 | const ArrayList = std.ArrayList; | 11 | const ArrayList = std.ArrayList; |
| 12 | const BufMap = std.BufMap; | 12 | const EnvMap = process.EnvMap; |
| 13 | const Allocator = mem.Allocator; | 13 | const Allocator = mem.Allocator; |
| 14 | const ExecError = build.Builder.ExecError; | 14 | const ExecError = build.Builder.ExecError; |
| 15 | 15 | ||
| ... | @@ -29,7 +29,7 @@ argv: ArrayList(Arg), | ... | @@ -29,7 +29,7 @@ argv: ArrayList(Arg), |
| 29 | cwd: ?[]const u8, | 29 | cwd: ?[]const u8, |
| 30 | 30 | ||
| 31 | /// Override this field to modify the environment, or use setEnvironmentVariable | 31 | /// Override this field to modify the environment, or use setEnvironmentVariable |
| 32 | env_map: ?*BufMap, | 32 | env_map: ?*EnvMap, |
| 33 | 33 | ||
| 34 | stdout_action: StdIoAction = .inherit, | 34 | stdout_action: StdIoAction = .inherit, |
| 35 | stderr_action: StdIoAction = .inherit, | 35 | stderr_action: StdIoAction = .inherit, |
| ... | @@ -91,8 +91,8 @@ pub fn addArgs(self: *RunStep, args: []const []const u8) void { | ... | @@ -91,8 +91,8 @@ pub fn addArgs(self: *RunStep, args: []const []const u8) void { |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | pub fn clearEnvironment(self: *RunStep) void { | 93 | pub fn clearEnvironment(self: *RunStep) void { |
| 94 | const new_env_map = self.builder.allocator.create(BufMap) catch unreachable; | 94 | const new_env_map = self.builder.allocator.create(EnvMap) catch unreachable; |
| 95 | new_env_map.* = BufMap.init(self.builder.allocator); | 95 | new_env_map.* = EnvMap.init(self.builder.allocator); |
| 96 | self.env_map = new_env_map; | 96 | self.env_map = new_env_map; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| ... | @@ -100,18 +100,7 @@ pub fn addPathDir(self: *RunStep, search_path: []const u8) void { | ... | @@ -100,18 +100,7 @@ pub fn addPathDir(self: *RunStep, search_path: []const u8) void { |
| 100 | const env_map = self.getEnvMap(); | 100 | const env_map = self.getEnvMap(); |
| 101 | 101 | ||
| 102 | var key: []const u8 = undefined; | 102 | var key: []const u8 = undefined; |
| 103 | var prev_path: ?[]const u8 = undefined; | 103 | var prev_path = env_map.get("PATH"); |
| 104 | if (builtin.os.tag == .windows) { | ||
| 105 | key = "Path"; | ||
| 106 | prev_path = env_map.get(key); | ||
| 107 | if (prev_path == null) { | ||
| 108 | key = "PATH"; | ||
| 109 | prev_path = env_map.get(key); | ||
| 110 | } | ||
| 111 | } else { | ||
| 112 | key = "PATH"; | ||
| 113 | prev_path = env_map.get(key); | ||
| 114 | } | ||
| 115 | 104 | ||
| 116 | if (prev_path) |pp| { | 105 | if (prev_path) |pp| { |
| 117 | const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path }); | 106 | const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path }); |
| ... | @@ -121,9 +110,9 @@ pub fn addPathDir(self: *RunStep, search_path: []const u8) void { | ... | @@ -121,9 +110,9 @@ pub fn addPathDir(self: *RunStep, search_path: []const u8) void { |
| 121 | } | 110 | } |
| 122 | } | 111 | } |
| 123 | 112 | ||
| 124 | pub fn getEnvMap(self: *RunStep) *BufMap { | 113 | pub fn getEnvMap(self: *RunStep) *EnvMap { |
| 125 | return self.env_map orelse { | 114 | return self.env_map orelse { |
| 126 | const env_map = self.builder.allocator.create(BufMap) catch unreachable; | 115 | const env_map = self.builder.allocator.create(EnvMap) catch unreachable; |
| 127 | env_map.* = process.getEnvMap(self.builder.allocator) catch unreachable; | 116 | env_map.* = process.getEnvMap(self.builder.allocator) catch unreachable; |
| 128 | self.env_map = env_map; | 117 | self.env_map = env_map; |
| 129 | return env_map; | 118 | return env_map; |
lib/std/child_process.zig+13-13| ... | @@ -12,7 +12,7 @@ const linux = os.linux; | ... | @@ -12,7 +12,7 @@ const linux = os.linux; |
| 12 | const mem = std.mem; | 12 | const mem = std.mem; |
| 13 | const math = std.math; | 13 | const math = std.math; |
| 14 | const debug = std.debug; | 14 | const debug = std.debug; |
| 15 | const BufMap = std.BufMap; | 15 | const EnvMap = process.EnvMap; |
| 16 | const Os = std.builtin.Os; | 16 | const Os = std.builtin.Os; |
| 17 | const TailQueue = std.TailQueue; | 17 | const TailQueue = std.TailQueue; |
| 18 | const maxInt = std.math.maxInt; | 18 | const maxInt = std.math.maxInt; |
| ... | @@ -34,7 +34,7 @@ pub const ChildProcess = struct { | ... | @@ -34,7 +34,7 @@ pub const ChildProcess = struct { |
| 34 | argv: []const []const u8, | 34 | argv: []const []const u8, |
| 35 | 35 | ||
| 36 | /// Leave as null to use the current env map using the supplied allocator. | 36 | /// Leave as null to use the current env map using the supplied allocator. |
| 37 | env_map: ?*const BufMap, | 37 | env_map: ?*const EnvMap, |
| 38 | 38 | ||
| 39 | stdin_behavior: StdIo, | 39 | stdin_behavior: StdIo, |
| 40 | stdout_behavior: StdIo, | 40 | stdout_behavior: StdIo, |
| ... | @@ -375,7 +375,7 @@ pub const ChildProcess = struct { | ... | @@ -375,7 +375,7 @@ pub const ChildProcess = struct { |
| 375 | argv: []const []const u8, | 375 | argv: []const []const u8, |
| 376 | cwd: ?[]const u8 = null, | 376 | cwd: ?[]const u8 = null, |
| 377 | cwd_dir: ?fs.Dir = null, | 377 | cwd_dir: ?fs.Dir = null, |
| 378 | env_map: ?*const BufMap = null, | 378 | env_map: ?*const EnvMap = null, |
| 379 | max_output_bytes: usize = 50 * 1024, | 379 | max_output_bytes: usize = 50 * 1024, |
| 380 | expand_arg0: Arg0Expand = .no_expand, | 380 | expand_arg0: Arg0Expand = .no_expand, |
| 381 | }) !ExecResult { | 381 | }) !ExecResult { |
| ... | @@ -1237,7 +1237,7 @@ fn readIntFd(fd: i32) !ErrInt { | ... | @@ -1237,7 +1237,7 @@ fn readIntFd(fd: i32) !ErrInt { |
| 1237 | } | 1237 | } |
| 1238 | 1238 | ||
| 1239 | /// Caller must free result. | 1239 | /// Caller must free result. |
| 1240 | pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ![]u16 { | 1240 | pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const EnvMap) ![]u16 { |
| 1241 | // count bytes needed | 1241 | // count bytes needed |
| 1242 | const max_chars_needed = x: { | 1242 | const max_chars_needed = x: { |
| 1243 | var max_chars_needed: usize = 4; // 4 for the final 4 null bytes | 1243 | var max_chars_needed: usize = 4; // 4 for the final 4 null bytes |
| ... | @@ -1245,7 +1245,7 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ! | ... | @@ -1245,7 +1245,7 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ! |
| 1245 | while (it.next()) |pair| { | 1245 | while (it.next()) |pair| { |
| 1246 | // +1 for '=' | 1246 | // +1 for '=' |
| 1247 | // +1 for null byte | 1247 | // +1 for null byte |
| 1248 | max_chars_needed += pair.key_ptr.len + pair.value_ptr.len + 2; | 1248 | max_chars_needed += pair.name.len + pair.value.len + 2; |
| 1249 | } | 1249 | } |
| 1250 | break :x max_chars_needed; | 1250 | break :x max_chars_needed; |
| 1251 | }; | 1251 | }; |
| ... | @@ -1255,10 +1255,10 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ! | ... | @@ -1255,10 +1255,10 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ! |
| 1255 | var it = env_map.iterator(); | 1255 | var it = env_map.iterator(); |
| 1256 | var i: usize = 0; | 1256 | var i: usize = 0; |
| 1257 | while (it.next()) |pair| { | 1257 | while (it.next()) |pair| { |
| 1258 | i += try unicode.utf8ToUtf16Le(result[i..], pair.key_ptr.*); | 1258 | i += try unicode.utf8ToUtf16Le(result[i..], pair.name); |
| 1259 | result[i] = '='; | 1259 | result[i] = '='; |
| 1260 | i += 1; | 1260 | i += 1; |
| 1261 | i += try unicode.utf8ToUtf16Le(result[i..], pair.value_ptr.*); | 1261 | i += try unicode.utf8ToUtf16Le(result[i..], pair.value); |
| 1262 | result[i] = 0; | 1262 | result[i] = 0; |
| 1263 | i += 1; | 1263 | i += 1; |
| 1264 | } | 1264 | } |
| ... | @@ -1273,17 +1273,17 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ! | ... | @@ -1273,17 +1273,17 @@ pub fn createWindowsEnvBlock(allocator: mem.Allocator, env_map: *const BufMap) ! |
| 1273 | return allocator.shrink(result, i); | 1273 | return allocator.shrink(result, i); |
| 1274 | } | 1274 | } |
| 1275 | 1275 | ||
| 1276 | pub fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const std.BufMap) ![:null]?[*:0]u8 { | 1276 | pub fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const EnvMap) ![:null]?[*:0]u8 { |
| 1277 | const envp_count = env_map.count(); | 1277 | const envp_count = env_map.count(); |
| 1278 | const envp_buf = try arena.allocSentinel(?[*:0]u8, envp_count, null); | 1278 | const envp_buf = try arena.allocSentinel(?[*:0]u8, envp_count, null); |
| 1279 | { | 1279 | { |
| 1280 | var it = env_map.iterator(); | 1280 | var it = env_map.iterator(); |
| 1281 | var i: usize = 0; | 1281 | var i: usize = 0; |
| 1282 | while (it.next()) |pair| : (i += 1) { | 1282 | while (it.next()) |pair| : (i += 1) { |
| 1283 | const env_buf = try arena.allocSentinel(u8, pair.key_ptr.len + pair.value_ptr.len + 1, 0); | 1283 | const env_buf = try arena.allocSentinel(u8, pair.name.len + pair.value.len + 1, 0); |
| 1284 | mem.copy(u8, env_buf, pair.key_ptr.*); | 1284 | mem.copy(u8, env_buf, pair.name); |
| 1285 | env_buf[pair.key_ptr.len] = '='; | 1285 | env_buf[pair.name.len] = '='; |
| 1286 | mem.copy(u8, env_buf[pair.key_ptr.len + 1 ..], pair.value_ptr.*); | 1286 | mem.copy(u8, env_buf[pair.name.len + 1 ..], pair.value); |
| 1287 | envp_buf[i] = env_buf.ptr; | 1287 | envp_buf[i] = env_buf.ptr; |
| 1288 | } | 1288 | } |
| 1289 | assert(i == envp_count); | 1289 | assert(i == envp_count); |
| ... | @@ -1294,7 +1294,7 @@ pub fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const std.BufMa | ... | @@ -1294,7 +1294,7 @@ pub fn createNullDelimitedEnvMap(arena: mem.Allocator, env_map: *const std.BufMa |
| 1294 | test "createNullDelimitedEnvMap" { | 1294 | test "createNullDelimitedEnvMap" { |
| 1295 | const testing = std.testing; | 1295 | const testing = std.testing; |
| 1296 | const allocator = testing.allocator; | 1296 | const allocator = testing.allocator; |
| 1297 | var envmap = BufMap.init(allocator); | 1297 | var envmap = EnvMap.init(allocator); |
| 1298 | defer envmap.deinit(); | 1298 | defer envmap.deinit(); |
| 1299 | 1299 | ||
| 1300 | try envmap.put("HOME", "/home/ifreund"); | 1300 | try envmap.put("HOME", "/home/ifreund"); |
lib/std/process.zig+1-1| ... | @@ -1364,7 +1364,7 @@ pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError { | ... | @@ -1364,7 +1364,7 @@ pub fn execv(allocator: mem.Allocator, argv: []const []const u8) ExecvError { |
| 1364 | pub fn execve( | 1364 | pub fn execve( |
| 1365 | allocator: mem.Allocator, | 1365 | allocator: mem.Allocator, |
| 1366 | argv: []const []const u8, | 1366 | argv: []const []const u8, |
| 1367 | env_map: ?*const std.BufMap, | 1367 | env_map: ?*const EnvMap, |
| 1368 | ) ExecvError { | 1368 | ) ExecvError { |
| 1369 | if (!can_execv) @compileError("The target OS does not support execv"); | 1369 | if (!can_execv) @compileError("The target OS does not support execv"); |
| 1370 | 1370 |