From: Mikko Rasa Date: Thu, 4 Mar 2021 23:21:29 +0000 (+0200) Subject: Allow AST to be dumped even if compilation fails X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=66af404fba419b0e8d167de46fc10a037c991a99;p=libs%2Fgl.git Allow AST to be dumped even if compilation fails --- 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) {