diff options
Diffstat (limited to 'source/slang/slang-compiler.cpp')
| -rw-r--r-- | source/slang/slang-compiler.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 18c92ec1a..15a1ceb4b 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1051,14 +1051,16 @@ namespace Slang // If emitted source is required, emit and set the path if (_useEmittedSource(compiler, translationUnit)) { - // If it's not file based we can set an appropriate path name, and it doesn't matter if it doesn't - // exist on the file system - options.sourceContentsPath = allocator.allocate(calcSourcePathForEntryPoints()); - CodeGenContext sourceCodeGenContext(this, sourceTarget, extensionTracker); SLANG_RETURN_ON_FAIL(sourceCodeGenContext.emitEntryPointsSource(sourceArtifact)); + // If it's not file based we can set an appropriate path name, and it doesn't matter if it doesn't + // exist on the file system. + // We set the name to the path as this will be used for downstream reporting. + auto sourcePath = calcSourcePathForEntryPoints(); + sourceArtifact->setName(sourcePath.getBuffer()); + sourceCodeGenContext.maybeDumpIntermediate(sourceArtifact); } else @@ -1067,10 +1069,17 @@ namespace Slang const auto& sourceFiles = translationUnit->getSourceFiles(); SLANG_ASSERT(sourceFiles.getCount() == 1); - const SourceFile* sourceFile = sourceFiles[0]; - - options.sourceContentsPath = SliceCaster::asTerminatedCharSlice(sourceFile->getPathInfo().foundPath); - options.sourceContents = SliceConverter::toTerminatedCharSlice(allocator, sourceFile->getContentBlob()); + SourceFile* sourceFile = sourceFiles[0]; + + // Make it have an artifact if doesn't have one already + // This is useful because it will mean any reps will be kept in scope + // + // For example if file backing is needed, the file rep will last the lifetime of the + // SourceFile + sourceFile->maybeAddArtifact(nullptr); + + sourceArtifact = sourceFile->getArtifact(); + SLANG_ASSERT(sourceArtifact); } } else @@ -1087,11 +1096,9 @@ namespace Slang if (sourceArtifact) { metadata = findAssociated<IArtifactPostEmitMetadata>(sourceArtifact); - - ComPtr<ISlangBlob> blob; - SLANG_RETURN_ON_FAIL(sourceArtifact->loadBlob(ArtifactKeep::Yes, blob.writeRef())); - options.sourceContents = SliceConverter::toTerminatedCharSlice(allocator, blob); + // Set the source artifacts + options.sourceArtifacts = makeSlice(sourceArtifact.readRef(), 1); } // Add any preprocessor definitions associated with the linkage @@ -1368,8 +1375,8 @@ namespace Slang } options.compilerSpecificArguments = allocator.allocate(compilerSpecificArguments); - options.requiredCapabilityVersions = SliceCaster::asSlice(requiredCapabilityVersions); - options.libraries = SliceCaster::asSlice(libraries); + options.requiredCapabilityVersions = SliceUtil::asSlice(requiredCapabilityVersions); + options.libraries = SliceUtil::asSlice(libraries); options.libraryPaths = allocator.allocate(libraryPaths); // Compile |
