parseTargetQueryOrReportFatalError
Function parameters
Parameters
Type definitions in this namespace
Types
- EnvVar
- Collects all the environment variables that Zig could possibly inspect, so
- EmitArtifact
- Every kind of artifact which the compiler can emit.
Functions in this namespace
Functions
- binNameAlloc
- Returns the standard file system basename of a binary generated by the Zig compiler.
- serializeCpu
- Renders a `std.Target.Cpu` value into a textual representation that can be parsed
- fmtId
- Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed.
- fmtIdFlags
- Return a Formatter for a Zig identifier, escaping it with `@""` syntax if needed.
- fmtString
- Return a formatter for escaping a double quoted Zig string.
- fmtChar
- Return a formatter for escaping a single quoted Zig string.
- stringEscape
- Print the string as escaped contents of a double quoted string.
- charEscape
- Print as escaped contents of a single-quoted string.
- readSourceFileToEndAlloc
- If the source can be UTF-16LE encoded, this function asserts that `gpa`
There are many assumptions in the entire codebase that Zig source files can
Values
- max_src_size
- There are many assumptions in the entire codebase that Zig source files can
Source
Implementation
pub fn parseTargetQueryOrReportFatalError(
allocator: Allocator,
opts: std.Target.Query.ParseOptions,
) std.Target.Query {
var opts_with_diags = opts;
var diags: std.Target.Query.ParseOptions.Diagnostics = .{};
if (opts_with_diags.diagnostics == null) {
opts_with_diags.diagnostics = &diags;
}
return std.Target.Query.parse(opts_with_diags) catch |err| switch (err) {
error.UnknownCpuModel => {
help: {
var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit();
for (diags.arch.?.allCpuModels()) |cpu| {
help_text.print(" {s}\n", .{cpu.name}) catch break :help;
}
std.log.info("available CPUs for architecture '{s}':\n{s}", .{
@tagName(diags.arch.?), help_text.items,
});
}
std.process.fatal("unknown CPU: '{s}'", .{diags.cpu_name.?});
},
error.UnknownCpuFeature => {
help: {
var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit();
for (diags.arch.?.allFeaturesList()) |feature| {
help_text.print(" {s}: {s}\n", .{ feature.name, feature.description }) catch break :help;
}
std.log.info("available CPU features for architecture '{s}':\n{s}", .{
@tagName(diags.arch.?), help_text.items,
});
}
std.process.fatal("unknown CPU feature: '{s}'", .{diags.unknown_feature_name.?});
},
error.UnknownObjectFormat => {
help: {
var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit();
inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| {
help_text.print(" {s}\n", .{field.name}) catch break :help;
}
std.log.info("available object formats:\n{s}", .{help_text.items});
}
std.process.fatal("unknown object format: '{s}'", .{opts.object_format.?});
},
error.UnknownArchitecture => {
help: {
var help_text = std.array_list.Managed(u8).init(allocator);
defer help_text.deinit();
inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".fields) |field| {
help_text.print(" {s}\n", .{field.name}) catch break :help;
}
std.log.info("available architectures:\n{s} native\n", .{help_text.items});
}
std.process.fatal("unknown architecture: '{s}'", .{diags.unknown_architecture_name.?});
},
else => |e| std.process.fatal("unable to parse target query '{s}': {s}", .{
opts.arch_os_abi, @errorName(e),
}),
};
}