Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderAssetBuilder.cpp
static void GetListOfIncludedFiles(AZStd::string_view sourceFilePath, const AZStd::vector<AZStd::string>& includeDirectories,
            const ShaderBuilderUtility::IncludedFilesParser& includedFilesParser, AZStd::unordered_set<AZStd::string>& includedFiles)
        {
            auto outcome = includedFilesParser.ParseFileAndGetIncludedFiles(sourceFilePath);
            if (!outcome.IsSuccess())
            {
                AZ_Warning(ShaderAssetBuilderName, false, outcome.GetError().c_str());
                return;
            }

            // Cache the path of the folder where @sourceFilePath is located.
            AZStd::string sourceFileFolderPath;
            {
                AZStd::string drive;
                AzFramework::StringFunc::Path::Split(sourceFilePath.data(), &drive, &sourceFileFolderPath);
                if (!drive.empty())
                {
                    AzFramework::StringFunc::Path::Join(drive.c_str(), sourceFileFolderPath.c_str(), sourceFileFolderPath);
                }
            }

            auto listOfRelativePaths = outcome.TakeValue();
            for (auto relativePath : listOfRelativePaths)
            {
                auto fullPath = DiscoverFullPath(relativePath, sourceFileFolderPath, includeDirectories);
                if (fullPath.empty())
                {
                    // The file doesn't exist in any of the includeDirectories. It doesn't exist in @sourceFileFolderPath either.
                    // The file may appear in the future in one of those directories, We must build an exhaustive list
                    // of full file paths where the file may appear in the future.
                    AppendListOfPossibleFutureLocations(includedFiles, relativePath, sourceFileFolderPath, includeDirectories);
                    continue;
                }

                // Add the file to the list and keep parsing recursively.
                if (includedFiles.count(fullPath))
                {
                    continue;
                }
                includedFiles.insert(fullPath);
                GetListOfIncludedFiles(fullPath, includeDirectories, includedFilesParser, includedFiles);
            }
        }
//! Parses, using depth-first recursive approach, azsl files. Looks for '#include <foo/bar/blah.h>' or '#include "foo/bar/blah.h"' lines
//! and in turn parses the included files.
//! The included files are searched in the directories listed in @includeDirectories. Basically it's a similar approach
//! as how most C-preprocessors would find included files.
Parses, using depth-first recursive approach, azsl files. Looks for '#include ' or '#include "foo/bar/blah.h"' lines
and in turn parses the included files.
The included files are searched in the directories listed in @includeDirectories. Basically it's a similar approach
as how most C-preprocessors would find included files.
Parses using depth - first recursive approach azsl files . Looks for ' #include ' or ' #include " foo / bar / blah . h " ' lines and in turn parses the included files . The included files are searched in the directories listed in @includeDirectories . Basically it ' s a similar approach as how most C - preprocessors would find included files .
static void GetListOfIncludedFiles(AZStd::string_view sourceFilePath, const AZStd::vector<AZStd::string>& includeDirectories,
            const ShaderBuilderUtility::IncludedFilesParser& includedFilesParser, AZStd::unordered_set<AZStd::string>& includedFiles)
        {
            auto outcome = includedFilesParser.ParseFileAndGetIncludedFiles(sourceFilePath);
            if (!outcome.IsSuccess())
            {
                AZ_Warning(ShaderAssetBuilderName, false, outcome.GetError().c_str());
                return;
            }
            AZStd::string sourceFileFolderPath;
            {
                AZStd::string drive;
                AzFramework::StringFunc::Path::Split(sourceFilePath.data(), &drive, &sourceFileFolderPath);
                if (!drive.empty())
                {
                    AzFramework::StringFunc::Path::Join(drive.c_str(), sourceFileFolderPath.c_str(), sourceFileFolderPath);
                }
            }
            auto listOfRelativePaths = outcome.TakeValue();
            for (auto relativePath : listOfRelativePaths)
            {
                auto fullPath = DiscoverFullPath(relativePath, sourceFileFolderPath, includeDirectories);
                if (fullPath.empty())
                {
                    AppendListOfPossibleFutureLocations(includedFiles, relativePath, sourceFileFolderPath, includeDirectories);
                    continue;
                }
                if (includedFiles.count(fullPath))
                {
                    continue;
                }
                includedFiles.insert(fullPath);
                GetListOfIncludedFiles(fullPath, includeDirectories, includedFilesParser, includedFiles);
            }
        }
static void GetListOfIncludedFiles ( AZStd :: string_view sourceFilePath , const AZStd :: vector < AZStd :: string > & includeDirectories , const ShaderBuilderUtility :: IncludedFilesParser & includedFilesParser , AZStd :: unordered_set < AZStd :: string > & includedFiles ) { auto outcome = includedFilesParser . ParseFileAndGetIncludedFiles ( sourceFilePath ) ; if ( ! outcome . IsSuccess ( ) ) { AZ_Warning ( ShaderAssetBuilderName , false , outcome . GetError ( ) . c_str ( ) ) ; return ; } AZStd :: string sourceFileFolderPath ; { AZStd :: string drive ; AzFramework :: StringFunc :: Path :: Split ( sourceFilePath . data ( ) , & drive , & sourceFileFolderPath ) ; if ( ! drive . empty ( ) ) { AzFramework :: StringFunc :: Path :: Join ( drive . c_str ( ) , sourceFileFolderPath . c_str ( ) , sourceFileFolderPath ) ; } } auto listOfRelativePaths = outcome . TakeValue ( ) ; for ( auto relativePath : listOfRelativePaths ) { auto fullPath = DiscoverFullPath ( relativePath , sourceFileFolderPath , includeDirectories ) ; if ( fullPath . empty ( ) ) { AppendListOfPossibleFutureLocations ( includedFiles , relativePath , sourceFileFolderPath , includeDirectories ) ; continue ; } if ( includedFiles . count ( fullPath ) ) { continue ; } includedFiles . insert ( fullPath ) ; GetListOfIncludedFiles ( fullPath , includeDirectories , includedFilesParser , includedFiles ) ; } }
Parses, using depth-first recursive approach, azsl files.
Parses using depth - first recursive approach azsl files .
// Cache the path of the folder where @sourceFilePath is located. // The file doesn't exist in any of the includeDirectories. It doesn't exist in @sourceFileFolderPath either. // The file may appear in the future in one of those directories, We must build an exhaustive list // of full file paths where the file may appear in the future. // Add the file to the list and keep parsing recursively.