summaryrefslogtreecommitdiff
path: root/source/slang/slang-module-library.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-04-27 17:53:21 -0400
committerGitHub <noreply@github.com>2022-04-27 17:53:21 -0400
commit634f5414f332f904c7db968810b3d6f0ca253959 (patch)
treec5747ca337e21ce74cc5997722b19a94604fe4aa /source/slang/slang-module-library.cpp
parentec530b300524635dfe0fd86949b0a4fc5c19a984 (diff)
Make artifact an interface (#2195)
* #include an absolute path didn't work - because paths were taken to always be relative. * Compile to a dxil library. * Added CompileProduct. * Support handling of ModuleLibrary. * CacheBehavior -> Cache * Use CompileProduct for -r references. * CompileProduct -> Artifact. * Determining an artifact type on binding. * Determine binary linkability. * Added Artifact::exists. * Added ArtifactKeep. * Small fixes. * Small improvements to Artifact. * Add zip extension. * Fix some comments. * Fix multiple adding of PublicDecoration. Make public output export for DXIL/lib. Add checking for simpleDecorations such that only added once. * Use 'whole program' to identify library build. * Move slang-artifact into compiler-core. * Split out Keep free functions. * Artifact::Keep -> ArtifactKeep. * Handle libraries as artifacts. * Add -target dxil so test infrastructure knows it needs DXC. * Linking working in DXC. * Improve handling around emit for 'export'. * Add comment around Artifact name. * Render test working with linking. * Improvements around Artifact handling. * Add ArtifactPayloadInfo. * Small tidy up around artifact. * Split out code to get info about Artifacts into artifact-info.cpp/.h * IArtifact interface and IArtifactInstance interface. * Fix small issues. * Fix compilation warning issue. * Fix missing SLANG_OVERRIDE. * Small fixes to make compilation work on Visual Studio 2022. * Small improvements to Artifact interface/naming. * Added Desc with each element in IArchive to allow more flexibility in usage. * Fix clang warning issue. * Add ArtifactPayload::Diagnostics * More discussion around IArtifact usage. * Re-add slang-artifact.h which was removed during merge. * Fix typo identified in review.
Diffstat (limited to 'source/slang/slang-module-library.cpp')
-rw-r--r--source/slang/slang-module-library.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/source/slang/slang-module-library.cpp b/source/slang/slang-module-library.cpp
index 76bb85ebb..140be4d64 100644
--- a/source/slang/slang-module-library.cpp
+++ b/source/slang/slang-module-library.cpp
@@ -13,6 +13,14 @@
namespace Slang {
+void* ModuleLibrary::getInterface(const Guid& uuid)
+{
+ if (uuid == ISlangUnknown::getTypeGuid() || uuid == IArtifactInstance::getTypeGuid())
+ {
+ return static_cast<IArtifactInstance*>(this);
+ }
+ return nullptr;
+}
SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary)
{
@@ -67,9 +75,9 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCo
return SLANG_OK;
}
-SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* product, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary)
+SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary)
{
- if (auto foundLibrary = product->findObjectInstance<ModuleLibrary>())
+ if (auto foundLibrary = (ModuleLibrary*)artifact->findElementObject(ModuleLibrary::getTypeGuid()))
{
outLibrary = foundLibrary;
return SLANG_OK;
@@ -77,7 +85,7 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* product, EndToEndComp
// Load the blob
ComPtr<ISlangBlob> blob;
- SLANG_RETURN_ON_FAIL(product->loadBlob(getIntermediateKeep(keep), blob));
+ SLANG_RETURN_ON_FAIL(artifact->loadBlob(getIntermediateKeep(keep), blob.writeRef()));
// Load the module
RefPtr<ModuleLibrary> library;
@@ -85,7 +93,7 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* product, EndToEndComp
if (canKeep(keep))
{
- product->add(Artifact::Entry::Style::Artifact, library);
+ artifact->addElement(artifact->getDesc(), library);
}
outLibrary = library;