diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-04-27 17:53:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 17:53:21 -0400 |
| commit | 634f5414f332f904c7db968810b3d6f0ca253959 (patch) | |
| tree | c5747ca337e21ce74cc5997722b19a94604fe4aa /source/compiler-core/slang-artifact-info.cpp | |
| parent | ec530b300524635dfe0fd86949b0a4fc5c19a984 (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/compiler-core/slang-artifact-info.cpp')
| -rw-r--r-- | source/compiler-core/slang-artifact-info.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/source/compiler-core/slang-artifact-info.cpp b/source/compiler-core/slang-artifact-info.cpp index 6aaf1552c..1b9209516 100644 --- a/source/compiler-core/slang-artifact-info.cpp +++ b/source/compiler-core/slang-artifact-info.cpp @@ -66,6 +66,8 @@ static ArtifactPayloadInfo::Lookup _makePayloadInfoLookup() {Payload::DebugInfo, Flavor::Unknown, 0}, + {Payload::Diagnostics, Flavor::Unknown, 0}, + {Payload::Zip, Flavor::Container, 0}, }; @@ -245,4 +247,68 @@ UnownedStringSlice ArtifactInfoUtil::getDefaultExtension(const ArtifactDesc& des } } +/* static */String ArtifactInfoUtil::getBaseNameFromPath(const ArtifactDesc& desc, const UnownedStringSlice& path) +{ + String name = Path::getFileName(path); + + const bool isSharedLibraryPrefixPlatform = SLANG_LINUX_FAMILY || SLANG_APPLE_FAMILY; + if (isSharedLibraryPrefixPlatform) + { + // Strip lib prefix + if (ArtifactInfoUtil::isCpuBinary(desc) && + (desc.kind == ArtifactKind::Library || + desc.kind == ArtifactKind::SharedLibrary)) + { + // If it starts with lib strip it + if (name.startsWith("lib")) + { + const String stripLib = name.getUnownedSlice().tail(3); + name = stripLib; + } + } + } + + // Strip any extension + { + auto descExt = ArtifactInfoUtil::getDefaultExtension(desc); + // Strip the extension if it's a match + if (descExt.getLength() && + Path::getPathExt(name) == descExt) + { + name = Path::getFileNameWithoutExt(name); + } + } + + return name; +} + +/* static */String ArtifactInfoUtil::getBaseName(IArtifact* artifact) +{ + const auto pathType = artifact->getPathType(); + + // If we have a path, get the base name from that + if (pathType != ArtifactPathType::None) + { + UnownedStringSlice path(artifact->getPath()); + const auto desc = artifact->getDesc(); + + return getBaseNameFromPath(desc, path); + } + + // Else use the name + return artifact->getName(); +} + +/* static */String ArtifactInfoUtil::getParentPath(IArtifact* artifact) +{ + const auto pathType = artifact->getPathType(); + const auto path = artifact->getPath(); + + if (pathType != ArtifactPathType::None && *path != 0) + { + return Path::getParentDirectory(path); + } + return String(); +} + } // namespace Slang |
