glslangValidator: Exit with an error if output file cannot be written

Propagate the error from glslang::OutputSpv[Hex|Bin] and exit with an error code if there is an error.
This commit is contained in:
Allan MacKinnon 2023-05-23 16:07:48 -04:00 committed by GitHub
parent a5bf69936d
commit 9fbc561947
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 8 deletions

View file

@ -1526,9 +1526,11 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
if (! (Options & EOptionMemoryLeakMode)) {
printf("%s", logger.getAllMessages().c_str());
if (Options & EOptionOutputHexadecimal) {
glslang::OutputSpvHex(spirv, GetBinaryName((EShLanguage)stage), variableName);
if (!glslang::OutputSpvHex(spirv, GetBinaryName((EShLanguage)stage), variableName))
exit(EFailUsage);
} else {
glslang::OutputSpvBin(spirv, GetBinaryName((EShLanguage)stage));
if (!glslang::OutputSpvBin(spirv, GetBinaryName((EShLanguage)stage)))
exit(EFailUsage);
}
outputFiles.push_back(GetBinaryName((EShLanguage)stage));