From 66af404fba419b0e8d167de46fc10a037c991a99 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 5 Mar 2021 01:21:29 +0200 Subject: [PATCH] Allow AST to be dumped even if compilation fails --- tools/glslcompiler.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/glslcompiler.cpp b/tools/glslcompiler.cpp index 0ce5f01d..b7b8097e 100644 --- a/tools/glslcompiler.cpp +++ b/tools/glslcompiler.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -73,7 +74,21 @@ int GlslCompiler::main() compiler.load_source(file, source_fn); compiler.specialize(spec_values); if(!parse_only) - compiler.compile(GL::SL::Compiler::PROGRAM); + { + try + { + compiler.compile(GL::SL::Compiler::PROGRAM); + } + catch(const GL::SL::invalid_shader_source &exc) + { + if(!dump_ast) + throw; + + IO::print("Compilation resulted in errors:\n%s\n", exc.what()); + combined = false; + stage = GL::SL::Stage::SHARED; + } + } if(dump_ast) { -- 2.43.0