Skip to content

Commit fa2b994

Browse files
Merge pull request #47 from Neko-Box-Coder/ClarityAndBugFixes
Clarity and include record bug fix, minor updates
2 parents 71dccac + afdd9aa commit fa2b994

File tree

7 files changed

+82
-67
lines changed

7 files changed

+82
-67
lines changed

External/ssLogger

Src/runcpp2/BuildsManager.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ namespace runcpp2
180180
return false;
181181
}
182182

183-
std::string processScriptPathStr = ProcessPath(scriptPath.string());
183+
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
184+
std::string processScriptPathStr = ProcessPath(cleanScriptPath.string());
184185

185186
if(Mappings.count(processScriptPathStr) > 0)
186187
return true;
@@ -204,7 +205,7 @@ namespace runcpp2
204205

205206
if(counter == MAX_TRIES)
206207
{
207-
ssLOG_ERROR("Failed to get unique hash for " << scriptPath.string() <<
208+
ssLOG_ERROR("Failed to get unique hash for " << cleanScriptPath.string() <<
208209
" after " << MAX_TRIES << " attempts");
209210
return false;
210211
}
@@ -229,7 +230,7 @@ namespace runcpp2
229230
return false;
230231
}
231232

232-
ssLOG_INFO("Build path " << scriptBuildPath << " for " << scriptPath);
233+
ssLOG_INFO("Build path " << scriptBuildPath << " for " << cleanScriptPath);
233234
Mappings[processScriptPathStr] = scriptBuildPathStr;
234235
ReverseMappings[scriptBuildPathStr] = processScriptPathStr;
235236
return true;
@@ -246,7 +247,8 @@ namespace runcpp2
246247
return false;
247248
}
248249

249-
std::string processScriptPathStr = ProcessPath(scriptPath.string());
250+
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
251+
std::string processScriptPathStr = ProcessPath(cleanScriptPath.string());
250252
if(Mappings.count(processScriptPathStr) == 0)
251253
return true;
252254

@@ -267,7 +269,8 @@ namespace runcpp2
267269
return false;
268270
}
269271

270-
return Mappings.count(ProcessPath(scriptPath.string()));
272+
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
273+
return Mappings.count(ProcessPath(cleanScriptPath.string()));
271274
}
272275

273276
bool BuildsManager::GetBuildMapping(const ghc::filesystem::path& scriptPath,
@@ -282,14 +285,16 @@ namespace runcpp2
282285
return false;
283286
}
284287

288+
ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal();
289+
285290
//If it doesn't exist, create the mapping
286-
if(!Mappings.count(ProcessPath(scriptPath.string())))
291+
if(!Mappings.count(ProcessPath(cleanScriptPath.string())))
287292
{
288-
if(!CreateBuildMapping(scriptPath))
293+
if(!CreateBuildMapping(cleanScriptPath))
289294
return false;
290295
}
291296

292-
outPath = BuildDirectory.string() + "/" + Mappings.at(ProcessPath(scriptPath.string()));
297+
outPath = BuildDirectory.string() + "/" + Mappings.at(ProcessPath(cleanScriptPath.string()));
293298
return true;
294299
}
295300

Src/runcpp2/DependenciesHelper.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ namespace
248248
const std::unordered_map< PlatformName,
249249
runcpp2::Data::ProfilesCommands> steps,
250250
const std::string& dependenciesCopiedDirectory,
251-
bool required)
251+
bool required,
252+
bool redirectIO)
252253
{
253254
ssLOG_FUNC_INFO();
254255

@@ -291,18 +292,22 @@ namespace
291292
std::string output;
292293

293294
if(!runcpp2::RunCommand(commands->at(k),
294-
true,
295+
redirectIO,
295296
processedDependencyPath,
296297
output,
297298
returnCode))
298299
{
299300
ssLOG_ERROR("Failed to run command with result: " << returnCode);
300301
ssLOG_ERROR("Was trying to run: " << commands->at(k));
301-
ssLOG_ERROR("Output: \n" << output);
302+
if(redirectIO)
303+
ssLOG_ERROR("Output: \n" << output);
302304
return false;
303305
}
304306
else
305-
ssLOG_INFO("Output: \n" << output);
307+
{
308+
if(redirectIO)
309+
ssLOG_INFO("Output: \n" << output);
310+
}
306311
}
307312

