layers: Fix APIDump to handle "stdout" special case
authorTobin Ehlis <tobin@lunarg.com>
Fri, 18 Sep 2015 20:32:12 +0000 (14:32 -0600)
committerTobin Ehlis <tobin@lunarg.com>
Fri, 18 Sep 2015 20:32:12 +0000 (14:32 -0600)
Also setting example vk_layer_settings.txt file to have APIDump write to stdout.

layers/vk_layer_settings.txt
vk-layer-generate.py

index 863371bbdf76895a4843849da5958bd70dc0cb4e..7251ff9e8a9d67035a66e5d0c7f85b915f257b43 100644 (file)
@@ -79,8 +79,8 @@ ThreadingLogFilename = stdout
 APIDumpDetailed = TRUE
 # NoAddr TRUE causes "address" to be dumped in place of hex addresses
 APIDumpNoAddr = FALSE
-# File = TRUE indicates that output should be written to file
-APIDumpFile = TRUE
+# File = TRUE indicates that output should be written to file instead of STDOUT
+APIDumpFile = FALSE
 # LogFilename is file to dump to when "File = TRUE" default is "vk_apidump.txt"
 APIDumpLogFilename = stdout
 # Flush = TRUE causes IO to be flushed after each line that's written
index 26873d45b3602c8652f58e388dc55f65ff39c03d..0d020b92251fca45e7a6e36327e8687f438cfc8c 100755 (executable)
@@ -732,13 +732,19 @@ class APIDumpSubcommand(Subcommand):
         header_txt.append('{')
         header_txt.append('    if(writeToFile)')
         header_txt.append('    {')
-        header_txt.append('        fileStream.open(fileName);')
-        header_txt.append('        if ((fileStream.rdstate() & fileStream.failbit) != 0) {')
+        header_txt.append('        if (fileName == "stdout")')
+        header_txt.append('        {')
         header_txt.append('            outputStream = &std::cout;')
-        header_txt.append('            (*outputStream) << endl << "APIDump ERROR: Bad output filename specified: " << fileName << ". Writing to STDOUT instead" << endl << endl;')
+        header_txt.append('            (*outputStream) << endl << "APIDump output filename \'stdout\' specified. Writing to STDOUT instead of a file." << endl << endl;')
+        header_txt.append('        } else {')
+        header_txt.append('            fileStream.open(fileName);')
+        header_txt.append('            if ((fileStream.rdstate() & fileStream.failbit) != 0) {')
+        header_txt.append('                outputStream = &std::cout;')
+        header_txt.append('                (*outputStream) << endl << "APIDump ERROR: Bad output filename specified: " << fileName << ". Writing to STDOUT instead" << endl << endl;')
+        header_txt.append('            }')
+        header_txt.append('            else')
+        header_txt.append('                outputStream = &fileStream;')
         header_txt.append('        }')
-        header_txt.append('        else')
-        header_txt.append('            outputStream = &fileStream;')
         header_txt.append('    }')
         header_txt.append('    else')
         header_txt.append('    {')