std.Build.Step.Run: Enable passing (generated) file content as args#25228
Merged
andrewrk merged 1 commit intoziglang:masterfrom Sep 20, 2025
Merged
std.Build.Step.Run: Enable passing (generated) file content as args#25228andrewrk merged 1 commit intoziglang:masterfrom
andrewrk merged 1 commit intoziglang:masterfrom
Conversation
aa43e17 to
1c25c1d
Compare
andrewrk
requested changes
Sep 19, 2025
Member
andrewrk
left a comment
There was a problem hiding this comment.
Nice work. Ready to merge aside from some minor requests.
Adds `addFileContentArg` and `addPrefixedFileContentArg` to pass the content of a file with a lazy path as an argument to a `std.Build.Step.Run`. This enables replicating shell `$()` / cmake `execute_process` with `OUTPUT_VARIABLE` as an input to another `execute_process` in conjuction with `captureStdOut`/`captureStdErr`. To also be able to replicate `$()` automatically trimming trailing newlines and cmake `OUTPUT_STRIP_TRAILING_WHITESPACE`, this patch adds an `options` arg to those functions which allows specifying the desired handling of surrounding whitespace. The `options` arg also allows to specify a custom `basename` for the output. e.g. to add a file extension (concrete use case: Zig `@import()` requires files to have a `.zig`/`.zon` extension to recognize them as valid source files).
1c25c1d to
4045043
Compare
Contributor
Author
|
Thanks for the review! I've addressed your comments |
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.