Cargo has a configuration file that allows this (Configuration - The Cargo Book) which helps me not write all the time the limit of cores, I’m wondering if Zig has an equivalent, preferably by an environment variable or configuration file.
I don’t know if there is a way to set it directly in your build file or with an environment variable.
But i found something hacky that might give you a Solution: (from Tigerbeetle build.zig)
fn build_ci_step(
b: *std.Build,
step_ci: *std.Build.Step,
command: anytype,
options: struct { max_rss: u64 = 0 },
) void {
const argv = .{ b.graph.zig_exe, "build" } ++ command;
const system_command = b.addSystemCommand(&argv);
const name = std.mem.join(b.allocator, " ", &command) catch @panic("OOM");
system_command.max_stdio_size = 128 * MiB; // Prevent error.StreamTooLong.
system_command.setName(name);
system_command.step.max_rss = options.max_rss;
hide_stderr(system_command);
step_ci.dependOn(&system_command.step);
}
If i understand correctly they are invoking zig build with customs flags again from within the build.zig.
I don’t know if this is a good way to do that tho ![]()
Well, that’s hacky, it’s one way to achieve it I guess, but not really what I wanted (non-hacky), thanks either way.
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.