std.Build.Step.ConfigHeader: permit inserting enum values

This commit is contained in:
Techatrix 2025-02-19 09:33:56 +01:00
parent 344db9e26b
commit c1c6f08296
No known key found for this signature in database
4 changed files with 4 additions and 1 deletions

View File

@ -131,7 +131,7 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty
.comptime_int => {
try config_header.values.put(field_name, .{ .int = v });
},
.enum_literal => {
.@"enum", .enum_literal => {
try config_header.values.put(field_name, .{ .ident = @tagName(v) });
},
.optional => {

View File

@ -10,6 +10,7 @@ pub fn build(b: *std.Build) void {
.SOME_ZERO = 0,
.SOME_ONE = 1,
.SOME_TEN = 10,
.SOME_ENUM = @as(enum { foo, bar }, .foo),
.SOME_ENUM_LITERAL = .@"test",
.SOME_STRING = "test",

View File

@ -9,6 +9,7 @@ int foo();
#define SOME_ZERO 0
#define SOME_ONE 1
#define SOME_TEN 10
#define SOME_ENUM foo
#define SOME_ENUM_LITERAL test
#define SOME_STRING "test"

View File

@ -8,6 +8,7 @@ int foo();
#undef SOME_ZERO
#undef SOME_ONE
#undef SOME_TEN
#undef SOME_ENUM
#undef SOME_ENUM_LITERAL
#undef SOME_STRING