Provides a directory 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_dir" will result in the child process seeing something like this: "-ozig-cache/.../output_dir"
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:
addDirectoryArg - for input directories given to the child processpub fn addOutputDirectoryArg2(
run: *Run,
basename: []const u8,
options: PathArgOptions,
) std.Build.LazyPath
pub fn addOutputDirectoryArg2(
run: *Run,
basename: []const u8,
options: PathArgOptions,
) std.Build.LazyPath {
if (basename.len == 0) @panic("basename must not be empty");
const graph = run.step.owner.graph;
const arena = graph.arena;
const output = arena.create(Output) catch @panic("OOM");
output.* = .{
.prefix = graph.dupeString(options.prefix),
.basename = graph.dupeString(basename),
.suffix = graph.dupeString(options.suffix),
.generated_file = graph.addGeneratedFile(&run.step),
.make_absolute = options.make_absolute,
};
run.argv.append(arena, .{ .output_directory = output }) catch @panic("OOM");
if (run.rename_step_with_output_arg) {
run.setName(std.fmt.allocPrint(arena, "{s} ({s})", .{ run.step.name, basename }) catch @panic("OOM"));
}
return .{ .generated = .{ .index = output.generated_file } };
}