From 3d98b8a273b9a07a0ea5d21857d7c637057a390c Mon Sep 17 00:00:00 2001 From: Henrik Nilsson <43480919+Henrik-N@users.noreply.github.com> Date: Mon, 12 Jun 2023 18:55:32 +0200 Subject: [PATCH] Updated example "Manual generation with the package manager from build.zig" --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 56d6494..46de264 100644 --- a/README.md +++ b/README.md @@ -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