Function addPrefixedOutputFileArg [src]
Provides a file path as a command line argument to the command being run.
Asserts basename is not empty.
For example, a prefix of "-o" and basename 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 basename have spaces.
The returned std.Build.LazyPath can be used as inputs to other APIs
throughout the build system.
Related:
addOutputFileArg - same thing but without the prefix
addFileArg - for input files given to the child process
Prototype
pub fn addPrefixedOutputFileArg( run: *Run, prefix: []const u8, basename: []const u8, ) std.Build.LazyPath
Parameters
run: *Run
prefix: []const u8
basename: []const u8
Source
pub fn addPrefixedOutputFileArg(
run: *Run,
prefix: []const u8,
basename: []const u8,
) std.Build.LazyPath {
const b = run.step.owner;
if (basename.len == 0) @panic("basename must not be empty");
const output = b.allocator.create(Output) catch @panic("OOM");
output.* = .{
.prefix = b.dupe(prefix),
.basename = b.dupe(basename),
.generated_file = .{ .step = &run.step },
};
run.argv.append(b.allocator, .{ .output_file = output }) catch @panic("OOM");
if (run.rename_step_with_output_arg) {
run.setName(b.fmt("{s} ({s})", .{ run.step.name, basename }));
}
return .{ .generated = .{ .file = &output.generated_file } };
}