@@ -370,18 +370,36 @@ namespace
370370 bool buildExecutable,
371371 const std::string& scriptName,
372372 const std::string& exeExt,
373- ghc::filesystem::file_time_type& finalObjectWriteTime)
373+ const std::vector<std::string>& copiedBinariesPaths,
374+ const ghc::filesystem::file_time_type& finalObjectWriteTime)
374375 {
375376 for (int i = 0 ; i < sourceHasCache.size (); ++i)
376377 {
377378 if (!sourceHasCache.at (i))
378379 return false ;
379380 }
380381
381- // TODO: Check dependencies objects timestamps
382-
382+ ghc::filesystem::file_time_type currentFinalObjectWriteTime = finalObjectWriteTime;
383383 std::error_code e;
384384
385+ for (int i = 0 ; i < copiedBinariesPaths.size (); ++i)
386+ {
387+ if (ghc::filesystem::exists (copiedBinariesPaths.at (i), e))
388+ {
389+ ghc::filesystem::file_time_type lastObjectWriteTime =
390+ ghc::filesystem::last_write_time (copiedBinariesPaths.at (i), e);
391+
392+ if (lastObjectWriteTime > currentFinalObjectWriteTime)
393+ currentFinalObjectWriteTime = lastObjectWriteTime;
394+ }
395+ else
396+ {
397+ ssLOG_ERROR (" Somehow copied binary path " << copiedBinariesPaths.at (i) <<
398+ " doesn't exist" );
399+ return false ;
400+ }
401+ }
402+
385403 // Check if output is cached
386404 if (buildExecutable)
387405 {
@@ -397,7 +415,7 @@ namespace
397415 ghc::filesystem::file_time_type lastExecutableWriteTime =
398416 ghc::filesystem::last_write_time (exeToCopy, e);
399417
400- if (lastExecutableWriteTime > finalObjectWriteTime )
418+ if (lastExecutableWriteTime > currentFinalObjectWriteTime )
401419 {
402420 ssLOG_INFO (" Using output cache" );
403421 return true ;
@@ -435,7 +453,7 @@ namespace
435453 ghc::filesystem::file_time_type lastSharedLibWriteTime =
436454 ghc::filesystem::last_write_time (sharedLibBuild, e);
437455
438- if (lastSharedLibWriteTime > finalObjectWriteTime )
456+ if (lastSharedLibWriteTime > currentFinalObjectWriteTime )
439457 {
440458 ssLOG_INFO (" Using output cache" );
441459 return true ;
@@ -778,17 +796,31 @@ runcpp2::StartPipeline( const std::string& scriptPath,
778796 return PipelineResult::UNEXPECTED_FAILURE;
779797 }
780798
799+ // Update finalObjectWriteTime
800+ for (int i = 0 ; i < copiedBinariesPaths.size (); ++i)
801+ {
802+ if (!ghc::filesystem::exists (copiedBinariesPaths.at (i), e))
803+ {
804+ ssLOG_ERROR (copiedBinariesPaths.at (i) << " reported as cached but doesn't exist" );
805+ return PipelineResult::UNEXPECTED_FAILURE;
806+ }
807+
808+ ghc::filesystem::file_time_type lastWriteTime =
809+ ghc::filesystem::last_write_time (copiedBinariesPaths.at (i), e);
810+
811+ if (lastWriteTime > finalObjectWriteTime)
812+ finalObjectWriteTime = lastWriteTime;
813+ }
781814
782- // TODO: Use this once we implement checking dependencies objects timestamps
783- (void )HasOutputCache;
784- // if(HasOutputCache( sourceHasCache,
785- // buildDir,
786- // profiles.at(profileIndex),
787- // currentOptions.count(CmdOptions::EXECUTABLE) > 0,
788- // scriptName,
789- // exeExt,
790- // finalObjectWriteTime))
791815 // Compiling/Linking
816+ if (!HasOutputCache ( sourceHasCache,
817+ buildDir,
818+ profiles.at (profileIndex),
819+ currentOptions.count (CmdOptions::EXECUTABLE) > 0 ,
820+ scriptName,
821+ exeExt,
822+ copiedBinariesPaths,
823+ finalObjectWriteTime))
792824 {
793825 for (int i = 0 ; i < cachedObjectsFiles.size (); ++i)
794826 copiedBinariesPaths.push_back (cachedObjectsFiles.at (i));
0 commit comments