diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 35 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 10 | ||||
| -rw-r--r-- | tools/slang-test/test-context.h | 6 |
3 files changed, 26 insertions, 25 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index b93833f89..fdd5cd13d 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -1094,6 +1094,14 @@ String getExpectedOutput(String const& outputStem) static TestResult runExecuteC(TestContext* context, TestInput& input) { + CPPCompilerSet* compilerSet = context->getCPPCompilerSet(); + CPPCompiler* compiler = compilerSet ? compilerSet->getDefaultCompiler() : nullptr; + + if (!compiler) + { + return TestResult::Ignored; + } + // If we are just collecting requirements, say it passed if (context->isCollectingRequirements()) { @@ -1112,7 +1120,7 @@ static TestResult runExecuteC(TestContext* context, TestInput& input) String modulePath = Path::combine(directory, moduleName); - CPPCompileOptions options; + CPPCompiler::CompileOptions options; // Compile this source options.sourceFiles.add(filePath); @@ -1120,33 +1128,10 @@ static TestResult runExecuteC(TestContext* context, TestInput& input) ExecuteResult exeRes; -#ifdef _WIN32 - // Find - List<WinVisualStudioUtil::VersionPath> versionPaths; - WinVisualStudioUtil::find(versionPaths); - - // Didn't find the visual studio compiler - if (versionPaths.getCount() <= 0) - { - return TestResult::Ignored; - } - - CommandLine cmdLine; - WinVisualStudioUtil::calcArgs(options, cmdLine); - - if (SLANG_FAILED(WinVisualStudioUtil::executeCompiler(versionPaths[0], cmdLine, exeRes))) - { - return TestResult::Fail; - } -#else - CommandLine cmdLine; - UnixCPPCompilerUtil::calcArgs(options, cmdLine); - - if (SLANG_FAILED(UnixCPPCompilerUtil::executeCompiler(cmdLine, exeRes))) + if (SLANG_FAILED(compiler->compile(options, exeRes))) { return TestResult::Fail; } -#endif // Execute the binary and see what we get { diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 0b17b3672..90052c4c4 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -90,3 +90,13 @@ void TestContext::setInnerMainFunc(const String& name, InnerMainFunc func) m_sharedLibTools.Add(name, tool); } } + +CPPCompilerSet* TestContext::getCPPCompilerSet() +{ + if (!cppCompilerSet) + { + cppCompilerSet = new CPPCompilerSet; + CPPCompilerUtil::initializeSet(cppCompilerSet); + } + return cppCompilerSet; +} diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index afc5bb427..895cb9c06 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -9,6 +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 "options.h" @@ -95,6 +96,9 @@ class TestContext /// If set, then tests are executed bool isExecuting() const { return testRequirements == nullptr; } + /// Get compiler factory + Slang::CPPCompilerSet* getCPPCompilerSet(); + /// Ctor TestContext(); /// Dtor @@ -111,6 +115,8 @@ class TestContext Slang::RenderApiFlags availableRenderApiFlags = 0; bool isAvailableRenderApiFlagsValid = false; + Slang::RefPtr<Slang::CPPCompilerSet> cppCompilerSet; + protected: struct SharedLibraryTool { |
