After trying to figure out how this would work with the new IO system, I’ll naturally need an IO system pointer - so next I tried to figure out if the build system exposes its own IO implementation, similar to b.allocator, but no luck.
My next idea was… hey, why not simply use std.c.access()… and that works wonderfully on macOS but breaks on Linux with:
error: dependency on libc must be explicitly specified in the build command
…naturally I don’t want that… std.posix.fstat on the other doesn’t seem to work on Windows, so I guess my only option is one of the std.IO stat functions. But for that I need an IO system, but at the same time I don’t want to infect the whole call chain down to this one really unimportant function which just needs to check if a file exists and absolutely nothing else.
Creating a function local IO system just for this one file-exists check seems like complete overkill and absolutely not how the IO system is supposed to be used (I guess).
I think what you want is runAllowFail with "ls" or "find".
It would be nice if build steps also had a way to deal with nonzero exit codes which allowed things to continue on a conditional basis too, actually. But that’s a separate ask.
Yeah that’s what I do now (create a temp IO object)…
What I’m doing is a bit of a hack in the first place of course, because it happens in the ‘build-tree-construction phase’, not in the actual build phase. But that whole thing I’m doing there (installing the Emscripten SDK into the Zig cache) doesn’t really fit into the build system philosophy, so it’s a hack to make another hack work, but currently I see no other way to solve that problem…
Ah thanks! I looked in the Build type but didn’t think that the interesting stuff might be hidden under .graph I simplified my build.zig to use the build system’s IO and it appears to work perfectly (also added the fallback for 0.15.2 back while at it).