diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-12-17 09:22:14 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-17 09:22:14 -0500 |
| commit | d2ddc590601778f309c81f7d19d5e7fed34210de (patch) | |
| tree | 8ad5dd912fe43e946a4e40cce3eb6c8410254600 /tools/slang-test/slangc-tool.cpp | |
| parent | d43c566fa29bbc0da1534aea236d54ee5ca104b8 (diff) | |
Feature/test tool shared libraries (#758)
* Remove circular reference to renderer on Vk & D3D12 DescriptorSetImpl
* Refactor Stbi image loading such that memory is correctly freed when goes out of scope.
Added Crt memory dump at termination.
Reduced erroneous reporting by scoping TestContext.
* Used capitalized acronym for STBImage to keep Tim happy.
* Split out TestReporter - to just handle reporting test results
Split out Options
Made TestContext hold options, and the reporter
Removed remaining memory leaks.
* Small optimization for rawWrite, such that it directly writes over print..
* Improve comments on TestCategorySet
* Fix typos in TestCategorySet
* Made slangc a cpp file as part of slang-test (removing need for separate project/shared library).
* * Made all test tools only available as dlls.
* Made possible to invoke test tool dll from command line
slang-test slangc [--bindir xxx] options to slangc
* Fix Visual Studio projects that are no longer needed.
Diffstat (limited to 'tools/slang-test/slangc-tool.cpp')
| -rw-r--r-- | tools/slang-test/slangc-tool.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tools/slang-test/slangc-tool.cpp b/tools/slang-test/slangc-tool.cpp new file mode 100644 index 000000000..3085e2ab5 --- /dev/null +++ b/tools/slang-test/slangc-tool.cpp @@ -0,0 +1,57 @@ +// test-context.cpp +#include "slangc-tool.h" + +using namespace Slang; + +SLANG_API void spSetCommandLineCompilerMode(SlangCompileRequest* request); + +static void _diagnosticCallback(char const* message, void* /*userData*/) +{ + auto stdError = AppContext::getStdError(); + stdError.put(message); + stdError.flush(); +} + +SlangResult SlangCTool::innerMain(AppContext* appContext, SlangSession* session, int argc, const char*const* argv) +{ + SlangCompileRequest* compileRequest = spCreateCompileRequest(session); + spSetDiagnosticCallback(compileRequest, &_diagnosticCallback, nullptr); + + spSetCommandLineCompilerMode(compileRequest); + // Do any app specific configuration + appContext->configureRequest(compileRequest); + + { + const SlangResult res = spProcessCommandLineArguments(compileRequest, &argv[1], argc - 1); + if (SLANG_FAILED(res)) + { + // TODO: print usage message + return res; + } + } + + SlangResult res = SLANG_OK; + +#ifndef _DEBUG + try +#endif + { + // Run the compiler (this will produce any diagnostics through SLANG_WRITER_TARGET_TYPE_DIAGNOSTIC). + res = spCompile(compileRequest); + // If the compilation failed, then get out of here... + // Turn into an internal Result -> such that return code can be used to vary result to match previous behavior + res = SLANG_FAILED(res) ? SLANG_E_INTERNAL_FAIL : res; + } +#ifndef _DEBUG + catch (Exception & e) + { + AppContext::getStdOut().print("internal compiler error: %S\n", e.Message.ToWString().begin()); + res = SLANG_FAIL; + } +#endif + + // Now that we are done, clean up after ourselves + spDestroyCompileRequest(compileRequest); + return res; +} + |
