A custom build.zig command to run system commands and see their output

Hey, welcome to Ziggit!

As I understand it the build process is split into two main stages, the ‘configure’ phase and the ‘make’ phase.
During the configure phase, the build graph is constructed. During the make phase, it is executed. These two phases are supposed to be completely separate and mixing them might result in unwanted behaviour. However as of now there aren’t really any safeguards to check this nor is there any documentation about which function exactly is allowed when (except for the occasional code comment).

Relevant issue: introduce build_runner.phase enum {configure, make} and assert the phase in many functions · Issue #14941 · ziglang/zig · GitHub

You are conflating the two stages by trying to edit your build graph while it is already being executed by creating steps inside a make function which I’m pretty sure is not allowed. That’s probably why the build script doesn’t work the way you expect.

To fix this you would probably have to have the loop walking the dir and creating build steps in your main build function anyways and then make all the steps you create during the walk depend on some other step that only gets executed if you invoke zig build eye.

1 Like