@@ -304,7 +304,6 @@ runcpp2::PipelineResult
304304runcpp2::ParseAndValidateScriptInfo (const ghc::filesystem::path& absoluteScriptPath,
305305 const ghc::filesystem::path& scriptDirectory,
306306 const std::string& scriptName,
307- const Data::ScriptInfo* lastScriptInfo,
308307 Data::ScriptInfo& outScriptInfo)
309308{
310309 ssLOG_FUNC_INFO ();
@@ -357,8 +356,8 @@ runcpp2::ParseAndValidateScriptInfo(const ghc::filesystem::path& absoluteScriptP
357356
358357 if (!parsableInfo.empty ())
359358 {
360- ssLOG_INFO (" Parsed script info YAML:" );
361- ssLOG_INFO (" \n " << outScriptInfo.ToString (" " ));
359+ ssLOG_DEBUG (" Parsed script info YAML:" );
360+ ssLOG_DEBUG (" \n " << outScriptInfo.ToString (" " ));
362361 }
363362
364363 return PipelineResult::SUCCESS;
@@ -507,7 +506,7 @@ runcpp2::PipelineResult
507506runcpp2::CheckScriptInfoChanges (const ghc::filesystem::path& buildDir,
508507 const Data::ScriptInfo& scriptInfo,
509508 const Data::Profile& profile,
510- const ghc::filesystem::path& scriptDirectory ,
509+ const ghc::filesystem::path& absoluteScriptPath ,
511510 const Data::ScriptInfo* lastScriptInfo,
512511 bool & outRecompileNeeded,
513512 bool & outRelinkNeeded,
@@ -516,6 +515,7 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
516515 ssLOG_FUNC_INFO ();
517516 INTERNAL_RUNCPP2_SAFE_START ();
518517
518+ const ghc::filesystem::path scriptDirectory = absoluteScriptPath.parent_path ();
519519 ghc::filesystem::path lastScriptInfoFilePath = buildDir / " LastScriptInfo.yaml" ;
520520 Data::ScriptInfo lastScriptInfoFromDisk;
521521
@@ -540,18 +540,45 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
540540
541541 // Compare script info in memory or from disk
542542 const Data::ScriptInfo* lastInfo = lastScriptInfo;
543- if (lastScriptInfo == nullptr && ghc::filesystem::exists (lastScriptInfoFilePath, e))
543+ if (lastInfo == nullptr && ghc::filesystem::exists (lastScriptInfoFilePath, e))
544544 {
545545 ssLOG_DEBUG (" Last script info file exists: " << lastScriptInfoFilePath);
546546 std::ifstream lastScriptInfoFile;
547547 lastScriptInfoFile.open (lastScriptInfoFilePath);
548548 std::stringstream lastScriptInfoBuffer;
549549 lastScriptInfoBuffer << lastScriptInfoFile.rdbuf ();
550550
551- if (ParseScriptInfo (lastScriptInfoBuffer.str (), lastScriptInfoFromDisk))
551+ int currentThreadTargetLevel = ssLOG_GET_CURRENT_THREAD_TARGET_LEVEL ();
552+ ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL (ssLOG_LEVEL_NONE);
553+
554+ do
555+ {
556+ {
557+ bool result = ParseScriptInfo (lastScriptInfoBuffer.str (), lastScriptInfoFromDisk);
558+ if (!result)
559+ break ;
560+ }
561+
562+ // Resolve imports for last script info
563+ runcpp2::PipelineResult result = ResolveScriptImports ( lastScriptInfoFromDisk,
564+ absoluteScriptPath,
565+ buildDir);
566+ if (result != PipelineResult::SUCCESS)
567+ break ;
568+
552569 lastInfo = &lastScriptInfoFromDisk;
570+ }
571+ while (false );
572+
573+ ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL (currentThreadTargetLevel);
574+
575+ if (lastInfo != nullptr )
576+ ssLOG_INFO (" Last script info parsed" );
577+ else
578+ ssLOG_INFO (" Failed to parse last script info" );
553579 }
554580
581+ // Check if the cached script info has changed
555582 if (lastInfo != nullptr )
556583 {
557584 // Check link flags
@@ -626,6 +653,9 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
626653 !lastDefines->Equals (*currentDefines)
627654 );
628655 }
656+
657+ if (outRecompileNeeded || outRelinkNeeded)
658+ ssLOG_INFO (" Last script info is out of date, recompiling or relinking..." );
629659 }
630660 else
631661 outRecompileNeeded = true ;
@@ -647,34 +677,31 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
647677 ssLOG_DEBUG (" Wrote current script info to " << lastScriptInfoFilePath.string ());
648678 }
649679
680+ if (!lastInfo)
681+ return PipelineResult::SUCCESS;
682+
650683 // Check if include paths have changed
651684 std::vector<ghc::filesystem::path> currentIncludePaths;
652- if (!GatherIncludePaths ( scriptDirectory,
653- scriptInfo,
654- profile,
655- {}, // Empty dependencies since we're just comparing paths
656- currentIncludePaths))
685+ if (!GatherIncludePaths (scriptDirectory, scriptInfo, profile, {}, currentIncludePaths))
657686 {
658687 ssLOG_ERROR (" Failed to gather current include paths" );
659688 return PipelineResult::UNEXPECTED_FAILURE;
660689 }
661690
662691 std::vector<ghc::filesystem::path> lastIncludePaths;
663- if (lastScriptInfo && !GatherIncludePaths ( scriptDirectory,
664- *lastScriptInfo,
665- profile,
666- {}, // Empty dependencies
667- lastIncludePaths))
692+ if (!GatherIncludePaths (scriptDirectory, *lastInfo, profile, {}, lastIncludePaths))
668693 {
669- ssLOG_ERROR (" Failed to gather last include paths" );
670- return PipelineResult::UNEXPECTED_FAILURE ;
694+ ssLOG_WARNING (" Failed to gather last include paths" );
695+ return PipelineResult::SUCCESS ;
671696 }
672697
673698 if (currentIncludePaths != lastIncludePaths)
674699 {
675700 ssLOG_INFO (" Include paths have changed" );
676701 outRecompileNeeded = true ;
677702 }
703+ else if (!outRecompileNeeded && !outRelinkNeeded)
704+ ssLOG_INFO (" Using script info cache" );
678705
679706 return PipelineResult::SUCCESS;
680707
@@ -1236,7 +1263,7 @@ bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& fi
12361263
12371264 if (found)
12381265 {
1239- ssLOG_INFO (" Found include file: " << resolvedInclude.string ());
1266+ ssLOG_DEBUG (" Found include file: " << resolvedInclude.string ());
12401267 currentIncludes.push_back (resolvedInclude);
12411268 filesToProcess.push (resolvedInclude);
12421269 }
0 commit comments