diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 8be8f797a..8137733ee 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -556,6 +556,7 @@ static PassThroughFlags _getPassThroughFlagsForTarget(SlangCompileTarget target) return PassThroughFlag::Dxc; } + case SLANG_HOST_CALLABLE: case SLANG_EXECUTABLE: case SLANG_SHARED_LIBRARY: { @@ -590,6 +591,8 @@ static SlangCompileTarget _getCompileTarget(const UnownedStringSlice& name) CASE("exe", EXECUTABLE) CASE("sharedlib", SHARED_LIBRARY) CASE("dll", SHARED_LIBRARY) + CASE("callable", HOST_CALLABLE) + CASE("host-callable", HOST_CALLABLE) #undef CASE return SLANG_TARGET_UNKNOWN; @@ -1369,39 +1372,49 @@ static TestResult runCPPCompilerCompile(TestContext* context, TestInput& input) String ext = Path::getFileExt(filePath); String modulePath = Path::combine(directory, moduleName); - // Find the target UnownedStringSlice targetExt = UnownedStringSlice::fromLiteral("c"); + + // Find the target Index index = cmdLine.findArgIndex(UnownedStringSlice::fromLiteral("-target")); if (index >= 0 && index + 1 < cmdLine.getArgCount()) { targetExt = cmdLine.m_args[index + 1].value.getUnownedSlice(); } - CPPCompiler::CompileOptions options; - options.sourceType = (targetExt == "c") ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP; + // If output was C/C++ we should try compiling + if (targetExt == "c" || targetExt == "cpp") + { + CPPCompiler::CompileOptions options; + options.sourceType = (targetExt == "c") ? CPPCompiler::SourceType::C : CPPCompiler::SourceType::CPP; - options.includePaths.add("tests/cross-compile"); + options.includePaths.add("tests/cross-compile"); - // Create a filename to write this out to - String cppSource = modulePath + "." + targetExt; - Slang::File::writeAllText(cppSource, actualOutput); + // Create a filename to write this out to + String cppSource = modulePath + "." + targetExt; + Slang::File::writeAllText(cppSource, actualOutput); - // Okay we can now try compiling + // Okay we can now try compiling - // Compile this source - options.sourceFiles.add(cppSource); - options.modulePath = modulePath; - options.targetType = CPPCompiler::TargetType::SharedLibrary; + // Compile this source + options.sourceFiles.add(cppSource); + options.modulePath = modulePath; + options.targetType = CPPCompiler::TargetType::SharedLibrary; - CPPCompiler::Output output; - if (SLANG_FAILED(compiler->compile(options, output))) - { - return TestResult::Fail; - } + CPPCompiler::Output output; + if (SLANG_FAILED(compiler->compile(options, output))) + { + return TestResult::Fail; + } - if (output.getCountByType(CPPCompiler::OutputMessage::Type::Error) > 0) + if (output.getCountByType(CPPCompiler::OutputMessage::Type::Error) > 0) + { + return TestResult::Fail; + } + } + else { - return TestResult::Fail; + // Can only be callable + SLANG_ASSERT(targetExt == "callable" || targetExt == "host-callable"); } return TestResult::Pass; |
