Documentation for the zig build system


I’m looking for an up-to-date documentation of the zig build system.
Particularly useful would be a section on gotchas between 0.11.0 and 0.12-dev.

The background is:
I’d like to use raylib and raygui from Zig, but so far haven’t found a setup that works.

Here are bindings for raylib and zig (0.11.0), but not including raygui: GitHub - Not-Nik/raylib-zig: Manually tweaked, auto-generated raylib bindings for zig.

Here someone created bindings for both raylib and raygui: GitHub - ryupold/raylib.zig: Idiomatic Zig bindings for raylib utilizing raylib_parser But it’s not clear to me how to build this. The git repo says it depends on zig (master) but was that written when 0.11.0 was the latest version? The ecosystem around this set of bindings looks great, they not only have raygui integration but also a set of examples and a guide for compilation to WASM. But I can’t get this to compile, it seems like a zig version mismatch, where raylib relies on zig 0.11.0 and the bindings and examples use zig 0.12.0. I’ve created an issue: ryupold/examples-raylib.zig/issues/9 (sorry, not a link. New users can post only two links)

Ok, maybe it’s better to just not use a binding. Raylib/raygui is a pretty fast moving target (as is zig) and having a set of bindings which might get out of date at any point looks increasingly less appealing.

I’m a bit overwhelmed by the Zig build system, so started googling for resources and starting points.
Someone posted a minimal setup on reddit: r/Zig/comments/16r0fj6/ysk_you_can_use_native_raylib_directly_in_zig_for/ (also, not a link, because of new user limitation)
I’ve moved this into a git repo: lhk/raylib_zig_build_setup (github repo)
works for me.

Importantly, you have to build this with zig 0.11.0.
That’s because the build.zig relies on raylibs build.zig, which is aligned with zig 0.11.0

Now, the next step would be to add raygui.
Again, I googled a bit, how to include a header into the build process.
And found a related question here on Ziggit: /t/can-you-locate-and-copy-dependency-files-specified-in-zon-files/1934/10

I think it should be possible to use the build setup from that question to include raygui.
If I understand correctly, the issue in that question is about using the package manager to handle dependencies.
If I’m fine with keeping raygui as a git submodule, that should be ok.
And then I think I can just copy over the header following the syntax in that linked question.

But by now I’m really deep in a rabbit hole of copy-pasting other peoples code.
I’d like to take a step back and understand this a bit better.
Is there something you’d recommend?

1 Like