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

addOutputFileArg2

Public Function
std.Build.Step.Run.addOutputFileArg2
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

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 process

Params

  • run: *Run
  • sub_path: []const u8

    The name of the generated output file which may have zero or more path components.

    Asserted to be non-empty.

  • options: PathArgOptions

File

Build/Step/Run.zig:318
318
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
347
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 } };
}