diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-09-01 09:35:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-01 09:35:18 -0400 |
| commit | cd8715a7760189c54b36c0c250efbe1db5b8635c (patch) | |
| tree | cd1b2e840e64cbdd9e9a383646f0e58a7f14ae97 /tools | |
| parent | 5c2c2cfc9918bb43225159e67a851e196e17759a (diff) | |
Passing source to Downstream compilation as artifacts (#2382)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Make DownstreamCompileOptions use POD types.
* CharSliceAllocator -> SliceAllocator
Added SliceConverter
CharSliceCaster -> SliceCaster
* First attempt at zero terminating around blobs.
* Fix clang warning.
* Add SlangTerminatedChars
Make Blob implementations support it.
Make most blobs 'terminated'.
* Fix bug setting up sourceFiles for CommandLineDownstreamCompiler.
* Traffic in TerminatedCharSlice for sourceFiles.
Use ArtifactDesc to generate temporary file names for source.
* Fix typo in testing for shared library/C++.
* Working with source being passed as artifacts to DownstreamCompiler.
* Use artifacts in SourceManager/SourceFile.
* Support infering extension from the original file extension.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index cd783bb05..ef5d16b2c 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -7,6 +7,9 @@ #include "../../source/core/slang-type-text-util.h" #include "../../source/core/slang-memory-arena.h" +#include "../../source/compiler-core/slang-artifact-desc-util.h" +#include "../../source/compiler-core/slang-artifact-helper.h" + #include "../../slang-com-helper.h" #include "../../source/core/slang-string-util.h" @@ -2232,13 +2235,17 @@ static TestResult runCPPCompilerSharedLibrary(TestContext* context, TestInput& i // Build a shared library options.targetType = SLANG_SHADER_SHARED_LIBRARY; + auto helper = DefaultArtifactHelper::getSingleton(); + // Compile this source - TerminatedCharSlice sourceFiles[] = { SliceCaster::asTerminatedCharSlice(filePath) }; + ComPtr<IArtifact> sourceArtifact; + helper->createFileArtifact(ArtifactDescUtil::makeDescForSourceLanguage(options.sourceLanguage), asCharSlice(filePath.getUnownedSlice()), sourceArtifact.writeRef()); + TerminatedCharSlice includePaths[] = { TerminatedCharSlice(".") }; - options.sourceFiles = makeSlice(sourceFiles, 1); + options.sourceArtifacts = makeSlice(sourceArtifact.readRef(), 1); options.includePaths = makeSlice(includePaths, 1); - options.modulePath = SliceCaster::asTerminatedCharSlice(modulePath); + options.modulePath = SliceUtil::asTerminatedCharSlice(modulePath); ComPtr<IArtifact> artifact; if (SLANG_FAILED(compiler->compile(options, artifact.writeRef()))) @@ -2353,11 +2360,16 @@ static TestResult runCPPCompilerExecute(TestContext* context, TestInput& input) options.sourceLanguage = (ext == "c") ? SLANG_SOURCE_LANGUAGE_C : SLANG_SOURCE_LANGUAGE_CPP; - TerminatedCharSlice filePaths[] = { SliceCaster::asTerminatedCharSlice(filePath) }; + TerminatedCharSlice filePaths[] = { SliceUtil::asTerminatedCharSlice(filePath) }; + + auto helper = DefaultArtifactHelper::getSingleton(); + + ComPtr<IArtifact> sourceArtifact; + helper->createFileArtifact(ArtifactDescUtil::makeDescForSourceLanguage(options.sourceLanguage), asCharSlice(filePath.getUnownedSlice()), sourceArtifact.writeRef()); // Compile this source - options.sourceFiles = makeSlice(filePaths, 1); - options.modulePath = SliceCaster::asTerminatedCharSlice(modulePath); + options.sourceArtifacts = makeSlice(sourceArtifact.readRef(), 1); + options.modulePath = SliceUtil::asTerminatedCharSlice(modulePath); ComPtr<IArtifact> artifact; if (SLANG_FAILED(compiler->compile(options, artifact.writeRef()))) |
