summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/render-test/render-test-main.cpp15
-rw-r--r--tools/slang-test/slangc-tool.cpp26
2 files changed, 33 insertions, 8 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 85e038e5a..f6f3e4ce6 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -787,14 +787,25 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi
}
}
-SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSession* session, int argcIn, const char*const* argvIn)
+SLANG_TEST_TOOL_API SlangResult innerMain(Slang::StdWriters* stdWriters, SlangSession* sharedSession, int inArgc, const char*const* inArgv)
{
using namespace Slang;
+ // 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(inArgc - 1), inArgv + 1))
+ {
+ SLANG_RETURN_ON_FAIL(slang_createGlobalSessionWithoutStdLib(SLANG_API_VERSION, session.writeRef()));
+ }
+
SlangResult res = SLANG_FAIL;
try
{
- res = _innerMain(stdWriters, session, argcIn, argvIn);
+ res = _innerMain(stdWriters, session, inArgc, inArgv);
}
catch (const Slang::Exception& exception)
{
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;
}
-