Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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

addOutputDirectoryArg2

Public Function
std.Build.Step.Run.addOutputDirectoryArg2
pub fn addOutputDirectoryArg2(
    run: *Run,
    basename: []const u8,
    options: PathArgOptions,
) std.Build.LazyPath

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:

Params

File

Build/Step/Run.zig:460
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
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 } };
}