summaryrefslogtreecommitdiff
path: root/tools/slang-test/slangc-tool.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-11-18 18:12:43 -0500
committerGitHub <noreply@github.com>2020-11-18 18:12:43 -0500
commite140c4950eb8c69606386ca57284c0655513b9e1 (patch)
tree1361dcf8cfc1597b63960226006af301ac82bfc6 /tools/slang-test/slangc-tool.cpp
parentd898d561e3c76ecf38db434ec7fbb4bbd0e25cb2 (diff)
Test for serializing out and reading back Stdlib (#1605)
* #include an absolute path didn't work - because paths were taken to always be relative. * Mangling/module name extraction for GenericDecl * Add comment on SerialFilter to explain re-enabling Stmt. * Support setting up SyntaxDecl when reconstructed after deserialization. * Improvements to setup SyntaxDecl. * Fix typo so can read compressed SourceLocs. * Fix issue with SourceManger. * Simple test for serializing out stdlib and reading back in. * Fix calling convention. * Add override to StdLib impls. * Fix typo. * Apply testing to an actual compute test when using load-stdlib Make -load/compile-stdlib processable by Slang Move out testing into util into TestToolUtil so can be shared. * Slightly more concise setup of session. * Fix some errors introduced with session handling. * Made setup for compile same across slangc and slangc-tool.
Diffstat (limited to 'tools/slang-test/slangc-tool.cpp')
-rw-r--r--tools/slang-test/slangc-tool.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/tools/slang-test/slangc-tool.cpp b/tools/slang-test/slangc-tool.cpp
index d7043001a..4757f2fff 100644
--- a/tools/slang-test/slangc-tool.cpp
+++ b/tools/slang-test/slangc-tool.cpp
@@ -2,6 +2,7 @@
#include "slangc-tool.h"
#include "../../source/core/slang-exception.h"
+#include "../../source/core/slang-test-tool-util.h"
using namespace Slang;
@@ -16,6 +17,9 @@ static void _diagnosticCallback(char const* message, void* /*userData*/)
static SlangResult _compile(SlangCompileRequest* compileRequest, int argc, const char*const* argv)
{
+ spSetDiagnosticCallback(compileRequest, &_diagnosticCallback, nullptr);
+ spSetCommandLineCompilerMode(compileRequest);
+
{
const SlangResult res = spProcessCommandLineArguments(compileRequest, &argv[1], argc - 1);
if (SLANG_FAILED(res))
@@ -48,22 +52,32 @@ static SlangResult _compile(SlangCompileRequest* compileRequest, int argc, const
return res;
}
-SlangResult SlangCTool::innerMain(StdWriters* stdWriters, SlangSession* session, int argc, const char*const* argv)
+SlangResult SlangCTool::innerMain(StdWriters* stdWriters, slang::IGlobalSession* sharedSession, int argc, const char*const* argv)
{
+ StdWriters::setSingleton(stdWriters);
+
+ // Assume we will used the shared session
+ ComPtr<slang::IGlobalSession> session(sharedSession);
+
+ // The sharedSession always has a pre-loaded stdlib.
+ // This differed test checks if the command line has an option to setup the stdlib.
+ // If so we *don't* use the sharedSession, and create a new stdlib-less session just for this compilation.
+ if (TestToolUtil::hasDeferredStdLib(Index(argc - 1), argv + 1))
+ {
+ SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef()));
+ }
+
SlangCompileRequest* compileRequest = spCreateCompileRequest(session);
- spSetDiagnosticCallback(compileRequest, &_diagnosticCallback, nullptr);
- spSetCommandLineCompilerMode(compileRequest);
// Do any app specific configuration
for (int i = 0; i < SLANG_WRITER_CHANNEL_COUNT_OF; ++i)
{
spSetWriter(compileRequest, SlangWriterChannel(i), stdWriters->getWriter(i));
}
-
- SlangResult res = _compile(compileRequest, argc, argv);
+ SlangResult res = _compile(compileRequest, argc, argv);
// Now that we are done, clean up after ourselves
spDestroyCompileRequest(compileRequest);
+
return res;
}
-