summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-visual-studio-compiler-util.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-24 09:25:51 -0400
committerGitHub <noreply@github.com>2022-08-24 09:25:51 -0400
commitf5755019246504ad4da4614d1e34a00d74970ea7 (patch)
tree8a0228427bd493681cffa2a94052c61dbc497a5d /source/compiler-core/slang-visual-studio-compiler-util.cpp
parent6ab0baf910dea838dca2d29557c3361297180a34 (diff)
Assorted Artifact improvements (#2374)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP replacing DownstreamCompileResult. * First attempt at replacing DownstreamCompileResult with IArtifact and associated types. * Small renaming around CharSlice. * ICastable -> ISlangCastable Added IClonable Fix issue with cloning in ArtifactDiagnostics. * Only add the blob if one is defined in DXC. * Guard adding blob representation. * Make cloneInterface available across code base. Set enums backing type for ArtifactDiagnostic. * Added ::create for ArtifactDiagnostics. * Use SemanticVersion for DownstreamCompilerDesc. Set sizes for enum types. * Depreciate old incompatible CompileOptions. Change SemanticVersion use 32 bits for the patch. * Split out CastableUtil. * Change IDownstreamCompiler to use canConvert and convert to use artifact types. * Fix typos. * Fix typo bug. Allow trafficing in PTX assembly/binaries * struct DownstreamCompilerBaseUtil -> struct DownstreamCompilerUtilBase * Add other riff types. * Small fix around artifact kind. * Make using slices instead of strings explicit on atomic ref counted types. (not complete). Added IArtifactList. Use IArtifactList to hold the 'associated' files. Use IUnknown for scoping for atomic ref counting. Small naming improvements. * Make artifact not use String in construction (so it owns contents). * Calculate compile products as artifacts. * Small improvements around ArtifactDesc. * Use ICastableList for list of artifacts and remove IArtifactList.
Diffstat (limited to 'source/compiler-core/slang-visual-studio-compiler-util.cpp')
-rw-r--r--source/compiler-core/slang-visual-studio-compiler-util.cpp53
1 files changed, 19 insertions, 34 deletions
diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp
index 4e703f58f..ff3f378d6 100644
--- a/source/compiler-core/slang-visual-studio-compiler-util.cpp
+++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp
@@ -16,69 +16,54 @@
#include "slang-artifact-desc-util.h"
#include "slang-artifact-diagnostic-util.h"
#include "slang-artifact-util.h"
+#include "slang-artifact-representation-impl.h"
namespace Slang
{
-/* static */ SlangResult VisualStudioCompilerUtil::calcModuleFilePath(const CompileOptions& options, StringBuilder& outPath)
+static void _addFile(const String& path, const ArtifactDesc& desc, IFileArtifactRepresentation* lockFile, List<ComPtr<IArtifact>>& outArtifacts)
{
- SLANG_ASSERT(options.modulePath.getLength());
-
- outPath.Clear();
+ auto fileRep = FileArtifactRepresentation::create(IFileArtifactRepresentation::Kind::Owned, path.getUnownedSlice(), lockFile, nullptr);
+ auto artifact = ArtifactUtil::createArtifact(desc);
+ artifact->addRepresentation(fileRep);
- switch (options.targetType)
- {
- case SLANG_SHADER_SHARED_LIBRARY:
- {
- outPath << options.modulePath << ".dll";
- return SLANG_OK;
- }
- case SLANG_HOST_EXECUTABLE:
- {
- outPath << options.modulePath << ".exe";
- return SLANG_OK;
- }
- case SLANG_OBJECT_CODE:
- {
- outPath << options.modulePath << ".obj";
- return SLANG_OK;
- }
- default: break;
- }
-
- return SLANG_FAIL;
+ outArtifacts.add(artifact);
}
-/* static */SlangResult VisualStudioCompilerUtil::calcCompileProducts(const CompileOptions& options, ProductFlags flags, List<String>& outPaths)
+/* static */SlangResult VisualStudioCompilerUtil::calcCompileProducts(const CompileOptions& options, ProductFlags flags, IFileArtifactRepresentation* lockFile, List<ComPtr<IArtifact>>& outArtifacts)
{
SLANG_ASSERT(options.modulePath.getLength());
- outPaths.clear();
+ const auto targetDesc = ArtifactDescUtil::makeDescForCompileTarget(options.targetType);
+
+ outArtifacts.clear();
if (flags & ProductFlag::Execution)
{
StringBuilder builder;
- SLANG_RETURN_ON_FAIL(calcModuleFilePath(options, builder));
- outPaths.add(builder);
+ const auto desc = ArtifactDescUtil::makeDescForCompileTarget(options.targetType);
+ SLANG_RETURN_ON_FAIL(ArtifactDescUtil::calcPathForDesc(desc, options.modulePath.getUnownedSlice(), builder));
+
+ _addFile(builder, desc, lockFile, outArtifacts);
}
if (flags & ProductFlag::Miscellaneous)
{
- outPaths.add(options.modulePath + ".ilk");
+ _addFile(options.modulePath + ".ilk", ArtifactDesc::make(ArtifactKind::BinaryFormat, ArtifactPayload::Unknown, ArtifactStyle::None), lockFile, outArtifacts);
if (options.targetType == SLANG_SHADER_SHARED_LIBRARY)
{
- outPaths.add(options.modulePath + ".exp");
- outPaths.add(options.modulePath + ".lib");
+ _addFile(options.modulePath + ".exp", ArtifactDesc::make(ArtifactKind::BinaryFormat, ArtifactPayload::Unknown, ArtifactStyle::None), lockFile, outArtifacts);
+ _addFile(options.modulePath + ".lib", ArtifactDesc::make(ArtifactKind::Library, ArtifactPayload::HostCPU, targetDesc), lockFile, outArtifacts);
}
}
if (flags & ProductFlag::Compile)
{
- outPaths.add(options.modulePath + ".obj");
+ _addFile(options.modulePath + ".obj", ArtifactDesc::make(ArtifactKind::ObjectCode, ArtifactPayload::HostCPU, targetDesc), lockFile, outArtifacts);
}
if (flags & ProductFlag::Debug)
{
// TODO(JS): Could try and determine based on debug information
- outPaths.add(options.modulePath + ".pdb");
+ _addFile(options.modulePath + ".pdb", ArtifactDesc::make(ArtifactKind::BinaryFormat, ArtifactPayload::DebugInfo, targetDesc), lockFile, outArtifacts);
}
return SLANG_OK;