Updated example "Manual generation with the package manager from build.zig"

This commit is contained in:
Henrik Nilsson
2023-06-12 18:55:32 +02:00
committed by GitHub
parent ff48aa1581
commit 3d98b8a273

View File

@@ -70,14 +70,15 @@ That will allow you to `@import("vulkan-zig")` in your executable's source.
In the event you have a specific need for it, the generator executable is made available through the dependency, allowing you to run the executable as a build step in your own build.zig file.
Doing so should look a bit like this:
```zig
const vkzig_dep = b.dependency("vulkan_zig", .{}); // passing the registry argument here not necessary when using the executable directly
const vkzig_generator = vkzig_dep.artifact("generator");
const vk_gen = b.dependency("vulkan_zig", .{}).artifact("generator"); // get generator executable reference
vkzig_generator.addArg("path/to/vk.xml");
const vkzig_src = vkzig_generator.addOutputFileArg("vk.zig"); // this is the FileSource representing the generated bindings
const generate_cmd = b.addRunArtifact(vk_gen);
generate_cmd.addArg(b.pathFromRoot("vk.xml")); // path to xml file to use when generating the bindings
const vkzig_bindings = b.createModule("vulkan-zig", .{ .source_file = vkzig_src });
exe.addModule("vulkan-zig", vkzig_bindings);
const vulkan_zig = b.addModule("vulkan-zig", .{
.source_file = generate_cmd.addOutputFileArg("vk.zig"), // this is the FileSource representing the generated bindings
});
exe.addModule("vulkan-zig", vulkan_zig);
```
### Function & field renaming