summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-gcc-compiler-util.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-09-01 10:06:19 -0400
committerGitHub <noreply@github.com>2022-09-01 10:06:19 -0400
commit3c0177134d126956336865623ea3d6861be59cfa (patch)
tree920ba158afe75edde6f5254617dfa22ffeb98403 /source/compiler-core/slang-gcc-compiler-util.cpp
parentcd8715a7760189c54b36c0c250efbe1db5b8635c (diff)
Make FileSystem files and OS files distinct (#2383)
* #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. * * Infer extension if can't determine from the artifact type * Split IOSFile/IExtFile representations * Move responsibility for creating OS file to the handler. * Disable the check memory path.
Diffstat (limited to 'source/compiler-core/slang-gcc-compiler-util.cpp')
-rw-r--r--source/compiler-core/slang-gcc-compiler-util.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp
index 8851477d7..f003ffb0f 100644
--- a/source/compiler-core/slang-gcc-compiler-util.cpp
+++ b/source/compiler-core/slang-gcc-compiler-util.cpp
@@ -432,7 +432,7 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS
return SLANG_OK;
}
-/* static */SlangResult GCCDownstreamCompilerUtil::calcCompileProducts(const CompileOptions& options, ProductFlags flags, IFileArtifactRepresentation* lockFile, List<ComPtr<IArtifact>>& outArtifacts)
+/* static */SlangResult GCCDownstreamCompilerUtil::calcCompileProducts(const CompileOptions& options, ProductFlags flags, IOSFileArtifactRepresentation* lockFile, List<ComPtr<IArtifact>>& outArtifacts)
{
SLANG_ASSERT(options.modulePath.count);
@@ -444,7 +444,7 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS
const auto desc = ArtifactDescUtil::makeDescForCompileTarget(options.targetType);
SLANG_RETURN_ON_FAIL(ArtifactDescUtil::calcPathForDesc(desc, asStringSlice(options.modulePath), builder));
- auto fileRep = FileArtifactRepresentation::create(IFileArtifactRepresentation::Kind::Owned, builder.getUnownedSlice(), lockFile, nullptr);
+ auto fileRep = OSFileArtifactRepresentation::create(IOSFileArtifactRepresentation::Kind::Owned, builder.getUnownedSlice(), lockFile);
auto artifact = ArtifactUtil::createArtifact(desc);
artifact->addRepresentation(fileRep);
@@ -615,11 +615,11 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS
// Files to compile, need to be on the file system.
for (IArtifact* sourceArtifact : options.sourceArtifacts)
{
- ComPtr<IFileArtifactRepresentation> fileRep;
+ ComPtr<IOSFileArtifactRepresentation> fileRep;
// TODO(JS):
// Do we want to keep the file on the file system? It's probably reasonable to do so.
- SLANG_RETURN_ON_FAIL(sourceArtifact->requireFile(ArtifactKeep::Yes, nullptr, fileRep.writeRef()));
+ SLANG_RETURN_ON_FAIL(sourceArtifact->requireFile(ArtifactKeep::Yes, fileRep.writeRef()));
cmdLine.addArg(fileRep->getPath());
}
@@ -644,13 +644,15 @@ static SlangResult _parseGCCFamilyLine(SliceAllocator& allocator, const UnownedS
// If it's a library for CPU types, try and use it
if (ArtifactDescUtil::isCpuBinary(artifactDesc) && artifactDesc.kind == ArtifactKind::Library)
{
- ComPtr<IFileArtifactRepresentation> fileRep;
+ ComPtr<IOSFileArtifactRepresentation> fileRep;
// Get the name and path (can be empty) to the library
- SLANG_RETURN_ON_FAIL(artifact->requireFile(ArtifactKeep::Yes, nullptr, fileRep.writeRef()));
+ SLANG_RETURN_ON_FAIL(artifact->requireFile(ArtifactKeep::Yes, fileRep.writeRef()));
- libPathPool.add(ArtifactUtil::getParentPath(fileRep));
- cmdLine.addPrefixPathArg("-l", ArtifactDescUtil::getBaseName(artifact->getDesc(), fileRep));
+ const UnownedStringSlice path(fileRep->getPath());
+ libPathPool.add(Path::getParentDirectory(path));
+
+ cmdLine.addPrefixPathArg("-l", ArtifactDescUtil::getBaseNameFromPath(artifact->getDesc(), path));
}
}