@@ -130,22 +130,6 @@ namespace
130130 }
131131 }
132132
133- // Update the include records
134- runcpp2::SourceIncludeMap sourcesIncludes;
135- if (!runcpp2::GatherFilesIncludes (sourcesNeedGathering, includePaths, sourcesIncludes))
136- return false ;
137-
138- for (auto it = sourcesIncludes.cbegin (); it != sourcesIncludes.cend (); ++it)
139- {
140- ssLOG_DEBUG (" Updating include record for " << it->first );
141- if (!includeManager.WriteIncludeRecord ( ghc::filesystem::path (it->first ),
142- it->second ))
143- {
144- ssLOG_ERROR (" Failed to write include record for " << it->first );
145- return false ;
146- }
147- }
148-
149133 return true ;
150134 }
151135
@@ -456,10 +440,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
456440 configPreferredProfile);
457441
458442 if (profileIndex == -1 )
459- {
460- ssLOG_ERROR (" Failed to find a profile to run" );
461443 return PipelineResult::NO_AVAILABLE_PROFILE;
462- }
463444
464445 // Parsing the script, setting up dependencies, compiling and linking
465446 std::vector<std::string> filesToCopyPaths;
@@ -586,34 +567,6 @@ runcpp2::StartPipeline( const std::string& scriptPath,
586567 return PipelineResult::UNEXPECTED_FAILURE;
587568 }
588569
589- // Update the include records
590- {
591- runcpp2::SourceIncludeMap sourcesIncludes;
592- if (!runcpp2::GatherFilesIncludes (sourceFiles, includePaths, sourcesIncludes))
593- return PipelineResult::UNEXPECTED_FAILURE;
594-
595- for (int i = 0 ; i < sourceFiles.size (); ++i)
596- {
597- ssLOG_DEBUG (" Updating include record for " << sourceFiles.at (i).string ());
598- if (!sourceHasCache.at (i))
599- {
600- if (sourcesIncludes.count (sourceFiles.at (i)) == 0 )
601- {
602- ssLOG_WARNING (" Includes not gathered for " << sourceFiles.at (i).string ());
603- continue ;
604- }
605-
606- if (!includeManager.WriteIncludeRecord ( sourceFiles.at (i),
607- sourcesIncludes.at (sourceFiles.at (i))))
608- {
609- ssLOG_ERROR (" Failed to write include record for " <<
610- sourceFiles.at (i).string ());
611- return PipelineResult::UNEXPECTED_FAILURE;
612- }
613- }
614- }
615- }
616-
617570 std::vector<std::string> linkFilesPaths;
618571 SeparateDependencyFiles (profiles.at (profileIndex).FilesTypes ,
619572 gatheredBinariesPaths,
@@ -664,6 +617,49 @@ runcpp2::StartPipeline( const std::string& scriptPath,
664617 for (int i = 0 ; i < cachedObjectsFiles.size (); ++i)
665618 linkFilesPaths.push_back (cachedObjectsFiles.at (i));
666619
620+ auto updateIncludeRecords =
621+ [
622+ &sourceFiles,
623+ &includePaths,
624+ &sourceHasCache,
625+ &includeManager
626+ ] () -> PipelineResult
627+ {
628+ runcpp2::SourceIncludeMap sourcesIncludes;
629+ if (!runcpp2::GatherFilesIncludes (sourceFiles, includePaths, sourcesIncludes))
630+ return PipelineResult::UNEXPECTED_FAILURE;
631+
632+ for (int i = 0 ; i < sourceFiles.size (); ++i)
633+ {
634+ ssLOG_DEBUG (" Updating include record for " << sourceFiles.at (i).string ());
635+ if (!sourceHasCache.at (i))
636+ {
637+ if (sourcesIncludes.count (sourceFiles.at (i)) == 0 )
638+ {
639+ ssLOG_WARNING ( " Includes not gathered for " <<
640+ sourceFiles.at (i).string ());
641+ continue ;
642+ }
643+
644+ if
645+ (
646+ !includeManager.WriteIncludeRecord
647+ (
648+ sourceFiles.at (i),
649+ sourcesIncludes.at (sourceFiles.at (i))
650+ )
651+ )
652+ {
653+ ssLOG_ERROR (" Failed to write include record for " <<
654+ sourceFiles.at (i).string ());
655+ return PipelineResult::UNEXPECTED_FAILURE;
656+ }
657+ }
658+ }
659+
660+ return PipelineResult::SUCCESS;
661+ };
662+
667663 if (currentOptions.count (CmdOptions::WATCH) > 0 )
668664 {
669665 if (!CompileScriptOnly ( buildDir,
@@ -680,7 +676,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
680676 return PipelineResult::COMPILE_LINK_FAILED;
681677 }
682678
683- return PipelineResult::SUCCESS ;
679+ return updateIncludeRecords () ;
684680 }
685681 else if (!CompileAndLinkScript ( buildDir,
686682 absoluteScriptPath,
@@ -698,6 +694,10 @@ runcpp2::StartPipeline( const std::string& scriptPath,
698694 ssLOG_ERROR (" Failed to compile or link script" );
699695 return PipelineResult::COMPILE_LINK_FAILED;
700696 }
697+
698+ result = updateIncludeRecords ();
699+ if (result != PipelineResult::SUCCESS)
700+ return result;
701701 }
702702 }
703703
0 commit comments