| author | |
| committer | |
| log | 1070c2a71a89175461273eba9f49bb85bdc83ecd |
| tree | 78be01bf6551d1aa1c1314769c9272846cb21ef6 |
| parent | f25de4c7a238d46a20c6a22e3b951ee09ecfb962 |
For naming consistency with `std.process.Environ.Map`.37 files changed, 290 insertions(+), 291 deletions(-)
lib/compiler/aro/aro/Compilation.zig+2-2| ... | ... | @@ -193,14 +193,14 @@ pub fn initDefault( |
| 193 | 193 | io: Io, |
| 194 | 194 | diagnostics: *Diagnostics, |
| 195 | 195 | cwd: Io.Dir, |
| 196 | env_map: *const std.process.Environ.Map, | |
| 196 | environ_map: *const std.process.Environ.Map, | |
| 197 | 197 | ) !Compilation { |
| 198 | 198 | var comp: Compilation = .{ |
| 199 | 199 | .gpa = gpa, |
| 200 | 200 | .arena = arena, |
| 201 | 201 | .io = io, |
| 202 | 202 | .diagnostics = diagnostics, |
| 203 | .environment = try Environment.loadAll(gpa, env_map), | |
| 203 | .environment = try Environment.loadAll(gpa, environ_map), | |
| 204 | 204 | .cwd = cwd, |
| 205 | 205 | }; |
| 206 | 206 | errdefer comp.deinit(); |
lib/compiler/build_runner.zig+5-5| ... | ... | @@ -87,7 +87,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 87 | 87 | .cwd = try process.getCwdAlloc(single_threaded_arena.allocator()), |
| 88 | 88 | }, |
| 89 | 89 | .zig_exe = zig_exe, |
| 90 | .env_map = try init.environ.createMap(arena), | |
| 90 | .environ_map = try init.environ.createMap(arena), | |
| 91 | 91 | .global_cache_root = global_cache_directory, |
| 92 | 92 | .zig_lib_directory = zig_lib_directory, |
| 93 | 93 | .host = .{ |
| ... | ... | @@ -130,13 +130,13 @@ pub fn main(init: process.Init.Minimal) !void { |
| 130 | 130 | var debounce_interval_ms: u16 = 50; |
| 131 | 131 | var webui_listen: ?Io.net.IpAddress = null; |
| 132 | 132 | |
| 133 | if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.env_map)) |str| { | |
| 133 | if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.environ_map)) |str| { | |
| 134 | 134 | if (std.meta.stringToEnum(ErrorStyle, str)) |style| { |
| 135 | 135 | error_style = style; |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | if (std.zig.EnvVar.ZIG_BUILD_MULTILINE_ERRORS.get(&graph.env_map)) |str| { | |
| 139 | if (std.zig.EnvVar.ZIG_BUILD_MULTILINE_ERRORS.get(&graph.environ_map)) |str| { | |
| 140 | 140 | if (std.meta.stringToEnum(MultilineErrors, str)) |style| { |
| 141 | 141 | multiline_errors = style; |
| 142 | 142 | } |
| ... | ... | @@ -433,8 +433,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 433 | 433 | } |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(&graph.env_map); | |
| 437 | const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.env_map); | |
| 436 | const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(&graph.environ_map); | |
| 437 | const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.environ_map); | |
| 438 | 438 | |
| 439 | 439 | graph.stderr_mode = switch (color) { |
| 440 | 440 | .auto => try .detect(io, .stderr(), NO_COLOR, CLICOLOR_FORCE), |
lib/compiler/libc.zig+3-3| ... | ... | @@ -29,7 +29,7 @@ pub fn main(init: std.process.Init) !void { |
| 29 | 29 | const gpa = init.gpa; |
| 30 | 30 | const io = init.io; |
| 31 | 31 | const args = try init.minimal.args.toSlice(arena); |
| 32 | const env_map = init.env_map; | |
| 32 | const environ_map = init.environ_map; | |
| 33 | 33 | |
| 34 | 34 | const zig_lib_directory = args[1]; |
| 35 | 35 | |
| ... | ... | @@ -92,7 +92,7 @@ pub fn main(init: std.process.Init) !void { |
| 92 | 92 | is_native_abi, |
| 93 | 93 | true, |
| 94 | 94 | libc_installation, |
| 95 | env_map, | |
| 95 | environ_map, | |
| 96 | 96 | ) catch |err| { |
| 97 | 97 | const zig_target = try target.zigTriple(arena); |
| 98 | 98 | fatal("unable to detect libc for target {s}: {t}", .{ zig_target, err }); |
| ... | ... | @@ -123,7 +123,7 @@ pub fn main(init: std.process.Init) !void { |
| 123 | 123 | var libc = LibCInstallation.findNative(gpa, io, .{ |
| 124 | 124 | .verbose = true, |
| 125 | 125 | .target = &target, |
| 126 | .env_map = env_map, | |
| 126 | .environ_map = environ_map, | |
| 127 | 127 | }) catch |err| { |
| 128 | 128 | fatal("unable to detect native libc: {t}", .{err}); |
| 129 | 129 | }; |
lib/compiler/resinator/compile.zig+2-2| ... | ... | @@ -80,7 +80,7 @@ pub const Dependencies = struct { |
| 80 | 80 | } |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io.Writer, options: CompileOptions, env_map: *const std.process.Environ.Map) !void { | |
| 83 | pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io.Writer, options: CompileOptions, environ_map: *const std.process.Environ.Map) !void { | |
| 84 | 84 | var lexer = lex.Lexer.init(source, .{ |
| 85 | 85 | .default_code_page = options.default_code_page, |
| 86 | 86 | .source_mappings = options.source_mappings, |
| ... | ... | @@ -148,7 +148,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io |
| 148 | 148 | try search_dirs.append(allocator, .{ .dir = dir, .path = try allocator.dupe(u8, system_include_path) }); |
| 149 | 149 | } |
| 150 | 150 | if (!options.ignore_include_env_var) { |
| 151 | const INCLUDE = env_map.get("INCLUDE") orelse ""; | |
| 151 | const INCLUDE = environ_map.get("INCLUDE") orelse ""; | |
| 152 | 152 | |
| 153 | 153 | // The only precedence here is llvm-rc which also uses the platform-specific |
| 154 | 154 | // delimiter. There's no precedence set by `rc.exe` since it's Windows-only. |
lib/compiler/resinator/main.zig+10-10| ... | ... | @@ -24,8 +24,8 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 24 | 24 | defer std.debug.assert(debug_allocator.deinit() == .ok); |
| 25 | 25 | const gpa = debug_allocator.allocator(); |
| 26 | 26 | |
| 27 | var env_map = try init.environ.createMap(gpa); | |
| 28 | defer env_map.deinit(); | |
| 27 | var environ_map = try init.environ.createMap(gpa); | |
| 28 | defer environ_map.deinit(); | |
| 29 | 29 | |
| 30 | 30 | var threaded: std.Io.Threaded = .init(gpa, .{ |
| 31 | 31 | .environ = init.environ, |
| ... | ... | @@ -151,8 +151,8 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 151 | 151 | defer argv.deinit(aro_arena); |
| 152 | 152 | |
| 153 | 153 | try argv.append(aro_arena, "arocc"); // dummy command name |
| 154 | const resolved_include_paths = try include_paths.get(&error_handler, &env_map); | |
| 155 | try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &env_map); | |
| 154 | const resolved_include_paths = try include_paths.get(&error_handler, &environ_map); | |
| 155 | try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &environ_map); | |
| 156 | 156 | try argv.append(aro_arena, switch (options.input_source) { |
| 157 | 157 | .stdio => "-", |
| 158 | 158 | .filename => |filename| filename, |
| ... | ... | @@ -286,7 +286,7 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 286 | 286 | .dependencies = maybe_dependencies, |
| 287 | 287 | .ignore_include_env_var = options.ignore_include_env_var, |
| 288 | 288 | .extra_include_paths = options.extra_include_paths.items, |
| 289 | .system_include_paths = try include_paths.get(&error_handler, &env_map), | |
| 289 | .system_include_paths = try include_paths.get(&error_handler, &environ_map), | |
| 290 | 290 | .default_language_id = options.default_language_id, |
| 291 | 291 | .default_code_page = default_code_page, |
| 292 | 292 | .disjoint_code_page = has_disjoint_code_page, |
| ... | ... | @@ -295,7 +295,7 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 295 | 295 | .max_string_literal_codepoints = options.max_string_literal_codepoints, |
| 296 | 296 | .silent_duplicate_control_ids = options.silent_duplicate_control_ids, |
| 297 | 297 | .warn_instead_of_error_on_invalid_code_page = options.warn_instead_of_error_on_invalid_code_page, |
| 298 | }, &env_map) catch |err| switch (err) { | |
| 298 | }, &environ_map) catch |err| switch (err) { | |
| 299 | 299 | error.ParseError, error.CompileError => { |
| 300 | 300 | try error_handler.emitDiagnostics(gpa, Io.Dir.cwd(), final_input, &diagnostics, mapping_results.mappings); |
| 301 | 301 | // Delete the output file on error |
| ... | ... | @@ -545,7 +545,7 @@ const LazyIncludePaths = struct { |
| 545 | 545 | pub fn get( |
| 546 | 546 | self: *LazyIncludePaths, |
| 547 | 547 | error_handler: *ErrorHandler, |
| 548 | env_map: *const std.process.Environ.Map, | |
| 548 | environ_map: *const std.process.Environ.Map, | |
| 549 | 549 | ) ![]const []const u8 { |
| 550 | 550 | const io = self.io; |
| 551 | 551 | |
| ... | ... | @@ -558,7 +558,7 @@ const LazyIncludePaths = struct { |
| 558 | 558 | self.auto_includes_option, |
| 559 | 559 | self.zig_lib_dir, |
| 560 | 560 | self.target_machine_type, |
| 561 | env_map, | |
| 561 | environ_map, | |
| 562 | 562 | ) catch |err| switch (err) { |
| 563 | 563 | error.OutOfMemory => |e| return e, |
| 564 | 564 | else => |e| { |
| ... | ... | @@ -586,7 +586,7 @@ fn getIncludePaths( |
| 586 | 586 | auto_includes_option: cli.Options.AutoIncludes, |
| 587 | 587 | zig_lib_dir: []const u8, |
| 588 | 588 | target_machine_type: std.coff.IMAGE.FILE.MACHINE, |
| 589 | env_map: *const std.process.Environ.Map, | |
| 589 | environ_map: *const std.process.Environ.Map, | |
| 590 | 590 | ) ![]const []const u8 { |
| 591 | 591 | if (auto_includes_option == .none) return &[_][]const u8{}; |
| 592 | 592 | |
| ... | ... | @@ -667,7 +667,7 @@ fn getIncludePaths( |
| 667 | 667 | is_native_abi, |
| 668 | 668 | true, |
| 669 | 669 | null, |
| 670 | env_map, | |
| 670 | environ_map, | |
| 671 | 671 | ) catch |err| switch (err) { |
| 672 | 672 | error.OutOfMemory => |e| return e, |
| 673 | 673 | else => return error.MingwIncludesNotFound, |
lib/compiler/resinator/preprocess.zig+2-2| ... | ... | @@ -86,7 +86,7 @@ fn hasAnyErrors(comp: *aro.Compilation) bool { |
| 86 | 86 | |
| 87 | 87 | /// `arena` is used for temporary -D argument strings and the INCLUDE environment variable. |
| 88 | 88 | /// The arena should be kept alive at least as long as `argv`. |
| 89 | pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8, env_map: *const std.process.Environ.Map) !void { | |
| 89 | pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options: cli.Options, system_include_paths: []const []const u8, environ_map: *const std.process.Environ.Map) !void { | |
| 90 | 90 | try argv.appendSlice(arena, &.{ |
| 91 | 91 | "-E", |
| 92 | 92 | "--comments", |
| ... | ... | @@ -109,7 +109,7 @@ pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | if (!options.ignore_include_env_var) { |
| 112 | const INCLUDE = env_map.get("INCLUDE") orelse ""; | |
| 112 | const INCLUDE = environ_map.get("INCLUDE") orelse ""; | |
| 113 | 113 | |
| 114 | 114 | // The only precedence here is llvm-rc which also uses the platform-specific |
| 115 | 115 | // delimiter. There's no precedence set by `rc.exe` since it's Windows-only. |
lib/compiler/translate-c/main.zig+4-4| ... | ... | @@ -13,7 +13,7 @@ pub fn main(init: std.process.Init) u8 { |
| 13 | 13 | const gpa = init.gpa; |
| 14 | 14 | const arena = init.arena.allocator(); |
| 15 | 15 | const io = init.io; |
| 16 | const env_map = init.env_map; | |
| 16 | const environ_map = init.environ_map; | |
| 17 | 17 | |
| 18 | 18 | const args = init.minimal.args.toSlice(arena) catch { |
| 19 | 19 | std.debug.print("ran out of memory allocating arguments\n", .{}); |
| ... | ... | @@ -26,8 +26,8 @@ pub fn main(init: std.process.Init) u8 { |
| 26 | 26 | zig_integration = true; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(env_map); | |
| 30 | const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(env_map); | |
| 29 | const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(environ_map); | |
| 30 | const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(environ_map); | |
| 31 | 31 | |
| 32 | 32 | var stderr_buf: [1024]u8 = undefined; |
| 33 | 33 | var stderr = Io.File.stderr().writer(io, &stderr_buf); |
| ... | ... | @@ -42,7 +42,7 @@ pub fn main(init: std.process.Init) u8 { |
| 42 | 42 | }; |
| 43 | 43 | defer diagnostics.deinit(); |
| 44 | 44 | |
| 45 | var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, .cwd(), env_map) catch |err| switch (err) { | |
| 45 | var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, .cwd(), environ_map) catch |err| switch (err) { | |
| 46 | 46 | error.OutOfMemory => { |
| 47 | 47 | std.debug.print("ran out of memory initializing C compilation\n", .{}); |
| 48 | 48 | if (fast_exit) process.exit(1); |
lib/std/Build.zig+6-7| ... | ... | @@ -12,7 +12,6 @@ const StringHashMap = std.StringHashMap; |
| 12 | 12 | const Allocator = std.mem.Allocator; |
| 13 | 13 | const Target = std.Target; |
| 14 | 14 | const process = std.process; |
| 15 | const EnvMap = std.process.Environ.Map; | |
| 16 | 15 | const File = std.Io.File; |
| 17 | 16 | const Sha256 = std.crypto.hash.sha2.Sha256; |
| 18 | 17 | const ArrayList = std.ArrayList; |
| ... | ... | @@ -118,7 +117,7 @@ pub const Graph = struct { |
| 118 | 117 | debug_compiler_runtime_libs: bool = false, |
| 119 | 118 | cache: Cache, |
| 120 | 119 | zig_exe: [:0]const u8, |
| 121 | env_map: EnvMap, | |
| 120 | environ_map: process.Environ.Map, | |
| 122 | 121 | global_cache_root: Cache.Directory, |
| 123 | 122 | zig_lib_directory: Cache.Directory, |
| 124 | 123 | needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .empty, |
| ... | ... | @@ -289,7 +288,7 @@ pub fn create( |
| 289 | 288 | .lib_dir = undefined, |
| 290 | 289 | .exe_dir = undefined, |
| 291 | 290 | .h_dir = undefined, |
| 292 | .dest_dir = graph.env_map.get("DESTDIR"), | |
| 291 | .dest_dir = graph.environ_map.get("DESTDIR"), | |
| 293 | 292 | .install_tls = .{ |
| 294 | 293 | .step = .init(.{ |
| 295 | 294 | .id = TopLevelStep.base_id, |
| ... | ... | @@ -1772,7 +1771,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 { |
| 1772 | 1771 | } |
| 1773 | 1772 | |
| 1774 | 1773 | if (builtin.os.tag == .windows) { |
| 1775 | if (b.graph.env_map.get("PATHEXT")) |PATHEXT| { | |
| 1774 | if (b.graph.environ_map.get("PATHEXT")) |PATHEXT| { | |
| 1776 | 1775 | var it = mem.tokenizeScalar(u8, PATHEXT, fs.path.delimiter); |
| 1777 | 1776 | |
| 1778 | 1777 | while (it.next()) |ext| { |
| ... | ... | @@ -1803,7 +1802,7 @@ pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const |
| 1803 | 1802 | return tryFindProgram(b, b.pathJoin(&.{ search_prefix, "bin", name })) orelse continue; |
| 1804 | 1803 | } |
| 1805 | 1804 | } |
| 1806 | if (b.graph.env_map.get("PATH")) |PATH| { | |
| 1805 | if (b.graph.environ_map.get("PATH")) |PATH| { | |
| 1807 | 1806 | for (names) |name| { |
| 1808 | 1807 | if (fs.path.isAbsolute(name)) { |
| 1809 | 1808 | return name; |
| ... | ... | @@ -1840,11 +1839,11 @@ pub fn runAllowFail( |
| 1840 | 1839 | const io = graph.io; |
| 1841 | 1840 | |
| 1842 | 1841 | const max_output_size = 400 * 1024; |
| 1843 | try Step.handleVerbose2(b, null, &graph.env_map, argv); | |
| 1842 | try Step.handleVerbose2(b, null, &graph.environ_map, argv); | |
| 1844 | 1843 | |
| 1845 | 1844 | var child = try std.process.spawn(io, .{ |
| 1846 | 1845 | .argv = argv, |
| 1847 | .env_map = &graph.env_map, | |
| 1846 | .environ_map = &graph.environ_map, | |
| 1848 | 1847 | .stdin = .ignore, |
| 1849 | 1848 | .stdout = .pipe, |
| 1850 | 1849 | .stderr = stderr_behavior, |
lib/std/Build/Step.zig+3-3| ... | ... | @@ -362,7 +362,7 @@ pub fn captureChildProcess( |
| 362 | 362 | |
| 363 | 363 | const result = std.process.run(arena, io, .{ |
| 364 | 364 | .argv = argv, |
| 365 | .env_map = &graph.env_map, | |
| 365 | .environ_map = &graph.environ_map, | |
| 366 | 366 | .progress_node = progress_node, |
| 367 | 367 | }) catch |err| return s.fail("failed to run {s}: {t}", .{ argv[0], err }); |
| 368 | 368 | |
| ... | ... | @@ -453,7 +453,7 @@ pub fn evalZigProcess( |
| 453 | 453 | |
| 454 | 454 | zp.child = std.process.spawn(io, .{ |
| 455 | 455 | .argv = argv, |
| 456 | .env_map = &b.graph.env_map, | |
| 456 | .environ_map = &b.graph.environ_map, | |
| 457 | 457 | .stdin = .pipe, |
| 458 | 458 | .stdout = .pipe, |
| 459 | 459 | .stderr = .pipe, |
| ... | ... | @@ -702,7 +702,7 @@ pub fn handleVerbose2( |
| 702 | 702 | // stderr before spawning them. |
| 703 | 703 | const text = try allocPrintCmd(b.allocator, opt_cwd, if (opt_env) |env| .{ |
| 704 | 704 | .child = env, |
| 705 | .parent = &graph.env_map, | |
| 705 | .parent = &graph.environ_map, | |
| 706 | 706 | } else null, argv); |
| 707 | 707 | std.debug.print("{s}\n", .{text}); |
| 708 | 708 | } |
lib/std/Build/Step/Compile.zig+2-2| ... | ... | @@ -741,7 +741,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult { |
| 741 | 741 | }; |
| 742 | 742 | |
| 743 | 743 | var code: u8 = undefined; |
| 744 | const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config"; | |
| 744 | const pkg_config_exe = b.graph.environ_map.get("PKG_CONFIG") orelse "pkg-config"; | |
| 745 | 745 | const stdout = if (b.runAllowFail(&[_][]const u8{ |
| 746 | 746 | pkg_config_exe, |
| 747 | 747 | pkg_name, |
| ... | ... | @@ -1846,7 +1846,7 @@ pub fn doAtomicSymLinks( |
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | fn execPkgConfigList(b: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg { |
| 1849 | const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config"; | |
| 1849 | const pkg_config_exe = b.graph.environ_map.get("PKG_CONFIG") orelse "pkg-config"; | |
| 1850 | 1850 | const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .ignore); |
| 1851 | 1851 | var list = std.array_list.Managed(PkgConfigPkg).init(b.allocator); |
| 1852 | 1852 | errdefer list.deinit(); |
lib/std/Build/Step/Options.zig+1-1| ... | ... | @@ -550,7 +550,7 @@ test Options { |
| 550 | 550 | .cwd = cwd, |
| 551 | 551 | }, |
| 552 | 552 | .zig_exe = "test", |
| 553 | .env_map = std.process.Environ.Map.init(arena.allocator()), | |
| 553 | .environ_map = std.process.Environ.Map.init(arena.allocator()), | |
| 554 | 554 | .global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() }, |
| 555 | 555 | .host = .{ |
| 556 | 556 | .query = .{}, |
lib/std/Build/Step/Run.zig+34-34| ... | ... | @@ -23,7 +23,7 @@ argv: std.ArrayList(Arg), |
| 23 | 23 | cwd: ?Build.LazyPath, |
| 24 | 24 | |
| 25 | 25 | /// Override this field to modify the environment, or use setEnvironmentVariable |
| 26 | env_map: ?*EnvMap, | |
| 26 | environ_map: ?*EnvMap, | |
| 27 | 27 | |
| 28 | 28 | /// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables. |
| 29 | 29 | color: Color = .auto, |
| ... | ... | @@ -215,7 +215,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { |
| 215 | 215 | }), |
| 216 | 216 | .argv = .{}, |
| 217 | 217 | .cwd = null, |
| 218 | .env_map = null, | |
| 218 | .environ_map = null, | |
| 219 | 219 | .disable_zig_progress = false, |
| 220 | 220 | .stdio = .infer_from_args, |
| 221 | 221 | .stdin = .none, |
| ... | ... | @@ -540,12 +540,12 @@ pub fn clearEnvironment(run: *Run) void { |
| 540 | 540 | const b = run.step.owner; |
| 541 | 541 | const new_env_map = b.allocator.create(EnvMap) catch @panic("OOM"); |
| 542 | 542 | new_env_map.* = .init(b.allocator); |
| 543 | run.env_map = new_env_map; | |
| 543 | run.environ_map = new_env_map; | |
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | pub fn addPathDir(run: *Run, search_path: []const u8) void { |
| 547 | 547 | const b = run.step.owner; |
| 548 | const env_map = getEnvMapInternal(run); | |
| 548 | const environ_map = getEnvMapInternal(run); | |
| 549 | 549 | |
| 550 | 550 | const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) { |
| 551 | 551 | .artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows, |
| ... | ... | @@ -562,7 +562,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void { |
| 562 | 562 | .output_file, .output_directory => false, |
| 563 | 563 | }; |
| 564 | 564 | const key = if (use_wine) "WINEPATH" else "PATH"; |
| 565 | const prev_path = env_map.get(key); | |
| 565 | const prev_path = environ_map.get(key); | |
| 566 | 566 | |
| 567 | 567 | if (prev_path) |pp| { |
| 568 | 568 | const new_path = b.fmt("{s}{c}{s}", .{ |
| ... | ... | @@ -570,9 +570,9 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void { |
| 570 | 570 | if (use_wine) Dir.path.delimiter_windows else Dir.path.delimiter, |
| 571 | 571 | search_path, |
| 572 | 572 | }); |
| 573 | env_map.put(key, new_path) catch @panic("OOM"); | |
| 573 | environ_map.put(key, new_path) catch @panic("OOM"); | |
| 574 | 574 | } else { |
| 575 | env_map.put(key, b.dupePath(search_path)) catch @panic("OOM"); | |
| 575 | environ_map.put(key, b.dupePath(search_path)) catch @panic("OOM"); | |
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | |
| ... | ... | @@ -583,18 +583,18 @@ pub fn getEnvMap(run: *Run) *EnvMap { |
| 583 | 583 | fn getEnvMapInternal(run: *Run) *EnvMap { |
| 584 | 584 | const graph = run.step.owner.graph; |
| 585 | 585 | const arena = graph.arena; |
| 586 | return run.env_map orelse { | |
| 586 | return run.environ_map orelse { | |
| 587 | 587 | const cloned_map = arena.create(EnvMap) catch @panic("OOM"); |
| 588 | cloned_map.* = graph.env_map.clone(arena) catch @panic("OOM"); | |
| 589 | run.env_map = cloned_map; | |
| 588 | cloned_map.* = graph.environ_map.clone(arena) catch @panic("OOM"); | |
| 589 | run.environ_map = cloned_map; | |
| 590 | 590 | return cloned_map; |
| 591 | 591 | }; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | pub fn setEnvironmentVariable(run: *Run, key: []const u8, value: []const u8) void { |
| 595 | const env_map = run.getEnvMap(); | |
| 595 | const environ_map = run.getEnvMap(); | |
| 596 | 596 | // This data structure already dupes keys and values. |
| 597 | env_map.put(key, value) catch @panic("OOM"); | |
| 597 | environ_map.put(key, value) catch @panic("OOM"); | |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void { |
| ... | ... | @@ -762,7 +762,7 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 { |
| 762 | 762 | const child_lazy_cwd = run.cwd orelse break :rel path_str; |
| 763 | 763 | const child_cwd = child_lazy_cwd.getPath3(b, &run.step).toString(arena) catch @panic("OOM"); |
| 764 | 764 | // Convert it from relative to *our* cwd, to relative to the *child's* cwd. |
| 765 | break :rel Dir.path.relative(arena, graph.cache.cwd, &graph.env_map, child_cwd, path_str) catch @panic("OOM"); | |
| 765 | break :rel Dir.path.relative(arena, graph.cache.cwd, &graph.environ_map, child_cwd, path_str) catch @panic("OOM"); | |
| 766 | 766 | }; |
| 767 | 767 | // Not every path can be made relative, e.g. if the path and the child cwd are on different |
| 768 | 768 | // disk designators on Windows. In that case, `relative` will return an absolute path which we can |
| ... | ... | @@ -794,8 +794,8 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 794 | 794 | var man = b.graph.cache.obtain(); |
| 795 | 795 | defer man.deinit(); |
| 796 | 796 | |
| 797 | if (run.env_map) |env_map| { | |
| 798 | for (env_map.keys(), env_map.values()) |key, value| { | |
| 797 | if (run.environ_map) |environ_map| { | |
| 798 | for (environ_map.keys(), environ_map.values()) |key, value| { | |
| 799 | 799 | man.hash.addBytes(key); |
| 800 | 800 | man.hash.addBytes(value); |
| 801 | 801 | } |
| ... | ... | @@ -1222,7 +1222,7 @@ fn runCommand( |
| 1222 | 1222 | const cwd: ?[]const u8 = if (run.cwd) |lazy_cwd| lazy_cwd.getPath2(b, step) else null; |
| 1223 | 1223 | |
| 1224 | 1224 | try step.handleChildProcUnsupported(); |
| 1225 | try Step.handleVerbose2(step.owner, cwd, run.env_map, argv); | |
| 1225 | try Step.handleVerbose2(step.owner, cwd, run.environ_map, argv); | |
| 1226 | 1226 | |
| 1227 | 1227 | const allow_skip = switch (run.stdio) { |
| 1228 | 1228 | .check, .zig_test => run.skip_foreign_checks, |
| ... | ... | @@ -1232,13 +1232,13 @@ fn runCommand( |
| 1232 | 1232 | var interp_argv = std.array_list.Managed([]const u8).init(b.allocator); |
| 1233 | 1233 | defer interp_argv.deinit(); |
| 1234 | 1234 | |
| 1235 | var env_map: EnvMap = env: { | |
| 1236 | const orig = run.env_map orelse &b.graph.env_map; | |
| 1235 | var environ_map: EnvMap = env: { | |
| 1236 | const orig = run.environ_map orelse &b.graph.environ_map; | |
| 1237 | 1237 | break :env try orig.clone(gpa); |
| 1238 | 1238 | }; |
| 1239 | defer env_map.deinit(); | |
| 1239 | defer environ_map.deinit(); | |
| 1240 | 1240 | |
| 1241 | const opt_generic_result = spawnChildAndCollect(run, argv, &env_map, has_side_effects, options, fuzz_context) catch |err| term: { | |
| 1241 | const opt_generic_result = spawnChildAndCollect(run, argv, &environ_map, has_side_effects, options, fuzz_context) catch |err| term: { | |
| 1242 | 1242 | // InvalidExe: cpu arch mismatch |
| 1243 | 1243 | // FileNotFound: can happen with a wrong dynamic linker path |
| 1244 | 1244 | if (err == error.InvalidExe or err == error.FileNotFound) interpret: { |
| ... | ... | @@ -1274,8 +1274,8 @@ fn runCommand( |
| 1274 | 1274 | |
| 1275 | 1275 | // Wine's excessive stderr logging is only situationally helpful. Disable it by default, but |
| 1276 | 1276 | // allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired. |
| 1277 | if (env_map.get("WINEDEBUG") == null) { | |
| 1278 | try env_map.put("WINEDEBUG", "-all"); | |
| 1277 | if (environ_map.get("WINEDEBUG") == null) { | |
| 1278 | try environ_map.put("WINEDEBUG", "-all"); | |
| 1279 | 1279 | } |
| 1280 | 1280 | } else { |
| 1281 | 1281 | return failForeign(run, "-fwine", argv[0], exe); |
| ... | ... | @@ -1372,9 +1372,9 @@ fn runCommand( |
| 1372 | 1372 | |
| 1373 | 1373 | gpa.free(step.result_failed_command.?); |
| 1374 | 1374 | step.result_failed_command = null; |
| 1375 | try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items); | |
| 1375 | try Step.handleVerbose2(step.owner, cwd, run.environ_map, interp_argv.items); | |
| 1376 | 1376 | |
| 1377 | break :term spawnChildAndCollect(run, interp_argv.items, &env_map, has_side_effects, options, fuzz_context) catch |e| { | |
| 1377 | break :term spawnChildAndCollect(run, interp_argv.items, &environ_map, has_side_effects, options, fuzz_context) catch |e| { | |
| 1378 | 1378 | if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped; |
| 1379 | 1379 | if (e == error.MakeFailed) return error.MakeFailed; // error already reported |
| 1380 | 1380 | return step.fail("unable to spawn interpreter {s}: {s}", .{ |
| ... | ... | @@ -1529,7 +1529,7 @@ const EvalGenericResult = struct { |
| 1529 | 1529 | fn spawnChildAndCollect( |
| 1530 | 1530 | run: *Run, |
| 1531 | 1531 | argv: []const []const u8, |
| 1532 | env_map: *EnvMap, | |
| 1532 | environ_map: *EnvMap, | |
| 1533 | 1533 | has_side_effects: bool, |
| 1534 | 1534 | options: Step.MakeOptions, |
| 1535 | 1535 | fuzz_context: ?FuzzContext, |
| ... | ... | @@ -1548,14 +1548,14 @@ fn spawnChildAndCollect( |
| 1548 | 1548 | // If an error occurs, it's caused by this command: |
| 1549 | 1549 | assert(run.step.result_failed_command == null); |
| 1550 | 1550 | run.step.result_failed_command = try Step.allocPrintCmd(options.gpa, child_cwd, .{ |
| 1551 | .child = env_map, | |
| 1552 | .parent = &graph.env_map, | |
| 1551 | .child = environ_map, | |
| 1552 | .parent = &graph.environ_map, | |
| 1553 | 1553 | }, argv); |
| 1554 | 1554 | |
| 1555 | 1555 | var spawn_options: process.SpawnOptions = .{ |
| 1556 | 1556 | .argv = argv, |
| 1557 | 1557 | .cwd = child_cwd, |
| 1558 | .env_map = env_map, | |
| 1558 | .environ_map = environ_map, | |
| 1559 | 1559 | .request_resource_usage_statistics = true, |
| 1560 | 1560 | .stdin = if (run.stdin != .none) s: { |
| 1561 | 1561 | assert(run.stdio != .inherit); |
| ... | ... | @@ -1595,7 +1595,7 @@ fn spawnChildAndCollect( |
| 1595 | 1595 | break :m stderr.terminal_mode; |
| 1596 | 1596 | } else .no_color; |
| 1597 | 1597 | defer if (inherit) io.unlockStderr(); |
| 1598 | try setColorEnvironmentVariables(run, env_map, terminal_mode); | |
| 1598 | try setColorEnvironmentVariables(run, environ_map, terminal_mode); | |
| 1599 | 1599 | var timer = try std.time.Timer.start(); |
| 1600 | 1600 | const res = try evalGeneric(run, spawn_options); |
| 1601 | 1601 | run.step.result_duration_ns = timer.read(); |
| ... | ... | @@ -1603,16 +1603,16 @@ fn spawnChildAndCollect( |
| 1603 | 1603 | } |
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | fn setColorEnvironmentVariables(run: *Run, env_map: *EnvMap, terminal_mode: Io.Terminal.Mode) !void { | |
| 1606 | fn setColorEnvironmentVariables(run: *Run, environ_map: *EnvMap, terminal_mode: Io.Terminal.Mode) !void { | |
| 1607 | 1607 | color: switch (run.color) { |
| 1608 | 1608 | .manual => {}, |
| 1609 | 1609 | .enable => { |
| 1610 | try env_map.put("CLICOLOR_FORCE", "1"); | |
| 1611 | _ = env_map.swapRemove("NO_COLOR"); | |
| 1610 | try environ_map.put("CLICOLOR_FORCE", "1"); | |
| 1611 | _ = environ_map.swapRemove("NO_COLOR"); | |
| 1612 | 1612 | }, |
| 1613 | 1613 | .disable => { |
| 1614 | try env_map.put("NO_COLOR", "1"); | |
| 1615 | _ = env_map.swapRemove("CLICOLOR_FORCE"); | |
| 1614 | try environ_map.put("NO_COLOR", "1"); | |
| 1615 | _ = environ_map.swapRemove("CLICOLOR_FORCE"); | |
| 1616 | 1616 | }, |
| 1617 | 1617 | .inherit => switch (terminal_mode) { |
| 1618 | 1618 | .no_color, .windows_api => continue :color .disable, |
lib/std/Build/WebServer.zig+1-1| ... | ... | @@ -568,7 +568,7 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim |
| 568 | 568 | |
| 569 | 569 | var child = try std.process.spawn(io, .{ |
| 570 | 570 | .argv = argv.items, |
| 571 | .env_map = &graph.env_map, | |
| 571 | .environ_map = &graph.environ_map, | |
| 572 | 572 | .stdin = .pipe, |
| 573 | 573 | .stdout = .pipe, |
| 574 | 574 | .stderr = .pipe, |
lib/std/Io/Threaded.zig+3-3| ... | ... | @@ -12887,8 +12887,8 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp |
| 12887 | 12887 | |
| 12888 | 12888 | const envp: [*:null]const ?[*:0]const u8 = m: { |
| 12889 | 12889 | const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno; |
| 12890 | if (options.env_map) |env_map| { | |
| 12891 | break :m (try env_map.createBlockPosix(arena, .{ | |
| 12890 | if (options.environ_map) |environ_map| { | |
| 12891 | break :m (try environ_map.createBlockPosix(arena, .{ | |
| 12892 | 12892 | .zig_progress_fd = prog_fd, |
| 12893 | 12893 | })).ptr; |
| 12894 | 12894 | } |
| ... | ... | @@ -13436,7 +13436,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro |
| 13436 | 13436 | const cwd_w = if (options.cwd) |cwd| try std.unicode.wtf8ToWtf16LeAllocZ(arena, cwd) else null; |
| 13437 | 13437 | const cwd_w_ptr = if (cwd_w) |cwd| cwd.ptr else null; |
| 13438 | 13438 | |
| 13439 | const maybe_envp_buf = if (options.env_map) |env_map| try env_map.createBlockWindows(arena) else null; | |
| 13439 | const maybe_envp_buf = if (options.environ_map) |environ_map| try environ_map.createBlockWindows(arena) else null; | |
| 13440 | 13440 | const envp_ptr = if (maybe_envp_buf) |envp_buf| envp_buf.ptr else null; |
| 13441 | 13441 | |
| 13442 | 13442 | const app_name_wtf8 = options.argv[0]; |
lib/std/fs/path.zig+10-10| ... | ... | @@ -1506,16 +1506,16 @@ fn testBasenameWindows(input: []const u8, expected_output: []const u8) !void { |
| 1506 | 1506 | /// on each), a zero-length string is returned. |
| 1507 | 1507 | /// |
| 1508 | 1508 | /// See `relativePosix` and `relativeWindows` for operating system specific |
| 1509 | /// details and for how `env_map` is used. | |
| 1509 | /// details and for how `environ_map` is used. | |
| 1510 | 1510 | pub fn relative( |
| 1511 | 1511 | gpa: Allocator, |
| 1512 | 1512 | cwd: []const u8, |
| 1513 | env_map: ?*const std.process.Environ.Map, | |
| 1513 | environ_map: ?*const std.process.Environ.Map, | |
| 1514 | 1514 | from: []const u8, |
| 1515 | 1515 | to: []const u8, |
| 1516 | 1516 | ) Allocator.Error![]u8 { |
| 1517 | 1517 | if (native_os == .windows) { |
| 1518 | return relativeWindows(gpa, cwd, env_map, from, to); | |
| 1518 | return relativeWindows(gpa, cwd, environ_map, from, to); | |
| 1519 | 1519 | } else { |
| 1520 | 1520 | return relativePosix(gpa, cwd, from, to); |
| 1521 | 1521 | } |
| ... | ... | @@ -1536,12 +1536,12 @@ pub fn relative( |
| 1536 | 1536 | /// Per-drive CWDs are stored in special semi-hidden environment variables of |
| 1537 | 1537 | /// the format `=<drive-letter>:`, e.g. `=C:`. This type of CWD is purely a |
| 1538 | 1538 | /// shell concept, so there's no guarantee that it'll be set or that it'll even |
| 1539 | /// be accurate. This is the only reason for the `env_map` parameter. `null` is | |
| 1539 | /// be accurate. This is the only reason for the `environ_map` parameter. `null` is | |
| 1540 | 1540 | /// treated equivalent to the environment variable missing. |
| 1541 | 1541 | pub fn relativeWindows( |
| 1542 | 1542 | gpa: Allocator, |
| 1543 | 1543 | cwd: []const u8, |
| 1544 | env_map: ?*const std.process.Environ.Map, | |
| 1544 | environ_map: ?*const std.process.Environ.Map, | |
| 1545 | 1545 | from: []const u8, |
| 1546 | 1546 | to: []const u8, |
| 1547 | 1547 | ) Allocator.Error![]u8 { |
| ... | ... | @@ -1565,13 +1565,13 @@ pub fn relativeWindows( |
| 1565 | 1565 | }; |
| 1566 | 1566 | |
| 1567 | 1567 | if (result_is_always_to) { |
| 1568 | return windowsResolveAgainstCwd(gpa, cwd, env_map, to, parsed_to); | |
| 1568 | return windowsResolveAgainstCwd(gpa, cwd, environ_map, to, parsed_to); | |
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | const resolved_from = try windowsResolveAgainstCwd(gpa, cwd, env_map, from, parsed_from); | |
| 1571 | const resolved_from = try windowsResolveAgainstCwd(gpa, cwd, environ_map, from, parsed_from); | |
| 1572 | 1572 | defer gpa.free(resolved_from); |
| 1573 | 1573 | var clean_up_resolved_to = true; |
| 1574 | const resolved_to = try windowsResolveAgainstCwd(gpa, cwd, env_map, to, parsed_to); | |
| 1574 | const resolved_to = try windowsResolveAgainstCwd(gpa, cwd, environ_map, to, parsed_to); | |
| 1575 | 1575 | defer if (clean_up_resolved_to) gpa.free(resolved_to); |
| 1576 | 1576 | |
| 1577 | 1577 | const parsed_resolved_from = parsePathWindows(u8, resolved_from); |
| ... | ... | @@ -1637,7 +1637,7 @@ pub fn relativeWindows( |
| 1637 | 1637 | fn windowsResolveAgainstCwd( |
| 1638 | 1638 | gpa: Allocator, |
| 1639 | 1639 | cwd: []const u8, |
| 1640 | env_map: ?*const std.process.Environ.Map, | |
| 1640 | environ_map: ?*const std.process.Environ.Map, | |
| 1641 | 1641 | path: []const u8, |
| 1642 | 1642 | parsed: WindowsPath2(u8), |
| 1643 | 1643 | ) ![]u8 { |
| ... | ... | @@ -1679,7 +1679,7 @@ fn windowsResolveAgainstCwd( |
| 1679 | 1679 | if (drive_letters_match) |
| 1680 | 1680 | break :drive_cwd cwd; |
| 1681 | 1681 | |
| 1682 | if (env_map) |m| { | |
| 1682 | if (environ_map) |m| { | |
| 1683 | 1683 | if (m.get(&.{ '=', parsed.root[0], ':' })) |v| { |
| 1684 | 1684 | break :drive_cwd try temp_allocator.dupe(u8, v); |
| 1685 | 1685 | } |
lib/std/http/Client.zig+5-5| ... | ... | @@ -1307,7 +1307,7 @@ pub fn deinit(client: *Client) void { |
| 1307 | 1307 | /// Asserts the client has no active connections. |
| 1308 | 1308 | /// Uses `arena` for a few small allocations that must outlive the client, or |
| 1309 | 1309 | /// at least until those fields are set to different values. |
| 1310 | pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.process.Environ.Map) !void { | |
| 1310 | pub fn initDefaultProxies(client: *Client, arena: Allocator, environ_map: *std.process.Environ.Map) !void { | |
| 1311 | 1311 | // Prevent any new connections from being created. |
| 1312 | 1312 | client.connection_pool.mutex.lock(); |
| 1313 | 1313 | defer client.connection_pool.mutex.unlock(); |
| ... | ... | @@ -1315,13 +1315,13 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce |
| 1315 | 1315 | assert(client.connection_pool.used.first == null); // There are active requests. |
| 1316 | 1316 | |
| 1317 | 1317 | if (client.http_proxy == null) { |
| 1318 | client.http_proxy = try createProxyFromEnvVar(arena, env_map, &.{ | |
| 1318 | client.http_proxy = try createProxyFromEnvVar(arena, environ_map, &.{ | |
| 1319 | 1319 | "http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY", |
| 1320 | 1320 | }); |
| 1321 | 1321 | } |
| 1322 | 1322 | |
| 1323 | 1323 | if (client.https_proxy == null) { |
| 1324 | client.https_proxy = try createProxyFromEnvVar(arena, env_map, &.{ | |
| 1324 | client.https_proxy = try createProxyFromEnvVar(arena, environ_map, &.{ | |
| 1325 | 1325 | "https_proxy", "HTTPS_PROXY", "all_proxy", "ALL_PROXY", |
| 1326 | 1326 | }); |
| 1327 | 1327 | } |
| ... | ... | @@ -1329,11 +1329,11 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce |
| 1329 | 1329 | |
| 1330 | 1330 | fn createProxyFromEnvVar( |
| 1331 | 1331 | arena: Allocator, |
| 1332 | env_map: *std.process.Environ.Map, | |
| 1332 | environ_map: *std.process.Environ.Map, | |
| 1333 | 1333 | env_var_names: []const []const u8, |
| 1334 | 1334 | ) !?*Proxy { |
| 1335 | 1335 | const content = for (env_var_names) |name| { |
| 1336 | const content = env_map.get(name) orelse continue; | |
| 1336 | const content = environ_map.get(name) orelse continue; | |
| 1337 | 1337 | if (content.len == 0) continue; |
| 1338 | 1338 | break content; |
| 1339 | 1339 | } else return null; |
lib/std/process.zig+5-5| ... | ... | @@ -46,7 +46,7 @@ pub const Init = struct { |
| 46 | 46 | /// configuration. Debug mode will set up leak checking. |
| 47 | 47 | io: Io, |
| 48 | 48 | /// Environment variables, initialized with `gpa`. Not threadsafe. |
| 49 | env_map: *Environ.Map, | |
| 49 | environ_map: *Environ.Map, | |
| 50 | 50 | |
| 51 | 51 | /// Alternative to `Init` as the first parameter of the main function. |
| 52 | 52 | pub const Minimal = struct { |
| ... | ... | @@ -295,7 +295,7 @@ pub const ReplaceOptions = struct { |
| 295 | 295 | arg0_expand: ArgExpansion = .no_expand, |
| 296 | 296 | /// Replaces the environment when provided. The PATH value from here is |
| 297 | 297 | /// never used to resolve `argv[0]`. |
| 298 | env_map: ?*const Environ.Map = null, | |
| 298 | environ_map: ?*const Environ.Map = null, | |
| 299 | 299 | }; |
| 300 | 300 | |
| 301 | 301 | /// Replaces the current process image with the executed process. If this |
| ... | ... | @@ -377,7 +377,7 @@ pub const SpawnOptions = struct { |
| 377 | 377 | /// Replaces the child environment when provided. The PATH value from here |
| 378 | 378 | /// is not used to resolve `argv[0]`; that resolution always uses parent |
| 379 | 379 | /// environment. |
| 380 | env_map: ?*const Environ.Map = null, | |
| 380 | environ_map: ?*const Environ.Map = null, | |
| 381 | 381 | expand_arg0: ArgExpansion = .no_expand, |
| 382 | 382 | /// When populated, a pipe will be created for the child process to |
| 383 | 383 | /// communicate progress back to the parent. The file descriptor of the |
| ... | ... | @@ -475,7 +475,7 @@ pub const RunOptions = struct { |
| 475 | 475 | /// Replaces the child environment when provided. The PATH value from here |
| 476 | 476 | /// is not used to resolve `argv[0]`; that resolution always uses parent |
| 477 | 477 | /// environment. |
| 478 | env_map: ?*const Environ.Map = null, | |
| 478 | environ_map: ?*const Environ.Map = null, | |
| 479 | 479 | expand_arg0: ArgExpansion = .no_expand, |
| 480 | 480 | /// When populated, a pipe will be created for the child process to |
| 481 | 481 | /// communicate progress back to the parent. The file descriptor of the |
| ... | ... | @@ -505,7 +505,7 @@ pub fn run(gpa: Allocator, io: Io, options: RunOptions) RunError!RunResult { |
| 505 | 505 | .argv = options.argv, |
| 506 | 506 | .cwd = options.cwd, |
| 507 | 507 | .cwd_dir = options.cwd_dir, |
| 508 | .env_map = options.env_map, | |
| 508 | .environ_map = options.environ_map, | |
| 509 | 509 | .expand_arg0 = options.expand_arg0, |
| 510 | 510 | .progress_node = options.progress_node, |
| 511 | 511 | .create_no_window = options.create_no_window, |
lib/std/start.zig+3-3| ... | ... | @@ -699,9 +699,9 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B |
| 699 | 699 | }); |
| 700 | 700 | defer threaded.deinit(); |
| 701 | 701 | |
| 702 | var env_map = std.process.Environ.createMap(.{ .block = environ }, gpa) catch |err| | |
| 702 | var environ_map = std.process.Environ.createMap(.{ .block = environ }, gpa) catch |err| | |
| 703 | 703 | std.process.fatal("failed to parse environment variables: {t}", .{err}); |
| 704 | defer env_map.deinit(); | |
| 704 | defer environ_map.deinit(); | |
| 705 | 705 | |
| 706 | 706 | return wrapMain(root.main(.{ |
| 707 | 707 | .minimal = .{ |
| ... | ... | @@ -711,7 +711,7 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B |
| 711 | 711 | .arena = &arena_allocator, |
| 712 | 712 | .gpa = gpa, |
| 713 | 713 | .io = threaded.io(), |
| 714 | .env_map = &env_map, | |
| 714 | .environ_map = &environ_map, | |
| 715 | 715 | })); |
| 716 | 716 | } |
| 717 | 717 |
lib/std/zig/LibCDirs.zig+3-3| ... | ... | @@ -28,7 +28,7 @@ pub fn detect( |
| 28 | 28 | is_native_abi: bool, |
| 29 | 29 | link_libc: bool, |
| 30 | 30 | libc_installation: ?*const LibCInstallation, |
| 31 | env_map: *const std.process.Environ.Map, | |
| 31 | environ_map: *const std.process.Environ.Map, | |
| 32 | 32 | ) LibCInstallation.FindError!LibCDirs { |
| 33 | 33 | if (!link_libc) { |
| 34 | 34 | return .{ |
| ... | ... | @@ -50,7 +50,7 @@ pub fn detect( |
| 50 | 50 | const libc = try arena.create(LibCInstallation); |
| 51 | 51 | libc.* = LibCInstallation.findNative(arena, io, .{ |
| 52 | 52 | .target = target, |
| 53 | .env_map = env_map, | |
| 53 | .environ_map = environ_map, | |
| 54 | 54 | }) catch |err| switch (err) { |
| 55 | 55 | error.CCompilerExitCode, |
| 56 | 56 | error.CCompilerCrashed, |
| ... | ... | @@ -91,7 +91,7 @@ pub fn detect( |
| 91 | 91 | libc.* = try LibCInstallation.findNative(arena, io, .{ |
| 92 | 92 | .verbose = true, |
| 93 | 93 | .target = target, |
| 94 | .env_map = env_map, | |
| 94 | .environ_map = environ_map, | |
| 95 | 95 | }); |
| 96 | 96 | return detectFromInstallation(arena, target, libc); |
| 97 | 97 | } |
lib/std/zig/LibCInstallation.zig+20-20| ... | ... | @@ -168,7 +168,7 @@ pub fn render(self: LibCInstallation, out: *std.Io.Writer) !void { |
| 168 | 168 | |
| 169 | 169 | pub const FindNativeOptions = struct { |
| 170 | 170 | target: *const std.Target, |
| 171 | env_map: *const Environ.Map, | |
| 171 | environ_map: *const Environ.Map, | |
| 172 | 172 | |
| 173 | 173 | /// If enabled, will print human-friendly errors to stderr. |
| 174 | 174 | verbose: bool = false, |
| ... | ... | @@ -193,7 +193,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib |
| 193 | 193 | }); |
| 194 | 194 | return self; |
| 195 | 195 | } else if (is_windows) { |
| 196 | const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.env_map) catch |err| switch (err) { | |
| 196 | const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.environ_map) catch |err| switch (err) { | |
| 197 | 197 | error.NotFound => return error.WindowsSdkNotFound, |
| 198 | 198 | error.PathTooLong => return error.WindowsSdkNotFound, |
| 199 | 199 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -240,17 +240,17 @@ pub fn deinit(self: *LibCInstallation, allocator: Allocator) void { |
| 240 | 240 | |
| 241 | 241 | fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void { |
| 242 | 242 | // Detect infinite loops. |
| 243 | var env_map = try args.env_map.clone(gpa); | |
| 244 | defer env_map.deinit(); | |
| 245 | const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: { | |
| 243 | var environ_map = try args.environ_map.clone(gpa); | |
| 244 | defer environ_map.deinit(); | |
| 245 | const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: { | |
| 246 | 246 | if (std.mem.eql(u8, phase, "1")) { |
| 247 | try env_map.put(inf_loop_env_key, "2"); | |
| 247 | try environ_map.put(inf_loop_env_key, "2"); | |
| 248 | 248 | break :blk true; |
| 249 | 249 | } else { |
| 250 | 250 | return error.ZigIsTheCCompiler; |
| 251 | 251 | } |
| 252 | 252 | } else blk: { |
| 253 | try env_map.put(inf_loop_env_key, "1"); | |
| 253 | try environ_map.put(inf_loop_env_key, "1"); | |
| 254 | 254 | break :blk false; |
| 255 | 255 | }; |
| 256 | 256 | |
| ... | ... | @@ -259,7 +259,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar |
| 259 | 259 | var argv = std.array_list.Managed([]const u8).init(gpa); |
| 260 | 260 | defer argv.deinit(); |
| 261 | 261 | |
| 262 | try appendCcExe(&argv, skip_cc_env_var, &env_map); | |
| 262 | try appendCcExe(&argv, skip_cc_env_var, &environ_map); | |
| 263 | 263 | try argv.appendSlice(&.{ |
| 264 | 264 | "-E", |
| 265 | 265 | "-Wp,-v", |
| ... | ... | @@ -270,7 +270,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar |
| 270 | 270 | const run_res = std.process.run(gpa, io, .{ |
| 271 | 271 | .max_output_bytes = 1024 * 1024, |
| 272 | 272 | .argv = argv.items, |
| 273 | .env_map = &env_map, | |
| 273 | .environ_map = &environ_map, | |
| 274 | 274 | // Some C compilers, such as Clang, are known to rely on argv[0] to find the path |
| 275 | 275 | // to their own executable, without even bothering to resolve PATH. This results in the message: |
| 276 | 276 | // error: unable to execute command: Executable "" doesn't exist! |
| ... | ... | @@ -446,7 +446,7 @@ fn findNativeCrtDirWindows( |
| 446 | 446 | |
| 447 | 447 | fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void { |
| 448 | 448 | self.crt_dir = try ccPrintFileName(gpa, io, .{ |
| 449 | .env_map = args.env_map, | |
| 449 | .environ_map = args.environ_map, | |
| 450 | 450 | .search_basename = switch (args.target.os.tag) { |
| 451 | 451 | .linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o", |
| 452 | 452 | else => "crt1.o", |
| ... | ... | @@ -551,7 +551,7 @@ fn findNativeMsvcLibDir( |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | pub const CCPrintFileNameOptions = struct { |
| 554 | env_map: *const Environ.Map, | |
| 554 | environ_map: *const Environ.Map, | |
| 555 | 555 | search_basename: []const u8, |
| 556 | 556 | want_dirname: enum { full_path, only_dir }, |
| 557 | 557 | verbose: bool = false, |
| ... | ... | @@ -560,17 +560,17 @@ pub const CCPrintFileNameOptions = struct { |
| 560 | 560 | /// caller owns returned memory |
| 561 | 561 | fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 { |
| 562 | 562 | // Detect infinite loops. |
| 563 | var env_map = try args.env_map.clone(gpa); | |
| 564 | defer env_map.deinit(); | |
| 565 | const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: { | |
| 563 | var environ_map = try args.environ_map.clone(gpa); | |
| 564 | defer environ_map.deinit(); | |
| 565 | const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: { | |
| 566 | 566 | if (std.mem.eql(u8, phase, "1")) { |
| 567 | try env_map.put(inf_loop_env_key, "2"); | |
| 567 | try environ_map.put(inf_loop_env_key, "2"); | |
| 568 | 568 | break :blk true; |
| 569 | 569 | } else { |
| 570 | 570 | return error.ZigIsTheCCompiler; |
| 571 | 571 | } |
| 572 | 572 | } else blk: { |
| 573 | try env_map.put(inf_loop_env_key, "1"); | |
| 573 | try environ_map.put(inf_loop_env_key, "1"); | |
| 574 | 574 | break :blk false; |
| 575 | 575 | }; |
| 576 | 576 | |
| ... | ... | @@ -580,13 +580,13 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 { |
| 580 | 580 | const arg1 = try std.fmt.allocPrint(gpa, "-print-file-name={s}", .{args.search_basename}); |
| 581 | 581 | defer gpa.free(arg1); |
| 582 | 582 | |
| 583 | try appendCcExe(&argv, skip_cc_env_var, &env_map); | |
| 583 | try appendCcExe(&argv, skip_cc_env_var, &environ_map); | |
| 584 | 584 | try argv.append(arg1); |
| 585 | 585 | |
| 586 | 586 | const run_res = std.process.run(gpa, io, .{ |
| 587 | 587 | .max_output_bytes = 1024 * 1024, |
| 588 | 588 | .argv = argv.items, |
| 589 | .env_map = &env_map, | |
| 589 | .environ_map = &environ_map, | |
| 590 | 590 | // Some C compilers, such as Clang, are known to rely on argv[0] to find the path |
| 591 | 591 | // to their own executable, without even bothering to resolve PATH. This results in the message: |
| 592 | 592 | // error: unable to execute command: Executable "" doesn't exist! |
| ... | ... | @@ -669,7 +669,7 @@ const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS"; |
| 669 | 669 | fn appendCcExe( |
| 670 | 670 | args: *std.array_list.Managed([]const u8), |
| 671 | 671 | skip_cc_env_var: bool, |
| 672 | env_map: *const Environ.Map, | |
| 672 | environ_map: *const Environ.Map, | |
| 673 | 673 | ) !void { |
| 674 | 674 | const default_cc_exe = if (is_windows) "cc.exe" else "cc"; |
| 675 | 675 | try args.ensureUnusedCapacity(1); |
| ... | ... | @@ -677,7 +677,7 @@ fn appendCcExe( |
| 677 | 677 | args.appendAssumeCapacity(default_cc_exe); |
| 678 | 678 | return; |
| 679 | 679 | } |
| 680 | const cc_env_var = std.zig.EnvVar.CC.get(env_map) orelse { | |
| 680 | const cc_env_var = std.zig.EnvVar.CC.get(environ_map) orelse { | |
| 681 | 681 | args.appendAssumeCapacity(default_cc_exe); |
| 682 | 682 | return; |
| 683 | 683 | }; |
lib/std/zig/WindowsSdk.zig+14-14| ... | ... | @@ -29,7 +29,7 @@ pub fn find( |
| 29 | 29 | gpa: Allocator, |
| 30 | 30 | io: Io, |
| 31 | 31 | arch: std.Target.Cpu.Arch, |
| 32 | env_map: *const Environ.Map, | |
| 32 | environ_map: *const Environ.Map, | |
| 33 | 33 | ) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk { |
| 34 | 34 | if (builtin.os.tag != .windows) return error.NotFound; |
| 35 | 35 | |
| ... | ... | @@ -55,7 +55,7 @@ pub fn find( |
| 55 | 55 | }; |
| 56 | 56 | errdefer if (windows81sdk) |*w| w.free(gpa); |
| 57 | 57 | |
| 58 | const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch, env_map) catch |err| switch (err) { | |
| 58 | const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch, environ_map) catch |err| switch (err) { | |
| 59 | 59 | error.MsvcLibDirNotFound => null, |
| 60 | 60 | error.OutOfMemory => return error.OutOfMemory, |
| 61 | 61 | }; |
| ... | ... | @@ -680,7 +680,7 @@ const MsvcLibDir = struct { |
| 680 | 680 | fn findInstancesDir( |
| 681 | 681 | gpa: Allocator, |
| 682 | 682 | io: Io, |
| 683 | env_map: *const Environ.Map, | |
| 683 | environ_map: *const Environ.Map, | |
| 684 | 684 | ) error{ OutOfMemory, PathNotFound }!Dir { |
| 685 | 685 | // First, try getting the packages cache path from the registry. |
| 686 | 686 | // This only seems to exist when the path is different from the default. |
| ... | ... | @@ -701,7 +701,7 @@ const MsvcLibDir = struct { |
| 701 | 701 | // If that can't be found, fall back to manually appending |
| 702 | 702 | // `Microsoft\VisualStudio\Packages\_Instances` to %PROGRAMDATA% |
| 703 | 703 | method3: { |
| 704 | const program_data = std.zig.EnvVar.PROGRAMDATA.get(env_map) orelse break :method3; | |
| 704 | const program_data = std.zig.EnvVar.PROGRAMDATA.get(environ_map) orelse break :method3; | |
| 705 | 705 | |
| 706 | 706 | if (!Dir.path.isAbsolute(program_data)) break :method3; |
| 707 | 707 | |
| ... | ... | @@ -765,13 +765,13 @@ const MsvcLibDir = struct { |
| 765 | 765 | gpa: Allocator, |
| 766 | 766 | io: Io, |
| 767 | 767 | arch: std.Target.Cpu.Arch, |
| 768 | env_map: *const Environ.Map, | |
| 768 | environ_map: *const Environ.Map, | |
| 769 | 769 | ) error{ OutOfMemory, PathNotFound }![]const u8 { |
| 770 | 770 | // Typically `%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances` |
| 771 | 771 | // This will contain directories with names of instance IDs like 80a758ca, |
| 772 | 772 | // which will contain `state.json` files that have the version and |
| 773 | 773 | // installation directory. |
| 774 | var instances_dir = try findInstancesDir(gpa, io, env_map); | |
| 774 | var instances_dir = try findInstancesDir(gpa, io, environ_map); | |
| 775 | 775 | defer instances_dir.close(io); |
| 776 | 776 | |
| 777 | 777 | var state_subpath_buf: [Dir.max_name_bytes + 32]u8 = undefined; |
| ... | ... | @@ -872,12 +872,12 @@ const MsvcLibDir = struct { |
| 872 | 872 | gpa: Allocator, |
| 873 | 873 | io: Io, |
| 874 | 874 | arch: std.Target.Cpu.Arch, |
| 875 | env_map: *const Environ.Map, | |
| 875 | environ_map: *const Environ.Map, | |
| 876 | 876 | ) error{ OutOfMemory, PathNotFound }![]const u8 { |
| 877 | 877 | |
| 878 | 878 | // %localappdata%\Microsoft\VisualStudio\ |
| 879 | 879 | // %appdata%\Local\Microsoft\VisualStudio\ |
| 880 | const local_app_data_path = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse return error.PathNotFound; | |
| 880 | const local_app_data_path = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse return error.PathNotFound; | |
| 881 | 881 | const visualstudio_folder_path = try Dir.path.join(gpa, &.{ |
| 882 | 882 | local_app_data_path, "Microsoft\\VisualStudio\\", |
| 883 | 883 | }); |
| ... | ... | @@ -968,11 +968,11 @@ const MsvcLibDir = struct { |
| 968 | 968 | gpa: Allocator, |
| 969 | 969 | io: Io, |
| 970 | 970 | arch: std.Target.Cpu.Arch, |
| 971 | env_map: *const Environ.Map, | |
| 971 | environ_map: *const Environ.Map, | |
| 972 | 972 | ) error{ OutOfMemory, PathNotFound }![]const u8 { |
| 973 | 973 | var base_path: std.array_list.Managed(u8) = base_path: { |
| 974 | 974 | try_env: { |
| 975 | if (env_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| { | |
| 975 | if (environ_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| { | |
| 976 | 976 | if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env; |
| 977 | 977 | if (!Dir.path.isAbsolute(VS140COMNTOOLS)) break :try_env; |
| 978 | 978 | var list = std.array_list.Managed(u8).init(gpa); |
| ... | ... | @@ -1046,13 +1046,13 @@ const MsvcLibDir = struct { |
| 1046 | 1046 | gpa: Allocator, |
| 1047 | 1047 | io: Io, |
| 1048 | 1048 | arch: std.Target.Cpu.Arch, |
| 1049 | env_map: *const Environ.Map, | |
| 1049 | environ_map: *const Environ.Map, | |
| 1050 | 1050 | ) error{ OutOfMemory, MsvcLibDirNotFound }![]const u8 { |
| 1051 | const full_path = MsvcLibDir.findViaCOM(gpa, io, arch, env_map) catch |err1| switch (err1) { | |
| 1051 | const full_path = MsvcLibDir.findViaCOM(gpa, io, arch, environ_map) catch |err1| switch (err1) { | |
| 1052 | 1052 | error.OutOfMemory => return error.OutOfMemory, |
| 1053 | error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, env_map) catch |err2| switch (err2) { | |
| 1053 | error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, environ_map) catch |err2| switch (err2) { | |
| 1054 | 1054 | error.OutOfMemory => return error.OutOfMemory, |
| 1055 | error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, arch, env_map) catch |err3| switch (err3) { | |
| 1055 | error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, arch, environ_map) catch |err3| switch (err3) { | |
| 1056 | 1056 | error.OutOfMemory => return error.OutOfMemory, |
| 1057 | 1057 | error.PathNotFound => return error.MsvcLibDirNotFound, |
| 1058 | 1058 | }, |
lib/std/zig/system/NativePaths.zig+8-8| ... | ... | @@ -18,12 +18,12 @@ pub fn detect( |
| 18 | 18 | arena: Allocator, |
| 19 | 19 | io: Io, |
| 20 | 20 | native_target: *const std.Target, |
| 21 | env_map: *process.Environ.Map, | |
| 21 | environ_map: *process.Environ.Map, | |
| 22 | 22 | ) !NativePaths { |
| 23 | 23 | var self: NativePaths = .{ .arena = arena }; |
| 24 | 24 | var is_nix = false; |
| 25 | 25 | |
| 26 | if (std.zig.EnvVar.NIX_CFLAGS_COMPILE.get(env_map)) |nix_cflags_compile| { | |
| 26 | if (std.zig.EnvVar.NIX_CFLAGS_COMPILE.get(environ_map)) |nix_cflags_compile| { | |
| 27 | 27 | is_nix = true; |
| 28 | 28 | var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' '); |
| 29 | 29 | while (true) { |
| ... | ... | @@ -49,7 +49,7 @@ pub fn detect( |
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | if (std.zig.EnvVar.NIX_LDFLAGS.get(env_map)) |nix_ldflags| { | |
| 52 | if (std.zig.EnvVar.NIX_LDFLAGS.get(environ_map)) |nix_ldflags| { | |
| 53 | 53 | is_nix = true; |
| 54 | 54 | var it = mem.tokenizeScalar(u8, nix_ldflags, ' '); |
| 55 | 55 | while (true) { |
| ... | ... | @@ -78,7 +78,7 @@ pub fn detect( |
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | if (std.zig.EnvVar.NIX_CFLAGS_LINK.get(env_map)) |nix_cflags_link| { | |
| 81 | if (std.zig.EnvVar.NIX_CFLAGS_LINK.get(environ_map)) |nix_cflags_link| { | |
| 82 | 82 | is_nix = true; |
| 83 | 83 | var it = mem.tokenizeScalar(u8, nix_cflags_link, ' '); |
| 84 | 84 | while (true) { |
| ... | ... | @@ -121,7 +121,7 @@ pub fn detect( |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // Check for homebrew paths |
| 124 | if (std.zig.EnvVar.HOMEBREW_PREFIX.get(env_map)) |prefix| { | |
| 124 | if (std.zig.EnvVar.HOMEBREW_PREFIX.get(environ_map)) |prefix| { | |
| 125 | 125 | try self.addLibDir(try std.fs.path.join(arena, &.{ prefix, "/lib" })); |
| 126 | 126 | try self.addIncludeDir(try std.fs.path.join(arena, &.{ prefix, "/include" })); |
| 127 | 127 | } |
| ... | ... | @@ -177,21 +177,21 @@ pub fn detect( |
| 177 | 177 | |
| 178 | 178 | // Distros like guix don't use FHS, so they rely on environment |
| 179 | 179 | // variables to search for headers and libraries. |
| 180 | if (std.zig.EnvVar.C_INCLUDE_PATH.get(env_map)) |c_include_path| { | |
| 180 | if (std.zig.EnvVar.C_INCLUDE_PATH.get(environ_map)) |c_include_path| { | |
| 181 | 181 | var it = mem.tokenizeScalar(u8, c_include_path, ':'); |
| 182 | 182 | while (it.next()) |dir| { |
| 183 | 183 | try self.addIncludeDir(dir); |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | if (std.zig.EnvVar.CPLUS_INCLUDE_PATH.get(env_map)) |cplus_include_path| { | |
| 187 | if (std.zig.EnvVar.CPLUS_INCLUDE_PATH.get(environ_map)) |cplus_include_path| { | |
| 188 | 188 | var it = mem.tokenizeScalar(u8, cplus_include_path, ':'); |
| 189 | 189 | while (it.next()) |dir| { |
| 190 | 190 | try self.addIncludeDir(dir); |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | if (std.zig.EnvVar.LIBRARY_PATH.get(env_map)) |library_path| { | |
| 194 | if (std.zig.EnvVar.LIBRARY_PATH.get(environ_map)) |library_path| { | |
| 195 | 195 | var it = mem.tokenizeScalar(u8, library_path, ':'); |
| 196 | 196 | while (it.next()) |dir| { |
| 197 | 197 | try self.addLibDir(dir); |
src/Compilation.zig+4-4| ... | ... | @@ -762,7 +762,7 @@ pub const Directories = struct { |
| 762 | 762 | .wasi => void, |
| 763 | 763 | else => []const u8, |
| 764 | 764 | }, |
| 765 | env_map: *const std.process.Environ.Map, | |
| 765 | environ_map: *const std.process.Environ.Map, | |
| 766 | 766 | ) Directories { |
| 767 | 767 | const wasi = builtin.target.os.tag == .wasi; |
| 768 | 768 | |
| ... | ... | @@ -781,7 +781,7 @@ pub const Directories = struct { |
| 781 | 781 | const global_cache: Cache.Directory = d: { |
| 782 | 782 | if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache"); |
| 783 | 783 | if (wasi) break :d openWasiPreopen(wasi_preopens, "/cache"); |
| 784 | const path = introspect.resolveGlobalCacheDir(arena, env_map) catch |err| { | |
| 784 | const path = introspect.resolveGlobalCacheDir(arena, environ_map) catch |err| { | |
| 785 | 785 | fatal("unable to resolve zig cache directory: {t}", .{err}); |
| 786 | 786 | }; |
| 787 | 787 | break :d openUnresolved(arena, io, cwd, path, .@"global cache"); |
| ... | ... | @@ -5713,7 +5713,7 @@ pub fn translateC( |
| 5713 | 5713 | translated_basename: []const u8, |
| 5714 | 5714 | owner_mod: *Package.Module, |
| 5715 | 5715 | prog_node: std.Progress.Node, |
| 5716 | env_map: *const std.process.Environ.Map, | |
| 5716 | environ_map: *const std.process.Environ.Map, | |
| 5717 | 5717 | ) !CImportResult { |
| 5718 | 5718 | dev.check(.translate_c_command); |
| 5719 | 5719 | |
| ... | ... | @@ -5783,7 +5783,7 @@ pub fn translateC( |
| 5783 | 5783 | } |
| 5784 | 5784 | |
| 5785 | 5785 | var stdout: []u8 = undefined; |
| 5786 | try @import("main.zig").translateC(gpa, arena, io, argv.items, env_map, prog_node, &stdout); | |
| 5786 | try @import("main.zig").translateC(gpa, arena, io, argv.items, environ_map, prog_node, &stdout); | |
| 5787 | 5787 | |
| 5788 | 5788 | if (out_dep_path) |dep_file_path| add_deps: { |
| 5789 | 5789 | if (comp.verbose_cimport) log.info("processing dep file at {s}", .{dep_file_path}); |
src/introspect.zig+5-5| ... | ... | @@ -102,25 +102,25 @@ pub fn findZigLibDirFromSelfExe( |
| 102 | 102 | return error.FileNotFound; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | pub fn resolveGlobalCacheDir(arena: Allocator, env_map: *const std.process.Environ.Map) ![]const u8 { | |
| 106 | if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map)) |value| return value; | |
| 105 | pub fn resolveGlobalCacheDir(arena: Allocator, environ_map: *const std.process.Environ.Map) ![]const u8 { | |
| 106 | if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map)) |value| return value; | |
| 107 | 107 | |
| 108 | 108 | const app_name = "zig"; |
| 109 | 109 | |
| 110 | 110 | switch (builtin.os.tag) { |
| 111 | 111 | .wasi => @compileError("on WASI the global cache dir must be resolved with preopens"), |
| 112 | 112 | .windows => { |
| 113 | const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse | |
| 113 | const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse | |
| 114 | 114 | return error.AppDataDirUnavailable; |
| 115 | 115 | return Dir.path.join(arena, &.{ local_app_data_dir, app_name }); |
| 116 | 116 | }, |
| 117 | 117 | else => { |
| 118 | if (std.zig.EnvVar.XDG_CACHE_HOME.get(env_map)) |cache_root| { | |
| 118 | if (std.zig.EnvVar.XDG_CACHE_HOME.get(environ_map)) |cache_root| { | |
| 119 | 119 | if (cache_root.len > 0) { |
| 120 | 120 | return Dir.path.join(arena, &.{ cache_root, app_name }); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | if (std.zig.EnvVar.HOME.get(env_map)) |home| { | |
| 123 | if (std.zig.EnvVar.HOME.get(environ_map)) |home| { | |
| 124 | 124 | if (home.len > 0) { |
| 125 | 125 | return Dir.path.join(arena, &.{ home, ".cache", app_name }); |
| 126 | 126 | } |
src/main.zig+80-80| ... | ... | @@ -191,7 +191,7 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void { |
| 191 | 191 | fatal("expected command argument", .{}); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | var env_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err}); | |
| 194 | var environ_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err}); | |
| 195 | 195 | |
| 196 | 196 | Compilation.setMainThread(); |
| 197 | 197 | |
| ... | ... | @@ -206,14 +206,14 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void { |
| 206 | 206 | |
| 207 | 207 | if (tracy.enable_allocation) { |
| 208 | 208 | var gpa_tracy = tracy.tracyAllocator(gpa); |
| 209 | return mainArgs(gpa_tracy.allocator(), arena, io, args, &env_map); | |
| 209 | return mainArgs(gpa_tracy.allocator(), arena, io, args, &environ_map); | |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | if (native_os == .wasi) { |
| 213 | 213 | wasi_preopens = try fs.wasi.preopensAlloc(arena); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | return mainArgs(gpa, arena, io, args, &env_map); | |
| 216 | return mainArgs(gpa, arena, io, args, &environ_map); | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | fn mainArgs( |
| ... | ... | @@ -221,9 +221,9 @@ fn mainArgs( |
| 221 | 221 | arena: Allocator, |
| 222 | 222 | io: Io, |
| 223 | 223 | args: []const [:0]const u8, |
| 224 | env_map: *process.Environ.Map, | |
| 224 | environ_map: *process.Environ.Map, | |
| 225 | 225 | ) !void { |
| 226 | if (process.can_replace and EnvVar.ZIG_IS_DETECTING_LIBC_PATHS.isSet(env_map)) { | |
| 226 | if (process.can_replace and EnvVar.ZIG_IS_DETECTING_LIBC_PATHS.isSet(environ_map)) { | |
| 227 | 227 | dev.check(.cc_command); |
| 228 | 228 | // In this case we have accidentally invoked ourselves as "the system C compiler" |
| 229 | 229 | // to figure out where libc is installed. This is essentially infinite recursion |
| ... | ... | @@ -233,7 +233,7 @@ fn mainArgs( |
| 233 | 233 | // why we have this additional environment variable here to check. |
| 234 | 234 | |
| 235 | 235 | const inf_loop_env_key: EnvVar = .ZIG_IS_TRYING_TO_NOT_CALL_ITSELF; |
| 236 | if (inf_loop_env_key.isSet(env_map)) { | |
| 236 | if (inf_loop_env_key.isSet(environ_map)) { | |
| 237 | 237 | fatal("{s}", .{ |
| 238 | 238 | "The compilation links against libc, but Zig is unable to provide a libc " ++ |
| 239 | 239 | "for this operating system, and no --libc " ++ |
| ... | ... | @@ -242,17 +242,17 @@ fn mainArgs( |
| 242 | 242 | "compiler is `zig cc`, so no libc installation was found.", |
| 243 | 243 | }); |
| 244 | 244 | } |
| 245 | try env_map.put(@tagName(inf_loop_env_key), "1"); | |
| 245 | try environ_map.put(@tagName(inf_loop_env_key), "1"); | |
| 246 | 246 | |
| 247 | 247 | // Some programs such as CMake will strip the `cc` and subsequent args from the |
| 248 | 248 | // CC environment variable. We detect and support this scenario here because of |
| 249 | 249 | // the ZIG_IS_DETECTING_LIBC_PATHS environment variable. |
| 250 | 250 | if (mem.eql(u8, args[1], "cc")) { |
| 251 | return process.replace(io, .{ .argv = args[1..], .env_map = env_map }); | |
| 251 | return process.replace(io, .{ .argv = args[1..], .environ_map = environ_map }); | |
| 252 | 252 | } else { |
| 253 | 253 | const modified_args = try arena.dupe([]const u8, args); |
| 254 | 254 | modified_args[0] = "cc"; |
| 255 | return process.replace(io, .{ .argv = modified_args, .env_map = env_map }); | |
| 255 | return process.replace(io, .{ .argv = modified_args, .environ_map = environ_map }); | |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| ... | ... | @@ -260,22 +260,22 @@ fn mainArgs( |
| 260 | 260 | const cmd_args = args[2..]; |
| 261 | 261 | if (mem.eql(u8, cmd, "build-exe")) { |
| 262 | 262 | dev.check(.build_exe_command); |
| 263 | return buildOutputType(gpa, arena, io, args, .{ .build = .Exe }, env_map); | |
| 263 | return buildOutputType(gpa, arena, io, args, .{ .build = .Exe }, environ_map); | |
| 264 | 264 | } else if (mem.eql(u8, cmd, "build-lib")) { |
| 265 | 265 | dev.check(.build_lib_command); |
| 266 | return buildOutputType(gpa, arena, io, args, .{ .build = .Lib }, env_map); | |
| 266 | return buildOutputType(gpa, arena, io, args, .{ .build = .Lib }, environ_map); | |
| 267 | 267 | } else if (mem.eql(u8, cmd, "build-obj")) { |
| 268 | 268 | dev.check(.build_obj_command); |
| 269 | return buildOutputType(gpa, arena, io, args, .{ .build = .Obj }, env_map); | |
| 269 | return buildOutputType(gpa, arena, io, args, .{ .build = .Obj }, environ_map); | |
| 270 | 270 | } else if (mem.eql(u8, cmd, "test")) { |
| 271 | 271 | dev.check(.test_command); |
| 272 | return buildOutputType(gpa, arena, io, args, .zig_test, env_map); | |
| 272 | return buildOutputType(gpa, arena, io, args, .zig_test, environ_map); | |
| 273 | 273 | } else if (mem.eql(u8, cmd, "test-obj")) { |
| 274 | 274 | dev.check(.test_command); |
| 275 | return buildOutputType(gpa, arena, io, args, .zig_test_obj, env_map); | |
| 275 | return buildOutputType(gpa, arena, io, args, .zig_test_obj, environ_map); | |
| 276 | 276 | } else if (mem.eql(u8, cmd, "run")) { |
| 277 | 277 | dev.check(.run_command); |
| 278 | return buildOutputType(gpa, arena, io, args, .run, env_map); | |
| 278 | return buildOutputType(gpa, arena, io, args, .run, environ_map); | |
| 279 | 279 | } else if (mem.eql(u8, cmd, "dlltool") or |
| 280 | 280 | mem.eql(u8, cmd, "ranlib") or |
| 281 | 281 | mem.eql(u8, cmd, "lib") or |
| ... | ... | @@ -285,7 +285,7 @@ fn mainArgs( |
| 285 | 285 | return process.exit(try llvmArMain(arena, args)); |
| 286 | 286 | } else if (mem.eql(u8, cmd, "build")) { |
| 287 | 287 | dev.check(.build_command); |
| 288 | return cmdBuild(gpa, arena, io, cmd_args, env_map); | |
| 288 | return cmdBuild(gpa, arena, io, cmd_args, environ_map); | |
| 289 | 289 | } else if (mem.eql(u8, cmd, "clang") or |
| 290 | 290 | mem.eql(u8, cmd, "-cc1") or mem.eql(u8, cmd, "-cc1as")) |
| 291 | 291 | { |
| ... | ... | @@ -299,16 +299,16 @@ fn mainArgs( |
| 299 | 299 | return process.exit(try lldMain(arena, args, true)); |
| 300 | 300 | } else if (mem.eql(u8, cmd, "cc")) { |
| 301 | 301 | dev.check(.cc_command); |
| 302 | return buildOutputType(gpa, arena, io, args, .cc, env_map); | |
| 302 | return buildOutputType(gpa, arena, io, args, .cc, environ_map); | |
| 303 | 303 | } else if (mem.eql(u8, cmd, "c++")) { |
| 304 | 304 | dev.check(.cc_command); |
| 305 | return buildOutputType(gpa, arena, io, args, .cpp, env_map); | |
| 305 | return buildOutputType(gpa, arena, io, args, .cpp, environ_map); | |
| 306 | 306 | } else if (mem.eql(u8, cmd, "translate-c")) { |
| 307 | 307 | dev.check(.translate_c_command); |
| 308 | return buildOutputType(gpa, arena, io, args, .translate_c, env_map); | |
| 308 | return buildOutputType(gpa, arena, io, args, .translate_c, environ_map); | |
| 309 | 309 | } else if (mem.eql(u8, cmd, "rc")) { |
| 310 | 310 | const use_server = cmd_args.len > 0 and std.mem.eql(u8, cmd_args[0], "--zig-integration"); |
| 311 | return jitCmd(gpa, arena, io, cmd_args, env_map, .{ | |
| 311 | return jitCmd(gpa, arena, io, cmd_args, environ_map, .{ | |
| 312 | 312 | .cmd_name = "resinator", |
| 313 | 313 | .root_src_path = "resinator/main.zig", |
| 314 | 314 | .depend_on_aro = true, |
| ... | ... | @@ -319,20 +319,20 @@ fn mainArgs( |
| 319 | 319 | dev.check(.fmt_command); |
| 320 | 320 | return @import("fmt.zig").run(gpa, arena, io, cmd_args); |
| 321 | 321 | } else if (mem.eql(u8, cmd, "objcopy")) { |
| 322 | return jitCmd(gpa, arena, io, cmd_args, env_map, .{ | |
| 322 | return jitCmd(gpa, arena, io, cmd_args, environ_map, .{ | |
| 323 | 323 | .cmd_name = "objcopy", |
| 324 | 324 | .root_src_path = "objcopy.zig", |
| 325 | 325 | }); |
| 326 | 326 | } else if (mem.eql(u8, cmd, "fetch")) { |
| 327 | return cmdFetch(gpa, arena, io, cmd_args, env_map); | |
| 327 | return cmdFetch(gpa, arena, io, cmd_args, environ_map); | |
| 328 | 328 | } else if (mem.eql(u8, cmd, "libc")) { |
| 329 | return jitCmd(gpa, arena, io, cmd_args, env_map, .{ | |
| 329 | return jitCmd(gpa, arena, io, cmd_args, environ_map, .{ | |
| 330 | 330 | .cmd_name = "libc", |
| 331 | 331 | .root_src_path = "libc.zig", |
| 332 | 332 | .prepend_zig_lib_dir_path = true, |
| 333 | 333 | }); |
| 334 | 334 | } else if (mem.eql(u8, cmd, "std")) { |
| 335 | return jitCmd(gpa, arena, io, cmd_args, env_map, .{ | |
| 335 | return jitCmd(gpa, arena, io, cmd_args, environ_map, .{ | |
| 336 | 336 | .cmd_name = "std", |
| 337 | 337 | .root_src_path = "std-docs.zig", |
| 338 | 338 | .prepend_zig_lib_dir_path = true, |
| ... | ... | @@ -362,11 +362,11 @@ fn mainArgs( |
| 362 | 362 | args, |
| 363 | 363 | if (native_os == .wasi) wasi_preopens, |
| 364 | 364 | &host, |
| 365 | env_map, | |
| 365 | environ_map, | |
| 366 | 366 | ); |
| 367 | 367 | return stdout_writer.interface.flush(); |
| 368 | 368 | } else if (mem.eql(u8, cmd, "reduce")) { |
| 369 | return jitCmd(gpa, arena, io, cmd_args, env_map, .{ | |
| 369 | return jitCmd(gpa, arena, io, cmd_args, environ_map, .{ | |
| 370 | 370 | .cmd_name = "reduce", |
| 371 | 371 | .root_src_path = "reduce.zig", |
| 372 | 372 | }); |
| ... | ... | @@ -811,7 +811,7 @@ fn buildOutputType( |
| 811 | 811 | io: Io, |
| 812 | 812 | all_args: []const []const u8, |
| 813 | 813 | arg_mode: ArgMode, |
| 814 | env_map: *process.Environ.Map, | |
| 814 | environ_map: *process.Environ.Map, | |
| 815 | 815 | ) !void { |
| 816 | 816 | var provided_name: ?[]const u8 = null; |
| 817 | 817 | var root_src_file: ?[]const u8 = null; |
| ... | ... | @@ -824,9 +824,9 @@ fn buildOutputType( |
| 824 | 824 | var debug_compile_errors = false; |
| 825 | 825 | var debug_incremental = false; |
| 826 | 826 | var verbose_link = (native_os != .wasi or builtin.link_libc) and |
| 827 | EnvVar.ZIG_VERBOSE_LINK.isSet(env_map); | |
| 827 | EnvVar.ZIG_VERBOSE_LINK.isSet(environ_map); | |
| 828 | 828 | var verbose_cc = (native_os != .wasi or builtin.link_libc) and |
| 829 | EnvVar.ZIG_VERBOSE_CC.isSet(env_map); | |
| 829 | EnvVar.ZIG_VERBOSE_CC.isSet(environ_map); | |
| 830 | 830 | var verbose_air = false; |
| 831 | 831 | var verbose_intern_pool = false; |
| 832 | 832 | var verbose_generic_instances = false; |
| ... | ... | @@ -898,9 +898,9 @@ fn buildOutputType( |
| 898 | 898 | var runtime_args_start: ?usize = null; |
| 899 | 899 | var test_filters: std.ArrayList([]const u8) = .empty; |
| 900 | 900 | var test_runner_path: ?[]const u8 = null; |
| 901 | var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(env_map); | |
| 902 | var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map); | |
| 903 | var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map); | |
| 901 | var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(environ_map); | |
| 902 | var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); | |
| 903 | var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map); | |
| 904 | 904 | var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no; |
| 905 | 905 | var subsystem: ?std.zig.Subsystem = null; |
| 906 | 906 | var major_subsystem_version: ?u16 = null; |
| ... | ... | @@ -997,7 +997,7 @@ fn buildOutputType( |
| 997 | 997 | .framework_dirs = .{}, |
| 998 | 998 | .rpath_list = .{}, |
| 999 | 999 | .each_lib_rpath = null, |
| 1000 | .libc_paths_file = EnvVar.ZIG_LIBC.get(env_map), | |
| 1000 | .libc_paths_file = EnvVar.ZIG_LIBC.get(environ_map), | |
| 1001 | 1001 | .native_system_include_paths = &.{}, |
| 1002 | 1002 | }; |
| 1003 | 1003 | defer create_module.link_inputs.deinit(gpa); |
| ... | ... | @@ -1006,9 +1006,9 @@ fn buildOutputType( |
| 1006 | 1006 | // if set, default the color setting to .off or .on, respectively |
| 1007 | 1007 | // explicit --color arguments will still override this setting. |
| 1008 | 1008 | // Disable color on WASI per https://github.com/WebAssembly/WASI/issues/162 |
| 1009 | var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet(env_map)) | |
| 1009 | var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet(environ_map)) | |
| 1010 | 1010 | .off |
| 1011 | else if (EnvVar.CLICOLOR_FORCE.isSet(env_map)) | |
| 1011 | else if (EnvVar.CLICOLOR_FORCE.isSet(environ_map)) | |
| 1012 | 1012 | .on |
| 1013 | 1013 | else |
| 1014 | 1014 | .auto; |
| ... | ... | @@ -3106,7 +3106,7 @@ fn buildOutputType( |
| 3106 | 3106 | }, |
| 3107 | 3107 | if (native_os == .wasi) wasi_preopens, |
| 3108 | 3108 | self_exe_path, |
| 3109 | env_map, | |
| 3109 | environ_map, | |
| 3110 | 3110 | ); |
| 3111 | 3111 | defer dirs.deinit(io); |
| 3112 | 3112 | |
| ... | ... | @@ -3118,7 +3118,7 @@ fn buildOutputType( |
| 3118 | 3118 | create_module.opts.emit_bin = emit_bin != .no; |
| 3119 | 3119 | create_module.opts.any_c_source_files = create_module.c_source_files.items.len != 0; |
| 3120 | 3120 | |
| 3121 | const main_mod = try createModule(gpa, arena, io, &create_module, 0, null, color, env_map); | |
| 3121 | const main_mod = try createModule(gpa, arena, io, &create_module, 0, null, color, environ_map); | |
| 3122 | 3122 | for (create_module.modules.keys(), create_module.modules.values()) |key, cli_mod| { |
| 3123 | 3123 | if (cli_mod.resolved == null) |
| 3124 | 3124 | fatal("module '{s}' declared but not used", .{key}); |
| ... | ... | @@ -3595,7 +3595,7 @@ fn buildOutputType( |
| 3595 | 3595 | .global_cc_argv = try cc_argv.toOwnedSlice(arena), |
| 3596 | 3596 | .file_system_inputs = &file_system_inputs, |
| 3597 | 3597 | .debug_compiler_runtime_libs = debug_compiler_runtime_libs, |
| 3598 | .environ_map = env_map, | |
| 3598 | .environ_map = environ_map, | |
| 3599 | 3599 | }) catch |err| switch (err) { |
| 3600 | 3600 | error.CreateFail => switch (create_diag) { |
| 3601 | 3601 | .cross_libc_unavailable => { |
| ... | ... | @@ -3659,7 +3659,7 @@ fn buildOutputType( |
| 3659 | 3659 | arg_mode, |
| 3660 | 3660 | all_args, |
| 3661 | 3661 | runtime_args_start, |
| 3662 | env_map, | |
| 3662 | environ_map, | |
| 3663 | 3663 | ); |
| 3664 | 3664 | return cleanExit(io); |
| 3665 | 3665 | }, |
| ... | ... | @@ -3686,7 +3686,7 @@ fn buildOutputType( |
| 3686 | 3686 | arg_mode, |
| 3687 | 3687 | all_args, |
| 3688 | 3688 | runtime_args_start, |
| 3689 | env_map, | |
| 3689 | environ_map, | |
| 3690 | 3690 | ); |
| 3691 | 3691 | return cleanExit(io); |
| 3692 | 3692 | }, |
| ... | ... | @@ -3699,7 +3699,7 @@ fn buildOutputType( |
| 3699 | 3699 | defer root_prog_node.end(); |
| 3700 | 3700 | |
| 3701 | 3701 | if (arg_mode == .translate_c) { |
| 3702 | return cmdTranslateC(comp, arena, null, null, root_prog_node, env_map); | |
| 3702 | return cmdTranslateC(comp, arena, null, null, root_prog_node, environ_map); | |
| 3703 | 3703 | } |
| 3704 | 3704 | |
| 3705 | 3705 | updateModule(comp, color, root_prog_node) catch |err| switch (err) { |
| ... | ... | @@ -3767,7 +3767,7 @@ fn buildOutputType( |
| 3767 | 3767 | all_args, |
| 3768 | 3768 | runtime_args_start, |
| 3769 | 3769 | create_module.resolved_options.link_libc, |
| 3770 | env_map, | |
| 3770 | environ_map, | |
| 3771 | 3771 | ); |
| 3772 | 3772 | } |
| 3773 | 3773 | |
| ... | ... | @@ -3823,7 +3823,7 @@ fn createModule( |
| 3823 | 3823 | index: usize, |
| 3824 | 3824 | parent: ?*Package.Module, |
| 3825 | 3825 | color: std.zig.Color, |
| 3826 | env_map: *process.Environ.Map, | |
| 3826 | environ_map: *process.Environ.Map, | |
| 3827 | 3827 | ) Allocator.Error!*Package.Module { |
| 3828 | 3828 | const cli_mod = &create_module.modules.values()[index]; |
| 3829 | 3829 | if (cli_mod.resolved) |m| return m; |
| ... | ... | @@ -4003,7 +4003,7 @@ fn createModule( |
| 4003 | 4003 | resolved_target.is_native_os and resolved_target.is_native_abi and |
| 4004 | 4004 | create_module.want_native_include_dirs) |
| 4005 | 4005 | { |
| 4006 | var paths = std.zig.system.NativePaths.detect(arena, io, target, env_map) catch |err| | |
| 4006 | var paths = std.zig.system.NativePaths.detect(arena, io, target, environ_map) catch |err| | |
| 4007 | 4007 | fatal("unable to detect native system paths: {t}", .{err}); |
| 4008 | 4008 | for (paths.warnings.items) |warning| { |
| 4009 | 4009 | warn("{s}", .{warning}); |
| ... | ... | @@ -4030,7 +4030,7 @@ fn createModule( |
| 4030 | 4030 | create_module.libc_installation = LibCInstallation.findNative(arena, io, .{ |
| 4031 | 4031 | .verbose = true, |
| 4032 | 4032 | .target = target, |
| 4033 | .env_map = env_map, | |
| 4033 | .environ_map = environ_map, | |
| 4034 | 4034 | }) catch |err| { |
| 4035 | 4035 | fatal("unable to find native libc installation: {t}", .{err}); |
| 4036 | 4036 | }; |
| ... | ... | @@ -4135,7 +4135,7 @@ fn createModule( |
| 4135 | 4135 | for (cli_mod.deps) |dep| { |
| 4136 | 4136 | const dep_index = create_module.modules.getIndex(dep.value) orelse |
| 4137 | 4137 | fatal("module '{s}' depends on non-existent module '{s}'", .{ name, dep.key }); |
| 4138 | const dep_mod = try createModule(gpa, arena, io, create_module, dep_index, mod, color, env_map); | |
| 4138 | const dep_mod = try createModule(gpa, arena, io, create_module, dep_index, mod, color, environ_map); | |
| 4139 | 4139 | try mod.deps.put(arena, dep.key, dep_mod); |
| 4140 | 4140 | } |
| 4141 | 4141 | |
| ... | ... | @@ -4157,7 +4157,7 @@ fn serve( |
| 4157 | 4157 | arg_mode: ArgMode, |
| 4158 | 4158 | all_args: []const []const u8, |
| 4159 | 4159 | runtime_args_start: ?usize, |
| 4160 | env_map: *process.Environ.Map, | |
| 4160 | environ_map: *process.Environ.Map, | |
| 4161 | 4161 | ) !void { |
| 4162 | 4162 | const gpa = comp.gpa; |
| 4163 | 4163 | const io = comp.io; |
| ... | ... | @@ -4205,7 +4205,7 @@ fn serve( |
| 4205 | 4205 | defer arena_instance.deinit(); |
| 4206 | 4206 | const arena = arena_instance.allocator(); |
| 4207 | 4207 | var output: Compilation.CImportResult = undefined; |
| 4208 | try cmdTranslateC(comp, arena, &output, file_system_inputs, main_progress_node, env_map); | |
| 4208 | try cmdTranslateC(comp, arena, &output, file_system_inputs, main_progress_node, environ_map); | |
| 4209 | 4209 | defer output.deinit(gpa); |
| 4210 | 4210 | |
| 4211 | 4211 | if (file_system_inputs.items.len != 0) { |
| ... | ... | @@ -4405,7 +4405,7 @@ fn runOrTest( |
| 4405 | 4405 | all_args: []const []const u8, |
| 4406 | 4406 | runtime_args_start: ?usize, |
| 4407 | 4407 | link_libc: bool, |
| 4408 | env_map: *process.Environ.Map, | |
| 4408 | environ_map: *process.Environ.Map, | |
| 4409 | 4409 | ) !void { |
| 4410 | 4410 | const raw_emit_bin = comp.emit_bin orelse return; |
| 4411 | 4411 | const exe_path = switch (comp.cache_use) { |
| ... | ... | @@ -4442,14 +4442,14 @@ fn runOrTest( |
| 4442 | 4442 | if (runtime_args_start) |i| { |
| 4443 | 4443 | try argv.appendSlice(all_args[i..]); |
| 4444 | 4444 | } |
| 4445 | try env_map.put("ZIG_EXE", self_exe_path); | |
| 4445 | try environ_map.put("ZIG_EXE", self_exe_path); | |
| 4446 | 4446 | |
| 4447 | 4447 | // We do not execve for tests because if the test fails we want to print |
| 4448 | 4448 | // the error message and invocation below. |
| 4449 | 4449 | if (process.can_replace and arg_mode == .run) { |
| 4450 | 4450 | // process replacement releases the locks; no need to destroy the Compilation here. |
| 4451 | 4451 | _ = try io.lockStderr(&.{}, .no_color); |
| 4452 | const err = process.replace(io, .{ .argv = argv.items, .env_map = env_map }); | |
| 4452 | const err = process.replace(io, .{ .argv = argv.items, .environ_map = environ_map }); | |
| 4453 | 4453 | io.unlockStderr(); |
| 4454 | 4454 | try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc); |
| 4455 | 4455 | const cmd = try std.mem.join(arena, " ", argv.items); |
| ... | ... | @@ -4471,7 +4471,7 @@ fn runOrTest( |
| 4471 | 4471 | |
| 4472 | 4472 | var child = std.process.spawn(io, .{ |
| 4473 | 4473 | .argv = argv.items, |
| 4474 | .env_map = env_map, | |
| 4474 | .environ_map = environ_map, | |
| 4475 | 4475 | .stdin = .inherit, |
| 4476 | 4476 | .stdout = .inherit, |
| 4477 | 4477 | .stderr = .inherit, |
| ... | ... | @@ -4626,7 +4626,7 @@ fn cmdTranslateC( |
| 4626 | 4626 | fancy_output: ?*Compilation.CImportResult, |
| 4627 | 4627 | file_system_inputs: ?*std.ArrayList(u8), |
| 4628 | 4628 | prog_node: std.Progress.Node, |
| 4629 | env_map: *process.Environ.Map, | |
| 4629 | environ_map: *process.Environ.Map, | |
| 4630 | 4630 | ) !void { |
| 4631 | 4631 | dev.check(.translate_c_command); |
| 4632 | 4632 | |
| ... | ... | @@ -4660,7 +4660,7 @@ fn cmdTranslateC( |
| 4660 | 4660 | translated_basename, |
| 4661 | 4661 | comp.root_mod, |
| 4662 | 4662 | prog_node, |
| 4663 | env_map, | |
| 4663 | environ_map, | |
| 4664 | 4664 | ); |
| 4665 | 4665 | |
| 4666 | 4666 | if (result.errors.errorMessageCount() != 0) { |
| ... | ... | @@ -4708,11 +4708,11 @@ pub fn translateC( |
| 4708 | 4708 | arena: Allocator, |
| 4709 | 4709 | io: Io, |
| 4710 | 4710 | argv: []const []const u8, |
| 4711 | env_map: *const process.Environ.Map, | |
| 4711 | environ_map: *const process.Environ.Map, | |
| 4712 | 4712 | prog_node: std.Progress.Node, |
| 4713 | 4713 | capture: ?*[]u8, |
| 4714 | 4714 | ) !void { |
| 4715 | try jitCmd(gpa, arena, io, argv, env_map, .{ | |
| 4715 | try jitCmd(gpa, arena, io, argv, environ_map, .{ | |
| 4716 | 4716 | .cmd_name = "translate-c", |
| 4717 | 4717 | .root_src_path = "translate-c/main.zig", |
| 4718 | 4718 | .depend_on_aro = true, |
| ... | ... | @@ -4869,21 +4869,21 @@ test sanitizeExampleName { |
| 4869 | 4869 | try std.testing.expectEqualStrings("test_project", try sanitizeExampleName(arena, "test project")); |
| 4870 | 4870 | } |
| 4871 | 4871 | |
| 4872 | fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, env_map: *process.Environ.Map) !void { | |
| 4872 | fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, environ_map: *process.Environ.Map) !void { | |
| 4873 | 4873 | dev.check(.build_command); |
| 4874 | 4874 | |
| 4875 | 4875 | var build_file: ?[]const u8 = null; |
| 4876 | var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map); | |
| 4877 | var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map); | |
| 4878 | var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(env_map); | |
| 4879 | var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(env_map); | |
| 4876 | var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map); | |
| 4877 | var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); | |
| 4878 | var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(environ_map); | |
| 4879 | var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(environ_map); | |
| 4880 | 4880 | var child_argv = std.array_list.Managed([]const u8).init(arena); |
| 4881 | 4881 | var reference_trace: ?u32 = null; |
| 4882 | 4882 | var debug_compile_errors = false; |
| 4883 | 4883 | var verbose_link = (native_os != .wasi or builtin.link_libc) and |
| 4884 | EnvVar.ZIG_VERBOSE_LINK.isSet(env_map); | |
| 4884 | EnvVar.ZIG_VERBOSE_LINK.isSet(environ_map); | |
| 4885 | 4885 | var verbose_cc = (native_os != .wasi or builtin.link_libc) and |
| 4886 | EnvVar.ZIG_VERBOSE_CC.isSet(env_map); | |
| 4886 | EnvVar.ZIG_VERBOSE_CC.isSet(environ_map); | |
| 4887 | 4887 | var verbose_air = false; |
| 4888 | 4888 | var verbose_intern_pool = false; |
| 4889 | 4889 | var verbose_generic_instances = false; |
| ... | ... | @@ -5080,7 +5080,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, |
| 5080 | 5080 | } |
| 5081 | 5081 | |
| 5082 | 5082 | const work_around_btrfs_bug = native_os == .linux and |
| 5083 | EnvVar.ZIG_BTRFS_WORKAROUND.isSet(env_map); | |
| 5083 | EnvVar.ZIG_BTRFS_WORKAROUND.isSet(environ_map); | |
| 5084 | 5084 | const root_prog_node = std.Progress.start(io, .{ |
| 5085 | 5085 | .disable_printing = (color == .off), |
| 5086 | 5086 | .root_name = "Compile Build Script", |
| ... | ... | @@ -5140,7 +5140,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, |
| 5140 | 5140 | } }, |
| 5141 | 5141 | {}, |
| 5142 | 5142 | self_exe_path, |
| 5143 | env_map, | |
| 5143 | environ_map, | |
| 5144 | 5144 | ); |
| 5145 | 5145 | defer dirs.deinit(io); |
| 5146 | 5146 | |
| ... | ... | @@ -5243,7 +5243,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, |
| 5243 | 5243 | job_queue.read_only = true; |
| 5244 | 5244 | cleanup_build_dir = job_queue.global_cache.handle; |
| 5245 | 5245 | } else { |
| 5246 | try http_client.initDefaultProxies(arena, env_map); | |
| 5246 | try http_client.initDefaultProxies(arena, environ_map); | |
| 5247 | 5247 | } |
| 5248 | 5248 | |
| 5249 | 5249 | try job_queue.all_fetches.ensureUnusedCapacity(gpa, 1); |
| ... | ... | @@ -5397,7 +5397,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, |
| 5397 | 5397 | .cache_mode = .whole, |
| 5398 | 5398 | .reference_trace = reference_trace, |
| 5399 | 5399 | .debug_compile_errors = debug_compile_errors, |
| 5400 | .environ_map = env_map, | |
| 5400 | .environ_map = environ_map, | |
| 5401 | 5401 | }) catch |err| switch (err) { |
| 5402 | 5402 | error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}), |
| 5403 | 5403 | else => fatal("failed to create compilation: {s}", .{@errorName(err)}), |
| ... | ... | @@ -5516,7 +5516,7 @@ fn jitCmd( |
| 5516 | 5516 | arena: Allocator, |
| 5517 | 5517 | io: Io, |
| 5518 | 5518 | args: []const []const u8, |
| 5519 | env_map: *const process.Environ.Map, | |
| 5519 | environ_map: *const process.Environ.Map, | |
| 5520 | 5520 | options: JitCmdOptions, |
| 5521 | 5521 | ) !void { |
| 5522 | 5522 | dev.check(.jit_command); |
| ... | ... | @@ -5538,13 +5538,13 @@ fn jitCmd( |
| 5538 | 5538 | const self_exe_path = process.executablePathAlloc(io, arena) catch |err| |
| 5539 | 5539 | fatal("unable to find self exe path: {t}", .{err}); |
| 5540 | 5540 | |
| 5541 | const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet(env_map)) | |
| 5541 | const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet(environ_map)) | |
| 5542 | 5542 | .Debug |
| 5543 | 5543 | else |
| 5544 | 5544 | .ReleaseFast; |
| 5545 | 5545 | const strip = optimize_mode != .Debug; |
| 5546 | const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map); | |
| 5547 | const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map); | |
| 5546 | const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map); | |
| 5547 | const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); | |
| 5548 | 5548 | |
| 5549 | 5549 | // This `init` calls `fatal` on error. |
| 5550 | 5550 | var dirs: Compilation.Directories = .init( |
| ... | ... | @@ -5555,7 +5555,7 @@ fn jitCmd( |
| 5555 | 5555 | .global, |
| 5556 | 5556 | if (native_os == .wasi) wasi_preopens, |
| 5557 | 5557 | self_exe_path, |
| 5558 | env_map, | |
| 5558 | environ_map, | |
| 5559 | 5559 | ); |
| 5560 | 5560 | defer dirs.deinit(io); |
| 5561 | 5561 | |
| ... | ... | @@ -5629,7 +5629,7 @@ fn jitCmd( |
| 5629 | 5629 | .self_exe_path = self_exe_path, |
| 5630 | 5630 | .thread_limit = thread_limit, |
| 5631 | 5631 | .cache_mode = .whole, |
| 5632 | .environ_map = env_map, | |
| 5632 | .environ_map = environ_map, | |
| 5633 | 5633 | }) catch |err| switch (err) { |
| 5634 | 5634 | error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}), |
| 5635 | 5635 | else => fatal("failed to create compilation: {s}", .{@errorName(err)}), |
| ... | ... | @@ -5676,11 +5676,11 @@ fn jitCmd( |
| 5676 | 5676 | child_argv.appendSliceAssumeCapacity(args); |
| 5677 | 5677 | |
| 5678 | 5678 | if (process.can_replace and options.capture == null) { |
| 5679 | if (EnvVar.ZIG_DEBUG_CMD.isSet(env_map)) { | |
| 5679 | if (EnvVar.ZIG_DEBUG_CMD.isSet(environ_map)) { | |
| 5680 | 5680 | const cmd = try std.mem.join(arena, " ", child_argv.items); |
| 5681 | 5681 | std.debug.print("{s}\n", .{cmd}); |
| 5682 | 5682 | } |
| 5683 | const err = process.replace(io, .{ .argv = child_argv.items, .env_map = env_map }); | |
| 5683 | const err = process.replace(io, .{ .argv = child_argv.items, .environ_map = environ_map }); | |
| 5684 | 5684 | const cmd = try std.mem.join(arena, " ", child_argv.items); |
| 5685 | 5685 | fatal("the following command failed to execve with '{t}':\n{s}", .{ err, cmd }); |
| 5686 | 5686 | } |
| ... | ... | @@ -6914,15 +6914,15 @@ fn cmdFetch( |
| 6914 | 6914 | arena: Allocator, |
| 6915 | 6915 | io: Io, |
| 6916 | 6916 | args: []const []const u8, |
| 6917 | env_map: *process.Environ.Map, | |
| 6917 | environ_map: *process.Environ.Map, | |
| 6918 | 6918 | ) !void { |
| 6919 | 6919 | dev.check(.fetch_command); |
| 6920 | 6920 | |
| 6921 | 6921 | const color: Color = .auto; |
| 6922 | 6922 | const work_around_btrfs_bug = native_os == .linux and |
| 6923 | EnvVar.ZIG_BTRFS_WORKAROUND.isSet(env_map); | |
| 6923 | EnvVar.ZIG_BTRFS_WORKAROUND.isSet(environ_map); | |
| 6924 | 6924 | var opt_path_or_url: ?[]const u8 = null; |
| 6925 | var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map); | |
| 6925 | var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); | |
| 6926 | 6926 | var debug_hash: bool = false; |
| 6927 | 6927 | var save: union(enum) { |
| 6928 | 6928 | no, |
| ... | ... | @@ -6968,7 +6968,7 @@ fn cmdFetch( |
| 6968 | 6968 | var http_client: std.http.Client = .{ .allocator = gpa, .io = io }; |
| 6969 | 6969 | defer http_client.deinit(); |
| 6970 | 6970 | |
| 6971 | try http_client.initDefaultProxies(arena, env_map); | |
| 6971 | try http_client.initDefaultProxies(arena, environ_map); | |
| 6972 | 6972 | |
| 6973 | 6973 | var root_prog_node = std.Progress.start(io, .{ |
| 6974 | 6974 | .root_name = "Fetch", |
| ... | ... | @@ -6976,7 +6976,7 @@ fn cmdFetch( |
| 6976 | 6976 | defer root_prog_node.end(); |
| 6977 | 6977 | |
| 6978 | 6978 | var global_cache_directory: Directory = l: { |
| 6979 | const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena, env_map); | |
| 6979 | const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena, environ_map); | |
| 6980 | 6980 | break :l .{ |
| 6981 | 6981 | .handle = try Io.Dir.cwd().createDirPathOpen(io, p, .{}), |
| 6982 | 6982 | .path = p, |
src/print_env.zig+5-5| ... | ... | @@ -19,10 +19,10 @@ pub fn cmdEnv( |
| 19 | 19 | else => void, |
| 20 | 20 | }, |
| 21 | 21 | host: *const std.Target, |
| 22 | env_map: *std.process.Environ.Map, | |
| 22 | environ_map: *std.process.Environ.Map, | |
| 23 | 23 | ) !void { |
| 24 | const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map); | |
| 25 | const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map); | |
| 24 | const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map); | |
| 25 | const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map); | |
| 26 | 26 | |
| 27 | 27 | const self_exe_path = switch (builtin.target.os.tag) { |
| 28 | 28 | .wasi => args[0], |
| ... | ... | @@ -39,7 +39,7 @@ pub fn cmdEnv( |
| 39 | 39 | .global, |
| 40 | 40 | if (builtin.target.os.tag == .wasi) wasi_preopens, |
| 41 | 41 | if (builtin.target.os.tag != .wasi) self_exe_path, |
| 42 | env_map, | |
| 42 | environ_map, | |
| 43 | 43 | ); |
| 44 | 44 | defer dirs.deinit(io); |
| 45 | 45 | |
| ... | ... | @@ -59,7 +59,7 @@ pub fn cmdEnv( |
| 59 | 59 | try root.field("target", triple, .{}); |
| 60 | 60 | var env = try root.beginStructField("env", .{}); |
| 61 | 61 | inline for (@typeInfo(EnvVar).@"enum".fields) |field| { |
| 62 | try env.field(field.name, @field(EnvVar, field.name).get(env_map), .{}); | |
| 62 | try env.field(field.name, @field(EnvVar, field.name).get(environ_map), .{}); | |
| 63 | 63 | } |
| 64 | 64 | try env.end(); |
| 65 | 65 | try root.end(); |
test/standalone/child_process/main.zig+3-3| ... | ... | @@ -12,8 +12,8 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 12 | 12 | const process_cwd_path = try std.process.getCwdAlloc(gpa); |
| 13 | 13 | defer gpa.free(process_cwd_path); |
| 14 | 14 | |
| 15 | var env_map = try init.environ.createMap(gpa); | |
| 16 | defer env_map.deinit(); | |
| 15 | var environ_map = try init.environ.createMap(gpa); | |
| 16 | defer environ_map.deinit(); | |
| 17 | 17 | |
| 18 | 18 | var it = try init.args.iterateAllocator(gpa); |
| 19 | 19 | defer it.deinit(); |
| ... | ... | @@ -23,7 +23,7 @@ pub fn main(init: std.process.Init.Minimal) !void { |
| 23 | 23 | const cwd_path = it.next() orelse break :child_path .{ child_path, false }; |
| 24 | 24 | // If there is a third argument, it is the current CWD somewhere within the cache directory. |
| 25 | 25 | // In that case, modify the child path in order to test spawning a path with a leading `..` component. |
| 26 | break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &env_map, cwd_path, child_path), true }; | |
| 26 | break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &environ_map, cwd_path, child_path), true }; | |
| 27 | 27 | }; |
| 28 | 28 | defer if (needs_free) gpa.free(child_path); |
| 29 | 29 |
test/standalone/empty_env/main.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub fn main(init: std.process.Init) !void { |
| 4 | try std.testing.expectEqual(0, init.env_map.count()); | |
| 4 | try std.testing.expectEqual(0, init.environ_map.count()); | |
| 5 | 5 | } |
test/standalone/env_vars/main.zig+14-14| ... | ... | @@ -126,26 +126,26 @@ pub fn main(init: std.process.Init) !void { |
| 126 | 126 | |
| 127 | 127 | // Environ.Map |
| 128 | 128 | { |
| 129 | var env_map = try environ.createMap(allocator); | |
| 130 | defer env_map.deinit(); | |
| 129 | var environ_map = try environ.createMap(allocator); | |
| 130 | defer environ_map.deinit(); | |
| 131 | 131 | |
| 132 | try std.testing.expectEqualSlices(u8, "123", env_map.get("FOO").?); | |
| 133 | try std.testing.expectEqual(null, env_map.get("FO")); | |
| 134 | try std.testing.expectEqual(null, env_map.get("FOOO")); | |
| 132 | try std.testing.expectEqualSlices(u8, "123", environ_map.get("FOO").?); | |
| 133 | try std.testing.expectEqual(null, environ_map.get("FO")); | |
| 134 | try std.testing.expectEqual(null, environ_map.get("FOOO")); | |
| 135 | 135 | if (builtin.os.tag == .windows) { |
| 136 | try std.testing.expectEqualSlices(u8, "123", env_map.get("foo").?); | |
| 136 | try std.testing.expectEqualSlices(u8, "123", environ_map.get("foo").?); | |
| 137 | 137 | } |
| 138 | try std.testing.expectEqualSlices(u8, "ABC=123", env_map.get("EQUALS").?); | |
| 139 | try std.testing.expectEqual(null, env_map.get("EQUALS=ABC")); | |
| 140 | try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("КИРиллИЦА").?); | |
| 138 | try std.testing.expectEqualSlices(u8, "ABC=123", environ_map.get("EQUALS").?); | |
| 139 | try std.testing.expectEqual(null, environ_map.get("EQUALS=ABC")); | |
| 140 | try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("КИРиллИЦА").?); | |
| 141 | 141 | if (builtin.os.tag == .windows) { |
| 142 | try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("кирИЛЛица").?); | |
| 142 | try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("кирИЛЛица").?); | |
| 143 | 143 | } |
| 144 | try std.testing.expectEqualSlices(u8, "", env_map.get("NO_VALUE").?); | |
| 145 | try std.testing.expectEqual(null, env_map.get("NOT_SET")); | |
| 144 | try std.testing.expectEqualSlices(u8, "", environ_map.get("NO_VALUE").?); | |
| 145 | try std.testing.expectEqual(null, environ_map.get("NOT_SET")); | |
| 146 | 146 | if (builtin.os.tag == .windows) { |
| 147 | try std.testing.expectEqualSlices(u8, "hi", env_map.get("=HIDDEN").?); | |
| 148 | try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", env_map.get("INVALID_UTF16_\xed\xa0\x80").?); | |
| 147 | try std.testing.expectEqualSlices(u8, "hi", environ_map.get("=HIDDEN").?); | |
| 148 | try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", environ_map.get("INVALID_UTF16_\xed\xa0\x80").?); | |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | } |
test/standalone/self_exe_symlink/create-symlink.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ pub fn main(init: std.process.Init) !void { |
| 12 | 12 | const cwd = try std.process.getCwdAlloc(init.arena.allocator()); |
| 13 | 13 | |
| 14 | 14 | // If `exe_path` is relative to our cwd, we need to convert it to be relative to the dirname of `symlink_path`. |
| 15 | const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.env_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path); | |
| 15 | const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.environ_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path); | |
| 16 | 16 | defer gpa.free(exe_rel_path); |
| 17 | 17 | |
| 18 | 18 | try std.Io.Dir.cwd().symLink(io, exe_rel_path, symlink_path, .{}); |
test/standalone/windows_bat_args/fuzz.zig+1-1| ... | ... | @@ -94,7 +94,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8 |
| 94 | 94 | const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat"); |
| 95 | 95 | |
| 96 | 96 | const result = try std.process.run(gpa, io, .{ |
| 97 | .env_map = env, | |
| 97 | .environ_map = env, | |
| 98 | 98 | .argv = argv, |
| 99 | 99 | }); |
| 100 | 100 | defer gpa.free(result.stdout); |
test/standalone/windows_bat_args/test.zig+1-1| ... | ... | @@ -141,7 +141,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8 |
| 141 | 141 | const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat"); |
| 142 | 142 | |
| 143 | 143 | const result = try std.process.run(gpa, io, .{ |
| 144 | .env_map = env, | |
| 144 | .environ_map = env, | |
| 145 | 145 | .argv = argv, |
| 146 | 146 | }); |
| 147 | 147 | defer gpa.free(result.stdout); |
test/standalone/windows_paths/test.zig+2-2| ... | ... | @@ -96,12 +96,12 @@ fn checkRelative( |
| 96 | 96 | expected_stdout: []const u8, |
| 97 | 97 | argv: []const []const u8, |
| 98 | 98 | cwd: ?[]const u8, |
| 99 | env_map: ?*const std.process.Environ.Map, | |
| 99 | environ_map: ?*const std.process.Environ.Map, | |
| 100 | 100 | ) !void { |
| 101 | 101 | const result = try std.process.run(allocator, io, .{ |
| 102 | 102 | .argv = argv, |
| 103 | 103 | .cwd = cwd, |
| 104 | .env_map = env_map, | |
| 104 | .environ_map = environ_map, | |
| 105 | 105 | }); |
| 106 | 106 | defer allocator.free(result.stdout); |
| 107 | 107 | defer allocator.free(result.stderr); |
tools/doctest.zig+19-19| ... | ... | @@ -32,10 +32,10 @@ const usage = |
| 32 | 32 | pub fn main(init: std.process.Init) !void { |
| 33 | 33 | const arena = init.arena.allocator(); |
| 34 | 34 | const io = init.io; |
| 35 | const env_map = init.env_map; | |
| 35 | const environ_map = init.environ_map; | |
| 36 | 36 | const cwd_path = try std.process.getCwdAlloc(arena); |
| 37 | 37 | |
| 38 | try env_map.put("CLICOLOR_FORCE", "1"); | |
| 38 | try environ_map.put("CLICOLOR_FORCE", "1"); | |
| 39 | 39 | |
| 40 | 40 | var args_it = try init.minimal.args.iterateAllocator(arena); |
| 41 | 41 | if (!args_it.skip()) fatal("missing argv[0]", .{}); |
| ... | ... | @@ -101,13 +101,13 @@ pub fn main(init: std.process.Init) !void { |
| 101 | 101 | out, |
| 102 | 102 | code, |
| 103 | 103 | tmp_dir_path, |
| 104 | try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_path), | |
| 105 | try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, input_path), | |
| 104 | try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_path), | |
| 105 | try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, input_path), | |
| 106 | 106 | if (opt_zig_lib_dir) |zig_lib_dir| |
| 107 | try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_lib_dir) | |
| 107 | try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_lib_dir) | |
| 108 | 108 | else |
| 109 | 109 | null, |
| 110 | env_map, | |
| 110 | environ_map, | |
| 111 | 111 | ); |
| 112 | 112 | |
| 113 | 113 | try out_file_writer.end(); |
| ... | ... | @@ -126,7 +126,7 @@ fn printOutput( |
| 126 | 126 | input_path: []const u8, |
| 127 | 127 | /// Relative to `tmp_dir_path`. |
| 128 | 128 | opt_zig_lib_dir: ?[]const u8, |
| 129 | env_map: *const process.Environ.Map, | |
| 129 | environ_map: *const process.Environ.Map, | |
| 130 | 130 | ) !void { |
| 131 | 131 | const host = try std.zig.system.resolveTargetQuery(io, .{}); |
| 132 | 132 | const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch); |
| ... | ... | @@ -199,7 +199,7 @@ fn printOutput( |
| 199 | 199 | const result = try process.run(arena, io, .{ |
| 200 | 200 | .argv = build_args.items, |
| 201 | 201 | .cwd = tmp_dir_path, |
| 202 | .env_map = env_map, | |
| 202 | .environ_map = environ_map, | |
| 203 | 203 | .max_output_bytes = max_doc_file_size, |
| 204 | 204 | }); |
| 205 | 205 | switch (result.term) { |
| ... | ... | @@ -221,7 +221,7 @@ fn printOutput( |
| 221 | 221 | try shell_out.writeAll(colored_stderr); |
| 222 | 222 | break :code_block; |
| 223 | 223 | } |
| 224 | const exec_result = run(arena, io, env_map, tmp_dir_path, build_args.items) catch | |
| 224 | const exec_result = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch | |
| 225 | 225 | fatal("example failed to compile", .{}); |
| 226 | 226 | |
| 227 | 227 | if (code.verbose_cimport) { |
| ... | ... | @@ -254,7 +254,7 @@ fn printOutput( |
| 254 | 254 | const result = if (expected_outcome == .fail) blk: { |
| 255 | 255 | const result = try process.run(arena, io, .{ |
| 256 | 256 | .argv = run_args, |
| 257 | .env_map = env_map, | |
| 257 | .environ_map = environ_map, | |
| 258 | 258 | .cwd = tmp_dir_path, |
| 259 | 259 | .max_output_bytes = max_doc_file_size, |
| 260 | 260 | }); |
| ... | ... | @@ -271,7 +271,7 @@ fn printOutput( |
| 271 | 271 | } |
| 272 | 272 | break :blk result; |
| 273 | 273 | } else blk: { |
| 274 | break :blk run(arena, io, env_map, tmp_dir_path, run_args) catch | |
| 274 | break :blk run(arena, io, environ_map, tmp_dir_path, run_args) catch | |
| 275 | 275 | fatal("example crashed", .{}); |
| 276 | 276 | }; |
| 277 | 277 | |
| ... | ... | @@ -340,7 +340,7 @@ fn printOutput( |
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch | |
| 343 | const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch | |
| 344 | 344 | fatal("test failed", .{}); |
| 345 | 345 | const escaped_stderr = try escapeHtml(arena, result.stderr); |
| 346 | 346 | const escaped_stdout = try escapeHtml(arena, result.stdout); |
| ... | ... | @@ -373,7 +373,7 @@ fn printOutput( |
| 373 | 373 | } |
| 374 | 374 | const result = try process.run(arena, io, .{ |
| 375 | 375 | .argv = test_args.items, |
| 376 | .env_map = env_map, | |
| 376 | .environ_map = environ_map, | |
| 377 | 377 | .cwd = tmp_dir_path, |
| 378 | 378 | .max_output_bytes = max_doc_file_size, |
| 379 | 379 | }); |
| ... | ... | @@ -429,7 +429,7 @@ fn printOutput( |
| 429 | 429 | |
| 430 | 430 | const result = try process.run(arena, io, .{ |
| 431 | 431 | .argv = test_args.items, |
| 432 | .env_map = env_map, | |
| 432 | .environ_map = environ_map, | |
| 433 | 433 | .cwd = tmp_dir_path, |
| 434 | 434 | .max_output_bytes = max_doc_file_size, |
| 435 | 435 | }); |
| ... | ... | @@ -505,7 +505,7 @@ fn printOutput( |
| 505 | 505 | if (maybe_error_match) |error_match| { |
| 506 | 506 | const result = try process.run(arena, io, .{ |
| 507 | 507 | .argv = build_args.items, |
| 508 | .env_map = env_map, | |
| 508 | .environ_map = environ_map, | |
| 509 | 509 | .cwd = tmp_dir_path, |
| 510 | 510 | .max_output_bytes = max_doc_file_size, |
| 511 | 511 | }); |
| ... | ... | @@ -531,7 +531,7 @@ fn printOutput( |
| 531 | 531 | const colored_stderr = try termColor(arena, escaped_stderr); |
| 532 | 532 | try shell_out.print("\n{s} ", .{colored_stderr}); |
| 533 | 533 | } else { |
| 534 | _ = run(arena, io, env_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{}); | |
| 534 | _ = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{}); | |
| 535 | 535 | } |
| 536 | 536 | try shell_out.writeAll("\n"); |
| 537 | 537 | }, |
| ... | ... | @@ -590,7 +590,7 @@ fn printOutput( |
| 590 | 590 | try test_args.append(option); |
| 591 | 591 | try shell_out.print("{s} ", .{option}); |
| 592 | 592 | } |
| 593 | const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{}); | |
| 593 | const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{}); | |
| 594 | 594 | const escaped_stderr = try escapeHtml(arena, result.stderr); |
| 595 | 595 | const escaped_stdout = try escapeHtml(arena, result.stdout); |
| 596 | 596 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); |
| ... | ... | @@ -1123,13 +1123,13 @@ fn in(slice: []const u8, number: u8) bool { |
| 1123 | 1123 | fn run( |
| 1124 | 1124 | allocator: Allocator, |
| 1125 | 1125 | io: Io, |
| 1126 | env_map: *const process.Environ.Map, | |
| 1126 | environ_map: *const process.Environ.Map, | |
| 1127 | 1127 | cwd: []const u8, |
| 1128 | 1128 | args: []const []const u8, |
| 1129 | 1129 | ) !process.RunResult { |
| 1130 | 1130 | const result = try process.run(allocator, io, .{ |
| 1131 | 1131 | .argv = args, |
| 1132 | .env_map = env_map, | |
| 1132 | .environ_map = environ_map, | |
| 1133 | 1133 | .cwd = cwd, |
| 1134 | 1134 | .max_output_bytes = max_doc_file_size, |
| 1135 | 1135 | }); |
tools/incr-check.zig+4-4| ... | ... | @@ -31,7 +31,7 @@ pub fn main(init: std.process.Init) !void { |
| 31 | 31 | const fatal = std.process.fatal; |
| 32 | 32 | const arena = init.arena.allocator(); |
| 33 | 33 | const io = init.io; |
| 34 | const env_map = init.env_map; | |
| 34 | const environ_map = init.environ_map; | |
| 35 | 35 | const cwd_path = try std.process.getCwdAlloc(arena); |
| 36 | 36 | |
| 37 | 37 | var opt_zig_exe: ?[]const u8 = null; |
| ... | ... | @@ -113,9 +113,9 @@ pub fn main(init: std.process.Init) !void { |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Convert paths to be relative to the cwd of the subprocess. |
| 116 | const resolved_zig_exe = try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_exe); | |
| 116 | const resolved_zig_exe = try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_exe); | |
| 117 | 117 | const opt_resolved_lib_dir = if (opt_lib_dir) |lib_dir| |
| 118 | try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, lib_dir) | |
| 118 | try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, lib_dir) | |
| 119 | 119 | else |
| 120 | 120 | null; |
| 121 | 121 | |
| ... | ... | @@ -176,7 +176,7 @@ pub fn main(init: std.process.Init) !void { |
| 176 | 176 | var cc_child_args: std.ArrayList([]const u8) = .empty; |
| 177 | 177 | if (target.backend == .cbe) { |
| 178 | 178 | const resolved_cc_zig_exe = if (opt_cc_zig) |cc_zig_exe| |
| 179 | try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, cc_zig_exe) | |
| 179 | try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, cc_zig_exe) | |
| 180 | 180 | else |
| 181 | 181 | resolved_zig_exe; |
| 182 | 182 |
tools/process_headers.zig+2-2| ... | ... | @@ -132,7 +132,7 @@ pub fn main(init: std.process.Init) !void { |
| 132 | 132 | const io = init.io; |
| 133 | 133 | const args = try init.minimal.args.toSlice(arena); |
| 134 | 134 | const cwd_path = try std.process.getCwdAlloc(arena); |
| 135 | const env_map = init.env_map; | |
| 135 | const environ_map = init.environ_map; | |
| 136 | 136 | |
| 137 | 137 | var search_paths = std.array_list.Managed([]const u8).init(arena); |
| 138 | 138 | var opt_out_dir: ?[]const u8 = null; |
| ... | ... | @@ -256,7 +256,7 @@ pub fn main(init: std.process.Init) !void { |
| 256 | 256 | switch (entry.kind) { |
| 257 | 257 | .directory => try dir_stack.append(full_path), |
| 258 | 258 | .file, .sym_link => { |
| 259 | const rel_path = try Dir.path.relative(arena, cwd_path, env_map, target_include_dir, full_path); | |
| 259 | const rel_path = try Dir.path.relative(arena, cwd_path, environ_map, target_include_dir, full_path); | |
| 260 | 260 | const max_size = 2 * 1024 * 1024 * 1024; |
| 261 | 261 | const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size)); |
| 262 | 262 | const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t"); |
tools/update-linux-headers.zig+2-2| ... | ... | @@ -145,7 +145,7 @@ pub fn main(init: std.process.Init) !void { |
| 145 | 145 | const arena = init.arena.allocator(); |
| 146 | 146 | const io = init.io; |
| 147 | 147 | const args = try init.minimal.args.toSlice(arena); |
| 148 | const env_map = init.env_map; | |
| 148 | const environ_map = init.environ_map; | |
| 149 | 149 | const cwd = try std.process.getCwdAlloc(arena); |
| 150 | 150 | |
| 151 | 151 | var search_paths = std.array_list.Managed([]const u8).init(arena); |
| ... | ... | @@ -209,7 +209,7 @@ pub fn main(init: std.process.Init) !void { |
| 209 | 209 | switch (entry.kind) { |
| 210 | 210 | .directory => try dir_stack.append(full_path), |
| 211 | 211 | .file => { |
| 212 | const rel_path = try Dir.path.relative(arena, cwd, env_map, target_include_dir, full_path); | |
| 212 | const rel_path = try Dir.path.relative(arena, cwd, environ_map, target_include_dir, full_path); | |
| 213 | 213 | const max_size = 2 * 1024 * 1024 * 1024; |
| 214 | 214 | const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size)); |
| 215 | 215 | const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t"); |