Gems/Atom/Asset/Shader/Code/Source/Editor/CommonFiles/Preprocessor.cpp
void InitializePreprocessorOptions(
            PreprocessorOptions& options, [[maybe_unused]] const char* builderName, const char* optionalIncludeFolder)
        {
            AZ_TraceContext("Init include-paths lookup options", "preprocessor");

            // get the scan folders of the projects:
            bool success = true;
            AZStd::vector<AZStd::string> scanFoldersVector;
            AzToolsFramework::AssetSystemRequestBus::BroadcastResult(success,
                &AzToolsFramework::AssetSystemRequestBus::Events::GetScanFolders,
                scanFoldersVector);
            AZ_Warning(builderName, success, "Preprocessor option: Could not acquire a list of scan folders from the database.");

            // Add the project path to list of include paths
            AZ::IO::FixedMaxPath projectPath = AZ::Utils::GetProjectPath();
            auto FindPath = [](AZ::IO::PathView searchPath)
            {
                return [searchPath](AZStd::string_view includePathView)
                {
                    return searchPath == AZ::IO::PathView(includePathView);
                };
            };
            if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(projectPath));
                it == options.m_projectIncludePaths.end())
            {
                options.m_projectIncludePaths.emplace_back(projectPath.c_str(), projectPath.Native().size());
            }
            if (optionalIncludeFolder)
            {
                if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(optionalIncludeFolder));
                    it == options.m_projectIncludePaths.end())
                {
                    if (AZ::IO::SystemFile::Exists(optionalIncludeFolder))
                    {
                        options.m_projectIncludePaths.emplace_back(AZStd::move(AZ::IO::Path(optionalIncludeFolder).LexicallyNormal().Native()));
                    }
                }
            }
            // but while we transfer to the set, we're going to keep only folders where +/ShaderLib exists
            for (AZ::IO::Path shaderScanFolder : scanFoldersVector)
            {
                shaderScanFolder /= "ShaderLib";
                if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(shaderScanFolder));
                    it == options.m_projectIncludePaths.end())
                {
                    // the folders constructed this fashion constitute the base of automatic include search paths
                    if (AZ::IO::SystemFile::Exists(shaderScanFolder.c_str()))
                    {
                        options.m_projectIncludePaths.emplace_back(AZStd::move(shaderScanFolder.LexicallyNormal().Native()));
                    }
                }
            }

            // finally the <engineroot>/Gems fallback
            AZ::IO::Path engineGemsFolder(AZStd::string_view{ AZ::Utils::GetEnginePath() });
            engineGemsFolder /= "Gems";
            if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(engineGemsFolder));
                it == options.m_projectIncludePaths.end())
            {
                if (AZ::IO::SystemFile::Exists(engineGemsFolder.c_str()))
                {
                    options.m_projectIncludePaths.emplace_back(AZStd::move(engineGemsFolder.Native()));
                }
            }
        }
// populate options with scan folders and contents of parsing shader_global_build_options.json
populate options with scan folders and contents of parsing shader_global_build_options.json
populate options with scan folders and contents of parsing shader_global_build_options . json
void InitializePreprocessorOptions(
            PreprocessorOptions& options, [[maybe_unused]] const char* builderName, const char* optionalIncludeFolder)
        {
            AZ_TraceContext("Init include-paths lookup options", "preprocessor");
            bool success = true;
            AZStd::vector<AZStd::string> scanFoldersVector;
            AzToolsFramework::AssetSystemRequestBus::BroadcastResult(success,
                &AzToolsFramework::AssetSystemRequestBus::Events::GetScanFolders,
                scanFoldersVector);
            AZ_Warning(builderName, success, "Preprocessor option: Could not acquire a list of scan folders from the database.");
            AZ::IO::FixedMaxPath projectPath = AZ::Utils::GetProjectPath();
            auto FindPath = [](AZ::IO::PathView searchPath)
            {
                return [searchPath](AZStd::string_view includePathView)
                {
                    return searchPath == AZ::IO::PathView(includePathView);
                };
            };
            if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(projectPath));
                it == options.m_projectIncludePaths.end())
            {
                options.m_projectIncludePaths.emplace_back(projectPath.c_str(), projectPath.Native().size());
            }
            if (optionalIncludeFolder)
            {
                if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(optionalIncludeFolder));
                    it == options.m_projectIncludePaths.end())
                {
                    if (AZ::IO::SystemFile::Exists(optionalIncludeFolder))
                    {
                        options.m_projectIncludePaths.emplace_back(AZStd::move(AZ::IO::Path(optionalIncludeFolder).LexicallyNormal().Native()));
                    }
                }
            }
            for (AZ::IO::Path shaderScanFolder : scanFoldersVector)
            {
                shaderScanFolder /= "ShaderLib";
                if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(shaderScanFolder));
                    it == options.m_projectIncludePaths.end())
                {
                    if (AZ::IO::SystemFile::Exists(shaderScanFolder.c_str()))
                    {
                        options.m_projectIncludePaths.emplace_back(AZStd::move(shaderScanFolder.LexicallyNormal().Native()));
                    }
                }
            }
            AZ::IO::Path engineGemsFolder(AZStd::string_view{ AZ::Utils::GetEnginePath() });
            engineGemsFolder /= "Gems";
            if (auto it = AZStd::find_if(options.m_projectIncludePaths.begin(), options.m_projectIncludePaths.end(), FindPath(engineGemsFolder));
                it == options.m_projectIncludePaths.end())
            {
                if (AZ::IO::SystemFile::Exists(engineGemsFolder.c_str()))
                {
                    options.m_projectIncludePaths.emplace_back(AZStd::move(engineGemsFolder.Native()));
                }
            }
        }
