Skip to content

Commit a07db5f

Browse files
Adding info logs & try catches
1 parent 5d062a5 commit a07db5f

File tree

4 files changed

+96
-8
lines changed

4 files changed

+96
-8
lines changed

Src/runcpp2/IncludeManager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,16 @@ namespace runcpp2
110110
INTERNAL_RUNCPP2_SAFE_START();
111111
ssLOG_FUNC_DEBUG();
112112

113+
ssLOG_DEBUG("Checking includes for " << sourceFile.string());
114+
113115
std::error_code e;
114116
ghc::filesystem::file_time_type sourceTime = ghc::filesystem::last_write_time(sourceFile, e);
115117

116118
if(sourceTime > recordTime)
119+
{
120+
ssLOG_DEBUG("Source file newer than include record");
117121
return true;
122+
}
118123

119124
for(const ghc::filesystem::path& include : includes)
120125
{
@@ -123,11 +128,17 @@ namespace runcpp2
123128
ghc::filesystem::file_time_type includeTime =
124129
ghc::filesystem::last_write_time(include, e);
125130
if(includeTime > recordTime)
131+
{
132+
ssLOG_DEBUG("Include time for " << include.string() <<
133+
" is newer than record time");
126134
return true;
135+
}
127136
}
128137
}
129138

139+
ssLOG_DEBUG("No update needed for " << sourceFile.string());
130140
return false;
141+
131142
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(true);
132143
}
133144

Src/runcpp2/PipelineSteps.cpp

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ bool runcpp2::CopyFiles(const ghc::filesystem::path& destDir,
180180
const std::vector<std::string>& filePaths,
181181
std::vector<std::string>& outCopiedPaths)
182182
{
183-
ssLOG_FUNC_DEBUG();
183+
ssLOG_FUNC_INFO();
184+
INTERNAL_RUNCPP2_SAFE_START();
184185

185186
std::error_code e;
186187
for (const std::string& srcPath : filePaths)
@@ -213,6 +214,8 @@ bool runcpp2::CopyFiles(const ghc::filesystem::path& destDir,
213214
}
214215

215216
return true;
217+
218+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
216219
}
217220

218221
runcpp2::PipelineResult
@@ -221,6 +224,9 @@ runcpp2::RunProfileCommands(const Data::ProfilesCommands* commands,
221224
const std::string& workingDir,
222225
const std::string& commandType)
223226
{
227+
ssLOG_FUNC_INFO();
228+
INTERNAL_RUNCPP2_SAFE_START();
229+
224230
if(commands != nullptr)
225231
{
226232
const std::vector<std::string>* commandSteps =
@@ -246,6 +252,8 @@ runcpp2::RunProfileCommands(const Data::ProfilesCommands* commands,
246252
}
247253
}
248254
return PipelineResult::SUCCESS;
255+
256+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
249257
}
250258

