zig
zig copied to clipboard
Build/Options: fix for struct array/slice and optional struct options
Closes #19656 Closes #19594
This looks like it fixes #19656 and #19594, can you confirm?
@Vexu Yes, I confirmed that both of issues can be fixed by this PR.
Any feedback about this PR?
Also, there are optional enums that doesn't work. This patch should work (+ some test):
diff --git a/lib/std/Build/Step/Options.zig b/lib/std/Build/Step/Options.zig
index 8348d74..e05255c 100644
--- a/lib/std/Build/Step/Options.zig
+++ b/lib/std/Build/Step/Options.zig
@@ -272,12 +272,17 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
try printEnum(options, out, T, info, indent);
if (name) |some| {
- try out.print("pub const {}: {} = .{p_};\n", .{
+ try out.print("pub const {}: {} = ", .{
std.zig.fmtId(some),
std.zig.fmtId(@typeName(T)),
- std.zig.fmtId(@tagName(value)),
});
}
+
+ if (indent == 0)
+ try out.print(".{p_};\n", .{std.zig.fmtId(@tagName(value))})
+ else
+ try out.print(".{p_},\n", .{std.zig.fmtId(@tagName(value))});
+
return;
},
.@"struct" => |info| {