mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 01:04:43 +01:00
rename env_map to environ_map
For naming consistency with `std.process.Environ.Map`.
This commit is contained in:
parent
f25de4c7a2
commit
1070c2a71a
37 changed files with 290 additions and 291 deletions
4
lib/compiler/aro/aro/Compilation.zig
vendored
4
lib/compiler/aro/aro/Compilation.zig
vendored
|
|
@ -193,14 +193,14 @@ pub fn initDefault(
|
|||
io: Io,
|
||||
diagnostics: *Diagnostics,
|
||||
cwd: Io.Dir,
|
||||
env_map: *const std.process.Environ.Map,
|
||||
environ_map: *const std.process.Environ.Map,
|
||||
) !Compilation {
|
||||
var comp: Compilation = .{
|
||||
.gpa = gpa,
|
||||
.arena = arena,
|
||||
.io = io,
|
||||
.diagnostics = diagnostics,
|
||||
.environment = try Environment.loadAll(gpa, env_map),
|
||||
.environment = try Environment.loadAll(gpa, environ_map),
|
||||
.cwd = cwd,
|
||||
};
|
||||
errdefer comp.deinit();
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ pub fn main(init: process.Init.Minimal) !void {
|
|||
.cwd = try process.getCwdAlloc(single_threaded_arena.allocator()),
|
||||
},
|
||||
.zig_exe = zig_exe,
|
||||
.env_map = try init.environ.createMap(arena),
|
||||
.environ_map = try init.environ.createMap(arena),
|
||||
.global_cache_root = global_cache_directory,
|
||||
.zig_lib_directory = zig_lib_directory,
|
||||
.host = .{
|
||||
|
|
@ -130,13 +130,13 @@ pub fn main(init: process.Init.Minimal) !void {
|
|||
var debounce_interval_ms: u16 = 50;
|
||||
var webui_listen: ?Io.net.IpAddress = null;
|
||||
|
||||
if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.env_map)) |str| {
|
||||
if (std.zig.EnvVar.ZIG_BUILD_ERROR_STYLE.get(&graph.environ_map)) |str| {
|
||||
if (std.meta.stringToEnum(ErrorStyle, str)) |style| {
|
||||
error_style = style;
|
||||
}
|
||||
}
|
||||
|
||||
if (std.zig.EnvVar.ZIG_BUILD_MULTILINE_ERRORS.get(&graph.env_map)) |str| {
|
||||
if (std.zig.EnvVar.ZIG_BUILD_MULTILINE_ERRORS.get(&graph.environ_map)) |str| {
|
||||
if (std.meta.stringToEnum(MultilineErrors, str)) |style| {
|
||||
multiline_errors = style;
|
||||
}
|
||||
|
|
@ -433,8 +433,8 @@ pub fn main(init: process.Init.Minimal) !void {
|
|||
}
|
||||
}
|
||||
|
||||
const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(&graph.env_map);
|
||||
const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.env_map);
|
||||
const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(&graph.environ_map);
|
||||
const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(&graph.environ_map);
|
||||
|
||||
graph.stderr_mode = switch (color) {
|
||||
.auto => try .detect(io, .stderr(), NO_COLOR, CLICOLOR_FORCE),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
const gpa = init.gpa;
|
||||
const io = init.io;
|
||||
const args = try init.minimal.args.toSlice(arena);
|
||||
const env_map = init.env_map;
|
||||
const environ_map = init.environ_map;
|
||||
|
||||
const zig_lib_directory = args[1];
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
is_native_abi,
|
||||
true,
|
||||
libc_installation,
|
||||
env_map,
|
||||
environ_map,
|
||||
) catch |err| {
|
||||
const zig_target = try target.zigTriple(arena);
|
||||
fatal("unable to detect libc for target {s}: {t}", .{ zig_target, err });
|
||||
|
|
@ -123,7 +123,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
var libc = LibCInstallation.findNative(gpa, io, .{
|
||||
.verbose = true,
|
||||
.target = &target,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
}) catch |err| {
|
||||
fatal("unable to detect native libc: {t}", .{err});
|
||||
};
|
||||
|
|
|
|||
4
lib/compiler/resinator/compile.zig
vendored
4
lib/compiler/resinator/compile.zig
vendored
|
|
@ -80,7 +80,7 @@ pub const Dependencies = struct {
|
|||
}
|
||||
};
|
||||
|
||||
pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io.Writer, options: CompileOptions, env_map: *const std.process.Environ.Map) !void {
|
||||
pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io.Writer, options: CompileOptions, environ_map: *const std.process.Environ.Map) !void {
|
||||
var lexer = lex.Lexer.init(source, .{
|
||||
.default_code_page = options.default_code_page,
|
||||
.source_mappings = options.source_mappings,
|
||||
|
|
@ -148,7 +148,7 @@ pub fn compile(allocator: Allocator, io: Io, source: []const u8, writer: *std.Io
|
|||
try search_dirs.append(allocator, .{ .dir = dir, .path = try allocator.dupe(u8, system_include_path) });
|
||||
}
|
||||
if (!options.ignore_include_env_var) {
|
||||
const INCLUDE = env_map.get("INCLUDE") orelse "";
|
||||
const INCLUDE = environ_map.get("INCLUDE") orelse "";
|
||||
|
||||
// The only precedence here is llvm-rc which also uses the platform-specific
|
||||
// delimiter. There's no precedence set by `rc.exe` since it's Windows-only.
|
||||
|
|
|
|||
20
lib/compiler/resinator/main.zig
vendored
20
lib/compiler/resinator/main.zig
vendored
|
|
@ -24,8 +24,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
|
|||
defer std.debug.assert(debug_allocator.deinit() == .ok);
|
||||
const gpa = debug_allocator.allocator();
|
||||
|
||||
var env_map = try init.environ.createMap(gpa);
|
||||
defer env_map.deinit();
|
||||
var environ_map = try init.environ.createMap(gpa);
|
||||
defer environ_map.deinit();
|
||||
|
||||
var threaded: std.Io.Threaded = .init(gpa, .{
|
||||
.environ = init.environ,
|
||||
|
|
@ -151,8 +151,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
|
|||
defer argv.deinit(aro_arena);
|
||||
|
||||
try argv.append(aro_arena, "arocc"); // dummy command name
|
||||
const resolved_include_paths = try include_paths.get(&error_handler, &env_map);
|
||||
try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &env_map);
|
||||
const resolved_include_paths = try include_paths.get(&error_handler, &environ_map);
|
||||
try preprocess.appendAroArgs(aro_arena, &argv, options, resolved_include_paths, &environ_map);
|
||||
try argv.append(aro_arena, switch (options.input_source) {
|
||||
.stdio => "-",
|
||||
.filename => |filename| filename,
|
||||
|
|
@ -286,7 +286,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
|
|||
.dependencies = maybe_dependencies,
|
||||
.ignore_include_env_var = options.ignore_include_env_var,
|
||||
.extra_include_paths = options.extra_include_paths.items,
|
||||
.system_include_paths = try include_paths.get(&error_handler, &env_map),
|
||||
.system_include_paths = try include_paths.get(&error_handler, &environ_map),
|
||||
.default_language_id = options.default_language_id,
|
||||
.default_code_page = default_code_page,
|
||||
.disjoint_code_page = has_disjoint_code_page,
|
||||
|
|
@ -295,7 +295,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
|
|||
.max_string_literal_codepoints = options.max_string_literal_codepoints,
|
||||
.silent_duplicate_control_ids = options.silent_duplicate_control_ids,
|
||||
.warn_instead_of_error_on_invalid_code_page = options.warn_instead_of_error_on_invalid_code_page,
|
||||
}, &env_map) catch |err| switch (err) {
|
||||
}, &environ_map) catch |err| switch (err) {
|
||||
error.ParseError, error.CompileError => {
|
||||
try error_handler.emitDiagnostics(gpa, Io.Dir.cwd(), final_input, &diagnostics, mapping_results.mappings);
|
||||
// Delete the output file on error
|
||||
|
|
@ -545,7 +545,7 @@ const LazyIncludePaths = struct {
|
|||
pub fn get(
|
||||
self: *LazyIncludePaths,
|
||||
error_handler: *ErrorHandler,
|
||||
env_map: *const std.process.Environ.Map,
|
||||
environ_map: *const std.process.Environ.Map,
|
||||
) ![]const []const u8 {
|
||||
const io = self.io;
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ const LazyIncludePaths = struct {
|
|||
self.auto_includes_option,
|
||||
self.zig_lib_dir,
|
||||
self.target_machine_type,
|
||||
env_map,
|
||||
environ_map,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => |e| {
|
||||
|
|
@ -586,7 +586,7 @@ fn getIncludePaths(
|
|||
auto_includes_option: cli.Options.AutoIncludes,
|
||||
zig_lib_dir: []const u8,
|
||||
target_machine_type: std.coff.IMAGE.FILE.MACHINE,
|
||||
env_map: *const std.process.Environ.Map,
|
||||
environ_map: *const std.process.Environ.Map,
|
||||
) ![]const []const u8 {
|
||||
if (auto_includes_option == .none) return &[_][]const u8{};
|
||||
|
||||
|
|
@ -667,7 +667,7 @@ fn getIncludePaths(
|
|||
is_native_abi,
|
||||
true,
|
||||
null,
|
||||
env_map,
|
||||
environ_map,
|
||||
) catch |err| switch (err) {
|
||||
error.OutOfMemory => |e| return e,
|
||||
else => return error.MingwIncludesNotFound,
|
||||
|
|
|
|||
4
lib/compiler/resinator/preprocess.zig
vendored
4
lib/compiler/resinator/preprocess.zig
vendored
|
|
@ -86,7 +86,7 @@ fn hasAnyErrors(comp: *aro.Compilation) bool {
|
|||
|
||||
/// `arena` is used for temporary -D argument strings and the INCLUDE environment variable.
|
||||
/// The arena should be kept alive at least as long as `argv`.
|
||||
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 {
|
||||
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 {
|
||||
try argv.appendSlice(arena, &.{
|
||||
"-E",
|
||||
"--comments",
|
||||
|
|
@ -109,7 +109,7 @@ pub fn appendAroArgs(arena: Allocator, argv: *std.ArrayList([]const u8), options
|
|||
}
|
||||
|
||||
if (!options.ignore_include_env_var) {
|
||||
const INCLUDE = env_map.get("INCLUDE") orelse "";
|
||||
const INCLUDE = environ_map.get("INCLUDE") orelse "";
|
||||
|
||||
// The only precedence here is llvm-rc which also uses the platform-specific
|
||||
// delimiter. There's no precedence set by `rc.exe` since it's Windows-only.
|
||||
|
|
|
|||
8
lib/compiler/translate-c/main.zig
vendored
8
lib/compiler/translate-c/main.zig
vendored
|
|
@ -13,7 +13,7 @@ pub fn main(init: std.process.Init) u8 {
|
|||
const gpa = init.gpa;
|
||||
const arena = init.arena.allocator();
|
||||
const io = init.io;
|
||||
const env_map = init.env_map;
|
||||
const environ_map = init.environ_map;
|
||||
|
||||
const args = init.minimal.args.toSlice(arena) catch {
|
||||
std.debug.print("ran out of memory allocating arguments\n", .{});
|
||||
|
|
@ -26,8 +26,8 @@ pub fn main(init: std.process.Init) u8 {
|
|||
zig_integration = true;
|
||||
}
|
||||
|
||||
const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(env_map);
|
||||
const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(env_map);
|
||||
const NO_COLOR = std.zig.EnvVar.NO_COLOR.isSet(environ_map);
|
||||
const CLICOLOR_FORCE = std.zig.EnvVar.CLICOLOR_FORCE.isSet(environ_map);
|
||||
|
||||
var stderr_buf: [1024]u8 = undefined;
|
||||
var stderr = Io.File.stderr().writer(io, &stderr_buf);
|
||||
|
|
@ -42,7 +42,7 @@ pub fn main(init: std.process.Init) u8 {
|
|||
};
|
||||
defer diagnostics.deinit();
|
||||
|
||||
var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, .cwd(), env_map) catch |err| switch (err) {
|
||||
var comp = aro.Compilation.initDefault(gpa, arena, io, &diagnostics, .cwd(), environ_map) catch |err| switch (err) {
|
||||
error.OutOfMemory => {
|
||||
std.debug.print("ran out of memory initializing C compilation\n", .{});
|
||||
if (fast_exit) process.exit(1);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ const StringHashMap = std.StringHashMap;
|
|||
const Allocator = std.mem.Allocator;
|
||||
const Target = std.Target;
|
||||
const process = std.process;
|
||||
const EnvMap = std.process.Environ.Map;
|
||||
const File = std.Io.File;
|
||||
const Sha256 = std.crypto.hash.sha2.Sha256;
|
||||
const ArrayList = std.ArrayList;
|
||||
|
|
@ -118,7 +117,7 @@ pub const Graph = struct {
|
|||
debug_compiler_runtime_libs: bool = false,
|
||||
cache: Cache,
|
||||
zig_exe: [:0]const u8,
|
||||
env_map: EnvMap,
|
||||
environ_map: process.Environ.Map,
|
||||
global_cache_root: Cache.Directory,
|
||||
zig_lib_directory: Cache.Directory,
|
||||
needed_lazy_dependencies: std.StringArrayHashMapUnmanaged(void) = .empty,
|
||||
|
|
@ -289,7 +288,7 @@ pub fn create(
|
|||
.lib_dir = undefined,
|
||||
.exe_dir = undefined,
|
||||
.h_dir = undefined,
|
||||
.dest_dir = graph.env_map.get("DESTDIR"),
|
||||
.dest_dir = graph.environ_map.get("DESTDIR"),
|
||||
.install_tls = .{
|
||||
.step = .init(.{
|
||||
.id = TopLevelStep.base_id,
|
||||
|
|
@ -1772,7 +1771,7 @@ fn tryFindProgram(b: *Build, full_path: []const u8) ?[]const u8 {
|
|||
}
|
||||
|
||||
if (builtin.os.tag == .windows) {
|
||||
if (b.graph.env_map.get("PATHEXT")) |PATHEXT| {
|
||||
if (b.graph.environ_map.get("PATHEXT")) |PATHEXT| {
|
||||
var it = mem.tokenizeScalar(u8, PATHEXT, fs.path.delimiter);
|
||||
|
||||
while (it.next()) |ext| {
|
||||
|
|
@ -1803,7 +1802,7 @@ pub fn findProgram(b: *Build, names: []const []const u8, paths: []const []const
|
|||
return tryFindProgram(b, b.pathJoin(&.{ search_prefix, "bin", name })) orelse continue;
|
||||
}
|
||||
}
|
||||
if (b.graph.env_map.get("PATH")) |PATH| {
|
||||
if (b.graph.environ_map.get("PATH")) |PATH| {
|
||||
for (names) |name| {
|
||||
if (fs.path.isAbsolute(name)) {
|
||||
return name;
|
||||
|
|
@ -1840,11 +1839,11 @@ pub fn runAllowFail(
|
|||
const io = graph.io;
|
||||
|
||||
const max_output_size = 400 * 1024;
|
||||
try Step.handleVerbose2(b, null, &graph.env_map, argv);
|
||||
try Step.handleVerbose2(b, null, &graph.environ_map, argv);
|
||||
|
||||
var child = try std.process.spawn(io, .{
|
||||
.argv = argv,
|
||||
.env_map = &graph.env_map,
|
||||
.environ_map = &graph.environ_map,
|
||||
.stdin = .ignore,
|
||||
.stdout = .pipe,
|
||||
.stderr = stderr_behavior,
|
||||
|
|
|
|||
|
|
@ -362,7 +362,7 @@ pub fn captureChildProcess(
|
|||
|
||||
const result = std.process.run(arena, io, .{
|
||||
.argv = argv,
|
||||
.env_map = &graph.env_map,
|
||||
.environ_map = &graph.environ_map,
|
||||
.progress_node = progress_node,
|
||||
}) catch |err| return s.fail("failed to run {s}: {t}", .{ argv[0], err });
|
||||
|
||||
|
|
@ -453,7 +453,7 @@ pub fn evalZigProcess(
|
|||
|
||||
zp.child = std.process.spawn(io, .{
|
||||
.argv = argv,
|
||||
.env_map = &b.graph.env_map,
|
||||
.environ_map = &b.graph.environ_map,
|
||||
.stdin = .pipe,
|
||||
.stdout = .pipe,
|
||||
.stderr = .pipe,
|
||||
|
|
@ -702,7 +702,7 @@ pub fn handleVerbose2(
|
|||
// stderr before spawning them.
|
||||
const text = try allocPrintCmd(b.allocator, opt_cwd, if (opt_env) |env| .{
|
||||
.child = env,
|
||||
.parent = &graph.env_map,
|
||||
.parent = &graph.environ_map,
|
||||
} else null, argv);
|
||||
std.debug.print("{s}\n", .{text});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -741,7 +741,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
|
|||
};
|
||||
|
||||
var code: u8 = undefined;
|
||||
const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
|
||||
const pkg_config_exe = b.graph.environ_map.get("PKG_CONFIG") orelse "pkg-config";
|
||||
const stdout = if (b.runAllowFail(&[_][]const u8{
|
||||
pkg_config_exe,
|
||||
pkg_name,
|
||||
|
|
@ -1846,7 +1846,7 @@ pub fn doAtomicSymLinks(
|
|||
}
|
||||
|
||||
fn execPkgConfigList(b: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg {
|
||||
const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
|
||||
const pkg_config_exe = b.graph.environ_map.get("PKG_CONFIG") orelse "pkg-config";
|
||||
const stdout = try b.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .ignore);
|
||||
var list = std.array_list.Managed(PkgConfigPkg).init(b.allocator);
|
||||
errdefer list.deinit();
|
||||
|
|
|
|||
|
|
@ -550,7 +550,7 @@ test Options {
|
|||
.cwd = cwd,
|
||||
},
|
||||
.zig_exe = "test",
|
||||
.env_map = std.process.Environ.Map.init(arena.allocator()),
|
||||
.environ_map = std.process.Environ.Map.init(arena.allocator()),
|
||||
.global_cache_root = .{ .path = "test", .handle = Io.Dir.cwd() },
|
||||
.host = .{
|
||||
.query = .{},
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ argv: std.ArrayList(Arg),
|
|||
cwd: ?Build.LazyPath,
|
||||
|
||||
/// Override this field to modify the environment, or use setEnvironmentVariable
|
||||
env_map: ?*EnvMap,
|
||||
environ_map: ?*EnvMap,
|
||||
|
||||
/// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables.
|
||||
color: Color = .auto,
|
||||
|
|
@ -215,7 +215,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run {
|
|||
}),
|
||||
.argv = .{},
|
||||
.cwd = null,
|
||||
.env_map = null,
|
||||
.environ_map = null,
|
||||
.disable_zig_progress = false,
|
||||
.stdio = .infer_from_args,
|
||||
.stdin = .none,
|
||||
|
|
@ -540,12 +540,12 @@ pub fn clearEnvironment(run: *Run) void {
|
|||
const b = run.step.owner;
|
||||
const new_env_map = b.allocator.create(EnvMap) catch @panic("OOM");
|
||||
new_env_map.* = .init(b.allocator);
|
||||
run.env_map = new_env_map;
|
||||
run.environ_map = new_env_map;
|
||||
}
|
||||
|
||||
pub fn addPathDir(run: *Run, search_path: []const u8) void {
|
||||
const b = run.step.owner;
|
||||
const env_map = getEnvMapInternal(run);
|
||||
const environ_map = getEnvMapInternal(run);
|
||||
|
||||
const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) {
|
||||
.artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows,
|
||||
|
|
@ -562,7 +562,7 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
|
|||
.output_file, .output_directory => false,
|
||||
};
|
||||
const key = if (use_wine) "WINEPATH" else "PATH";
|
||||
const prev_path = env_map.get(key);
|
||||
const prev_path = environ_map.get(key);
|
||||
|
||||
if (prev_path) |pp| {
|
||||
const new_path = b.fmt("{s}{c}{s}", .{
|
||||
|
|
@ -570,9 +570,9 @@ pub fn addPathDir(run: *Run, search_path: []const u8) void {
|
|||
if (use_wine) Dir.path.delimiter_windows else Dir.path.delimiter,
|
||||
search_path,
|
||||
});
|
||||
env_map.put(key, new_path) catch @panic("OOM");
|
||||
environ_map.put(key, new_path) catch @panic("OOM");
|
||||
} else {
|
||||
env_map.put(key, b.dupePath(search_path)) catch @panic("OOM");
|
||||
environ_map.put(key, b.dupePath(search_path)) catch @panic("OOM");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -583,18 +583,18 @@ pub fn getEnvMap(run: *Run) *EnvMap {
|
|||
fn getEnvMapInternal(run: *Run) *EnvMap {
|
||||
const graph = run.step.owner.graph;
|
||||
const arena = graph.arena;
|
||||
return run.env_map orelse {
|
||||
return run.environ_map orelse {
|
||||
const cloned_map = arena.create(EnvMap) catch @panic("OOM");
|
||||
cloned_map.* = graph.env_map.clone(arena) catch @panic("OOM");
|
||||
run.env_map = cloned_map;
|
||||
cloned_map.* = graph.environ_map.clone(arena) catch @panic("OOM");
|
||||
run.environ_map = cloned_map;
|
||||
return cloned_map;
|
||||
};
|
||||
}
|
||||
|
||||
pub fn setEnvironmentVariable(run: *Run, key: []const u8, value: []const u8) void {
|
||||
const env_map = run.getEnvMap();
|
||||
const environ_map = run.getEnvMap();
|
||||
// This data structure already dupes keys and values.
|
||||
env_map.put(key, value) catch @panic("OOM");
|
||||
environ_map.put(key, value) catch @panic("OOM");
|
||||
}
|
||||
|
||||
pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void {
|
||||
|
|
@ -762,7 +762,7 @@ fn convertPathArg(run: *Run, path: Build.Cache.Path) []const u8 {
|
|||
const child_lazy_cwd = run.cwd orelse break :rel path_str;
|
||||
const child_cwd = child_lazy_cwd.getPath3(b, &run.step).toString(arena) catch @panic("OOM");
|
||||
// Convert it from relative to *our* cwd, to relative to the *child's* cwd.
|
||||
break :rel Dir.path.relative(arena, graph.cache.cwd, &graph.env_map, child_cwd, path_str) catch @panic("OOM");
|
||||
break :rel Dir.path.relative(arena, graph.cache.cwd, &graph.environ_map, child_cwd, path_str) catch @panic("OOM");
|
||||
};
|
||||
// Not every path can be made relative, e.g. if the path and the child cwd are on different
|
||||
// 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 {
|
|||
var man = b.graph.cache.obtain();
|
||||
defer man.deinit();
|
||||
|
||||
if (run.env_map) |env_map| {
|
||||
for (env_map.keys(), env_map.values()) |key, value| {
|
||||
if (run.environ_map) |environ_map| {
|
||||
for (environ_map.keys(), environ_map.values()) |key, value| {
|
||||
man.hash.addBytes(key);
|
||||
man.hash.addBytes(value);
|
||||
}
|
||||
|
|
@ -1222,7 +1222,7 @@ fn runCommand(
|
|||
const cwd: ?[]const u8 = if (run.cwd) |lazy_cwd| lazy_cwd.getPath2(b, step) else null;
|
||||
|
||||
try step.handleChildProcUnsupported();
|
||||
try Step.handleVerbose2(step.owner, cwd, run.env_map, argv);
|
||||
try Step.handleVerbose2(step.owner, cwd, run.environ_map, argv);
|
||||
|
||||
const allow_skip = switch (run.stdio) {
|
||||
.check, .zig_test => run.skip_foreign_checks,
|
||||
|
|
@ -1232,13 +1232,13 @@ fn runCommand(
|
|||
var interp_argv = std.array_list.Managed([]const u8).init(b.allocator);
|
||||
defer interp_argv.deinit();
|
||||
|
||||
var env_map: EnvMap = env: {
|
||||
const orig = run.env_map orelse &b.graph.env_map;
|
||||
var environ_map: EnvMap = env: {
|
||||
const orig = run.environ_map orelse &b.graph.environ_map;
|
||||
break :env try orig.clone(gpa);
|
||||
};
|
||||
defer env_map.deinit();
|
||||
defer environ_map.deinit();
|
||||
|
||||
const opt_generic_result = spawnChildAndCollect(run, argv, &env_map, has_side_effects, options, fuzz_context) catch |err| term: {
|
||||
const opt_generic_result = spawnChildAndCollect(run, argv, &environ_map, has_side_effects, options, fuzz_context) catch |err| term: {
|
||||
// InvalidExe: cpu arch mismatch
|
||||
// FileNotFound: can happen with a wrong dynamic linker path
|
||||
if (err == error.InvalidExe or err == error.FileNotFound) interpret: {
|
||||
|
|
@ -1274,8 +1274,8 @@ fn runCommand(
|
|||
|
||||
// Wine's excessive stderr logging is only situationally helpful. Disable it by default, but
|
||||
// allow the user to override it (e.g. with `WINEDEBUG=err+all`) if desired.
|
||||
if (env_map.get("WINEDEBUG") == null) {
|
||||
try env_map.put("WINEDEBUG", "-all");
|
||||
if (environ_map.get("WINEDEBUG") == null) {
|
||||
try environ_map.put("WINEDEBUG", "-all");
|
||||
}
|
||||
} else {
|
||||
return failForeign(run, "-fwine", argv[0], exe);
|
||||
|
|
@ -1372,9 +1372,9 @@ fn runCommand(
|
|||
|
||||
gpa.free(step.result_failed_command.?);
|
||||
step.result_failed_command = null;
|
||||
try Step.handleVerbose2(step.owner, cwd, run.env_map, interp_argv.items);
|
||||
try Step.handleVerbose2(step.owner, cwd, run.environ_map, interp_argv.items);
|
||||
|
||||
break :term spawnChildAndCollect(run, interp_argv.items, &env_map, has_side_effects, options, fuzz_context) catch |e| {
|
||||
break :term spawnChildAndCollect(run, interp_argv.items, &environ_map, has_side_effects, options, fuzz_context) catch |e| {
|
||||
if (!run.failing_to_execute_foreign_is_an_error) return error.MakeSkipped;
|
||||
if (e == error.MakeFailed) return error.MakeFailed; // error already reported
|
||||
return step.fail("unable to spawn interpreter {s}: {s}", .{
|
||||
|
|
@ -1529,7 +1529,7 @@ const EvalGenericResult = struct {
|
|||
fn spawnChildAndCollect(
|
||||
run: *Run,
|
||||
argv: []const []const u8,
|
||||
env_map: *EnvMap,
|
||||
environ_map: *EnvMap,
|
||||
has_side_effects: bool,
|
||||
options: Step.MakeOptions,
|
||||
fuzz_context: ?FuzzContext,
|
||||
|
|
@ -1548,14 +1548,14 @@ fn spawnChildAndCollect(
|
|||
// If an error occurs, it's caused by this command:
|
||||
assert(run.step.result_failed_command == null);
|
||||
run.step.result_failed_command = try Step.allocPrintCmd(options.gpa, child_cwd, .{
|
||||
.child = env_map,
|
||||
.parent = &graph.env_map,
|
||||
.child = environ_map,
|
||||
.parent = &graph.environ_map,
|
||||
}, argv);
|
||||
|
||||
var spawn_options: process.SpawnOptions = .{
|
||||
.argv = argv,
|
||||
.cwd = child_cwd,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.request_resource_usage_statistics = true,
|
||||
.stdin = if (run.stdin != .none) s: {
|
||||
assert(run.stdio != .inherit);
|
||||
|
|
@ -1595,7 +1595,7 @@ fn spawnChildAndCollect(
|
|||
break :m stderr.terminal_mode;
|
||||
} else .no_color;
|
||||
defer if (inherit) io.unlockStderr();
|
||||
try setColorEnvironmentVariables(run, env_map, terminal_mode);
|
||||
try setColorEnvironmentVariables(run, environ_map, terminal_mode);
|
||||
var timer = try std.time.Timer.start();
|
||||
const res = try evalGeneric(run, spawn_options);
|
||||
run.step.result_duration_ns = timer.read();
|
||||
|
|
@ -1603,16 +1603,16 @@ fn spawnChildAndCollect(
|
|||
}
|
||||
}
|
||||
|
||||
fn setColorEnvironmentVariables(run: *Run, env_map: *EnvMap, terminal_mode: Io.Terminal.Mode) !void {
|
||||
fn setColorEnvironmentVariables(run: *Run, environ_map: *EnvMap, terminal_mode: Io.Terminal.Mode) !void {
|
||||
color: switch (run.color) {
|
||||
.manual => {},
|
||||
.enable => {
|
||||
try env_map.put("CLICOLOR_FORCE", "1");
|
||||
_ = env_map.swapRemove("NO_COLOR");
|
||||
try environ_map.put("CLICOLOR_FORCE", "1");
|
||||
_ = environ_map.swapRemove("NO_COLOR");
|
||||
},
|
||||
.disable => {
|
||||
try env_map.put("NO_COLOR", "1");
|
||||
_ = env_map.swapRemove("CLICOLOR_FORCE");
|
||||
try environ_map.put("NO_COLOR", "1");
|
||||
_ = environ_map.swapRemove("CLICOLOR_FORCE");
|
||||
},
|
||||
.inherit => switch (terminal_mode) {
|
||||
.no_color, .windows_api => continue :color .disable,
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim
|
|||
|
||||
var child = try std.process.spawn(io, .{
|
||||
.argv = argv.items,
|
||||
.env_map = &graph.env_map,
|
||||
.environ_map = &graph.environ_map,
|
||||
.stdin = .pipe,
|
||||
.stdout = .pipe,
|
||||
.stderr = .pipe,
|
||||
|
|
|
|||
|
|
@ -12887,8 +12887,8 @@ fn spawnPosix(t: *Threaded, options: process.SpawnOptions) process.SpawnError!Sp
|
|||
|
||||
const envp: [*:null]const ?[*:0]const u8 = m: {
|
||||
const prog_fd: i32 = if (prog_pipe[1] == -1) -1 else prog_fileno;
|
||||
if (options.env_map) |env_map| {
|
||||
break :m (try env_map.createBlockPosix(arena, .{
|
||||
if (options.environ_map) |environ_map| {
|
||||
break :m (try environ_map.createBlockPosix(arena, .{
|
||||
.zig_progress_fd = prog_fd,
|
||||
})).ptr;
|
||||
}
|
||||
|
|
@ -13436,7 +13436,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro
|
|||
const cwd_w = if (options.cwd) |cwd| try std.unicode.wtf8ToWtf16LeAllocZ(arena, cwd) else null;
|
||||
const cwd_w_ptr = if (cwd_w) |cwd| cwd.ptr else null;
|
||||
|
||||
const maybe_envp_buf = if (options.env_map) |env_map| try env_map.createBlockWindows(arena) else null;
|
||||
const maybe_envp_buf = if (options.environ_map) |environ_map| try environ_map.createBlockWindows(arena) else null;
|
||||
const envp_ptr = if (maybe_envp_buf) |envp_buf| envp_buf.ptr else null;
|
||||
|
||||
const app_name_wtf8 = options.argv[0];
|
||||
|
|
|
|||
|
|
@ -1506,16 +1506,16 @@ fn testBasenameWindows(input: []const u8, expected_output: []const u8) !void {
|
|||
/// on each), a zero-length string is returned.
|
||||
///
|
||||
/// See `relativePosix` and `relativeWindows` for operating system specific
|
||||
/// details and for how `env_map` is used.
|
||||
/// details and for how `environ_map` is used.
|
||||
pub fn relative(
|
||||
gpa: Allocator,
|
||||
cwd: []const u8,
|
||||
env_map: ?*const std.process.Environ.Map,
|
||||
environ_map: ?*const std.process.Environ.Map,
|
||||
from: []const u8,
|
||||
to: []const u8,
|
||||
) Allocator.Error![]u8 {
|
||||
if (native_os == .windows) {
|
||||
return relativeWindows(gpa, cwd, env_map, from, to);
|
||||
return relativeWindows(gpa, cwd, environ_map, from, to);
|
||||
} else {
|
||||
return relativePosix(gpa, cwd, from, to);
|
||||
}
|
||||
|
|
@ -1536,12 +1536,12 @@ pub fn relative(
|
|||
/// Per-drive CWDs are stored in special semi-hidden environment variables of
|
||||
/// the format `=<drive-letter>:`, e.g. `=C:`. This type of CWD is purely a
|
||||
/// shell concept, so there's no guarantee that it'll be set or that it'll even
|
||||
/// be accurate. This is the only reason for the `env_map` parameter. `null` is
|
||||
/// be accurate. This is the only reason for the `environ_map` parameter. `null` is
|
||||
/// treated equivalent to the environment variable missing.
|
||||
pub fn relativeWindows(
|
||||
gpa: Allocator,
|
||||
cwd: []const u8,
|
||||
env_map: ?*const std.process.Environ.Map,
|
||||
environ_map: ?*const std.process.Environ.Map,
|
||||
from: []const u8,
|
||||
to: []const u8,
|
||||
) Allocator.Error![]u8 {
|
||||
|
|
@ -1565,13 +1565,13 @@ pub fn relativeWindows(
|
|||
};
|
||||
|
||||
if (result_is_always_to) {
|
||||
return windowsResolveAgainstCwd(gpa, cwd, env_map, to, parsed_to);
|
||||
return windowsResolveAgainstCwd(gpa, cwd, environ_map, to, parsed_to);
|
||||
}
|
||||
|
||||
const resolved_from = try windowsResolveAgainstCwd(gpa, cwd, env_map, from, parsed_from);
|
||||
const resolved_from = try windowsResolveAgainstCwd(gpa, cwd, environ_map, from, parsed_from);
|
||||
defer gpa.free(resolved_from);
|
||||
var clean_up_resolved_to = true;
|
||||
const resolved_to = try windowsResolveAgainstCwd(gpa, cwd, env_map, to, parsed_to);
|
||||
const resolved_to = try windowsResolveAgainstCwd(gpa, cwd, environ_map, to, parsed_to);
|
||||
defer if (clean_up_resolved_to) gpa.free(resolved_to);
|
||||
|
||||
const parsed_resolved_from = parsePathWindows(u8, resolved_from);
|
||||
|
|
@ -1637,7 +1637,7 @@ pub fn relativeWindows(
|
|||
fn windowsResolveAgainstCwd(
|
||||
gpa: Allocator,
|
||||
cwd: []const u8,
|
||||
env_map: ?*const std.process.Environ.Map,
|
||||
environ_map: ?*const std.process.Environ.Map,
|
||||
path: []const u8,
|
||||
parsed: WindowsPath2(u8),
|
||||
) ![]u8 {
|
||||
|
|
@ -1679,7 +1679,7 @@ fn windowsResolveAgainstCwd(
|
|||
if (drive_letters_match)
|
||||
break :drive_cwd cwd;
|
||||
|
||||
if (env_map) |m| {
|
||||
if (environ_map) |m| {
|
||||
if (m.get(&.{ '=', parsed.root[0], ':' })) |v| {
|
||||
break :drive_cwd try temp_allocator.dupe(u8, v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1307,7 +1307,7 @@ pub fn deinit(client: *Client) void {
|
|||
/// Asserts the client has no active connections.
|
||||
/// Uses `arena` for a few small allocations that must outlive the client, or
|
||||
/// at least until those fields are set to different values.
|
||||
pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.process.Environ.Map) !void {
|
||||
pub fn initDefaultProxies(client: *Client, arena: Allocator, environ_map: *std.process.Environ.Map) !void {
|
||||
// Prevent any new connections from being created.
|
||||
client.connection_pool.mutex.lock();
|
||||
defer client.connection_pool.mutex.unlock();
|
||||
|
|
@ -1315,13 +1315,13 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce
|
|||
assert(client.connection_pool.used.first == null); // There are active requests.
|
||||
|
||||
if (client.http_proxy == null) {
|
||||
client.http_proxy = try createProxyFromEnvVar(arena, env_map, &.{
|
||||
client.http_proxy = try createProxyFromEnvVar(arena, environ_map, &.{
|
||||
"http_proxy", "HTTP_PROXY", "all_proxy", "ALL_PROXY",
|
||||
});
|
||||
}
|
||||
|
||||
if (client.https_proxy == null) {
|
||||
client.https_proxy = try createProxyFromEnvVar(arena, env_map, &.{
|
||||
client.https_proxy = try createProxyFromEnvVar(arena, environ_map, &.{
|
||||
"https_proxy", "HTTPS_PROXY", "all_proxy", "ALL_PROXY",
|
||||
});
|
||||
}
|
||||
|
|
@ -1329,11 +1329,11 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, env_map: *std.proce
|
|||
|
||||
fn createProxyFromEnvVar(
|
||||
arena: Allocator,
|
||||
env_map: *std.process.Environ.Map,
|
||||
environ_map: *std.process.Environ.Map,
|
||||
env_var_names: []const []const u8,
|
||||
) !?*Proxy {
|
||||
const content = for (env_var_names) |name| {
|
||||
const content = env_map.get(name) orelse continue;
|
||||
const content = environ_map.get(name) orelse continue;
|
||||
if (content.len == 0) continue;
|
||||
break content;
|
||||
} else return null;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ pub const Init = struct {
|
|||
/// configuration. Debug mode will set up leak checking.
|
||||
io: Io,
|
||||
/// Environment variables, initialized with `gpa`. Not threadsafe.
|
||||
env_map: *Environ.Map,
|
||||
environ_map: *Environ.Map,
|
||||
|
||||
/// Alternative to `Init` as the first parameter of the main function.
|
||||
pub const Minimal = struct {
|
||||
|
|
@ -295,7 +295,7 @@ pub const ReplaceOptions = struct {
|
|||
arg0_expand: ArgExpansion = .no_expand,
|
||||
/// Replaces the environment when provided. The PATH value from here is
|
||||
/// never used to resolve `argv[0]`.
|
||||
env_map: ?*const Environ.Map = null,
|
||||
environ_map: ?*const Environ.Map = null,
|
||||
};
|
||||
|
||||
/// Replaces the current process image with the executed process. If this
|
||||
|
|
@ -377,7 +377,7 @@ pub const SpawnOptions = struct {
|
|||
/// Replaces the child environment when provided. The PATH value from here
|
||||
/// is not used to resolve `argv[0]`; that resolution always uses parent
|
||||
/// environment.
|
||||
env_map: ?*const Environ.Map = null,
|
||||
environ_map: ?*const Environ.Map = null,
|
||||
expand_arg0: ArgExpansion = .no_expand,
|
||||
/// When populated, a pipe will be created for the child process to
|
||||
/// communicate progress back to the parent. The file descriptor of the
|
||||
|
|
@ -475,7 +475,7 @@ pub const RunOptions = struct {
|
|||
/// Replaces the child environment when provided. The PATH value from here
|
||||
/// is not used to resolve `argv[0]`; that resolution always uses parent
|
||||
/// environment.
|
||||
env_map: ?*const Environ.Map = null,
|
||||
environ_map: ?*const Environ.Map = null,
|
||||
expand_arg0: ArgExpansion = .no_expand,
|
||||
/// When populated, a pipe will be created for the child process to
|
||||
/// 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 {
|
|||
.argv = options.argv,
|
||||
.cwd = options.cwd,
|
||||
.cwd_dir = options.cwd_dir,
|
||||
.env_map = options.env_map,
|
||||
.environ_map = options.environ_map,
|
||||
.expand_arg0 = options.expand_arg0,
|
||||
.progress_node = options.progress_node,
|
||||
.create_no_window = options.create_no_window,
|
||||
|
|
|
|||
|
|
@ -699,9 +699,9 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B
|
|||
});
|
||||
defer threaded.deinit();
|
||||
|
||||
var env_map = std.process.Environ.createMap(.{ .block = environ }, gpa) catch |err|
|
||||
var environ_map = std.process.Environ.createMap(.{ .block = environ }, gpa) catch |err|
|
||||
std.process.fatal("failed to parse environment variables: {t}", .{err});
|
||||
defer env_map.deinit();
|
||||
defer environ_map.deinit();
|
||||
|
||||
return wrapMain(root.main(.{
|
||||
.minimal = .{
|
||||
|
|
@ -711,7 +711,7 @@ inline fn callMain(args: std.process.Args.Vector, environ: std.process.Environ.B
|
|||
.arena = &arena_allocator,
|
||||
.gpa = gpa,
|
||||
.io = threaded.io(),
|
||||
.env_map = &env_map,
|
||||
.environ_map = &environ_map,
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub fn detect(
|
|||
is_native_abi: bool,
|
||||
link_libc: bool,
|
||||
libc_installation: ?*const LibCInstallation,
|
||||
env_map: *const std.process.Environ.Map,
|
||||
environ_map: *const std.process.Environ.Map,
|
||||
) LibCInstallation.FindError!LibCDirs {
|
||||
if (!link_libc) {
|
||||
return .{
|
||||
|
|
@ -50,7 +50,7 @@ pub fn detect(
|
|||
const libc = try arena.create(LibCInstallation);
|
||||
libc.* = LibCInstallation.findNative(arena, io, .{
|
||||
.target = target,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
}) catch |err| switch (err) {
|
||||
error.CCompilerExitCode,
|
||||
error.CCompilerCrashed,
|
||||
|
|
@ -91,7 +91,7 @@ pub fn detect(
|
|||
libc.* = try LibCInstallation.findNative(arena, io, .{
|
||||
.verbose = true,
|
||||
.target = target,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
});
|
||||
return detectFromInstallation(arena, target, libc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ pub fn render(self: LibCInstallation, out: *std.Io.Writer) !void {
|
|||
|
||||
pub const FindNativeOptions = struct {
|
||||
target: *const std.Target,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
|
||||
/// If enabled, will print human-friendly errors to stderr.
|
||||
verbose: bool = false,
|
||||
|
|
@ -193,7 +193,7 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib
|
|||
});
|
||||
return self;
|
||||
} else if (is_windows) {
|
||||
const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.env_map) catch |err| switch (err) {
|
||||
const sdk = std.zig.WindowsSdk.find(gpa, io, args.target.cpu.arch, args.environ_map) catch |err| switch (err) {
|
||||
error.NotFound => return error.WindowsSdkNotFound,
|
||||
error.PathTooLong => return error.WindowsSdkNotFound,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
|
|
@ -240,17 +240,17 @@ pub fn deinit(self: *LibCInstallation, allocator: Allocator) void {
|
|||
|
||||
fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
|
||||
// Detect infinite loops.
|
||||
var env_map = try args.env_map.clone(gpa);
|
||||
defer env_map.deinit();
|
||||
const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: {
|
||||
var environ_map = try args.environ_map.clone(gpa);
|
||||
defer environ_map.deinit();
|
||||
const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: {
|
||||
if (std.mem.eql(u8, phase, "1")) {
|
||||
try env_map.put(inf_loop_env_key, "2");
|
||||
try environ_map.put(inf_loop_env_key, "2");
|
||||
break :blk true;
|
||||
} else {
|
||||
return error.ZigIsTheCCompiler;
|
||||
}
|
||||
} else blk: {
|
||||
try env_map.put(inf_loop_env_key, "1");
|
||||
try environ_map.put(inf_loop_env_key, "1");
|
||||
break :blk false;
|
||||
};
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
|
|||
var argv = std.array_list.Managed([]const u8).init(gpa);
|
||||
defer argv.deinit();
|
||||
|
||||
try appendCcExe(&argv, skip_cc_env_var, &env_map);
|
||||
try appendCcExe(&argv, skip_cc_env_var, &environ_map);
|
||||
try argv.appendSlice(&.{
|
||||
"-E",
|
||||
"-Wp,-v",
|
||||
|
|
@ -270,7 +270,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar
|
|||
const run_res = std.process.run(gpa, io, .{
|
||||
.max_output_bytes = 1024 * 1024,
|
||||
.argv = argv.items,
|
||||
.env_map = &env_map,
|
||||
.environ_map = &environ_map,
|
||||
// Some C compilers, such as Clang, are known to rely on argv[0] to find the path
|
||||
// to their own executable, without even bothering to resolve PATH. This results in the message:
|
||||
// error: unable to execute command: Executable "" doesn't exist!
|
||||
|
|
@ -446,7 +446,7 @@ fn findNativeCrtDirWindows(
|
|||
|
||||
fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void {
|
||||
self.crt_dir = try ccPrintFileName(gpa, io, .{
|
||||
.env_map = args.env_map,
|
||||
.environ_map = args.environ_map,
|
||||
.search_basename = switch (args.target.os.tag) {
|
||||
.linux => if (args.target.abi.isAndroid()) "crtbegin_dynamic.o" else "crt1.o",
|
||||
else => "crt1.o",
|
||||
|
|
@ -551,7 +551,7 @@ fn findNativeMsvcLibDir(
|
|||
}
|
||||
|
||||
pub const CCPrintFileNameOptions = struct {
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
search_basename: []const u8,
|
||||
want_dirname: enum { full_path, only_dir },
|
||||
verbose: bool = false,
|
||||
|
|
@ -560,17 +560,17 @@ pub const CCPrintFileNameOptions = struct {
|
|||
/// caller owns returned memory
|
||||
fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
|
||||
// Detect infinite loops.
|
||||
var env_map = try args.env_map.clone(gpa);
|
||||
defer env_map.deinit();
|
||||
const skip_cc_env_var = if (env_map.get(inf_loop_env_key)) |phase| blk: {
|
||||
var environ_map = try args.environ_map.clone(gpa);
|
||||
defer environ_map.deinit();
|
||||
const skip_cc_env_var = if (environ_map.get(inf_loop_env_key)) |phase| blk: {
|
||||
if (std.mem.eql(u8, phase, "1")) {
|
||||
try env_map.put(inf_loop_env_key, "2");
|
||||
try environ_map.put(inf_loop_env_key, "2");
|
||||
break :blk true;
|
||||
} else {
|
||||
return error.ZigIsTheCCompiler;
|
||||
}
|
||||
} else blk: {
|
||||
try env_map.put(inf_loop_env_key, "1");
|
||||
try environ_map.put(inf_loop_env_key, "1");
|
||||
break :blk false;
|
||||
};
|
||||
|
||||
|
|
@ -580,13 +580,13 @@ fn ccPrintFileName(gpa: Allocator, io: Io, args: CCPrintFileNameOptions) ![]u8 {
|
|||
const arg1 = try std.fmt.allocPrint(gpa, "-print-file-name={s}", .{args.search_basename});
|
||||
defer gpa.free(arg1);
|
||||
|
||||
try appendCcExe(&argv, skip_cc_env_var, &env_map);
|
||||
try appendCcExe(&argv, skip_cc_env_var, &environ_map);
|
||||
try argv.append(arg1);
|
||||
|
||||
const run_res = std.process.run(gpa, io, .{
|
||||
.max_output_bytes = 1024 * 1024,
|
||||
.argv = argv.items,
|
||||
.env_map = &env_map,
|
||||
.environ_map = &environ_map,
|
||||
// Some C compilers, such as Clang, are known to rely on argv[0] to find the path
|
||||
// to their own executable, without even bothering to resolve PATH. This results in the message:
|
||||
// error: unable to execute command: Executable "" doesn't exist!
|
||||
|
|
@ -669,7 +669,7 @@ const inf_loop_env_key = "ZIG_IS_DETECTING_LIBC_PATHS";
|
|||
fn appendCcExe(
|
||||
args: *std.array_list.Managed([]const u8),
|
||||
skip_cc_env_var: bool,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) !void {
|
||||
const default_cc_exe = if (is_windows) "cc.exe" else "cc";
|
||||
try args.ensureUnusedCapacity(1);
|
||||
|
|
@ -677,7 +677,7 @@ fn appendCcExe(
|
|||
args.appendAssumeCapacity(default_cc_exe);
|
||||
return;
|
||||
}
|
||||
const cc_env_var = std.zig.EnvVar.CC.get(env_map) orelse {
|
||||
const cc_env_var = std.zig.EnvVar.CC.get(environ_map) orelse {
|
||||
args.appendAssumeCapacity(default_cc_exe);
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub fn find(
|
|||
gpa: Allocator,
|
||||
io: Io,
|
||||
arch: std.Target.Cpu.Arch,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, NotFound, PathTooLong }!WindowsSdk {
|
||||
if (builtin.os.tag != .windows) return error.NotFound;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ pub fn find(
|
|||
};
|
||||
errdefer if (windows81sdk) |*w| w.free(gpa);
|
||||
|
||||
const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch, env_map) catch |err| switch (err) {
|
||||
const msvc_lib_dir: ?[]const u8 = MsvcLibDir.find(gpa, io, arch, environ_map) catch |err| switch (err) {
|
||||
error.MsvcLibDirNotFound => null,
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
};
|
||||
|
|
@ -680,7 +680,7 @@ const MsvcLibDir = struct {
|
|||
fn findInstancesDir(
|
||||
gpa: Allocator,
|
||||
io: Io,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, PathNotFound }!Dir {
|
||||
// First, try getting the packages cache path from the registry.
|
||||
// This only seems to exist when the path is different from the default.
|
||||
|
|
@ -701,7 +701,7 @@ const MsvcLibDir = struct {
|
|||
// If that can't be found, fall back to manually appending
|
||||
// `Microsoft\VisualStudio\Packages\_Instances` to %PROGRAMDATA%
|
||||
method3: {
|
||||
const program_data = std.zig.EnvVar.PROGRAMDATA.get(env_map) orelse break :method3;
|
||||
const program_data = std.zig.EnvVar.PROGRAMDATA.get(environ_map) orelse break :method3;
|
||||
|
||||
if (!Dir.path.isAbsolute(program_data)) break :method3;
|
||||
|
||||
|
|
@ -765,13 +765,13 @@ const MsvcLibDir = struct {
|
|||
gpa: Allocator,
|
||||
io: Io,
|
||||
arch: std.Target.Cpu.Arch,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, PathNotFound }![]const u8 {
|
||||
// Typically `%PROGRAMDATA%\Microsoft\VisualStudio\Packages\_Instances`
|
||||
// This will contain directories with names of instance IDs like 80a758ca,
|
||||
// which will contain `state.json` files that have the version and
|
||||
// installation directory.
|
||||
var instances_dir = try findInstancesDir(gpa, io, env_map);
|
||||
var instances_dir = try findInstancesDir(gpa, io, environ_map);
|
||||
defer instances_dir.close(io);
|
||||
|
||||
var state_subpath_buf: [Dir.max_name_bytes + 32]u8 = undefined;
|
||||
|
|
@ -872,12 +872,12 @@ const MsvcLibDir = struct {
|
|||
gpa: Allocator,
|
||||
io: Io,
|
||||
arch: std.Target.Cpu.Arch,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, PathNotFound }![]const u8 {
|
||||
|
||||
// %localappdata%\Microsoft\VisualStudio\
|
||||
// %appdata%\Local\Microsoft\VisualStudio\
|
||||
const local_app_data_path = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse return error.PathNotFound;
|
||||
const local_app_data_path = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse return error.PathNotFound;
|
||||
const visualstudio_folder_path = try Dir.path.join(gpa, &.{
|
||||
local_app_data_path, "Microsoft\\VisualStudio\\",
|
||||
});
|
||||
|
|
@ -968,11 +968,11 @@ const MsvcLibDir = struct {
|
|||
gpa: Allocator,
|
||||
io: Io,
|
||||
arch: std.Target.Cpu.Arch,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, PathNotFound }![]const u8 {
|
||||
var base_path: std.array_list.Managed(u8) = base_path: {
|
||||
try_env: {
|
||||
if (env_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {
|
||||
if (environ_map.get("VS140COMNTOOLS")) |VS140COMNTOOLS| {
|
||||
if (VS140COMNTOOLS.len < "C:\\Common7\\Tools".len) break :try_env;
|
||||
if (!Dir.path.isAbsolute(VS140COMNTOOLS)) break :try_env;
|
||||
var list = std.array_list.Managed(u8).init(gpa);
|
||||
|
|
@ -1046,13 +1046,13 @@ const MsvcLibDir = struct {
|
|||
gpa: Allocator,
|
||||
io: Io,
|
||||
arch: std.Target.Cpu.Arch,
|
||||
env_map: *const Environ.Map,
|
||||
environ_map: *const Environ.Map,
|
||||
) error{ OutOfMemory, MsvcLibDirNotFound }![]const u8 {
|
||||
const full_path = MsvcLibDir.findViaCOM(gpa, io, arch, env_map) catch |err1| switch (err1) {
|
||||
const full_path = MsvcLibDir.findViaCOM(gpa, io, arch, environ_map) catch |err1| switch (err1) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, env_map) catch |err2| switch (err2) {
|
||||
error.PathNotFound => MsvcLibDir.findViaRegistry(gpa, io, arch, environ_map) catch |err2| switch (err2) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, arch, env_map) catch |err3| switch (err3) {
|
||||
error.PathNotFound => MsvcLibDir.findViaVs7Key(gpa, io, arch, environ_map) catch |err3| switch (err3) {
|
||||
error.OutOfMemory => return error.OutOfMemory,
|
||||
error.PathNotFound => return error.MsvcLibDirNotFound,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ pub fn detect(
|
|||
arena: Allocator,
|
||||
io: Io,
|
||||
native_target: *const std.Target,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !NativePaths {
|
||||
var self: NativePaths = .{ .arena = arena };
|
||||
var is_nix = false;
|
||||
|
||||
if (std.zig.EnvVar.NIX_CFLAGS_COMPILE.get(env_map)) |nix_cflags_compile| {
|
||||
if (std.zig.EnvVar.NIX_CFLAGS_COMPILE.get(environ_map)) |nix_cflags_compile| {
|
||||
is_nix = true;
|
||||
var it = mem.tokenizeScalar(u8, nix_cflags_compile, ' ');
|
||||
while (true) {
|
||||
|
|
@ -49,7 +49,7 @@ pub fn detect(
|
|||
}
|
||||
}
|
||||
|
||||
if (std.zig.EnvVar.NIX_LDFLAGS.get(env_map)) |nix_ldflags| {
|
||||
if (std.zig.EnvVar.NIX_LDFLAGS.get(environ_map)) |nix_ldflags| {
|
||||
is_nix = true;
|
||||
var it = mem.tokenizeScalar(u8, nix_ldflags, ' ');
|
||||
while (true) {
|
||||
|
|
@ -78,7 +78,7 @@ pub fn detect(
|
|||
}
|
||||
}
|
||||
|
||||
if (std.zig.EnvVar.NIX_CFLAGS_LINK.get(env_map)) |nix_cflags_link| {
|
||||
if (std.zig.EnvVar.NIX_CFLAGS_LINK.get(environ_map)) |nix_cflags_link| {
|
||||
is_nix = true;
|
||||
var it = mem.tokenizeScalar(u8, nix_cflags_link, ' ');
|
||||
while (true) {
|
||||
|
|
@ -121,7 +121,7 @@ pub fn detect(
|
|||
}
|
||||
|
||||
// Check for homebrew paths
|
||||
if (std.zig.EnvVar.HOMEBREW_PREFIX.get(env_map)) |prefix| {
|
||||
if (std.zig.EnvVar.HOMEBREW_PREFIX.get(environ_map)) |prefix| {
|
||||
try self.addLibDir(try std.fs.path.join(arena, &.{ prefix, "/lib" }));
|
||||
try self.addIncludeDir(try std.fs.path.join(arena, &.{ prefix, "/include" }));
|
||||
}
|
||||
|
|
@ -177,21 +177,21 @@ pub fn detect(
|
|||
|
||||
// Distros like guix don't use FHS, so they rely on environment
|
||||
// variables to search for headers and libraries.
|
||||
if (std.zig.EnvVar.C_INCLUDE_PATH.get(env_map)) |c_include_path| {
|
||||
if (std.zig.EnvVar.C_INCLUDE_PATH.get(environ_map)) |c_include_path| {
|
||||
var it = mem.tokenizeScalar(u8, c_include_path, ':');
|
||||
while (it.next()) |dir| {
|
||||
try self.addIncludeDir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (std.zig.EnvVar.CPLUS_INCLUDE_PATH.get(env_map)) |cplus_include_path| {
|
||||
if (std.zig.EnvVar.CPLUS_INCLUDE_PATH.get(environ_map)) |cplus_include_path| {
|
||||
var it = mem.tokenizeScalar(u8, cplus_include_path, ':');
|
||||
while (it.next()) |dir| {
|
||||
try self.addIncludeDir(dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (std.zig.EnvVar.LIBRARY_PATH.get(env_map)) |library_path| {
|
||||
if (std.zig.EnvVar.LIBRARY_PATH.get(environ_map)) |library_path| {
|
||||
var it = mem.tokenizeScalar(u8, library_path, ':');
|
||||
while (it.next()) |dir| {
|
||||
try self.addLibDir(dir);
|
||||
|
|
|
|||
|
|
@ -762,7 +762,7 @@ pub const Directories = struct {
|
|||
.wasi => void,
|
||||
else => []const u8,
|
||||
},
|
||||
env_map: *const std.process.Environ.Map,
|
||||
environ_map: *const std.process.Environ.Map,
|
||||
) Directories {
|
||||
const wasi = builtin.target.os.tag == .wasi;
|
||||
|
||||
|
|
@ -781,7 +781,7 @@ pub const Directories = struct {
|
|||
const global_cache: Cache.Directory = d: {
|
||||
if (override_global_cache) |path| break :d openUnresolved(arena, io, cwd, path, .@"global cache");
|
||||
if (wasi) break :d openWasiPreopen(wasi_preopens, "/cache");
|
||||
const path = introspect.resolveGlobalCacheDir(arena, env_map) catch |err| {
|
||||
const path = introspect.resolveGlobalCacheDir(arena, environ_map) catch |err| {
|
||||
fatal("unable to resolve zig cache directory: {t}", .{err});
|
||||
};
|
||||
break :d openUnresolved(arena, io, cwd, path, .@"global cache");
|
||||
|
|
@ -5713,7 +5713,7 @@ pub fn translateC(
|
|||
translated_basename: []const u8,
|
||||
owner_mod: *Package.Module,
|
||||
prog_node: std.Progress.Node,
|
||||
env_map: *const std.process.Environ.Map,
|
||||
environ_map: *const std.process.Environ.Map,
|
||||
) !CImportResult {
|
||||
dev.check(.translate_c_command);
|
||||
|
||||
|
|
@ -5783,7 +5783,7 @@ pub fn translateC(
|
|||
}
|
||||
|
||||
var stdout: []u8 = undefined;
|
||||
try @import("main.zig").translateC(gpa, arena, io, argv.items, env_map, prog_node, &stdout);
|
||||
try @import("main.zig").translateC(gpa, arena, io, argv.items, environ_map, prog_node, &stdout);
|
||||
|
||||
if (out_dep_path) |dep_file_path| add_deps: {
|
||||
if (comp.verbose_cimport) log.info("processing dep file at {s}", .{dep_file_path});
|
||||
|
|
|
|||
|
|
@ -102,25 +102,25 @@ pub fn findZigLibDirFromSelfExe(
|
|||
return error.FileNotFound;
|
||||
}
|
||||
|
||||
pub fn resolveGlobalCacheDir(arena: Allocator, env_map: *const std.process.Environ.Map) ![]const u8 {
|
||||
if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map)) |value| return value;
|
||||
pub fn resolveGlobalCacheDir(arena: Allocator, environ_map: *const std.process.Environ.Map) ![]const u8 {
|
||||
if (std.zig.EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map)) |value| return value;
|
||||
|
||||
const app_name = "zig";
|
||||
|
||||
switch (builtin.os.tag) {
|
||||
.wasi => @compileError("on WASI the global cache dir must be resolved with preopens"),
|
||||
.windows => {
|
||||
const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(env_map) orelse
|
||||
const local_app_data_dir = std.zig.EnvVar.LOCALAPPDATA.get(environ_map) orelse
|
||||
return error.AppDataDirUnavailable;
|
||||
return Dir.path.join(arena, &.{ local_app_data_dir, app_name });
|
||||
},
|
||||
else => {
|
||||
if (std.zig.EnvVar.XDG_CACHE_HOME.get(env_map)) |cache_root| {
|
||||
if (std.zig.EnvVar.XDG_CACHE_HOME.get(environ_map)) |cache_root| {
|
||||
if (cache_root.len > 0) {
|
||||
return Dir.path.join(arena, &.{ cache_root, app_name });
|
||||
}
|
||||
}
|
||||
if (std.zig.EnvVar.HOME.get(env_map)) |home| {
|
||||
if (std.zig.EnvVar.HOME.get(environ_map)) |home| {
|
||||
if (home.len > 0) {
|
||||
return Dir.path.join(arena, &.{ home, ".cache", app_name });
|
||||
}
|
||||
|
|
|
|||
160
src/main.zig
160
src/main.zig
|
|
@ -191,7 +191,7 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
|
|||
fatal("expected command argument", .{});
|
||||
}
|
||||
|
||||
var env_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err});
|
||||
var environ_map = init.environ.createMap(arena) catch |err| fatal("failed to parse environment: {t}", .{err});
|
||||
|
||||
Compilation.setMainThread();
|
||||
|
||||
|
|
@ -206,14 +206,14 @@ pub fn main(init: std.process.Init.Minimal) anyerror!void {
|
|||
|
||||
if (tracy.enable_allocation) {
|
||||
var gpa_tracy = tracy.tracyAllocator(gpa);
|
||||
return mainArgs(gpa_tracy.allocator(), arena, io, args, &env_map);
|
||||
return mainArgs(gpa_tracy.allocator(), arena, io, args, &environ_map);
|
||||
}
|
||||
|
||||
if (native_os == .wasi) {
|
||||
wasi_preopens = try fs.wasi.preopensAlloc(arena);
|
||||
}
|
||||
|
||||
return mainArgs(gpa, arena, io, args, &env_map);
|
||||
return mainArgs(gpa, arena, io, args, &environ_map);
|
||||
}
|
||||
|
||||
fn mainArgs(
|
||||
|
|
@ -221,9 +221,9 @@ fn mainArgs(
|
|||
arena: Allocator,
|
||||
io: Io,
|
||||
args: []const [:0]const u8,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !void {
|
||||
if (process.can_replace and EnvVar.ZIG_IS_DETECTING_LIBC_PATHS.isSet(env_map)) {
|
||||
if (process.can_replace and EnvVar.ZIG_IS_DETECTING_LIBC_PATHS.isSet(environ_map)) {
|
||||
dev.check(.cc_command);
|
||||
// In this case we have accidentally invoked ourselves as "the system C compiler"
|
||||
// to figure out where libc is installed. This is essentially infinite recursion
|
||||
|
|
@ -233,7 +233,7 @@ fn mainArgs(
|
|||
// why we have this additional environment variable here to check.
|
||||
|
||||
const inf_loop_env_key: EnvVar = .ZIG_IS_TRYING_TO_NOT_CALL_ITSELF;
|
||||
if (inf_loop_env_key.isSet(env_map)) {
|
||||
if (inf_loop_env_key.isSet(environ_map)) {
|
||||
fatal("{s}", .{
|
||||
"The compilation links against libc, but Zig is unable to provide a libc " ++
|
||||
"for this operating system, and no --libc " ++
|
||||
|
|
@ -242,17 +242,17 @@ fn mainArgs(
|
|||
"compiler is `zig cc`, so no libc installation was found.",
|
||||
});
|
||||
}
|
||||
try env_map.put(@tagName(inf_loop_env_key), "1");
|
||||
try environ_map.put(@tagName(inf_loop_env_key), "1");
|
||||
|
||||
// Some programs such as CMake will strip the `cc` and subsequent args from the
|
||||
// CC environment variable. We detect and support this scenario here because of
|
||||
// the ZIG_IS_DETECTING_LIBC_PATHS environment variable.
|
||||
if (mem.eql(u8, args[1], "cc")) {
|
||||
return process.replace(io, .{ .argv = args[1..], .env_map = env_map });
|
||||
return process.replace(io, .{ .argv = args[1..], .environ_map = environ_map });
|
||||
} else {
|
||||
const modified_args = try arena.dupe([]const u8, args);
|
||||
modified_args[0] = "cc";
|
||||
return process.replace(io, .{ .argv = modified_args, .env_map = env_map });
|
||||
return process.replace(io, .{ .argv = modified_args, .environ_map = environ_map });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -260,22 +260,22 @@ fn mainArgs(
|
|||
const cmd_args = args[2..];
|
||||
if (mem.eql(u8, cmd, "build-exe")) {
|
||||
dev.check(.build_exe_command);
|
||||
return buildOutputType(gpa, arena, io, args, .{ .build = .Exe }, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .{ .build = .Exe }, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "build-lib")) {
|
||||
dev.check(.build_lib_command);
|
||||
return buildOutputType(gpa, arena, io, args, .{ .build = .Lib }, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .{ .build = .Lib }, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "build-obj")) {
|
||||
dev.check(.build_obj_command);
|
||||
return buildOutputType(gpa, arena, io, args, .{ .build = .Obj }, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .{ .build = .Obj }, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "test")) {
|
||||
dev.check(.test_command);
|
||||
return buildOutputType(gpa, arena, io, args, .zig_test, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .zig_test, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "test-obj")) {
|
||||
dev.check(.test_command);
|
||||
return buildOutputType(gpa, arena, io, args, .zig_test_obj, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .zig_test_obj, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "run")) {
|
||||
dev.check(.run_command);
|
||||
return buildOutputType(gpa, arena, io, args, .run, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .run, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "dlltool") or
|
||||
mem.eql(u8, cmd, "ranlib") or
|
||||
mem.eql(u8, cmd, "lib") or
|
||||
|
|
@ -285,7 +285,7 @@ fn mainArgs(
|
|||
return process.exit(try llvmArMain(arena, args));
|
||||
} else if (mem.eql(u8, cmd, "build")) {
|
||||
dev.check(.build_command);
|
||||
return cmdBuild(gpa, arena, io, cmd_args, env_map);
|
||||
return cmdBuild(gpa, arena, io, cmd_args, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "clang") or
|
||||
mem.eql(u8, cmd, "-cc1") or mem.eql(u8, cmd, "-cc1as"))
|
||||
{
|
||||
|
|
@ -299,16 +299,16 @@ fn mainArgs(
|
|||
return process.exit(try lldMain(arena, args, true));
|
||||
} else if (mem.eql(u8, cmd, "cc")) {
|
||||
dev.check(.cc_command);
|
||||
return buildOutputType(gpa, arena, io, args, .cc, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .cc, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "c++")) {
|
||||
dev.check(.cc_command);
|
||||
return buildOutputType(gpa, arena, io, args, .cpp, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .cpp, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "translate-c")) {
|
||||
dev.check(.translate_c_command);
|
||||
return buildOutputType(gpa, arena, io, args, .translate_c, env_map);
|
||||
return buildOutputType(gpa, arena, io, args, .translate_c, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "rc")) {
|
||||
const use_server = cmd_args.len > 0 and std.mem.eql(u8, cmd_args[0], "--zig-integration");
|
||||
return jitCmd(gpa, arena, io, cmd_args, env_map, .{
|
||||
return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
|
||||
.cmd_name = "resinator",
|
||||
.root_src_path = "resinator/main.zig",
|
||||
.depend_on_aro = true,
|
||||
|
|
@ -319,20 +319,20 @@ fn mainArgs(
|
|||
dev.check(.fmt_command);
|
||||
return @import("fmt.zig").run(gpa, arena, io, cmd_args);
|
||||
} else if (mem.eql(u8, cmd, "objcopy")) {
|
||||
return jitCmd(gpa, arena, io, cmd_args, env_map, .{
|
||||
return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
|
||||
.cmd_name = "objcopy",
|
||||
.root_src_path = "objcopy.zig",
|
||||
});
|
||||
} else if (mem.eql(u8, cmd, "fetch")) {
|
||||
return cmdFetch(gpa, arena, io, cmd_args, env_map);
|
||||
return cmdFetch(gpa, arena, io, cmd_args, environ_map);
|
||||
} else if (mem.eql(u8, cmd, "libc")) {
|
||||
return jitCmd(gpa, arena, io, cmd_args, env_map, .{
|
||||
return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
|
||||
.cmd_name = "libc",
|
||||
.root_src_path = "libc.zig",
|
||||
.prepend_zig_lib_dir_path = true,
|
||||
});
|
||||
} else if (mem.eql(u8, cmd, "std")) {
|
||||
return jitCmd(gpa, arena, io, cmd_args, env_map, .{
|
||||
return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
|
||||
.cmd_name = "std",
|
||||
.root_src_path = "std-docs.zig",
|
||||
.prepend_zig_lib_dir_path = true,
|
||||
|
|
@ -362,11 +362,11 @@ fn mainArgs(
|
|||
args,
|
||||
if (native_os == .wasi) wasi_preopens,
|
||||
&host,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
return stdout_writer.interface.flush();
|
||||
} else if (mem.eql(u8, cmd, "reduce")) {
|
||||
return jitCmd(gpa, arena, io, cmd_args, env_map, .{
|
||||
return jitCmd(gpa, arena, io, cmd_args, environ_map, .{
|
||||
.cmd_name = "reduce",
|
||||
.root_src_path = "reduce.zig",
|
||||
});
|
||||
|
|
@ -811,7 +811,7 @@ fn buildOutputType(
|
|||
io: Io,
|
||||
all_args: []const []const u8,
|
||||
arg_mode: ArgMode,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !void {
|
||||
var provided_name: ?[]const u8 = null;
|
||||
var root_src_file: ?[]const u8 = null;
|
||||
|
|
@ -824,9 +824,9 @@ fn buildOutputType(
|
|||
var debug_compile_errors = false;
|
||||
var debug_incremental = false;
|
||||
var verbose_link = (native_os != .wasi or builtin.link_libc) and
|
||||
EnvVar.ZIG_VERBOSE_LINK.isSet(env_map);
|
||||
EnvVar.ZIG_VERBOSE_LINK.isSet(environ_map);
|
||||
var verbose_cc = (native_os != .wasi or builtin.link_libc) and
|
||||
EnvVar.ZIG_VERBOSE_CC.isSet(env_map);
|
||||
EnvVar.ZIG_VERBOSE_CC.isSet(environ_map);
|
||||
var verbose_air = false;
|
||||
var verbose_intern_pool = false;
|
||||
var verbose_generic_instances = false;
|
||||
|
|
@ -898,9 +898,9 @@ fn buildOutputType(
|
|||
var runtime_args_start: ?usize = null;
|
||||
var test_filters: std.ArrayList([]const u8) = .empty;
|
||||
var test_runner_path: ?[]const u8 = null;
|
||||
var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(env_map);
|
||||
var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
|
||||
var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
|
||||
var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(environ_map);
|
||||
var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
|
||||
var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
|
||||
var clang_preprocessor_mode: Compilation.ClangPreprocessorMode = .no;
|
||||
var subsystem: ?std.zig.Subsystem = null;
|
||||
var major_subsystem_version: ?u16 = null;
|
||||
|
|
@ -997,7 +997,7 @@ fn buildOutputType(
|
|||
.framework_dirs = .{},
|
||||
.rpath_list = .{},
|
||||
.each_lib_rpath = null,
|
||||
.libc_paths_file = EnvVar.ZIG_LIBC.get(env_map),
|
||||
.libc_paths_file = EnvVar.ZIG_LIBC.get(environ_map),
|
||||
.native_system_include_paths = &.{},
|
||||
};
|
||||
defer create_module.link_inputs.deinit(gpa);
|
||||
|
|
@ -1006,9 +1006,9 @@ fn buildOutputType(
|
|||
// if set, default the color setting to .off or .on, respectively
|
||||
// explicit --color arguments will still override this setting.
|
||||
// Disable color on WASI per https://github.com/WebAssembly/WASI/issues/162
|
||||
var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet(env_map))
|
||||
var color: Color = if (native_os == .wasi or EnvVar.NO_COLOR.isSet(environ_map))
|
||||
.off
|
||||
else if (EnvVar.CLICOLOR_FORCE.isSet(env_map))
|
||||
else if (EnvVar.CLICOLOR_FORCE.isSet(environ_map))
|
||||
.on
|
||||
else
|
||||
.auto;
|
||||
|
|
@ -3106,7 +3106,7 @@ fn buildOutputType(
|
|||
},
|
||||
if (native_os == .wasi) wasi_preopens,
|
||||
self_exe_path,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
defer dirs.deinit(io);
|
||||
|
||||
|
|
@ -3118,7 +3118,7 @@ fn buildOutputType(
|
|||
create_module.opts.emit_bin = emit_bin != .no;
|
||||
create_module.opts.any_c_source_files = create_module.c_source_files.items.len != 0;
|
||||
|
||||
const main_mod = try createModule(gpa, arena, io, &create_module, 0, null, color, env_map);
|
||||
const main_mod = try createModule(gpa, arena, io, &create_module, 0, null, color, environ_map);
|
||||
for (create_module.modules.keys(), create_module.modules.values()) |key, cli_mod| {
|
||||
if (cli_mod.resolved == null)
|
||||
fatal("module '{s}' declared but not used", .{key});
|
||||
|
|
@ -3595,7 +3595,7 @@ fn buildOutputType(
|
|||
.global_cc_argv = try cc_argv.toOwnedSlice(arena),
|
||||
.file_system_inputs = &file_system_inputs,
|
||||
.debug_compiler_runtime_libs = debug_compiler_runtime_libs,
|
||||
.environ_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
}) catch |err| switch (err) {
|
||||
error.CreateFail => switch (create_diag) {
|
||||
.cross_libc_unavailable => {
|
||||
|
|
@ -3659,7 +3659,7 @@ fn buildOutputType(
|
|||
arg_mode,
|
||||
all_args,
|
||||
runtime_args_start,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
return cleanExit(io);
|
||||
},
|
||||
|
|
@ -3686,7 +3686,7 @@ fn buildOutputType(
|
|||
arg_mode,
|
||||
all_args,
|
||||
runtime_args_start,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
return cleanExit(io);
|
||||
},
|
||||
|
|
@ -3699,7 +3699,7 @@ fn buildOutputType(
|
|||
defer root_prog_node.end();
|
||||
|
||||
if (arg_mode == .translate_c) {
|
||||
return cmdTranslateC(comp, arena, null, null, root_prog_node, env_map);
|
||||
return cmdTranslateC(comp, arena, null, null, root_prog_node, environ_map);
|
||||
}
|
||||
|
||||
updateModule(comp, color, root_prog_node) catch |err| switch (err) {
|
||||
|
|
@ -3767,7 +3767,7 @@ fn buildOutputType(
|
|||
all_args,
|
||||
runtime_args_start,
|
||||
create_module.resolved_options.link_libc,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -3823,7 +3823,7 @@ fn createModule(
|
|||
index: usize,
|
||||
parent: ?*Package.Module,
|
||||
color: std.zig.Color,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) Allocator.Error!*Package.Module {
|
||||
const cli_mod = &create_module.modules.values()[index];
|
||||
if (cli_mod.resolved) |m| return m;
|
||||
|
|
@ -4003,7 +4003,7 @@ fn createModule(
|
|||
resolved_target.is_native_os and resolved_target.is_native_abi and
|
||||
create_module.want_native_include_dirs)
|
||||
{
|
||||
var paths = std.zig.system.NativePaths.detect(arena, io, target, env_map) catch |err|
|
||||
var paths = std.zig.system.NativePaths.detect(arena, io, target, environ_map) catch |err|
|
||||
fatal("unable to detect native system paths: {t}", .{err});
|
||||
for (paths.warnings.items) |warning| {
|
||||
warn("{s}", .{warning});
|
||||
|
|
@ -4030,7 +4030,7 @@ fn createModule(
|
|||
create_module.libc_installation = LibCInstallation.findNative(arena, io, .{
|
||||
.verbose = true,
|
||||
.target = target,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
}) catch |err| {
|
||||
fatal("unable to find native libc installation: {t}", .{err});
|
||||
};
|
||||
|
|
@ -4135,7 +4135,7 @@ fn createModule(
|
|||
for (cli_mod.deps) |dep| {
|
||||
const dep_index = create_module.modules.getIndex(dep.value) orelse
|
||||
fatal("module '{s}' depends on non-existent module '{s}'", .{ name, dep.key });
|
||||
const dep_mod = try createModule(gpa, arena, io, create_module, dep_index, mod, color, env_map);
|
||||
const dep_mod = try createModule(gpa, arena, io, create_module, dep_index, mod, color, environ_map);
|
||||
try mod.deps.put(arena, dep.key, dep_mod);
|
||||
}
|
||||
|
||||
|
|
@ -4157,7 +4157,7 @@ fn serve(
|
|||
arg_mode: ArgMode,
|
||||
all_args: []const []const u8,
|
||||
runtime_args_start: ?usize,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !void {
|
||||
const gpa = comp.gpa;
|
||||
const io = comp.io;
|
||||
|
|
@ -4205,7 +4205,7 @@ fn serve(
|
|||
defer arena_instance.deinit();
|
||||
const arena = arena_instance.allocator();
|
||||
var output: Compilation.CImportResult = undefined;
|
||||
try cmdTranslateC(comp, arena, &output, file_system_inputs, main_progress_node, env_map);
|
||||
try cmdTranslateC(comp, arena, &output, file_system_inputs, main_progress_node, environ_map);
|
||||
defer output.deinit(gpa);
|
||||
|
||||
if (file_system_inputs.items.len != 0) {
|
||||
|
|
@ -4405,7 +4405,7 @@ fn runOrTest(
|
|||
all_args: []const []const u8,
|
||||
runtime_args_start: ?usize,
|
||||
link_libc: bool,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !void {
|
||||
const raw_emit_bin = comp.emit_bin orelse return;
|
||||
const exe_path = switch (comp.cache_use) {
|
||||
|
|
@ -4442,14 +4442,14 @@ fn runOrTest(
|
|||
if (runtime_args_start) |i| {
|
||||
try argv.appendSlice(all_args[i..]);
|
||||
}
|
||||
try env_map.put("ZIG_EXE", self_exe_path);
|
||||
try environ_map.put("ZIG_EXE", self_exe_path);
|
||||
|
||||
// We do not execve for tests because if the test fails we want to print
|
||||
// the error message and invocation below.
|
||||
if (process.can_replace and arg_mode == .run) {
|
||||
// process replacement releases the locks; no need to destroy the Compilation here.
|
||||
_ = try io.lockStderr(&.{}, .no_color);
|
||||
const err = process.replace(io, .{ .argv = argv.items, .env_map = env_map });
|
||||
const err = process.replace(io, .{ .argv = argv.items, .environ_map = environ_map });
|
||||
io.unlockStderr();
|
||||
try warnAboutForeignBinaries(io, arena, arg_mode, target, link_libc);
|
||||
const cmd = try std.mem.join(arena, " ", argv.items);
|
||||
|
|
@ -4471,7 +4471,7 @@ fn runOrTest(
|
|||
|
||||
var child = std.process.spawn(io, .{
|
||||
.argv = argv.items,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.stdin = .inherit,
|
||||
.stdout = .inherit,
|
||||
.stderr = .inherit,
|
||||
|
|
@ -4626,7 +4626,7 @@ fn cmdTranslateC(
|
|||
fancy_output: ?*Compilation.CImportResult,
|
||||
file_system_inputs: ?*std.ArrayList(u8),
|
||||
prog_node: std.Progress.Node,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !void {
|
||||
dev.check(.translate_c_command);
|
||||
|
||||
|
|
@ -4660,7 +4660,7 @@ fn cmdTranslateC(
|
|||
translated_basename,
|
||||
comp.root_mod,
|
||||
prog_node,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
|
||||
if (result.errors.errorMessageCount() != 0) {
|
||||
|
|
@ -4708,11 +4708,11 @@ pub fn translateC(
|
|||
arena: Allocator,
|
||||
io: Io,
|
||||
argv: []const []const u8,
|
||||
env_map: *const process.Environ.Map,
|
||||
environ_map: *const process.Environ.Map,
|
||||
prog_node: std.Progress.Node,
|
||||
capture: ?*[]u8,
|
||||
) !void {
|
||||
try jitCmd(gpa, arena, io, argv, env_map, .{
|
||||
try jitCmd(gpa, arena, io, argv, environ_map, .{
|
||||
.cmd_name = "translate-c",
|
||||
.root_src_path = "translate-c/main.zig",
|
||||
.depend_on_aro = true,
|
||||
|
|
@ -4869,21 +4869,21 @@ test sanitizeExampleName {
|
|||
try std.testing.expectEqualStrings("test_project", try sanitizeExampleName(arena, "test project"));
|
||||
}
|
||||
|
||||
fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, env_map: *process.Environ.Map) !void {
|
||||
fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, environ_map: *process.Environ.Map) !void {
|
||||
dev.check(.build_command);
|
||||
|
||||
var build_file: ?[]const u8 = null;
|
||||
var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
|
||||
var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
|
||||
var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(env_map);
|
||||
var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(env_map);
|
||||
var override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
|
||||
var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
|
||||
var override_local_cache_dir: ?[]const u8 = EnvVar.ZIG_LOCAL_CACHE_DIR.get(environ_map);
|
||||
var override_build_runner: ?[]const u8 = EnvVar.ZIG_BUILD_RUNNER.get(environ_map);
|
||||
var child_argv = std.array_list.Managed([]const u8).init(arena);
|
||||
var reference_trace: ?u32 = null;
|
||||
var debug_compile_errors = false;
|
||||
var verbose_link = (native_os != .wasi or builtin.link_libc) and
|
||||
EnvVar.ZIG_VERBOSE_LINK.isSet(env_map);
|
||||
EnvVar.ZIG_VERBOSE_LINK.isSet(environ_map);
|
||||
var verbose_cc = (native_os != .wasi or builtin.link_libc) and
|
||||
EnvVar.ZIG_VERBOSE_CC.isSet(env_map);
|
||||
EnvVar.ZIG_VERBOSE_CC.isSet(environ_map);
|
||||
var verbose_air = false;
|
||||
var verbose_intern_pool = false;
|
||||
var verbose_generic_instances = false;
|
||||
|
|
@ -5080,7 +5080,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
|||
}
|
||||
|
||||
const work_around_btrfs_bug = native_os == .linux and
|
||||
EnvVar.ZIG_BTRFS_WORKAROUND.isSet(env_map);
|
||||
EnvVar.ZIG_BTRFS_WORKAROUND.isSet(environ_map);
|
||||
const root_prog_node = std.Progress.start(io, .{
|
||||
.disable_printing = (color == .off),
|
||||
.root_name = "Compile Build Script",
|
||||
|
|
@ -5140,7 +5140,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
|||
} },
|
||||
{},
|
||||
self_exe_path,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
defer dirs.deinit(io);
|
||||
|
||||
|
|
@ -5243,7 +5243,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
|||
job_queue.read_only = true;
|
||||
cleanup_build_dir = job_queue.global_cache.handle;
|
||||
} else {
|
||||
try http_client.initDefaultProxies(arena, env_map);
|
||||
try http_client.initDefaultProxies(arena, environ_map);
|
||||
}
|
||||
|
||||
try job_queue.all_fetches.ensureUnusedCapacity(gpa, 1);
|
||||
|
|
@ -5397,7 +5397,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8,
|
|||
.cache_mode = .whole,
|
||||
.reference_trace = reference_trace,
|
||||
.debug_compile_errors = debug_compile_errors,
|
||||
.environ_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
}) catch |err| switch (err) {
|
||||
error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),
|
||||
else => fatal("failed to create compilation: {s}", .{@errorName(err)}),
|
||||
|
|
@ -5516,7 +5516,7 @@ fn jitCmd(
|
|||
arena: Allocator,
|
||||
io: Io,
|
||||
args: []const []const u8,
|
||||
env_map: *const process.Environ.Map,
|
||||
environ_map: *const process.Environ.Map,
|
||||
options: JitCmdOptions,
|
||||
) !void {
|
||||
dev.check(.jit_command);
|
||||
|
|
@ -5538,13 +5538,13 @@ fn jitCmd(
|
|||
const self_exe_path = process.executablePathAlloc(io, arena) catch |err|
|
||||
fatal("unable to find self exe path: {t}", .{err});
|
||||
|
||||
const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet(env_map))
|
||||
const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet(environ_map))
|
||||
.Debug
|
||||
else
|
||||
.ReleaseFast;
|
||||
const strip = optimize_mode != .Debug;
|
||||
const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
|
||||
const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
|
||||
const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
|
||||
const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
|
||||
|
||||
// This `init` calls `fatal` on error.
|
||||
var dirs: Compilation.Directories = .init(
|
||||
|
|
@ -5555,7 +5555,7 @@ fn jitCmd(
|
|||
.global,
|
||||
if (native_os == .wasi) wasi_preopens,
|
||||
self_exe_path,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
defer dirs.deinit(io);
|
||||
|
||||
|
|
@ -5629,7 +5629,7 @@ fn jitCmd(
|
|||
.self_exe_path = self_exe_path,
|
||||
.thread_limit = thread_limit,
|
||||
.cache_mode = .whole,
|
||||
.environ_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
}) catch |err| switch (err) {
|
||||
error.CreateFail => fatal("failed to create compilation: {f}", .{create_diag}),
|
||||
else => fatal("failed to create compilation: {s}", .{@errorName(err)}),
|
||||
|
|
@ -5676,11 +5676,11 @@ fn jitCmd(
|
|||
child_argv.appendSliceAssumeCapacity(args);
|
||||
|
||||
if (process.can_replace and options.capture == null) {
|
||||
if (EnvVar.ZIG_DEBUG_CMD.isSet(env_map)) {
|
||||
if (EnvVar.ZIG_DEBUG_CMD.isSet(environ_map)) {
|
||||
const cmd = try std.mem.join(arena, " ", child_argv.items);
|
||||
std.debug.print("{s}\n", .{cmd});
|
||||
}
|
||||
const err = process.replace(io, .{ .argv = child_argv.items, .env_map = env_map });
|
||||
const err = process.replace(io, .{ .argv = child_argv.items, .environ_map = environ_map });
|
||||
const cmd = try std.mem.join(arena, " ", child_argv.items);
|
||||
fatal("the following command failed to execve with '{t}':\n{s}", .{ err, cmd });
|
||||
}
|
||||
|
|
@ -6914,15 +6914,15 @@ fn cmdFetch(
|
|||
arena: Allocator,
|
||||
io: Io,
|
||||
args: []const []const u8,
|
||||
env_map: *process.Environ.Map,
|
||||
environ_map: *process.Environ.Map,
|
||||
) !void {
|
||||
dev.check(.fetch_command);
|
||||
|
||||
const color: Color = .auto;
|
||||
const work_around_btrfs_bug = native_os == .linux and
|
||||
EnvVar.ZIG_BTRFS_WORKAROUND.isSet(env_map);
|
||||
EnvVar.ZIG_BTRFS_WORKAROUND.isSet(environ_map);
|
||||
var opt_path_or_url: ?[]const u8 = null;
|
||||
var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
|
||||
var override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
|
||||
var debug_hash: bool = false;
|
||||
var save: union(enum) {
|
||||
no,
|
||||
|
|
@ -6968,7 +6968,7 @@ fn cmdFetch(
|
|||
var http_client: std.http.Client = .{ .allocator = gpa, .io = io };
|
||||
defer http_client.deinit();
|
||||
|
||||
try http_client.initDefaultProxies(arena, env_map);
|
||||
try http_client.initDefaultProxies(arena, environ_map);
|
||||
|
||||
var root_prog_node = std.Progress.start(io, .{
|
||||
.root_name = "Fetch",
|
||||
|
|
@ -6976,7 +6976,7 @@ fn cmdFetch(
|
|||
defer root_prog_node.end();
|
||||
|
||||
var global_cache_directory: Directory = l: {
|
||||
const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena, env_map);
|
||||
const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena, environ_map);
|
||||
break :l .{
|
||||
.handle = try Io.Dir.cwd().createDirPathOpen(io, p, .{}),
|
||||
.path = p,
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ pub fn cmdEnv(
|
|||
else => void,
|
||||
},
|
||||
host: *const std.Target,
|
||||
env_map: *std.process.Environ.Map,
|
||||
environ_map: *std.process.Environ.Map,
|
||||
) !void {
|
||||
const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(env_map);
|
||||
const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(env_map);
|
||||
const override_lib_dir: ?[]const u8 = EnvVar.ZIG_LIB_DIR.get(environ_map);
|
||||
const override_global_cache_dir: ?[]const u8 = EnvVar.ZIG_GLOBAL_CACHE_DIR.get(environ_map);
|
||||
|
||||
const self_exe_path = switch (builtin.target.os.tag) {
|
||||
.wasi => args[0],
|
||||
|
|
@ -39,7 +39,7 @@ pub fn cmdEnv(
|
|||
.global,
|
||||
if (builtin.target.os.tag == .wasi) wasi_preopens,
|
||||
if (builtin.target.os.tag != .wasi) self_exe_path,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
defer dirs.deinit(io);
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ pub fn cmdEnv(
|
|||
try root.field("target", triple, .{});
|
||||
var env = try root.beginStructField("env", .{});
|
||||
inline for (@typeInfo(EnvVar).@"enum".fields) |field| {
|
||||
try env.field(field.name, @field(EnvVar, field.name).get(env_map), .{});
|
||||
try env.field(field.name, @field(EnvVar, field.name).get(environ_map), .{});
|
||||
}
|
||||
try env.end();
|
||||
try root.end();
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ pub fn main(init: std.process.Init.Minimal) !void {
|
|||
const process_cwd_path = try std.process.getCwdAlloc(gpa);
|
||||
defer gpa.free(process_cwd_path);
|
||||
|
||||
var env_map = try init.environ.createMap(gpa);
|
||||
defer env_map.deinit();
|
||||
var environ_map = try init.environ.createMap(gpa);
|
||||
defer environ_map.deinit();
|
||||
|
||||
var it = try init.args.iterateAllocator(gpa);
|
||||
defer it.deinit();
|
||||
|
|
@ -23,7 +23,7 @@ pub fn main(init: std.process.Init.Minimal) !void {
|
|||
const cwd_path = it.next() orelse break :child_path .{ child_path, false };
|
||||
// If there is a third argument, it is the current CWD somewhere within the cache directory.
|
||||
// In that case, modify the child path in order to test spawning a path with a leading `..` component.
|
||||
break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &env_map, cwd_path, child_path), true };
|
||||
break :child_path .{ try std.fs.path.relative(gpa, process_cwd_path, &environ_map, cwd_path, child_path), true };
|
||||
};
|
||||
defer if (needs_free) gpa.free(child_path);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main(init: std.process.Init) !void {
|
||||
try std.testing.expectEqual(0, init.env_map.count());
|
||||
try std.testing.expectEqual(0, init.environ_map.count());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,26 +126,26 @@ pub fn main(init: std.process.Init) !void {
|
|||
|
||||
// Environ.Map
|
||||
{
|
||||
var env_map = try environ.createMap(allocator);
|
||||
defer env_map.deinit();
|
||||
var environ_map = try environ.createMap(allocator);
|
||||
defer environ_map.deinit();
|
||||
|
||||
try std.testing.expectEqualSlices(u8, "123", env_map.get("FOO").?);
|
||||
try std.testing.expectEqual(null, env_map.get("FO"));
|
||||
try std.testing.expectEqual(null, env_map.get("FOOO"));
|
||||
try std.testing.expectEqualSlices(u8, "123", environ_map.get("FOO").?);
|
||||
try std.testing.expectEqual(null, environ_map.get("FO"));
|
||||
try std.testing.expectEqual(null, environ_map.get("FOOO"));
|
||||
if (builtin.os.tag == .windows) {
|
||||
try std.testing.expectEqualSlices(u8, "123", env_map.get("foo").?);
|
||||
try std.testing.expectEqualSlices(u8, "123", environ_map.get("foo").?);
|
||||
}
|
||||
try std.testing.expectEqualSlices(u8, "ABC=123", env_map.get("EQUALS").?);
|
||||
try std.testing.expectEqual(null, env_map.get("EQUALS=ABC"));
|
||||
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("КИРиллИЦА").?);
|
||||
try std.testing.expectEqualSlices(u8, "ABC=123", environ_map.get("EQUALS").?);
|
||||
try std.testing.expectEqual(null, environ_map.get("EQUALS=ABC"));
|
||||
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("КИРиллИЦА").?);
|
||||
if (builtin.os.tag == .windows) {
|
||||
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", env_map.get("кирИЛЛица").?);
|
||||
try std.testing.expectEqualSlices(u8, "non-ascii አማርኛ \u{10FFFF}", environ_map.get("кирИЛЛица").?);
|
||||
}
|
||||
try std.testing.expectEqualSlices(u8, "", env_map.get("NO_VALUE").?);
|
||||
try std.testing.expectEqual(null, env_map.get("NOT_SET"));
|
||||
try std.testing.expectEqualSlices(u8, "", environ_map.get("NO_VALUE").?);
|
||||
try std.testing.expectEqual(null, environ_map.get("NOT_SET"));
|
||||
if (builtin.os.tag == .windows) {
|
||||
try std.testing.expectEqualSlices(u8, "hi", env_map.get("=HIDDEN").?);
|
||||
try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", env_map.get("INVALID_UTF16_\xed\xa0\x80").?);
|
||||
try std.testing.expectEqualSlices(u8, "hi", environ_map.get("=HIDDEN").?);
|
||||
try std.testing.expectEqualSlices(u8, "\xed\xa0\x80", environ_map.get("INVALID_UTF16_\xed\xa0\x80").?);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
const cwd = try std.process.getCwdAlloc(init.arena.allocator());
|
||||
|
||||
// If `exe_path` is relative to our cwd, we need to convert it to be relative to the dirname of `symlink_path`.
|
||||
const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.env_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path);
|
||||
const exe_rel_path = try std.fs.path.relative(gpa, cwd, init.environ_map, std.fs.path.dirname(symlink_path) orelse ".", exe_path);
|
||||
defer gpa.free(exe_rel_path);
|
||||
|
||||
try std.Io.Dir.cwd().symLink(io, exe_rel_path, symlink_path, .{});
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
|
|||
const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
|
||||
|
||||
const result = try std.process.run(gpa, io, .{
|
||||
.env_map = env,
|
||||
.environ_map = env,
|
||||
.argv = argv,
|
||||
});
|
||||
defer gpa.free(result.stdout);
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ fn testExecBat(gpa: Allocator, io: Io, bat: []const u8, args: []const []const u8
|
|||
const can_have_trailing_empty_args = std.mem.eql(u8, bat, "args3.bat");
|
||||
|
||||
const result = try std.process.run(gpa, io, .{
|
||||
.env_map = env,
|
||||
.environ_map = env,
|
||||
.argv = argv,
|
||||
});
|
||||
defer gpa.free(result.stdout);
|
||||
|
|
|
|||
|
|
@ -96,12 +96,12 @@ fn checkRelative(
|
|||
expected_stdout: []const u8,
|
||||
argv: []const []const u8,
|
||||
cwd: ?[]const u8,
|
||||
env_map: ?*const std.process.Environ.Map,
|
||||
environ_map: ?*const std.process.Environ.Map,
|
||||
) !void {
|
||||
const result = try std.process.run(allocator, io, .{
|
||||
.argv = argv,
|
||||
.cwd = cwd,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
});
|
||||
defer allocator.free(result.stdout);
|
||||
defer allocator.free(result.stderr);
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ const usage =
|
|||
pub fn main(init: std.process.Init) !void {
|
||||
const arena = init.arena.allocator();
|
||||
const io = init.io;
|
||||
const env_map = init.env_map;
|
||||
const environ_map = init.environ_map;
|
||||
const cwd_path = try std.process.getCwdAlloc(arena);
|
||||
|
||||
try env_map.put("CLICOLOR_FORCE", "1");
|
||||
try environ_map.put("CLICOLOR_FORCE", "1");
|
||||
|
||||
var args_it = try init.minimal.args.iterateAllocator(arena);
|
||||
if (!args_it.skip()) fatal("missing argv[0]", .{});
|
||||
|
|
@ -101,13 +101,13 @@ pub fn main(init: std.process.Init) !void {
|
|||
out,
|
||||
code,
|
||||
tmp_dir_path,
|
||||
try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_path),
|
||||
try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, input_path),
|
||||
try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_path),
|
||||
try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, input_path),
|
||||
if (opt_zig_lib_dir) |zig_lib_dir|
|
||||
try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_lib_dir)
|
||||
try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_lib_dir)
|
||||
else
|
||||
null,
|
||||
env_map,
|
||||
environ_map,
|
||||
);
|
||||
|
||||
try out_file_writer.end();
|
||||
|
|
@ -126,7 +126,7 @@ fn printOutput(
|
|||
input_path: []const u8,
|
||||
/// Relative to `tmp_dir_path`.
|
||||
opt_zig_lib_dir: ?[]const u8,
|
||||
env_map: *const process.Environ.Map,
|
||||
environ_map: *const process.Environ.Map,
|
||||
) !void {
|
||||
const host = try std.zig.system.resolveTargetQuery(io, .{});
|
||||
const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch);
|
||||
|
|
@ -199,7 +199,7 @@ fn printOutput(
|
|||
const result = try process.run(arena, io, .{
|
||||
.argv = build_args.items,
|
||||
.cwd = tmp_dir_path,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.max_output_bytes = max_doc_file_size,
|
||||
});
|
||||
switch (result.term) {
|
||||
|
|
@ -221,7 +221,7 @@ fn printOutput(
|
|||
try shell_out.writeAll(colored_stderr);
|
||||
break :code_block;
|
||||
}
|
||||
const exec_result = run(arena, io, env_map, tmp_dir_path, build_args.items) catch
|
||||
const exec_result = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch
|
||||
fatal("example failed to compile", .{});
|
||||
|
||||
if (code.verbose_cimport) {
|
||||
|
|
@ -254,7 +254,7 @@ fn printOutput(
|
|||
const result = if (expected_outcome == .fail) blk: {
|
||||
const result = try process.run(arena, io, .{
|
||||
.argv = run_args,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.cwd = tmp_dir_path,
|
||||
.max_output_bytes = max_doc_file_size,
|
||||
});
|
||||
|
|
@ -271,7 +271,7 @@ fn printOutput(
|
|||
}
|
||||
break :blk result;
|
||||
} else blk: {
|
||||
break :blk run(arena, io, env_map, tmp_dir_path, run_args) catch
|
||||
break :blk run(arena, io, environ_map, tmp_dir_path, run_args) catch
|
||||
fatal("example crashed", .{});
|
||||
};
|
||||
|
||||
|
|
@ -340,7 +340,7 @@ fn printOutput(
|
|||
}
|
||||
}
|
||||
|
||||
const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch
|
||||
const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch
|
||||
fatal("test failed", .{});
|
||||
const escaped_stderr = try escapeHtml(arena, result.stderr);
|
||||
const escaped_stdout = try escapeHtml(arena, result.stdout);
|
||||
|
|
@ -373,7 +373,7 @@ fn printOutput(
|
|||
}
|
||||
const result = try process.run(arena, io, .{
|
||||
.argv = test_args.items,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.cwd = tmp_dir_path,
|
||||
.max_output_bytes = max_doc_file_size,
|
||||
});
|
||||
|
|
@ -429,7 +429,7 @@ fn printOutput(
|
|||
|
||||
const result = try process.run(arena, io, .{
|
||||
.argv = test_args.items,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.cwd = tmp_dir_path,
|
||||
.max_output_bytes = max_doc_file_size,
|
||||
});
|
||||
|
|
@ -505,7 +505,7 @@ fn printOutput(
|
|||
if (maybe_error_match) |error_match| {
|
||||
const result = try process.run(arena, io, .{
|
||||
.argv = build_args.items,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.cwd = tmp_dir_path,
|
||||
.max_output_bytes = max_doc_file_size,
|
||||
});
|
||||
|
|
@ -531,7 +531,7 @@ fn printOutput(
|
|||
const colored_stderr = try termColor(arena, escaped_stderr);
|
||||
try shell_out.print("\n{s} ", .{colored_stderr});
|
||||
} else {
|
||||
_ = run(arena, io, env_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{});
|
||||
_ = run(arena, io, environ_map, tmp_dir_path, build_args.items) catch fatal("example failed to compile", .{});
|
||||
}
|
||||
try shell_out.writeAll("\n");
|
||||
},
|
||||
|
|
@ -590,7 +590,7 @@ fn printOutput(
|
|||
try test_args.append(option);
|
||||
try shell_out.print("{s} ", .{option});
|
||||
}
|
||||
const result = run(arena, io, env_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{});
|
||||
const result = run(arena, io, environ_map, tmp_dir_path, test_args.items) catch fatal("test failed", .{});
|
||||
const escaped_stderr = try escapeHtml(arena, result.stderr);
|
||||
const escaped_stdout = try escapeHtml(arena, result.stdout);
|
||||
try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout });
|
||||
|
|
@ -1123,13 +1123,13 @@ fn in(slice: []const u8, number: u8) bool {
|
|||
fn run(
|
||||
allocator: Allocator,
|
||||
io: Io,
|
||||
env_map: *const process.Environ.Map,
|
||||
environ_map: *const process.Environ.Map,
|
||||
cwd: []const u8,
|
||||
args: []const []const u8,
|
||||
) !process.RunResult {
|
||||
const result = try process.run(allocator, io, .{
|
||||
.argv = args,
|
||||
.env_map = env_map,
|
||||
.environ_map = environ_map,
|
||||
.cwd = cwd,
|
||||
.max_output_bytes = max_doc_file_size,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
const fatal = std.process.fatal;
|
||||
const arena = init.arena.allocator();
|
||||
const io = init.io;
|
||||
const env_map = init.env_map;
|
||||
const environ_map = init.environ_map;
|
||||
const cwd_path = try std.process.getCwdAlloc(arena);
|
||||
|
||||
var opt_zig_exe: ?[]const u8 = null;
|
||||
|
|
@ -113,9 +113,9 @@ pub fn main(init: std.process.Init) !void {
|
|||
}
|
||||
|
||||
// Convert paths to be relative to the cwd of the subprocess.
|
||||
const resolved_zig_exe = try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, zig_exe);
|
||||
const resolved_zig_exe = try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, zig_exe);
|
||||
const opt_resolved_lib_dir = if (opt_lib_dir) |lib_dir|
|
||||
try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, lib_dir)
|
||||
try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, lib_dir)
|
||||
else
|
||||
null;
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
var cc_child_args: std.ArrayList([]const u8) = .empty;
|
||||
if (target.backend == .cbe) {
|
||||
const resolved_cc_zig_exe = if (opt_cc_zig) |cc_zig_exe|
|
||||
try Dir.path.relative(arena, cwd_path, env_map, tmp_dir_path, cc_zig_exe)
|
||||
try Dir.path.relative(arena, cwd_path, environ_map, tmp_dir_path, cc_zig_exe)
|
||||
else
|
||||
resolved_zig_exe;
|
||||
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
const io = init.io;
|
||||
const args = try init.minimal.args.toSlice(arena);
|
||||
const cwd_path = try std.process.getCwdAlloc(arena);
|
||||
const env_map = init.env_map;
|
||||
const environ_map = init.environ_map;
|
||||
|
||||
var search_paths = std.array_list.Managed([]const u8).init(arena);
|
||||
var opt_out_dir: ?[]const u8 = null;
|
||||
|
|
@ -256,7 +256,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
switch (entry.kind) {
|
||||
.directory => try dir_stack.append(full_path),
|
||||
.file, .sym_link => {
|
||||
const rel_path = try Dir.path.relative(arena, cwd_path, env_map, target_include_dir, full_path);
|
||||
const rel_path = try Dir.path.relative(arena, cwd_path, environ_map, target_include_dir, full_path);
|
||||
const max_size = 2 * 1024 * 1024 * 1024;
|
||||
const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
|
||||
const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
const arena = init.arena.allocator();
|
||||
const io = init.io;
|
||||
const args = try init.minimal.args.toSlice(arena);
|
||||
const env_map = init.env_map;
|
||||
const environ_map = init.environ_map;
|
||||
const cwd = try std.process.getCwdAlloc(arena);
|
||||
|
||||
var search_paths = std.array_list.Managed([]const u8).init(arena);
|
||||
|
|
@ -209,7 +209,7 @@ pub fn main(init: std.process.Init) !void {
|
|||
switch (entry.kind) {
|
||||
.directory => try dir_stack.append(full_path),
|
||||
.file => {
|
||||
const rel_path = try Dir.path.relative(arena, cwd, env_map, target_include_dir, full_path);
|
||||
const rel_path = try Dir.path.relative(arena, cwd, environ_map, target_include_dir, full_path);
|
||||
const max_size = 2 * 1024 * 1024 * 1024;
|
||||
const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
|
||||
const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue