Update parser for VulkanSC changes

The update that added the VulkanSC changes to vk.xml broke vulkan-zig previously.
This commit is contained in:
Robin Voetter
2023-03-04 01:24:30 +01:00
parent c801ac0d2e
commit 070500f5e5
7 changed files with 138 additions and 50 deletions

View File

@@ -1,5 +1,5 @@
const std = @import("std");
const generate = @import("generator.zig").generate;
const generator = @import("generator.zig");
const path = std.fs.path;
const Build = std.Build;
const Step = Build.Step;
@@ -14,6 +14,10 @@ pub const GenerateStep = struct {
generated_file: std.build.GeneratedFile,
/// The path to vk.xml
spec_path: []const u8,
/// The API to generate for.
/// Defaults to Vulkan.
// Note: VulkanSC is experimental.
api: generator.Api = .vulkan,
/// Initialize a Vulkan generation step, for `builder`. `spec_path` is the path to
/// vk.xml, relative to the project root. The generated bindings will be placed at
@@ -44,6 +48,11 @@ pub const GenerateStep = struct {
return create(builder, spec_path, output_name);
}
/// Set the API to generate for.
pub fn setApi(self: *GenerateStep, api_to_generate: generator.Api) void {
self.api = api_to_generate;
}
/// Returns the module with the generated budings, with name `module_name`.
pub fn getModule(self: *GenerateStep) *std.build.Module {
return self.builder.createModule(.{
@@ -87,7 +96,7 @@ pub const GenerateStep = struct {
}
var out_buffer = std.ArrayList(u8).init(self.builder.allocator);
generate(self.builder.allocator, spec, out_buffer.writer()) catch |err| switch (err) {
generator.generate(self.builder.allocator, self.api, spec, out_buffer.writer()) catch |err| switch (err) {
error.InvalidXml => {
std.log.err("invalid vulkan registry - invalid xml", .{});
std.log.err("please check that the correct vk.xml file is passed", .{});