[PATCH vkd3d] vkd3d-compiler: Write to stdout if the output file is -.
Zebediah Figura
zfigura at codeweavers.com
Wed Aug 12 09:46:34 CDT 2020
Signed-off-by: Zebediah Figura <zfigura at 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
More information about the wine-devel
mailing list