diff --git a/README.md b/README.md index b9f17e9..a996a3a 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,36 @@ CI tested weekly with latest zig version. This project depends on packaged `flatc` compiler @v23.3.3, built with zig using [a fork of google/flatbuffers](https://github.com/travisstaloch/flatbuffers). -# Gen Steps -To auto generate code from a flatbuffers file in your build.zig see the example in [#18](https://github.com/travisstaloch/flatbufferz/pull/18). +# Gen Step +To generate code from a flatbuffers file in your build.zig: + +```console +zig fetch --save git+https://github.com/travisstaloch/flatbufferz +``` + +```zig +const std = @import("std"); + +pub fn build(b: *std.Build) !void { + const exe = b.addExecutable(.{ + // ... + }); + + const fbz_dep = b.dependency("flatbufferz", .{}); + const gen_step = try @import("flatbufferz").GenStep.create( + b, + fbz_dep.artifact("flatc-zig"), + &.{"src/myschema.fbs"}, + &.{}, + "flatc-zig", + ); + + + exe.root_module.addImport("generated", gen_step.module); + exe.root_module.addImport("flatbufferz", fbz_dep.module("flatbufferz")); +} + +``` # Usage