diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig index 5743d9800ced11e00ff61ce5a122c6c5bca83b3f..3b0e6c2e7f7ee9e95bae247bb8e952850f4d9e7a 100644 --- a/lib/std/Build/Configuration.zig +++ b/lib/std/Build/Configuration.zig @@ -2120,27 +2120,18 @@ pub const OptionalCSourceLanguage = enum(u3) { objective_cpp, assembly, assembly_with_preprocessor, + default, pub fn init(x: ?std.Build.Module.CSourceLanguage) @This() { return switch (x orelse return .default) { - .c => .c, - .cpp => .cpp, - .objective_c => .objective_c, - .objective_cpp => .objective_cpp, - .assembly => .assembly, - .assembly_with_preprocessor => .assembly_with_preprocessor, + inline else => |tag| @field(@This(), @tagName(tag)), }; } pub fn get(this: @This()) ?std.Build.Module.CSourceLanguage { return switch (this) { - .c => .c, - .cpp => .cpp, - .objective_c => .objective_c, - .objective_cpp => .objective_cpp, - .assembly => .assembly, - .assembly_with_preprocessor => .assembly_with_preprocessor, + inline else => |tag| @field(std.Build.Module.CSourceLanguage, @tagName(tag)), .default => null, }; } @@ -2268,10 +2259,7 @@ pub const TargetQuery = struct { pub fn init(x: std.Target.Query.CpuModel) @This() { return switch (x) { - .native => .native, - .baseline => .baseline, - .determined_by_arch_os => .determined_by_arch_os, - .explicit => .explicit, + inline else => |_, tag| @field(@This(), @tagName(tag)), }; } }; @@ -2329,71 +2317,13 @@ pub const TargetQuery = struct { pub fn init(x: ?std.Target.Abi) @This() { return switch (x orelse return .default) { - .none => .none, - .gnu => .gnu, - .gnuabin32 => .gnuabin32, - .gnuabi64 => .gnuabi64, - .gnueabi => .gnueabi, - .gnueabihf => .gnueabihf, - .gnuf32 => .gnuf32, - .gnusf => .gnusf, - .gnux32 => .gnux32, - .eabi => .eabi, - .eabihf => .eabihf, - .abin32 => .abin32, - .x32 => .x32, - .ilp32 => .ilp32, - .android => .android, - .androideabi => .androideabi, - .musl => .musl, - .muslabin32 => .muslabin32, - .muslabi64 => .muslabi64, - .musleabi => .musleabi, - .musleabihf => .musleabihf, - .muslf32 => .muslf32, - .muslsf => .muslsf, - .muslx32 => .muslx32, - .msvc => .msvc, - .itanium => .itanium, - .simulator => .simulator, - .ohos => .ohos, - .ohoseabi => .ohoseabi, - .call0 => .call0, + inline else => |tag| @field(@This(), @tagName(tag)), }; } pub fn unwrap(this: @This()) ?std.Target.Abi { return switch (this) { - .none => .none, - .gnu => .gnu, - .gnuabin32 => .gnuabin32, - .gnuabi64 => .gnuabi64, - .gnueabi => .gnueabi, - .gnueabihf => .gnueabihf, - .gnuf32 => .gnuf32, - .gnusf => .gnusf, - .gnux32 => .gnux32, - .eabi => .eabi, - .eabihf => .eabihf, - .abin32 => .abin32, - .x32 => .x32, - .ilp32 => .ilp32, - .android => .android, - .androideabi => .androideabi, - .musl => .musl, - .muslabin32 => .muslabin32, - .muslabi64 => .muslabi64, - .musleabi => .musleabi, - .musleabihf => .musleabihf, - .muslf32 => .muslf32, - .muslsf => .muslsf, - .muslx32 => .muslx32, - .msvc => .msvc, - .itanium => .itanium, - .simulator => .simulator, - .ohos => .ohos, - .ohoseabi => .ohoseabi, - .call0 => .call0, + inline else => |tag| @field(std.Target.Abi, @tagName(tag)), .default => null, }; } @@ -2465,132 +2395,13 @@ pub const TargetQuery = struct { pub fn init(x: ?std.Target.Cpu.Arch) @This() { return switch (x orelse return .default) { - .aarch64 => .aarch64, - .aarch64_be => .aarch64_be, - .alpha => .alpha, - .amdgcn => .amdgcn, - .arc => .arc, - .arceb => .arceb, - .arm => .arm, - .armeb => .armeb, - .avr => .avr, - .bpfeb => .bpfeb, - .bpfel => .bpfel, - .csky => .csky, - .ez80 => .ez80, - .hexagon => .hexagon, - .hppa => .hppa, - .hppa64 => .hppa64, - .kalimba => .kalimba, - .kvx => .kvx, - .lanai => .lanai, - .loongarch32 => .loongarch32, - .loongarch64 => .loongarch64, - .m68k => .m68k, - .m88k => .m88k, - .microblaze => .microblaze, - .microblazeel => .microblazeel, - .mips => .mips, - .mipsel => .mipsel, - .mips64 => .mips64, - .mips64el => .mips64el, - .msp430 => .msp430, - .nvptx => .nvptx, - .nvptx64 => .nvptx64, - .or1k => .or1k, - .powerpc => .powerpc, - .powerpcle => .powerpcle, - .powerpc64 => .powerpc64, - .powerpc64le => .powerpc64le, - .propeller => .propeller, - .riscv32 => .riscv32, - .riscv32be => .riscv32be, - .riscv64 => .riscv64, - .riscv64be => .riscv64be, - .s390x => .s390x, - .sh => .sh, - .sheb => .sheb, - .sparc => .sparc, - .sparc64 => .sparc64, - .spirv32 => .spirv32, - .spirv64 => .spirv64, - .thumb => .thumb, - .thumbeb => .thumbeb, - .ve => .ve, - .wasm32 => .wasm32, - .wasm64 => .wasm64, - .x86_16 => .x86_16, - .x86 => .x86, - .x86_64 => .x86_64, - .xcore => .xcore, - .xtensa => .xtensa, - .xtensaeb => .xtensaeb, + inline else => |tag| @field(@This(), @tagName(tag)), }; } pub fn unwrap(this: @This()) ?std.Target.Cpu.Arch { return switch (this) { - .aarch64 => .aarch64, - .aarch64_be => .aarch64_be, - .alpha => .alpha, - .amdgcn => .amdgcn, - .arc => .arc, - .arceb => .arceb, - .arm => .arm, - .armeb => .armeb, - .avr => .avr, - .bpfeb => .bpfeb, - .bpfel => .bpfel, - .csky => .csky, - .ez80 => .ez80, - .hexagon => .hexagon, - .hppa => .hppa, - .hppa64 => .hppa64, - .kalimba => .kalimba, - .kvx => .kvx, - .lanai => .lanai, - .loongarch32 => .loongarch32, - .loongarch64 => .loongarch64, - .m68k => .m68k, - .m88k => .m88k, - .microblaze => .microblaze, - .microblazeel => .microblazeel, - .mips => .mips, - .mipsel => .mipsel, - .mips64 => .mips64, - .mips64el => .mips64el, - .msp430 => .msp430, - .nvptx => .nvptx, - .nvptx64 => .nvptx64, - .or1k => .or1k, - .powerpc => .powerpc, - .powerpcle => .powerpcle, - .powerpc64 => .powerpc64, - .powerpc64le => .powerpc64le, - .propeller => .propeller, - .riscv32 => .riscv32, - .riscv32be => .riscv32be, - .riscv64 => .riscv64, - .riscv64be => .riscv64be, - .s390x => .s390x, - .sh => .sh, - .sheb => .sheb, - .sparc => .sparc, - .sparc64 => .sparc64, - .spirv32 => .spirv32, - .spirv64 => .spirv64, - .thumb => .thumb, - .thumbeb => .thumbeb, - .ve => .ve, - .wasm32 => .wasm32, - .wasm64 => .wasm64, - .x86_16 => .x86_16, - .x86 => .x86, - .x86_64 => .x86_64, - .xcore => .xcore, - .xtensa => .xtensa, - .xtensaeb => .xtensaeb, - + inline else => |tag| @field(std.Target.Cpu.Arch, @tagName(tag)), .default => null, }; } @@ -2649,106 +2460,13 @@ pub const TargetQuery = struct { pub fn init(x: ?std.Target.Os.Tag) @This() { return switch (x orelse return .default) { - .freestanding => .freestanding, - .other => .other, - .contiki => .contiki, - .fuchsia => .fuchsia, - .hermit => .hermit, - .managarm => .managarm, - .haiku => .haiku, - .hurd => .hurd, - .illumos => .illumos, - .linux => .linux, - .plan9 => .plan9, - .rtems => .rtems, - .serenity => .serenity, - .dragonfly => .dragonfly, - .freebsd => .freebsd, - .netbsd => .netbsd, - .openbsd => .openbsd, - .driverkit => .driverkit, - .ios => .ios, - .maccatalyst => .maccatalyst, - .macos => .macos, - .tvos => .tvos, - .visionos => .visionos, - .watchos => .watchos, - .windows => .windows, - .uefi => .uefi, - .@"3ds" => .@"3ds", - .wiiu => .wiiu, - .@"switch" => .@"switch", - .psx => .psx, - .ps3 => .ps3, - .ps4 => .ps4, - .ps5 => .ps5, - .psp => .psp, - .vita => .vita, - .emscripten => .emscripten, - .wasi => .wasi, - .amdhsa => .amdhsa, - .amdpal => .amdpal, - .cuda => .cuda, - .mesa3d => .mesa3d, - .nvcl => .nvcl, - .opencl => .opencl, - .opengl => .opengl, - .vulkan => .vulkan, - .tios => .tios, - .ashetos => .ashetos, + inline else => |tag| @field(@This(), @tagName(tag)), }; } pub fn unwrap(this: @This()) ?std.Target.Os.Tag { return switch (this) { - .freestanding => .freestanding, - .other => .other, - .contiki => .contiki, - .fuchsia => .fuchsia, - .hermit => .hermit, - .managarm => .managarm, - .haiku => .haiku, - .hurd => .hurd, - .illumos => .illumos, - .linux => .linux, - .plan9 => .plan9, - .rtems => .rtems, - .serenity => .serenity, - .dragonfly => .dragonfly, - .freebsd => .freebsd, - .netbsd => .netbsd, - .openbsd => .openbsd, - .driverkit => .driverkit, - .ios => .ios, - .maccatalyst => .maccatalyst, - .macos => .macos, - .tvos => .tvos, - .visionos => .visionos, - .watchos => .watchos, - .windows => .windows, - .uefi => .uefi, - .@"3ds" => .@"3ds", - .wiiu => .wiiu, - .@"switch" => .@"switch", - .psx => .psx, - .ps3 => .ps3, - .ps4 => .ps4, - .ps5 => .ps5, - .psp => .psp, - .vita => .vita, - .emscripten => .emscripten, - .wasi => .wasi, - .amdhsa => .amdhsa, - .amdpal => .amdpal, - .cuda => .cuda, - .mesa3d => .mesa3d, - .nvcl => .nvcl, - .opencl => .opencl, - .opengl => .opengl, - .vulkan => .vulkan, - .tios => .tios, - .ashetos => .ashetos, - + inline else => |tag| @field(std.Target.Os.Tag, @tagName(tag)), .default => null, }; } @@ -2769,30 +2487,13 @@ pub const TargetQuery = struct { pub fn init(x: ?std.Target.ObjectFormat) @This() { return switch (x orelse return .default) { - .c => .c, - .coff => .coff, - .elf => .elf, - .hex => .hex, - .macho => .macho, - .plan9 => .plan9, - .raw => .raw, - .spirv => .spirv, - .wasm => .wasm, + inline else => |tag| @field(@This(), @tagName(tag)), }; } pub fn unwrap(this: @This()) ?std.Target.ObjectFormat { return switch (this) { - .c => .c, - .coff => .coff, - .elf => .elf, - .hex => .hex, - .macho => .macho, - .plan9 => .plan9, - .raw => .raw, - .spirv => .spirv, - .wasm => .wasm, - + inline else => |tag| @field(std.Target.ObjectFormat, @tagName(tag)), .default => null, }; }