From cd8715a7760189c54b36c0c250efbe1db5b8635c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 1 Sep 2022 09:35:18 -0400 Subject: 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. --- tools/slang-test/slang-test-main.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'tools') 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 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 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 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 artifact; if (SLANG_FAILED(compiler->compile(options, artifact.writeRef()))) -- cgit v1.2.3