summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-08-12 15:41:41 -0400
committerGitHub <noreply@github.com>2019-08-12 15:41:41 -0400
commit6fc2c37d9a4c408331db1b33deb3b46e74d2a7d2 (patch)
treed763d0f85b61f853f5877ab9ee28d3edaeef302c /tools
parenta0416216ffaf3bd3b0533d967a6d62c477b22d09 (diff)
Callable CPU code support (#1014)
* First pass support for compiling to a loaded shared library. * Improve documentation for cpu target. * Removed the SLANG_COMPILE_FLAG_LOAD_SHARED_LIBRARY flag. Use the SLANG_HOST_CALLABLE code target Document mechanism. * Fix typo in cpp-resource.slang In test code if the target is 'callable' we don't need to compile (indeed there is no source file). * Small refactor using CommandLineCPPCompiler as base class to implement VisualStudioCPPCompiler and GCCCPPCompiler. * Improvements around CPPCompiler. Mechanism to know products produced. Cleaning up products after execution. * Fix multiple definition of 'SourceType'
Diffstat (limited to 'tools')
-rw-r--r--tools/slang-test/slang-test-main.cpp51
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;