Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

make

Step.make
pub fn make(
    step_index: Configuration.Step.Index,
    maker: *Maker,
    progress_node: std.Progress.Node,
) MakeError!void

File

Code

pub fn make(
    step_index: Configuration.Step.Index,
    maker: *Maker,
    progress_node: std.Progress.Node,
) MakeError!void {
    const graph = maker.graph;
    const arena = graph.arena; // TODO don't leak into the process arena
    const io = graph.io;
    const c = &maker.scanned_config.configuration;
    const conf_step = step_index.ptr(c);
    const s = maker.stepByIndex(step_index);

    var start_ts: ?Io.Timestamp = t: {
        if (!graph.time_report) break :t null;
        const flags = conf_step.flags(c);
        switch (flags.tag) {
            .compile => break :t null,
            .run => {
                const run_flags: Configuration.Step.Run.Flags = @bitCast(flags);
                if (run_flags.stdio == .zig_test) break :t null;
            },
            else => {},
        }
        break :t Io.Clock.awake.now(io);
    };
    const make_result = switch (s.extended) {
        inline else => |*extended| extended.make(step_index, maker, progress_node),
    };
    if (start_ts) |*ts| {
        const duration = ts.untilNow(io, .awake);
        maker.web_server.?.updateTimeReportGeneric(step_index, duration);
    }

    make_result catch |err| switch (err) {
        error.MakeFailed, error.MakeSkipped => |e| return e,
        error.OutOfMemory => {
            s.result_oom = true;
            return error.MakeFailed;
        },
        error.Canceled => |e| return e,
    };

    if (!s.test_results.isSuccess()) {
        return error.MakeFailed;
    }

    const max_rss = conf_step.max_rss.toBytes();
    if (max_rss != 0 and s.result_peak_rss > max_rss) {
        if (std.fmt.allocPrint(
            arena,
            "memory usage peaked at {0B:.2} ({0d} bytes), exceeding the declared upper bound of {1B:.2} ({1d} bytes)",
            .{ s.result_peak_rss, max_rss },
        )) |msg| {
            s.oomWrap(s.result_error_msgs.append(arena, msg));
        } else |_| s.result_oom = true;
    }
}