summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-12-12 08:57:48 -0500
committerGitHub <noreply@github.com>2018-12-12 08:57:48 -0500
commit49ed6b60d662906f290578f802f80b0ead1a2b9d (patch)
treee47050f6508a4b3a4d38b756e9b3c53e0d159507 /source/slang/slang.cpp
parent62d3e387774255be4d507cca045ac97dabac9970 (diff)
Running tests in slang-test process (#740)
* First pass at having an interface to write text to that can be replaced. Simplifed and made more rigerous the interface used to write formatted strings. * Added AppContext to simplify setting up and parsing around of streams. * Added more simplified way to get the std error/out from AppContext. * Work in progress using dll for tools to speed up testing. * First pass at ISlangWriter interface. * Added support for writing VaArgs. Added NullWriter. * Use ISlangWriter for output. * Use ISlangWriter for output - replacing OutputCallback. Make IRDump go to ISlangWriter * SlangWriterTargetType -> SlangWriterChannel Improvements around AppContext * Shared library working with slang-reflection-test. * Dll testing working for render-test. * Include va_list definintion from header. * Fix errors from clang. * Fix typo for linux. * Added -usexes option * Fix typo. * Fix arguments problem on linux. * Fix typo for linux. * Add windows tool shared library projects. * Fix warning from x86 win build. Fix signed warning from slang-test/main.cpp * First attempt at getting premake to work on travis, and run tests. * Try moving build out into script. * Invoke bash scripts so they don't have to be executable. * Drive configuration/tests from env parameters set by travis * Try using source to run travis tests. * Remove the build.linux directory - but doing so will overwrite Makefile. * Made -fno-delete-null-pointer-checks gcc only. * Try to fix warning from -fno-delete-null-pointer-checks * Turn of warnings for unknown switches. * Try to make premake choose the correct tooling. * Disabled missing braces warning. * Disable -Wundefined-var-template on clang. * -Wunused-function disabled for clang. * Fix typo due to SlangBool. * Remove this nullptr tests. * "-Wno-unused-private-field" for clang. * Added "-Wno-undefined-bool-conversion" * Add DominatorList::end fix. * Split scripts into travis_build.sh travis_test.sh * Fix gcc/clang template pre-declaration issue around QualType. * Fix premake to build such that pthread correctly links with slang-glslang
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp65
1 files changed, 61 insertions, 4 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 8fe08884e..b0adb2025 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -13,6 +13,7 @@
#include "../slang/type-layout.h"
#include "slang-file-system.h"
+#include "../core/slang-writer.h"
#include "ir-serialize.h"
@@ -305,6 +306,12 @@ CompileRequest::CompileRequest(Session* session)
sourceManager->initialize(session->getBuiltinSourceManager());
+ // Set all the default writers
+ for (int i = 0; i < int(WriterChannel::CountOf); ++i)
+ {
+ setWriter(WriterChannel(i), nullptr);
+ }
+
// Set up the default file system
SLANG_ASSERT(fileSystem == nullptr);
fileSystemExt = new CacheFileSystem(DefaultFileSystem::getSingleton());
@@ -368,9 +375,38 @@ MatrixLayoutMode TargetRequest::getDefaultMatrixLayoutMode()
}
-
//
+static ISlangWriter* _getDefaultWriter(WriterChannel chan)
+{
+ static FileWriter stdOut(stdout, WriterFlag::IsStatic | WriterFlag::IsUnowned);
+ static FileWriter stdError(stderr, WriterFlag::IsStatic | WriterFlag::IsUnowned);
+ static NullWriter nullWriter(WriterFlag::IsStatic | WriterFlag::IsConsole);
+
+ switch (chan)
+ {
+ case WriterChannel::StdError: return &stdError;
+ case WriterChannel::StdOutput: return &stdOut;
+ case WriterChannel::Diagnostic: return &nullWriter;
+ default:
+ {
+ SLANG_ASSERT(!"Unknown type");
+ return &stdError;
+ }
+ }
+}
+
+void CompileRequest::setWriter(WriterChannel chan, ISlangWriter* writer)
+{
+ writer = writer ? writer : _getDefaultWriter(chan);
+ m_writers[int(chan)] = writer;
+
+ if (chan == WriterChannel::Diagnostic)
+ {
+ mSink.writer = writer;
+ }
+}
+
SlangResult CompileRequest::loadFile(String const& path, ISlangBlob** outBlob)
{
return fileSystemExt->loadFile(path.Buffer(), outBlob);
@@ -1205,7 +1241,6 @@ SLANG_API void spSetFileSystem(
}
}
-
SLANG_API void spSetCompileFlags(
SlangCompileRequest* request,
SlangCompileFlags flags)
@@ -1319,11 +1354,33 @@ SLANG_API void spSetDiagnosticCallback(
SlangDiagnosticCallback callback,
void const* userData)
{
+ using namespace Slang;
+
if(!request) return;
auto req = REQ(request);
- req->mSink.callback = callback;
- req->mSink.callbackUserData = (void*) userData;
+ ComPtr<ISlangWriter> writer(new CallbackWriter(callback, userData, WriterFlag::IsConsole));
+ req->setWriter(WriterChannel::Diagnostic, writer);
+}
+
+SLANG_API void spSetWriter(
+ SlangCompileRequest* request,
+ SlangWriterChannel chan,
+ ISlangWriter* writer)
+{
+ if (!request) return;
+ auto req = REQ(request);
+
+ req->setWriter(Slang::WriterChannel(chan), writer);
+}
+
+SLANG_API ISlangWriter* spGetWriter(
+ SlangCompileRequest* request,
+ SlangWriterChannel chan)
+{
+ if (!request) return nullptr;
+ auto req = REQ(request);
+ return req->getWriter(Slang::WriterChannel(chan));
}
SLANG_API void spAddSearchPath(