diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-08-20 09:43:59 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-20 09:43:59 -0400 |
| commit | 7258ef4ddebd021208a019f6ee73edcda57a88f7 (patch) | |
| tree | 30cccf48c8f03e59e48a2d265e05494238fe758d /tools | |
| parent | 3e78e4654cdf9556869325f2ed2da517f252d879 (diff) | |
User defined downstream compiler prelude (#1028)
* Added setDownstreamCompilerPrelude
Renamed setPassThroughPath to setDownstreamCompilerPath.
Fixed tests.
Added prelude directory & code to TestToolUtil to setup default preludes for testing/command line apis.
* Fix merge problem
* Remove hacks to make prelude work by adding a search path as no longer needed with 'user prelude'.
* Split up prelude into scalar intrinsics, and types.
Use slang.h for main header.
slang-cpp-prelude.h can now just include what it needs (relative to prelude directory) and define the few remaining things/work arounds.
* Fix typo.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/render-test/render-test-main.cpp | 7 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 52 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 1 |
3 files changed, 9 insertions, 51 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 91230b9d0..e8170be40 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -13,13 +13,14 @@ #include "shader-renderer-util.h" +#include "../source/core/slang-io.h" + #include "shader-input-layout.h" #include <stdio.h> #include <stdlib.h> -// TODO(JS): We need to put the prelude into a better place #define SLANG_PRELUDE_NAMESPACE CPPPrelude -#include "../../tests/cross-compile/slang-cpp-prelude.h" +#include "../../prelude/slang-cpp-types.h" #include "../../source/core/slang-test-tool-util.h" #include "../../source/core/slang-memory-arena.h" @@ -1059,6 +1060,8 @@ int main(int argc, char** argv) using namespace Slang; SlangSession* session = spCreateSession(nullptr); + TestToolUtil::setSessionDefaultPrelude(argv[0], session); + auto stdWriters = StdWriters::initDefaultSingleton(); SlangResult res = innerMain(stdWriters, session, argc, argv); diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 63e2456d9..ff80c7ec0 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -32,7 +32,7 @@ using namespace Slang; #include <stdarg.h> #define SLANG_PRELUDE_NAMESPACE CPPPrelude -#include "../../tests/cross-compile/slang-cpp-prelude.h" +#include "../../prelude/slang-cpp-types.h" // Options for a particular test struct TestOptions @@ -1388,54 +1388,6 @@ static TestResult runCPPCompilerCompile(TestContext* context, TestInput& input) return TestResult::Fail; } - String modulePath = _calcModulePath(input); - - // Find the target - UnownedStringSlice targetExt = UnownedStringSlice::fromLiteral("c"); - Index index = cmdLine.findArgIndex(UnownedStringSlice::fromLiteral("-target")); - if (index >= 0 && index + 1 < cmdLine.getArgCount()) - { - targetExt = cmdLine.m_args[index + 1].value.getUnownedSlice(); - } - - // 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"); - - String actualOutput = exeRes.standardOutput; - - // Create a filename to write this out to - String cppSource = modulePath + "." + targetExt; - Slang::File::writeAllText(cppSource, actualOutput); - - // Okay we can now try compiling - - // 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; - } - - if (output.getCountByType(CPPCompiler::Diagnostic::Type::Error) > 0) - { - return TestResult::Fail; - } - } - else - { - // Can only be callable - SLANG_ASSERT(targetExt == "callable" || targetExt == "host-callable"); - } - return TestResult::Pass; } @@ -2853,6 +2805,8 @@ SlangResult innerMain(int argc, char** argv) TestContext context; SLANG_RETURN_ON_FAIL(SLANG_FAILED(context.init())) + TestToolUtil::setSessionDefaultPrelude(argv[0], context.getSession()); + auto& categorySet = context.categorySet; // Set up our test categories here diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 5da998f03..fe9bdbc0e 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -21,6 +21,7 @@ Result TestContext::init() { return SLANG_FAIL; } + return SLANG_OK; } |