308313
return true;
@@ -499,6 +504,7 @@ bool runcpp2::CleanupDependencies( const runcpp2::Data::Profile& profile,
499504
if(!RunDependenciesSteps( profile,
500505
availableDependencies.at(i)->Cleanup,
501506
dependenciesLocalCopiesPaths.at(i),
507+
false,
502508
false))
503509
{
504510
ssLOG_ERROR("Failed to cleanup dependency " << availableDependencies.at(i)->Name);
@@ -586,7 +592,8 @@ bool runcpp2::SetupDependenciesIfNeeded(const runcpp2::Data::Profile& profile,
586592
if(!RunDependenciesSteps( profile,
587593
availableDependencies.at(i)->Setup,
588594
dependenciesLocalCopiesPaths.at(i),
589-
true))
595+
true,
596+
false))
590597
{
591598
ssLOG_ERROR("Failed to setup dependency " <<
592599
availableDependencies.at(i)->Name);
@@ -694,7 +701,8 @@ bool runcpp2::BuildDependencies(const runcpp2::Data::Profile& profile,
694701
if(!RunDependenciesSteps( profile,
695702
availableDependencies.at(i)->Build,
696703
dependenciesLocalCopiesPaths.at(i),
697-
true))
704+
true,
705+
false))
698706
{
699707
ssLOG_ERROR("Failed to build dependency " << availableDependencies.at(i)->Name);
700708
return false;
@@ -971,7 +979,7 @@ bool runcpp2::GatherDependenciesBinaries( const std::vector<Data::DependencyIn
971979
//Do a check to see if any dependencies are copied
972980
if(outBinariesPaths.size() - nonLinkFilesCount < minimumDependenciesCopiesCount)
973981
{
974-
ssLOG_WARNING("We could missing some link files for dependencies");
982+
ssLOG_WARNING("We could be missing some link files for dependencies");
975983

976984
for(int i = 0; i < outBinariesPaths.size(); ++i)
977985
ssLOG_WARNING("outBinariesPaths[" << i << "]: " << outBinariesPaths.at(i));

Src/runcpp2/IncludeManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ namespace runcpp2
150150
{
151151
CO_OVERRIDE_MEMBER_IMPL(OverrideInstance, ghc::filesystem::path, (sourceFile));
152152

153-
std::size_t pathHash = std::hash<std::string>{}(sourceFile.string());
153+
ghc::filesystem::path cleanSourceFile = sourceFile.lexically_normal();
154+
std::size_t pathHash = std::hash<std::string>{}(cleanSourceFile.string());
154155
return IncludeRecordDir / (std::to_string(pathHash) + ".Includes");
155156
}
156157
}

Src/runcpp2/ProfileHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int runcpp2::GetPreferredProfileIndex( const std::string& scriptPath,
202202

203203
if(availableProfiles.empty())
204204
{
205-
ssLOG_ERROR("No compilers/linkers found");
205+
ssLOG_ERROR("No compilers/linkers found that can be used for " << scriptPath);
206206
return -1;
207207
}
208208

Src/runcpp2/runcpp2.cpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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

mkdocs/docs/TODO.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
- Add ability to reference local YAML for user config
2020
- Add version for user config and prompt for update
2121
- Add wildcard support for filenames and extensions (Files Globbing)
22-
22+
- Add the ability to query script build directory
23+
- Add the ability to list script dependencies
2324

2425
## Not planned yet
2526

0 commit comments

Comments
 (0)