void InitializePreprocessorOptions ( PreprocessorOptions & options , [[ maybe_unused ]] const char * builderName , const char * optionalIncludeFolder ) { AZ_TraceContext ( " " , " " ) ; bool success = true ; AZStd :: vector < AZStd :: string > scanFoldersVector ; AzToolsFramework :: AssetSystemRequestBus :: BroadcastResult ( success , & AzToolsFramework :: AssetSystemRequestBus :: Events :: GetScanFolders , scanFoldersVector ) ; AZ_Warning ( builderName , success , " " ) ; AZ :: IO :: FixedMaxPath projectPath = AZ :: Utils :: GetProjectPath ( ) ; auto FindPath = [ ] ( AZ :: IO :: PathView searchPath ) { return [ searchPath ] ( AZStd :: string_view includePathView ) { return searchPath == AZ :: IO :: PathView ( includePathView ) ; } ; } ; if ( auto it = AZStd :: find_if ( options . m_projectIncludePaths . begin ( ) , options . m_projectIncludePaths . end ( ) , FindPath ( projectPath ) ) ; it == options . m_projectIncludePaths . end ( ) ) { options . m_projectIncludePaths . emplace_back ( projectPath . c_str ( ) , projectPath . Native ( ) . size ( ) ) ; } if ( optionalIncludeFolder ) { if ( auto it = AZStd :: find_if ( options . m_projectIncludePaths . begin ( ) , options . m_projectIncludePaths . end ( ) , FindPath ( optionalIncludeFolder ) ) ; it == options . m_projectIncludePaths . end ( ) ) { if ( AZ :: IO :: SystemFile :: Exists ( optionalIncludeFolder ) ) { options . m_projectIncludePaths . emplace_back ( AZStd :: move ( AZ :: IO :: Path ( optionalIncludeFolder ) . LexicallyNormal ( ) . Native ( ) ) ) ; } } } for ( AZ :: IO :: Path shaderScanFolder : scanFoldersVector ) { shaderScanFolder /= " " ; if ( auto it = AZStd :: find_if ( options . m_projectIncludePaths . begin ( ) , options . m_projectIncludePaths . end ( ) , FindPath ( shaderScanFolder ) ) ; it == options . m_projectIncludePaths . end ( ) ) { if ( AZ :: IO :: SystemFile :: Exists ( shaderScanFolder . c_str ( ) ) ) { options . m_projectIncludePaths . emplace_back ( AZStd :: move ( shaderScanFolder . LexicallyNormal ( ) . Native ( ) ) ) ; } } } AZ :: IO :: Path engineGemsFolder ( AZStd :: string_view { AZ :: Utils :: GetEnginePath ( ) } ) ; engineGemsFolder /= " " ; if ( auto it = AZStd :: find_if ( options . m_projectIncludePaths . begin ( ) , options . m_projectIncludePaths . end ( ) , FindPath ( engineGemsFolder ) ) ; it == options . m_projectIncludePaths . end ( ) ) { if ( AZ :: IO :: SystemFile :: Exists ( engineGemsFolder . c_str ( ) ) ) { options . m_projectIncludePaths . emplace_back ( AZStd :: move ( engineGemsFolder . Native ( ) ) ) ; } } }
populate options with scan folders and contents of parsing shader_global_build_options.json
populate options with scan folders and contents of parsing shader_global_build_options . json
// get the scan folders of the projects: // Add the project path to list of include paths // but while we transfer to the set, we're going to keep only folders where +/ShaderLib exists // the folders constructed this fashion constitute the base of automatic include search paths // finally the <engineroot>/Gems fallback