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. --- source/compiler-core/slang-gcc-compiler-util.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source/compiler-core/slang-gcc-compiler-util.cpp') diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp index 7bbde64c4..8851477d7 100644 --- a/source/compiler-core/slang-gcc-compiler-util.cpp +++ b/source/compiler-core/slang-gcc-compiler-util.cpp @@ -356,7 +356,7 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS SliceAllocator allocator; diagnostics->reset(); - diagnostics->setRaw(SliceCaster::asCharSlice(exeRes.standardError)); + diagnostics->setRaw(SliceUtil::asCharSlice(exeRes.standardError)); // We hold in workDiagnostics so as it is more convenient to append to the last with a continuation // also means we don't hold the allocations of building up continuations, just the results when finally allocated at the end @@ -456,7 +456,6 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS /* static */SlangResult GCCDownstreamCompilerUtil::calcArgs(const CompileOptions& options, CommandLine& cmdLine) { - SLANG_ASSERT(options.sourceContents.count == 0); SLANG_ASSERT(options.modulePath.count); PlatformKind platformKind = (options.platform == PlatformKind::Unknown) ? PlatformUtil::getPlatformKind() : options.platform; @@ -613,10 +612,15 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS } } - // Files to compile - for (const auto& sourceFile : options.sourceFiles) + // Files to compile, need to be on the file system. + for (IArtifact* sourceArtifact : options.sourceArtifacts) { - cmdLine.addArg(asString(sourceFile)); + ComPtr fileRep; + + // TODO(JS): + // Do we want to keep the file on the file system? It's probably reasonable to do so. + SLANG_RETURN_ON_FAIL(sourceArtifact->requireFile(ArtifactKeep::Yes, nullptr, fileRep.writeRef())); + cmdLine.addArg(fileRep->getPath()); } // Add the library paths -- cgit v1.2.3