Add enum to addBuildOptions

This commit is contained in:
DrDeano 2020-05-16 00:12:22 +01:00
parent d061e5854a
commit b2cb8beed9
No known key found for this signature in database
GPG Key ID: 96188600582B9ED7

View File

@ -1678,6 +1678,16 @@ pub const LibExeObjStep = struct {
pub fn addBuildOption(self: *LibExeObjStep, comptime T: type, name: []const u8, value: T) void {
const out = self.build_options_contents.outStream();
switch (@typeInfo(T)) {
.Enum => |enum_info| {
out.print("const {} = enum {{\n", .{@typeName(T)}) catch unreachable;
inline for (enum_info.fields) |field| {
out.print(" {},\n", .{ field.name }) catch unreachable;
}
out.print("}};\n", .{}) catch unreachable;
},
else => {},
}
out.print("pub const {} = {};\n", .{ name, value }) catch unreachable;
}