pub const ObjectFormat = enum {
/// C source code.
c,
/// The Common Object File Format used by Windows and UEFI.
coff,
/// The Executable and Linkable Format used by many Unixes.
elf,
/// The Intel HEX format for storing binary code in ASCII text.
hex,
/// The Mach object format used by macOS and other Apple platforms.
macho,
/// The a.out format used by Plan 9 from Bell Labs.
plan9,
/// Machine code with no metadata.
raw,
/// The Khronos Group's Standard Portable Intermediate Representation V.
spirv,
/// The WebAssembly binary format.
wasm,
pub fn fileExt(of: ObjectFormat, arch: Cpu.Arch) [:0]const u8 {
return switch (of) {
.c => ".c",
.coff => ".obj",
.elf, .macho, .wasm => ".o",
.hex => ".ihex",
.plan9 => arch.plan9Ext(),
.raw => ".bin",
.spirv => ".spv",
};
}
pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {
return switch (os_tag) {
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => .macho,
.plan9 => .plan9,
.uefi, .windows => .coff,
else => switch (arch) {
.spirv32, .spirv64 => .spirv,
.wasm32, .wasm64 => .wasm,
.spork8 => .raw,
else => .elf,
},
};
}
}