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 run: *Runsub_path: []const u8The name of the generated output file which may have zero or more path components.
Asserted to be non-empty.
options: PathArgOptions318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347pub 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 } };
}
Provides a file path as a command line argument to the command being run.
For example, a prefix of "-o" and
sub_pathof "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_pathhave spaces.The returned
std.Build.LazyPathcan be used as inputs to other APIs throughout the build system.Related:
addFileArg- for input files given to the child process