stage2: support environment variables for verbose options
The presence of ZIG_VERBOSE_LINK now enables --verbose-link. The presence of ZIG_VERBOSE_CC now enables --verbose-cc. These are useful when debugging usage of `zig cc` which does not have CLI flags for these options, since they are not valid C compiler flags.
This commit is contained in:
13
src/main.zig
13
src/main.zig
@@ -448,6 +448,15 @@ const Emit = union(enum) {
|
||||
}
|
||||
};
|
||||
|
||||
fn optionalBoolEnvVar(arena: *Allocator, name: []const u8) !bool {
|
||||
if (std.process.getEnvVarOwned(arena, name)) |value| {
|
||||
return true;
|
||||
} else |err| switch (err) {
|
||||
error.EnvironmentVariableNotFound => return false,
|
||||
else => |e| return e,
|
||||
}
|
||||
}
|
||||
|
||||
fn optionalStringEnvVar(arena: *Allocator, name: []const u8) !?[]const u8 {
|
||||
if (std.process.getEnvVarOwned(arena, name)) |value| {
|
||||
return value;
|
||||
@@ -482,8 +491,8 @@ fn buildOutputType(
|
||||
var single_threaded = false;
|
||||
var function_sections = false;
|
||||
var watch = false;
|
||||
var verbose_link = false;
|
||||
var verbose_cc = false;
|
||||
var verbose_link = try optionalBoolEnvVar(arena, "ZIG_VERBOSE_LINK");
|
||||
var verbose_cc = try optionalBoolEnvVar(arena, "ZIG_VERBOSE_CC");
|
||||
var verbose_tokenize = false;
|
||||
var verbose_ast = false;
|
||||
var verbose_ir = false;
|
||||
|
||||
Reference in New Issue
Block a user