mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-10 15:45:37 +00:00
Fixed cyclical included check
This commit is contained in:
parent
aa51d6de2a
commit
68d0698924
@ -74,11 +74,12 @@ namespace Shader
|
|||||||
|
|
||||||
// Recursively replaces include statements with the actual source of the included files.
|
// Recursively replaces include statements with the actual source of the included files.
|
||||||
// Adjusts #line statements accordingly and detects cyclic includes.
|
// Adjusts #line statements accordingly and detects cyclic includes.
|
||||||
// includingFiles is the set of files that include this file directly or indirectly, and is intentionally not a reference to allow automatic cleanup.
|
// cycleIncludeChecker is the set of files that include this file directly or indirectly, and is intentionally not a reference to allow automatic cleanup.
|
||||||
static bool parseIncludes(const std::filesystem::path& shaderPath, std::string& source, const std::string& fileName, int& fileNumber, std::set<std::filesystem::path>& includingFiles)
|
static bool parseIncludes(const std::filesystem::path& shaderPath, std::string& source, const std::string& fileName, int& fileNumber, std::set<std::filesystem::path> cycleIncludeChecker,std::set<std::filesystem::path>& includedFiles)
|
||||||
{
|
{
|
||||||
|
includedFiles.insert(shaderPath / fileName);
|
||||||
// An include is cyclic if it is being included by itself
|
// An include is cyclic if it is being included by itself
|
||||||
if (includingFiles.insert(shaderPath/fileName).second == false)
|
if (cycleIncludeChecker.insert(shaderPath/fileName).second == false)
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "Shader " << fileName << " error: Detected cyclic #includes";
|
Log(Debug::Error) << "Shader " << fileName << " error: Detected cyclic #includes";
|
||||||
return false;
|
return false;
|
||||||
@ -135,7 +136,7 @@ namespace Shader
|
|||||||
buffer << includeFstream.rdbuf();
|
buffer << includeFstream.rdbuf();
|
||||||
std::string stringRepresentation = buffer.str();
|
std::string stringRepresentation = buffer.str();
|
||||||
if (!addLineDirectivesAfterConditionalBlocks(stringRepresentation)
|
if (!addLineDirectivesAfterConditionalBlocks(stringRepresentation)
|
||||||
|| !parseIncludes(shaderPath, stringRepresentation, includeFilename, fileNumber, includingFiles))
|
|| !parseIncludes(shaderPath, stringRepresentation, includeFilename, fileNumber, cycleIncludeChecker, includedFiles))
|
||||||
{
|
{
|
||||||
Log(Debug::Error) << "In file included from " << fileName << "." << lineNumber;
|
Log(Debug::Error) << "In file included from " << fileName << "." << lineNumber;
|
||||||
return false;
|
return false;
|
||||||
@ -431,7 +432,7 @@ namespace Shader
|
|||||||
int fileNumber = 1;
|
int fileNumber = 1;
|
||||||
std::string source = buffer.str();
|
std::string source = buffer.str();
|
||||||
if (!addLineDirectivesAfterConditionalBlocks(source)
|
if (!addLineDirectivesAfterConditionalBlocks(source)
|
||||||
|| !parseIncludes(std::filesystem::path(Manager.mPath), source, templateName, fileNumber, insertedPaths))
|
|| !parseIncludes(std::filesystem::path(Manager.mPath), source, templateName, fileNumber, {}, insertedPaths))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -478,7 +479,7 @@ namespace Shader
|
|||||||
int fileNumber = 1;
|
int fileNumber = 1;
|
||||||
std::string source = buffer.str();
|
std::string source = buffer.str();
|
||||||
if (!addLineDirectivesAfterConditionalBlocks(source)
|
if (!addLineDirectivesAfterConditionalBlocks(source)
|
||||||
|| !parseIncludes(std::filesystem::path(mPath), source, templateName, fileNumber, insertedPaths))
|
|| !parseIncludes(std::filesystem::path(mPath), source, templateName, fileNumber, {}, insertedPaths))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
templateIt = mShaderTemplates.insert(std::make_pair(templateName, source)).first;
|
templateIt = mShaderTemplates.insert(std::make_pair(templateName, source)).first;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user