std.Build.Step.Run: Enable passing (generated) file content as args #25228
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds
addFileContentArgandaddPrefixedFileContentArgto pass the contentof a file with a lazy path as an argument to a
std.Build.Step.Run.This enables replicating shell
$()/ cmakeexecute_processwithOUTPUT_VARIABLEas an input to another
execute_processin conjuction withcaptureStdOut/captureStdErr.To also be able to replicate
$()automatically trimming trailing newlines and cmakeOUTPUT_STRIP_TRAILING_WHITESPACE, this patch also adds anoptionsarg to thosefunctions which allows specifying the desired handling of surrounding whitespace.
The
optionsarg also allows to specify a custombasenamefor the output. e.g.to add a file extension (concrete use case: Zig
@import()requires files to have a.zig/.zonextension to recognize them as valid source files).I've tested this patch on a private project and it worked just fine, however if I should write some kind of test case I'll be happy to do so. I just wasn't sure what such a test case should look like, so any advice on that would be appreciated.