251259
runcpp2::PipelineResult runcpp2::ValidateInputs(const std::string& scriptPath,
@@ -254,6 +262,7 @@ runcpp2::PipelineResult runcpp2::ValidateInputs(const std::string& scriptPath,
254262
ghc::filesystem::path& outScriptDirectory,
255263
std::string& outScriptName)
256264
{
265+
ssLOG_FUNC_INFO();
257266
INTERNAL_RUNCPP2_SAFE_START();
258267

259268
if(profiles.empty())
@@ -298,6 +307,7 @@ runcpp2::ParseAndValidateScriptInfo(const ghc::filesystem::path& absoluteScriptP
298307
const Data::ScriptInfo* lastScriptInfo,
299308
Data::ScriptInfo& outScriptInfo)
300309
{
310+
ssLOG_FUNC_INFO();
301311
INTERNAL_RUNCPP2_SAFE_START();
302312

303313
//Check if there's script info as yaml file instead
@@ -360,6 +370,9 @@ runcpp2::PipelineResult runcpp2::HandleCleanup( const Data::ScriptInfo& scriptIn
360370
const ghc::filesystem::path& absoluteScriptPath,
361371
BuildsManager& buildsManager)
362372
{
373+
ssLOG_FUNC_INFO();
374+
INTERNAL_RUNCPP2_SAFE_START();
375+
363376
const Data::ProfilesCommands* cleanupCommands =
364377
runcpp2::GetValueFromPlatformMap(scriptInfo.Cleanup);
365378

@@ -407,6 +420,8 @@ runcpp2::PipelineResult runcpp2::HandleCleanup( const Data::ScriptInfo& scriptIn
407420
return PipelineResult::UNEXPECTED_FAILURE;
408421
}
409422
return PipelineResult::SUCCESS;
423+
424+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
410425
}
411426

412427
runcpp2::PipelineResult
@@ -417,6 +432,9 @@ runcpp2::InitializeBuildDirectory( const ghc::filesystem::path& configDir,
417432
ghc::filesystem::path& outBuildDir,
418433
IncludeManager& outIncludeManager)
419434
{
435+
ssLOG_FUNC_INFO();
436+
INTERNAL_RUNCPP2_SAFE_START();
437+
420438
//Create build directory
421439
ghc::filesystem::path buildDirPath = useLocalBuildDir ?
422440
ghc::filesystem::current_path() / ".runcpp2" :
@@ -458,6 +476,8 @@ runcpp2::InitializeBuildDirectory( const ghc::filesystem::path& configDir,
458476
}
459477

460478
return PipelineResult::SUCCESS;
479+
480+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
461481
}
462482

463483
runcpp2::PipelineResult
@@ -470,6 +490,9 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
470490
bool& outRelinkNeeded,
471491
std::vector<std::string>& outChangedDependencies)
472492
{
493+
ssLOG_FUNC_INFO();
494+
INTERNAL_RUNCPP2_SAFE_START();
495+
473496
ghc::filesystem::path lastScriptInfoFilePath = buildDir / "LastScriptInfo.yaml";
474497
Data::ScriptInfo lastScriptInfoFromDisk;
475498

@@ -631,6 +654,8 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir,
631654
}
632655

633656
return PipelineResult::SUCCESS;
657+
658+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
634659
}
635660

636661
runcpp2::PipelineResult
@@ -643,6 +668,9 @@ runcpp2::ProcessDependencies( Data::ScriptInfo& scriptInfo,
643668
std::vector<Data::DependencyInfo*>& outAvailableDependencies,
644669
std::vector<std::string>& outGatheredBinariesPaths)
645670
{
671+
ssLOG_FUNC_INFO();
672+
INTERNAL_RUNCPP2_SAFE_START();
673+
646674
for(int i = 0; i < scriptInfo.Dependencies.size(); ++i)
647675
{
648676
if(IsDependencyAvailableForThisPlatform(scriptInfo.Dependencies.at(i)))
@@ -730,13 +758,18 @@ runcpp2::ProcessDependencies( Data::ScriptInfo& scriptInfo,
730758
}
731759

732760
return PipelineResult::SUCCESS;
761+
762+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
733763
}
734764

735765
void runcpp2::SeparateDependencyFiles( const Data::FilesTypesInfo& filesTypes,
736766
const std::vector<std::string>& gatheredBinariesPaths,
737767
std::vector<std::string>& outLinkFilesPaths,
738768
std::vector<std::string>& outFilesToCopyPaths)
739769
{
770+
ssLOG_FUNC_INFO();
771+
INTERNAL_RUNCPP2_SAFE_START();
772+
740773
std::unordered_set<std::string> linkExtensions;
741774

742775
//Populate the set of link extensions
@@ -777,12 +810,16 @@ void runcpp2::SeparateDependencyFiles( const Data::FilesTypesInfo& filesTypes,
777810
ssLOG_INFO("Files to copy:");
778811
for(int i = 0; i < outFilesToCopyPaths.size(); ++i)
779812
ssLOG_INFO(" " << outFilesToCopyPaths[i]);
813+
814+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(void());
780815
}
781816

782817
runcpp2::PipelineResult runcpp2::HandlePreBuild(const Data::ScriptInfo& scriptInfo,
783818
const Data::Profile& profile,
784819
const ghc::filesystem::path& buildDir)
785820
{
821+
ssLOG_FUNC_INFO();
822+
786823
const Data::ProfilesCommands* preBuildCommands =
787824
runcpp2::GetValueFromPlatformMap(scriptInfo.PreBuild);
788825

@@ -793,6 +830,8 @@ runcpp2::PipelineResult runcpp2::HandlePostBuild( const Data::ScriptInfo& scri
793830
const Data::Profile& profile,
794831
const ghc::filesystem::path& buildDir)
795832
{
833+
ssLOG_FUNC_INFO();
834+
796835
const Data::ProfilesCommands* postBuildCommands =
797836
GetValueFromPlatformMap(scriptInfo.PostBuild);
798837

@@ -807,6 +846,9 @@ runcpp2::RunCompiledOutput( const ghc::filesystem::path& target,
807846
const std::unordered_map<CmdOptions, std::string>& currentOptions,
808847
int& returnStatus)
809848
{
849+
ssLOG_FUNC_INFO();
850+
INTERNAL_RUNCPP2_SAFE_START();
851+
810852
//Prepare run arguments
811853
std::vector<std::string> finalRunArgs;
812854
finalRunArgs.push_back(target.string());
@@ -837,6 +879,8 @@ runcpp2::RunCompiledOutput( const ghc::filesystem::path& target,
837879
}
838880

839881
return PipelineResult::SUCCESS;
882+
883+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
840884
}
841885

842886
runcpp2::PipelineResult
@@ -847,6 +891,9 @@ runcpp2::HandleBuildOutput( const ghc::filesystem::path& target,
847891
const std::string& buildOutputDir,
848892
const std::unordered_map<CmdOptions, std::string>& currentOptions)
849893
{
894+
ssLOG_FUNC_INFO();
895+
INTERNAL_RUNCPP2_SAFE_START();
896+
850897
//Copy the output file
851898
std::vector<std::string> filesToCopy = filesToCopyPaths;
852899
filesToCopy.push_back(target);
@@ -869,6 +916,8 @@ runcpp2::HandleBuildOutput( const ghc::filesystem::path& target,
869916

870917
ssLOG_BASE("Build completed. Files copied to " << buildOutputDir);
871918
return PipelineResult::SUCCESS;
919+
920+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
872921
}
873922

874923
runcpp2::PipelineResult
@@ -878,6 +927,9 @@ runcpp2::GetTargetPath( const ghc::filesystem::path& buildDir,
878927
const std::unordered_map<CmdOptions, std::string>& currentOptions,
879928
ghc::filesystem::path& outTarget)
880929
{
930+
ssLOG_FUNC_INFO();
931+
INTERNAL_RUNCPP2_SAFE_START();
932+
881933
std::string exeExt = "";
882934
#ifdef _WIN32
883935
exeExt = ".exe";
@@ -913,13 +965,18 @@ runcpp2::GetTargetPath( const ghc::filesystem::path& buildDir,
913965
}
914966

915967
return PipelineResult::SUCCESS;
968+
969+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(PipelineResult::UNEXPECTED_FAILURE);
916970
}
917971

918972
bool runcpp2::GatherSourceFiles(const ghc::filesystem::path& absoluteScriptPath,
919973
const Data::ScriptInfo& scriptInfo,
920974
const Data::Profile& currentProfile,
921975
std::vector<ghc::filesystem::path>& outSourcePaths)
922976
{
977+
ssLOG_FUNC_INFO();
978+
INTERNAL_RUNCPP2_SAFE_START();
979+
923980
if(!currentProfile.FileExtensions.count(absoluteScriptPath.extension()))
924981
{
925982
ssLOG_ERROR("File extension of script doesn't match profile");
@@ -1005,6 +1062,8 @@ bool runcpp2::GatherSourceFiles(const ghc::filesystem::path& absoluteScriptPath,
10051062
}
10061063

10071064
return true;
1065+
1066+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
10081067
}
10091068

10101069
bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory,
@@ -1013,7 +1072,9 @@ bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory
10131072
const std::vector<Data::DependencyInfo*>& dependencies,
10141073
std::vector<ghc::filesystem::path>& outIncludePaths)
10151074
{
1016-
ssLOG_FUNC_DEBUG();
1075+
ssLOG_FUNC_INFO();
1076+
INTERNAL_RUNCPP2_SAFE_START();
1077+
10171078
outIncludePaths.clear();
10181079

10191080
if(!scriptDirectory.is_absolute())
@@ -1077,20 +1138,24 @@ bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory
10771138
}
10781139

10791140
return true;
1141+
1142+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
10801143
}
10811144

10821145
bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& files,
10831146
const std::vector<ghc::filesystem::path>& includePaths,
10841147
SourceIncludeMap& outSourceIncludes)
10851148
{
1149+
ssLOG_FUNC_INFO();
10861150
INTERNAL_RUNCPP2_SAFE_START();
1087-
ssLOG_FUNC_DEBUG();
10881151

10891152
outSourceIncludes.clear();
10901153
std::unordered_set<std::string> visitedFiles;
10911154

10921155
for(const ghc::filesystem::path& file : files)
10931156
{
1157+
ssLOG_INFO("Gathering includes for " << file.string());
1158+
10941159
std::vector<ghc::filesystem::path>& currentIncludes = outSourceIncludes[file.string()];
10951160
std::queue<ghc::filesystem::path> filesToProcess;
10961161
filesToProcess.push(file);
@@ -1148,6 +1213,7 @@ bool runcpp2::GatherFilesIncludes( const std::vector<ghc::filesystem::path>& fi
11481213

11491214
if(found)
11501215
{
1216+
ssLOG_INFO("Found include file: " << resolvedInclude.string());
11511217
currentIncludes.push_back(resolvedInclude);
11521218
filesToProcess.push(resolvedInclude);
11531219
}

Src/runcpp2/runcpp2.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace
3737
std::vector<ghc::filesystem::path>& outCachedObjectsFiles,
3838
ghc::filesystem::file_time_type& outFinalObjectWriteTime)
3939
{
40-
ssLOG_FUNC_DEBUG();
40+
ssLOG_FUNC_INFO();
4141

4242
outHasCache.clear();
4343
outHasCache = std::vector<bool>(sourceFiles.size(), false);
@@ -108,17 +108,21 @@ namespace
108108

109109
if(needsGather)
110110
{
111+
ssLOG_DEBUG("Needs to update include record for " <<
112+
sourceFiles.at(i).string());
111113
sourcesNeedGathering.push_back(sourceFiles.at(i));
112114
useCache = false;
113115
}
114116
}
115117

116118
if(useCache)
117119
{
118-
ssLOG_DEBUG("Using cache for " << sourceFiles.at(i).string());
120+
ssLOG_INFO("Using cache for " << sourceFiles.at(i).string());
119121
outHasCache.at(i) = true;
120122
outCachedObjectsFiles.push_back(currentObjectFilePath);
121123
}
124+
else
125+
ssLOG_INFO("Cache invalidated for " << sourceFiles.at(i).string());
122126

123127
if(lastObjectWriteTime > outFinalObjectWriteTime)
124128
outFinalObjectWriteTime = lastObjectWriteTime;
@@ -132,6 +136,7 @@ namespace
132136

133137
for(auto it = sourcesIncludes.cbegin(); it != sourcesIncludes.cend(); ++it)
134138
{
139+
ssLOG_DEBUG("Updating include record for " << it->first);
135140
if(!includeManager.WriteIncludeRecord( ghc::filesystem::path(it->first),
136141
it->second))
137142
{
@@ -305,7 +310,7 @@ runcpp2::CheckSourcesNeedUpdate( const std::string& scriptPath,
305310
bool& outNeedsUpdate)
306311
{
307312
INTERNAL_RUNCPP2_SAFE_START();
308-
ssLOG_FUNC_DEBUG();
313+
ssLOG_FUNC_INFO();
309314

310315
//Validate inputs and get paths
311316
ghc::filesystem::path absoluteScriptPath;
@@ -345,13 +350,19 @@ runcpp2::CheckSourcesNeedUpdate( const std::string& scriptPath,
345350
if(!GatherSourceFiles(absoluteScriptPath, scriptInfo, currentProfile, sourceFiles))
346351
return PipelineResult::UNEXPECTED_FAILURE;
347352

353+
for(int i = 0; i < sourceFiles.size(); ++i)
354+
ssLOG_DEBUG("sourceFiles.at(i).string(): " << sourceFiles.at(i).string());
355+
348356
//Get include paths
349357
std::vector<ghc::filesystem::path> includePaths;
350358
if(!GatherIncludePaths(scriptDirectory, scriptInfo, currentProfile, {}, includePaths))
351359
{
352360
ssLOG_ERROR("Failed to gather include paths");
353361
return PipelineResult::UNEXPECTED_FAILURE;
354362
}
363+
364+
for(int i = 0; i < includePaths.size(); ++i)
365+
ssLOG_DEBUG("includePaths.at(i).string(): " << includePaths.at(i).string());
355366

356367
for(int i = 0; i < sourceFiles.size(); ++i)
357368
{
@@ -390,7 +401,7 @@ runcpp2::StartPipeline( const std::string& scriptPath,
390401
int& returnStatus)
391402
{
392403
INTERNAL_RUNCPP2_SAFE_START();
393-
ssLOG_FUNC_DEBUG();
404+
ssLOG_FUNC_INFO();
394405

395406
//Validate inputs and get paths
396407
ghc::filesystem::path absoluteScriptPath;

0 commit comments

Comments
 (0)