summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-compiler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-compiler.cpp')
-rw-r--r--source/slang/slang-compiler.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index ce380681e..06cc9d759 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -578,6 +578,22 @@ namespace Slang
}
}
+ SlangResult CodeGenContext::requireTranslationUnitSourceFiles()
+ {
+ if (auto endToEndReq = isPassThroughEnabled())
+ {
+ for (auto entryPointIndex : getEntryPointIndices())
+ {
+ auto translationUnit = getPassThroughTranslationUnit(endToEndReq, entryPointIndex);
+ SLANG_ASSERT(translationUnit);
+ /// Make sure we have the source files
+ SLANG_RETURN_ON_FAIL(translationUnit->requireSourceFiles());
+ }
+ }
+
+ return SLANG_OK;
+ }
+
#if SLANG_VC
// TODO(JS): This is a workaround
// In debug VS builds there is a warning on line about it being unreachable.
@@ -587,9 +603,11 @@ namespace Slang
# pragma warning(disable:4702)
#endif
SlangResult CodeGenContext::emitEntryPointsSource(ComPtr<IArtifact>& outArtifact)
- {
+ {
outArtifact.setNull();
+ SLANG_RETURN_ON_FAIL(requireTranslationUnitSourceFiles());
+
auto endToEndReq = isPassThroughEnabled();
if(endToEndReq)
{
@@ -597,6 +615,10 @@ namespace Slang
{
auto translationUnit = getPassThroughTranslationUnit(endToEndReq, entryPointIndex);
SLANG_ASSERT(translationUnit);
+
+ /// Make sure we have the source files
+ SLANG_RETURN_ON_FAIL(translationUnit->requireSourceFiles());
+
// Generate a string that includes the content of
// the source file(s), along with a line directive
// to ensure that we get reasonable messages
@@ -835,23 +857,7 @@ namespace Slang
if (compiler->isFileBased())
{
// It can only have *one* source file as otherwise we have to combine to make a new source file anyway
- const auto& sourceFiles = translationUnit->getSourceFiles();
-
- // The *assumption* here is that if it's file based that assuming it can find the file with the same contents
- // it can compile directly without having to save off as a file
- if (sourceFiles.getCount() == 1)
- {
- const SourceFile* sourceFile = sourceFiles[0];
- // We need the path to be found and set
- //
- // NOTE! That the downstream compiler can determine if the path and contents match such that it can be used
- // without writing file
- const PathInfo& pathInfo = sourceFile->getPathInfo();
- if ((pathInfo.type == PathInfo::Type::FoundPath || pathInfo.type == PathInfo::Type::Normal) && pathInfo.foundPath.getLength())
- {
- return false;
- }
- }
+ return translationUnit->getSourceArtifacts().getCount() != 1;
}
return true;
}
@@ -1066,12 +1072,10 @@ namespace Slang
else
{
// Special case if we have a single file, so that we pass the path, and the contents as is.
- const auto& sourceFiles = translationUnit->getSourceFiles();
- SLANG_ASSERT(sourceFiles.getCount() == 1);
-
- SourceFile* sourceFile = sourceFiles[0];
+ const auto& sourceArtifacts = translationUnit->getSourceArtifacts();
+ SLANG_ASSERT(sourceArtifacts.getCount() == 1);
- sourceArtifact = sourceFile->getArtifact();
+ sourceArtifact = sourceArtifacts[0];
SLANG_ASSERT(sourceArtifact);
}
}