Provides a file path as a command line argument to the command being run.
For example, a prefix of "-o" and sub_path of "output.txt" will result in
the child process seeing something like this: "-ozig-cache/.../output.txt"
The child process will see a single argument, regardless of whether the
prefix or sub_path have spaces.
The returned std.Build.LazyPath can be used as inputs to other APIs
throughout the build system.
Related:
addFileArg - for input files given to the child processpub fn addOutputFileArg2(
run: *Run,
/// The name of the generated output file which may have zero or more path
/// components.
///
/// Asserted to be non-empty.
sub_path: []const u8,
options: PathArgOptions,
) std.Build.LazyPath
pub fn addOutputFileArg2(
run: *Run,
/// The name of the generated output file which may have zero or more path
/// components.
///
/// Asserted to be non-empty.
sub_path: []const u8,
options: PathArgOptions,
) std.Build.LazyPath {
const b = run.step.owner;
const graph = b.graph;
const arena = graph.arena;
assert(sub_path.len != 0);
const output = graph.create(Output);
output.* = .{
.prefix = graph.dupeString(options.prefix),
.basename = graph.dupeString(sub_path),
.suffix = graph.dupeString(options.suffix),
.generated_file = graph.addGeneratedFile(&run.step),
.make_absolute = options.make_absolute,
};
run.argv.append(arena, .{ .output_file = output }) catch @panic("OOM");
if (run.rename_step_with_output_arg) {
run.setName(b.fmt("{s} ({s})", .{ run.step.name, sub_path }));
}
return .{ .generated = .{ .index = output.generated_file } };
}