Hi, I'm having an issue where I want to run an executable in build.zig, but I get an out of memory error if I try to use std.process.run with the Debug allocator. Any help, also I'm wondering if this is really the best way to do this in Zig?
pub fn build(b: *std.Build) !void {
var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
var allocator: std.mem.Allocator = undefined;
var threaded: std.Io.Threaded = .init_single_threaded;
const io = threaded.io();
allocator = debug_allocator.allocator();
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "hello",
.root_module = b.createModule(.{
.root_source_file = b.path("hello.zig"),
.target = b.graph.host,
}),
});
const vulkan_headers = b.dependency("vulkan_headers", .{});
const vulkan = b.dependency("vulkan", .{
.registry = vulkan_headers.path("registry/vk.xml"),
}).module("vulkan-zig");
exe.root_module.addImport("vulkan", vulkan);
const zglfw = b.dependency("zglfw", .{
.target = target,
.optimize = optimize,
.import_vulkan = true,
});
const zglfw_mod = zglfw.module("root");
zglfw_mod.addImport("vulkan", vulkan);
exe.root_module.addImport("glfw", zglfw_mod);
if (target.result.os.tag != .emscripten) {
exe.root_module.linkLibrary(zglfw.artifact("glfw"));
}
b.installArtifact(exe);
const buildshaders = b.step("buildshaders", "Build some shaders or summ");
_ = buildshaders;
const argv = [_][]const u8{"buildshaders.sh"};
_ = try std.process.run(allocator, io, .{ .argv = &argv });
// For ZLS diagnostics:
const exe_check = b.addExecutable(.{
.name = "hello",
.root_module = exe.root_module,
});
const check = b.step("check", "check if hello compiles");
check.dependOn(&exe_check.step);
}