Hey, does anyone know how you can print the output from external tools when building? In my case I am compiling shaders and cannot see the error messages from the tool (glslangValidator)
fn add_shader(b: *std.Build, exe: *std.Build.Step.Compile, name: []const u8) void {
const source = std.fmt.allocPrint(b.allocator, "src/shaders/{s}", .{name}) catch @panic("OOM");
const outpath = std.fmt.allocPrint(b.allocator, "src/shaders/{s}.spv", .{name}) catch @panic("OOM");
const shader_compilation = b.addSystemCommand(&.{"glslangValidator"});
shader_compilation.addArg("--target-env");
shader_compilation.addArg("vulkan1.3");
shader_compilation.addArg("--target-env");
shader_compilation.addArg("spirv1.5");
shader_compilation.addArg("-V");
shader_compilation.addArg("-o");
const output = shader_compilation.addOutputFileArg(outpath);
shader_compilation.addFileArg(b.path(source));
_ = shader_compilation.captureStdOut();
const captured_output = shader_compilation.captured_stdout.?.generated_file.getPath();
std.log.info("Shader Compilation Output Path: {s}", .{captured_output});
exe.root_module.addAnonymousImport(name, .{ .root_source_file = output });
}
I tried to get the path of the output files since i know the stdout gets stored in .zig-cache but i get this error
thread 14924 panic: getPath() was called on a GeneratedFile that wasn't built yet. Is there a missing Step dependency on step 'run glslangValidator (src/shaders/mesh.vert.spv)'?