From 86e11e0e111fab60b9517056ac049bfac6e3bd25 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 16 Jan 2019 13:31:42 -0500 Subject: Feature/external compiler reporting (#776) * Added support for converting SlangResult to string in PlatformUtil. * * Added reportExternalCompilerError * Made external compilers use this * Made DiagnosticSink accept UnownedStringSlice * Made emitXXX compiler functions return SlangError * Use smart pointers to handle life of Com interfaces * * Make SlangResult compatible with HRESULT for some common cases. * Make PlatformUtil::appendResult return SlangResult * Compile check SLANG_RESULT. * Add tests for checking diagnostics from external compilers. * * Make external compiler tests only run on windows for now. * Added 'windows' and 'unix' categories * Added categories based on what backends are available. Will make more tests run on linux and handle case where dxcompiler is not available on appveyor. * * Added spSessionCheckPassThroughSupport * Use to determine whats available for categories for tests * Add support for outputting source filename/s when using pass through. --- source/slang/compiler.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source/slang/compiler.h') diff --git a/source/slang/compiler.h b/source/slang/compiler.h index 2c5d217e6..1cfb9201d 100644 --- a/source/slang/compiler.h +++ b/source/slang/compiler.h @@ -528,8 +528,24 @@ namespace Slang char const* text, CodeGenTarget target); - /* Returns true if a codeGen target is available. */ + /* Returns SLANG_OK if a codeGen target is available. */ SlangResult checkCompileTargetSupport(Session* session, CodeGenTarget target); + /* Returns SLANG_OK if pass through support is available */ + SlangResult checkExternalCompilerSupport(Session* session, PassThroughMode passThrough); + + /* Report an error appearing from external compiler to the diagnostic sink error to the diagnostic sink. + @param compilerName The name of the compiler the error came for (or nullptr if not known) + @param res Result associated with the error. The error code will be reported. (Can take HRESULT - and will expand to string if known) + @param diagnostic The diagnostic string associated with the compile failure + @param sink The diagnostic sink to report to */ + void reportExternalCompileError(const char* compilerName, SlangResult res, const UnownedStringSlice& diagnostic, DiagnosticSink* sink); + + /* Given a translationUnitRequest determines a filename that is most suitable to identify the input. + If the translation is a pass through will attempt to get the source file pathname. If the source is slang generated + there is no equivalent name so will return 'slang-generated' + @param translationUnitRequest The request to find an appropriate source path for + @return the appropriate source filename */ + String calcTranslationUnitSourcePath(TranslationUnitRequest* translationUnitRequest); struct TypeCheckingCache; // -- cgit v1.2.3