diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-08-24 14:42:55 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 11:42:55 -0700 |
| commit | 3746a47ce407b14c4afbfc5b625513cf81b5e890 (patch) | |
| tree | 2b925a4229b7c6bd093e1720d8e0b3447b9acdcb /source/compiler-core/slang-artifact-handler-impl.cpp | |
| parent | 14d99e80c47a0daac6ef76b5d68511c828147265 (diff) | |
Improvements around file tracking and Artifacts (#2379)
Diffstat (limited to 'source/compiler-core/slang-artifact-handler-impl.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-handler-impl.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/source/compiler-core/slang-artifact-handler-impl.cpp b/source/compiler-core/slang-artifact-handler-impl.cpp index b9dfb29b1..c8e7bf247 100644 --- a/source/compiler-core/slang-artifact-handler-impl.cpp +++ b/source/compiler-core/slang-artifact-handler-impl.cpp @@ -145,7 +145,7 @@ SlangResult DefaultArtifactHandler::getOrCreateRepresentation(IArtifact* artifac if (guid == ISlangSharedLibrary::getTypeGuid()) { ComPtr<ISlangSharedLibrary> sharedLib; - SLANG_RETURN_ON_FAIL(_loadSharedLibrary(artifact, keep, sharedLib.writeRef())); + SLANG_RETURN_ON_FAIL(_loadSharedLibrary(artifact, sharedLib.writeRef())); return _addRepresentation(artifact, keep, sharedLib, outCastable); } @@ -223,7 +223,7 @@ SlangResult DefaultArtifactHandler::getOrCreateFileRepresentation(IArtifact* art return SLANG_OK; } -SlangResult DefaultArtifactHandler::_loadSharedLibrary(IArtifact* artifact, ArtifactKeep keep, ISlangSharedLibrary** outSharedLibrary) +SlangResult DefaultArtifactHandler::_loadSharedLibrary(IArtifact* artifact, ISlangSharedLibrary** outSharedLibrary) { // If it is 'shared library' for a CPU like thing, we can try and load it const auto desc = artifact->getDesc(); @@ -233,7 +233,10 @@ SlangResult DefaultArtifactHandler::_loadSharedLibrary(IArtifact* artifact, Arti { // Get as a file represenation on the OS file system ComPtr<IFileArtifactRepresentation> fileRep; - SLANG_RETURN_ON_FAIL(artifact->requireFile(ArtifactKeep::No, nullptr, fileRep.writeRef())); + + // We want to keep the file representation, otherwise every request, could produce a new file + // and that seems like a bad idea. + SLANG_RETURN_ON_FAIL(artifact->requireFile(ArtifactKeep::Yes, nullptr, fileRep.writeRef())); // We requested on the OS file system, just check that's what we got... SLANG_ASSERT(fileRep->getFileSystem() == nullptr); @@ -244,22 +247,8 @@ SlangResult DefaultArtifactHandler::_loadSharedLibrary(IArtifact* artifact, Arti { return SLANG_FAIL; } - - // The ScopeSharedLibrary will keep the fileRep in scope as long as is needed - auto sharedLibrary = new ScopeSharedLibrary(handle, fileRep); - - if (canKeep(keep)) - { - // We want to keep the fileRep, as that is necessary for the sharedLibrary to even work - artifact->addRepresentation(fileRep); - // Keep the shared library - artifact->addRepresentation(sharedLibrary); - } - // Output - sharedLibrary->addRef(); - *outSharedLibrary = sharedLibrary; - + *outSharedLibrary = ScopeSharedLibrary::create(handle, fileRep).detach(); return SLANG_OK; } |
