From 0174470593881b5fe6c22594c9df875ab95a6735 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 12 Jul 2017 13:26:53 -0700 Subject: Properly register error on downstream compiler failure - The old code was just doing `exit(1)` if glslang or `D3DCompile` failed, which is obviously unacceptable - The new approach adds the output to the diagnostic buffer (or invokes the callback), and tracks the error count just like any other errors --- source/slang/compiler.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/slang/compiler.cpp') diff --git a/source/slang/compiler.cpp b/source/slang/compiler.cpp index 7df978707..284bb200a 100644 --- a/source/slang/compiler.cpp +++ b/source/slang/compiler.cpp @@ -236,15 +236,14 @@ namespace Slang // TODO(tfoley): need a better policy for how we translate diagnostics // back into the Slang world (although we should always try to generate // HLSL that doesn't produce any diagnostics...) - String diagnostics = (char const*) diagnosticsBlob->GetBufferPointer(); - fprintf(stderr, "%s", diagnostics.begin()); - OutputDebugStringA(diagnostics.begin()); + entryPoint->compileRequest->mSink.diagnoseRaw( + FAILED(hr) ? Severity::Error : Severity::Warning, + (char const*) diagnosticsBlob->GetBufferPointer()); diagnosticsBlob->Release(); } if (FAILED(hr)) { - // TODO(tfoley): What to do on failure? - exit(1); + return List(); } return data; } @@ -376,9 +375,10 @@ namespace Slang if (err) { - OutputDebugStringA(diagnosticOutput.Buffer()); - fprintf(stderr, "%s", diagnosticOutput.Buffer()); - exit(1); + entryPoint->compileRequest->mSink.diagnoseRaw( + Severity::Error, + diagnosticOutput.begin()); + return err; } return 0; -- cgit v1.2.3