summaryrefslogtreecommitdiff
path: root/tools/slang-test/slang-test-main.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-12-10 10:02:19 -0500
committerGitHub <noreply@github.com>2019-12-10 10:02:19 -0500
commit79ec0cfdb5f3461c763e0bf712cf42eb87fccb90 (patch)
treecf0c3c0b6e7f10d3a29930cd3aeef586298d4234 /tools/slang-test/slang-test-main.cpp
parent2e52217cb870b4101c1639fed78224f89bf119b3 (diff)
DownstreamCompiler abstraction (#1149)
* CPPCompiler -> DownstreamCompiler * Added DownstreamCompileResult to start abstraction such that we don't need files. * * Split out slang-blob.cpp * Made CompileResult hold a DownstreamCompileResult - for access to binary or ISlangSharedLibrary * Keep temporary files in scope. * Add a hash to the hex dump stream. * Move all file tracking into DownstreamCompiler.
Diffstat (limited to 'tools/slang-test/slang-test-main.cpp')
-rw-r--r--tools/slang-test/slang-test-main.cpp58
1 files changed, 31 insertions, 27 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index e0474ebe6..51c3ecea9 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -19,7 +19,7 @@ using namespace Slang;
#include "options.h"
#include "slangc-tool.h"
-#include "../../source/core/slang-cpp-compiler.h"
+#include "../../source/core/slang-downstream-compiler.h"
#include "../../source/core/slang-process-util.h"
@@ -1257,13 +1257,13 @@ String getExpectedOutput(String const& outputStem)
return expectedOutput;
}
-static String _calcSummary(const CPPCompiler::Output& inOutput)
+static String _calcSummary(const DownstreamDiagnostics& inOutput)
{
- CPPCompiler::Output output(inOutput);
+ DownstreamDiagnostics output(inOutput);
// We only want to analyse errors for now
- output.removeByType(CPPCompiler::Diagnostic::Type::Info);
- output.removeByType(CPPCompiler::Diagnostic::Type::Warning);
+ output.removeByType(DownstreamDiagnostics::Diagnostic::Type::Info);
+ output.removeByType(DownstreamDiagnostics::Diagnostic::Type::Warning);
StringBuilder builder;
@@ -1280,9 +1280,9 @@ static String _calcModulePath(const TestInput& input)
return Path::combine(directory, moduleName);
}
-static TestResult runCPPCompilerCompile(TestContext* context, TestInput& input)
+static TestResult runCompilerCompile(TestContext* context, TestInput& input)
{
- CPPCompiler* compiler = context->getDefaultCPPCompiler();
+ DownstreamCompiler* compiler = context->getDefaultCompiler();
if (!compiler)
{
return TestResult::Ignored;
@@ -1322,9 +1322,9 @@ static TestResult runCPPCompilerCompile(TestContext* context, TestInput& input)
return TestResult::Pass;
}
-static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& input)
+static TestResult runCompilerSharedLibrary(TestContext* context, TestInput& input)
{
- CPPCompiler* compiler = context->getDefaultCPPCompiler();
+ DownstreamCompiler* compiler = context->getDefaultCompiler();
if (!compiler)
{
return TestResult::Ignored;
@@ -1352,12 +1352,12 @@ static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& i
File::remove(sharedLibraryPath);
// Set up the compilation options
- CPPCompiler::CompileOptions options;
+ DownstreamCompiler::CompileOptions options;
- options.sourceType = (ext == "c") ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP;
+ options.sourceType = (ext == "c") ? DownstreamCompiler::SourceType::C : DownstreamCompiler::SourceType::CPP;
// Build a shared library
- options.targetType = CPPCompiler::TargetType::SharedLibrary;
+ options.targetType = DownstreamCompiler::TargetType::SharedLibrary;
// Compile this source
options.sourceFiles.add(filePath);
@@ -1365,16 +1365,18 @@ static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& i
options.includePaths.add(".");
- CPPCompiler::Output output;
- if (SLANG_FAILED(compiler->compile(options, output)))
+ RefPtr<DownstreamCompileResult> compileResult;
+ if (SLANG_FAILED(compiler->compile(options, compileResult)))
{
return TestResult::Fail;
}
- if (SLANG_FAILED(output.result))
+ const auto& diagnostics = compileResult->getDiagnostics();
+
+ if (SLANG_FAILED(diagnostics.result))
{
// Compilation failed
- String actualOutput = _calcSummary(output);
+ String actualOutput = _calcSummary(diagnostics);
// Write the output
Slang::File::writeAllText(actualOutputPath, actualOutput);
@@ -1438,9 +1440,9 @@ static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& i
return TestResult::Pass;
}
-static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
+static TestResult runCompilerExecute(TestContext* context, TestInput& input)
{
- CPPCompiler* compiler = context->getDefaultCPPCompiler();
+ DownstreamCompiler* compiler = context->getDefaultCompiler();
if (!compiler)
{
return TestResult::Ignored;
@@ -1472,26 +1474,28 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input)
}
// Set up the compilation options
- CPPCompiler::CompileOptions options;
+ DownstreamCompiler::CompileOptions options;
- options.sourceType = (ext == "c") ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP;
+ options.sourceType = (ext == "c") ? DownstreamCompiler::SourceType::C : DownstreamCompiler::SourceType::CPP;
// Compile this source
options.sourceFiles.add(filePath);
options.modulePath = modulePath;
- CPPCompiler::Output output;
- if (SLANG_FAILED(compiler->compile(options, output)))
+ RefPtr<DownstreamCompileResult> compileResult;
+ if (SLANG_FAILED(compiler->compile(options, compileResult)))
{
return TestResult::Fail;
}
String actualOutput;
+ const auto& diagnostics = compileResult->getDiagnostics();
+
// If the actual compilation failed, then the output will be
- if (SLANG_FAILED(output.result))
+ if (SLANG_FAILED(diagnostics.result))
{
- actualOutput = _calcSummary(output);
+ actualOutput = _calcSummary(diagnostics);
}
else
{
@@ -2438,9 +2442,9 @@ static const TestCommandInfo s_testCommandInfos[] =
{ "COMPARE_RENDER_COMPUTE", &runSlangRenderComputeComparisonTest},
{ "COMPARE_GLSL", &runGLSLComparisonTest},
{ "CROSS_COMPILE", &runCrossCompilerTest},
- { "CPP_COMPILER_EXECUTE", &runCPPCompilerExecute},
- { "CPP_COMPILER_SHARED_LIBRARY", &runCPPCompilerSharedLibrary},
- { "CPP_COMPILER_COMPILE", &runCPPCompilerCompile},
+ { "CPP_COMPILER_EXECUTE", &runCompilerExecute},
+ { "CPP_COMPILER_SHARED_LIBRARY", &runCompilerSharedLibrary},
+ { "CPP_COMPILER_COMPILE", &runCompilerCompile},
{ "PERFORMANCE_PROFILE", &runPerformanceProfile},
{ "COMPILE", &runCompile},
};