diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-12-10 10:02:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-10 10:02:19 -0500 |
| commit | 79ec0cfdb5f3461c763e0bf712cf42eb87fccb90 (patch) | |
| tree | cf0c3c0b6e7f10d3a29930cd3aeef586298d4234 /tools | |
| parent | 2e52217cb870b4101c1639fed78224f89bf119b3 (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')
| -rw-r--r-- | tools/render-test/slang-support.cpp | 1 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 58 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 16 | ||||
| -rw-r--r-- | tools/slang-test/test-context.h | 10 |
4 files changed, 45 insertions, 40 deletions
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index 9a7c13d7a..37c9b1036 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -158,6 +158,7 @@ static const char computeEntryPointName[] = "computeMain"; SLANG_RETURN_ON_FAIL(res); // We are going to get the entry point count... lets check what we have + if (input.passThrough == SLANG_PASS_THROUGH_NONE) { auto reflection = spGetReflection(slangRequest); // Get the amount of entry points in reflection 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}, }; diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index fe9bdbc0e..c37261b61 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -92,21 +92,21 @@ void TestContext::setInnerMainFunc(const String& name, InnerMainFunc func) } } -CPPCompilerSet* TestContext::getCPPCompilerSet() +DownstreamCompilerSet* TestContext::getCompilerSet() { - if (!cppCompilerSet) + if (!compilerSet) { - cppCompilerSet = new CPPCompilerSet; + compilerSet = new DownstreamCompilerSet; - CPPCompilerUtil::InitializeSetDesc desc; - CPPCompilerUtil::initializeSet(desc, cppCompilerSet); + DownstreamCompilerUtil::InitializeSetDesc desc; + DownstreamCompilerUtil::initializeSet(desc, compilerSet); } - return cppCompilerSet; + return compilerSet; } -Slang::CPPCompiler* TestContext::getDefaultCPPCompiler() +Slang::DownstreamCompiler* TestContext::getDefaultCompiler() { - CPPCompilerSet* set = getCPPCompilerSet(); + DownstreamCompilerSet* set = getCompilerSet(); return set ? set->getDefaultCompiler() : nullptr; } diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index a9f3cec25..aa81fc72a 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -9,7 +9,7 @@ #include "../../source/core/slang-dictionary.h" #include "../../source/core/slang-test-tool-util.h" #include "../../source/core/slang-render-api-util.h" -#include "../../source/core/slang-cpp-compiler.h" +#include "../../source/core/slang-downstream-compiler.h" #include "options.h" @@ -92,9 +92,9 @@ class TestContext /// If set, then tests are executed bool isExecuting() const { return testRequirements == nullptr; } - /// Get compiler factory - Slang::CPPCompilerSet* getCPPCompilerSet(); - Slang::CPPCompiler* getDefaultCPPCompiler(); + /// Get compiler set + Slang::DownstreamCompilerSet* getCompilerSet(); + Slang::DownstreamCompiler* getDefaultCompiler(); /// Ctor TestContext(); @@ -112,7 +112,7 @@ class TestContext Slang::RenderApiFlags availableRenderApiFlags = 0; bool isAvailableRenderApiFlagsValid = false; - Slang::RefPtr<Slang::CPPCompilerSet> cppCompilerSet; + Slang::RefPtr<Slang::DownstreamCompilerSet> compilerSet; protected: struct SharedLibraryTool |
