summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-artifact-helper.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-09-01 09:35:18 -0400
committerGitHub <noreply@github.com>2022-09-01 09:35:18 -0400
commitcd8715a7760189c54b36c0c250efbe1db5b8635c (patch)
treecd1b2e840e64cbdd9e9a383646f0e58a7f14ae97 /source/compiler-core/slang-artifact-helper.cpp
parent5c2c2cfc9918bb43225159e67a851e196e17759a (diff)
Passing source to Downstream compilation as artifacts (#2382)
* #include an absolute path didn't work - because paths were taken to always be relative. * Make DownstreamCompileOptions use POD types. * CharSliceAllocator -> SliceAllocator Added SliceConverter CharSliceCaster -> SliceCaster * First attempt at zero terminating around blobs. * Fix clang warning. * Add SlangTerminatedChars Make Blob implementations support it. Make most blobs 'terminated'. * Fix bug setting up sourceFiles for CommandLineDownstreamCompiler. * Traffic in TerminatedCharSlice for sourceFiles. Use ArtifactDesc to generate temporary file names for source. * Fix typo in testing for shared library/C++. * Working with source being passed as artifacts to DownstreamCompiler. * Use artifacts in SourceManager/SourceFile. * Support infering extension from the original file extension.
Diffstat (limited to 'source/compiler-core/slang-artifact-helper.cpp')
-rw-r--r--source/compiler-core/slang-artifact-helper.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/source/compiler-core/slang-artifact-helper.cpp b/source/compiler-core/slang-artifact-helper.cpp
index d24d08909..27965b0cc 100644
--- a/source/compiler-core/slang-artifact-helper.cpp
+++ b/source/compiler-core/slang-artifact-helper.cpp
@@ -7,6 +7,8 @@
#include "slang-artifact-desc-util.h"
#include "slang-artifact-util.h"
+#include "../compiler-core/slang-slice-allocator.h"
+
#include "../core/slang-castable-list-impl.h"
#include "../core/slang-castable-util.h"
@@ -108,12 +110,21 @@ SlangResult DefaultArtifactHelper::createLockFile(const char* inNameBase, ISlang
return SLANG_OK;
}
-SlangResult DefaultArtifactHelper::calcArtifactPath(const ArtifactDesc& desc, const char* inBasePath, ISlangBlob** outPath)
+SlangResult DefaultArtifactHelper::calcArtifactDescPath(const ArtifactDesc& desc, const char* inBasePath, ISlangBlob** outPath)
{
UnownedStringSlice basePath(inBasePath);
StringBuilder path;
SLANG_RETURN_ON_FAIL(ArtifactDescUtil::calcPathForDesc(desc, basePath, path));
- *outPath = StringBlob::create(path).detach();
+ *outPath = StringBlob::moveCreate(path).detach();
+ return SLANG_OK;
+}
+
+SlangResult DefaultArtifactHelper::calcArtifactPath(IArtifact* artifact, const char* inBasePath, ISlangBlob** outPath)
+{
+ UnownedStringSlice basePath(inBasePath);
+ StringBuilder path;
+ SLANG_RETURN_ON_FAIL(ArtifactUtil::calcPath(artifact, basePath, path));
+ *outPath = StringBlob::moveCreate(path).detach();
return SLANG_OK;
}
@@ -140,4 +151,24 @@ SlangResult DefaultArtifactHelper::createCastableList(const Guid& guid, ICastabl
return SLANG_E_NO_INTERFACE;
}
+SlangResult DefaultArtifactHelper::createFileArtifactRepresentation(
+ IFileArtifactRepresentation::Kind kind, const CharSlice& path, IFileArtifactRepresentation* lockFile, ISlangMutableFileSystem* fileSystem, IFileArtifactRepresentation** outRep)
+{
+ *outRep = FileArtifactRepresentation::create(kind, asStringSlice(path), lockFile, fileSystem).detach();
+ return SLANG_OK;
+}
+
+
+SlangResult DefaultArtifactHelper::createFileArtifact(const ArtifactDesc& desc, const CharSlice& path, IArtifact** outArtifact)
+{
+ auto artifact = Artifact::create(desc);
+
+ auto fileRep = new FileArtifactRepresentation(IFileArtifactRepresentation::Kind::Reference, asStringSlice(path), nullptr, nullptr);
+
+ artifact->addRepresentation(fileRep);
+
+ *outArtifact = artifact.detach();
+ return SLANG_OK;
+}
+
} // namespace Slang