mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
Support passing enum slices to b.dependency()
This commit is contained in:
parent
fd5eba9358
commit
2c1a349fb9
@ -530,7 +530,17 @@ fn addUserInputOptionFromArg(
|
|||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
},
|
},
|
||||||
.slice => {
|
.slice => switch (@typeInfo(ptr_info.child)) {
|
||||||
|
.@"enum" => return if (maybe_value) |v| {
|
||||||
|
var list = ArrayList([]const u8).initCapacity(arena, v.len) catch @panic("OOM");
|
||||||
|
for (v) |tag| list.appendAssumeCapacity(@tagName(tag));
|
||||||
|
map.put(field.name, .{
|
||||||
|
.name = field.name,
|
||||||
|
.value = .{ .list = list },
|
||||||
|
.used = false,
|
||||||
|
}) catch @panic("OOM");
|
||||||
|
},
|
||||||
|
else => {
|
||||||
comptime var slice_info = ptr_info;
|
comptime var slice_info = ptr_info;
|
||||||
slice_info.is_const = true;
|
slice_info.is_const = true;
|
||||||
slice_info.sentinel_ptr = null;
|
slice_info.sentinel_ptr = null;
|
||||||
@ -543,6 +553,7 @@ fn addUserInputOptionFromArg(
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
},
|
},
|
||||||
.null => unreachable,
|
.null => unreachable,
|
||||||
|
|||||||
@ -50,7 +50,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.{ .cwd_relative = "c.txt" },
|
.{ .cwd_relative = "c.txt" },
|
||||||
}),
|
}),
|
||||||
.@"enum" = @as(Enum, .alfa),
|
.@"enum" = @as(Enum, .alfa),
|
||||||
//.enum_list = @as([]const Enum, &.{ .alfa, .bravo, .charlie }),
|
.enum_list = @as([]const Enum, &.{ .alfa, .bravo, .charlie }),
|
||||||
//.build_id = @as(std.zig.BuildId, .uuid),
|
//.build_id = @as(std.zig.BuildId, .uuid),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.{ .cwd_relative = "c.txt" },
|
.{ .cwd_relative = "c.txt" },
|
||||||
}),
|
}),
|
||||||
.@"enum" = @as(?Enum, .alfa),
|
.@"enum" = @as(?Enum, .alfa),
|
||||||
//.enum_list = @as(?[]const Enum, &.{ .alfa, .bravo, .charlie }),
|
.enum_list = @as(?[]const Enum, &.{ .alfa, .bravo, .charlie }),
|
||||||
//.build_id = @as(?std.zig.BuildId, .uuid),
|
//.build_id = @as(?std.zig.BuildId, .uuid),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.{ .cwd_relative = "c.txt" },
|
.{ .cwd_relative = "c.txt" },
|
||||||
},
|
},
|
||||||
.@"enum" = .alfa,
|
.@"enum" = .alfa,
|
||||||
//.enum_list = &[_]Enum{ .alfa, .bravo, .charlie },
|
.enum_list = &[_]Enum{ .alfa, .bravo, .charlie },
|
||||||
//.build_id = @as(std.zig.BuildId, .uuid),
|
//.build_id = @as(std.zig.BuildId, .uuid),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -114,7 +114,6 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const mut_lazy_path_list: []std.Build.LazyPath = &mut_lazy_path_list_buf;
|
const mut_lazy_path_list: []std.Build.LazyPath = &mut_lazy_path_list_buf;
|
||||||
var mut_enum_list_buf = [_]Enum{ .alfa, .bravo, .charlie };
|
var mut_enum_list_buf = [_]Enum{ .alfa, .bravo, .charlie };
|
||||||
const mut_enum_list: []Enum = &mut_enum_list_buf;
|
const mut_enum_list: []Enum = &mut_enum_list_buf;
|
||||||
_ = mut_enum_list;
|
|
||||||
|
|
||||||
// Most supported option types are serialized to a string representation,
|
// Most supported option types are serialized to a string representation,
|
||||||
// so alternative representations of the same option value should resolve
|
// so alternative representations of the same option value should resolve
|
||||||
@ -130,7 +129,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
.lazy_path = @as(std.Build.LazyPath, .{ .cwd_relative = "abc.txt" }),
|
.lazy_path = @as(std.Build.LazyPath, .{ .cwd_relative = "abc.txt" }),
|
||||||
.lazy_path_list = mut_lazy_path_list,
|
.lazy_path_list = mut_lazy_path_list,
|
||||||
.@"enum" = "alfa",
|
.@"enum" = "alfa",
|
||||||
//.enum_list = mut_enum_list,
|
.enum_list = mut_enum_list,
|
||||||
//.build_id = @as(std.zig.BuildId, .uuid),
|
//.build_id = @as(std.zig.BuildId, .uuid),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user