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 standard library. Public Function
pubfnaddRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
// Avoid the common case of the step name looking like "run test test".conststep_name = if (exe.kind.isTest() andmem.eql(u8, exe.name, "test"))
b.fmt("run {t}", .{exe.kind})
elseb.fmt("run {t} {s}", .{ exe.kind, exe.name });
construn_step = Step.Run.create(b, step_name);
run_step.producer = exe;
if (exe.kind == .@"test") {
run_step.addArtifactArg(exe);
consttest_server_mode: bool = s: {
if (exe.test_runner) |r| break :sr.mode == .server;
if (exe.use_llvm == false) {
// The default test runner does not use the server protocol if the selected backend// is too immature to support it. Keep this logic in sync with `need_simple` in the// default test runner implementation.switch (exe.rootModuleTarget().cpu.arch) {
// stage2_aarch64
.aarch64,
.aarch64_be,
// stage2_powerpc
.powerpc,
.powerpcle,
.powerpc64,
.powerpc64le,
// stage2_riscv64
.riscv64,
=> break :sfalse,
else => {},
}
}
break :strue;
};
if (test_server_mode) {
run_step.enableTestRunnerMode();
} elseif (exe.test_runner == null) {
// If a test runner does not use the `std.zig.Server` protocol, it can instead// communicate failure via its exit code.run_step.expectExitCode(0);
}
} else {
run_step.addArtifactArg(exe);
}
returnrun_step;
}
Creates a
Step.Runwith an executable built withaddExecutable. Add command line arguments with methods ofStep.Run.It doesn't have to target the host. In some cases cross-compiled binaries can even be executed.
This is declarative; it constructs a build step that may or may not be run depending on the options provided by the user to the build command.
See also:
addSystemCommandaddRunFile