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

addFileContentArg2

Public Function
std.Build.Step.Run.addFileContentArg2
pub fn addFileContentArg2(run: *Run, lp: std.Build.LazyPath, options: ArgOptions) void

Appends the content of an input file to the command line arguments prepended with a string.

For example, a prefix of "-F" will result in the child process seeing something like this: "-Fmy file content"

The child process will see a single argument, even if the prefix and/or the file contain whitespace. This means that the entire file content up to EOF is rendered as one contiguous string, including escape sequences. Notably, any (trailing) newlines will show up like this: "hello,\nfile world!\n"

Modifications to the source file will be detected as a cache miss in subsequent builds, causing the child process to be re-executed.

This function may not be used to supply the first argument of a Run step.

Related:

Params

File

Build/Step/Run.zig:412
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
pub fn addFileContentArg2(run: *Run, lp: std.Build.LazyPath, options: ArgOptions) void {
    const graph = run.step.owner.graph;
    const arena = graph.arena;

    // Some parts of this step's configure phase API rely on the first argument being somewhat
    // transparent/readable, but the content of the file specified by `lp` remains completely
    // opaque until its path can be resolved during the make phase.
    if (run.argv.items.len == 0) {
        @panic("'addFileContentArg'/'addPrefixedFileContentArg' cannot be first argument");
    }

    const file_content: DecoratedFileContent = .{
        .prefix = graph.dupeString(options.prefix),
        .lazy_path = lp.dupe(graph),
        .suffix = graph.dupeString(options.suffix),
    };
    run.argv.append(arena, .{ .file_content = file_content }) catch @panic("OOM");
    lp.addStepDependencies(&run.step);
}