[PATCH vkd3d] vkd3d-compiler: Write to stdout if the output file is -.
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> --- I've found this feature to be occasionally useful. programs/vkd3d-compiler/main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/programs/vkd3d-compiler/main.c b/programs/vkd3d-compiler/main.c index 68bc030b..a1adb616 100644 --- a/programs/vkd3d-compiler/main.c +++ b/programs/vkd3d-compiler/main.c @@ -119,7 +119,11 @@ static bool write_shader(const struct vkd3d_shader_code *shader, const char *fil { FILE *fd; - if (!(fd = fopen(filename, "wb"))) + if (!strcmp(filename, "-")) + { + fd = stdout; + } + else if (!(fd = fopen(filename, "wb"))) { fprintf(stderr, "Cannot open file for writing: '%s'.\n", filename); return false; @@ -128,7 +132,8 @@ static bool write_shader(const struct vkd3d_shader_code *shader, const char *fil if (fwrite(shader->code, 1, shader->size, fd) != shader->size) fprintf(stderr, "Could not write shader bytecode to file: '%s'.\n", filename); - fclose(fd); + if (fd != stdout) + fclose(fd); return true; } @@ -143,7 +148,8 @@ static void print_usage(const char *program_name) " --buffer-uav=<type> Specify the buffer type to use for buffer UAV bindings.\n" " Valid values are 'buffer-texture' (default) and\n" " 'storage-buffer'.\n" - " -o, --output=<file> Write the output to <file>.\n" + " -o, --output=<file> Write the output to <file>. If <file> is -, write to\n" + " standard output.\n" " --print-source-types Display the supported source types and exit.\n" " --print-target-types Display the supported target types for the specified\n" " source type and exit.\n" -- 2.27.0
Hi, While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=77000 Your paranoid android. === debiant (build log) === Task: Patch failed to apply === debiant (build log) === Task: Patch failed to apply
On Wed, 12 Aug 2020 at 19:16, Zebediah Figura <zfigura(a)codeweavers.com> wrote:
Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com> --- I've found this feature to be occasionally useful.
programs/vkd3d-compiler/main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
I have a slightly more elaborate patch for this already in my tree.
participants (3)
-
Henri Verbeet -
Marvin -
Zebediah Figura