From c63b0a65bedc19d13bf1bed1b5625784a3c580ff Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sun, 23 Feb 2025 13:31:29 +0000 Subject: [PATCH 1/5] Updating paths to be normalized --- Src/runcpp2/BuildsManager.cpp | 21 +++++++++++++-------- Src/runcpp2/IncludeManager.cpp | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Src/runcpp2/BuildsManager.cpp b/Src/runcpp2/BuildsManager.cpp index 941b5ba..0c3ec1e 100644 --- a/Src/runcpp2/BuildsManager.cpp +++ b/Src/runcpp2/BuildsManager.cpp @@ -180,7 +180,8 @@ namespace runcpp2 return false; } - std::string processScriptPathStr = ProcessPath(scriptPath.string()); + ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal(); + std::string processScriptPathStr = ProcessPath(cleanScriptPath.string()); if(Mappings.count(processScriptPathStr) > 0) return true; @@ -204,7 +205,7 @@ namespace runcpp2 if(counter == MAX_TRIES) { - ssLOG_ERROR("Failed to get unique hash for " << scriptPath.string() << + ssLOG_ERROR("Failed to get unique hash for " << cleanScriptPath.string() << " after " << MAX_TRIES << " attempts"); return false; } @@ -229,7 +230,7 @@ namespace runcpp2 return false; } - ssLOG_INFO("Build path " << scriptBuildPath << " for " << scriptPath); + ssLOG_INFO("Build path " << scriptBuildPath << " for " << cleanScriptPath); Mappings[processScriptPathStr] = scriptBuildPathStr; ReverseMappings[scriptBuildPathStr] = processScriptPathStr; return true; @@ -246,7 +247,8 @@ namespace runcpp2 return false; } - std::string processScriptPathStr = ProcessPath(scriptPath.string()); + ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal(); + std::string processScriptPathStr = ProcessPath(cleanScriptPath.string()); if(Mappings.count(processScriptPathStr) == 0) return true; @@ -267,7 +269,8 @@ namespace runcpp2 return false; } - return Mappings.count(ProcessPath(scriptPath.string())); + ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal(); + return Mappings.count(ProcessPath(cleanScriptPath.string())); } bool BuildsManager::GetBuildMapping(const ghc::filesystem::path& scriptPath, @@ -282,14 +285,16 @@ namespace runcpp2 return false; } + ghc::filesystem::path cleanScriptPath = scriptPath.lexically_normal(); + //If it doesn't exist, create the mapping - if(!Mappings.count(ProcessPath(scriptPath.string()))) + if(!Mappings.count(ProcessPath(cleanScriptPath.string()))) { - if(!CreateBuildMapping(scriptPath)) + if(!CreateBuildMapping(cleanScriptPath)) return false; } - outPath = BuildDirectory.string() + "/" + Mappings.at(ProcessPath(scriptPath.string())); + outPath = BuildDirectory.string() + "/" + Mappings.at(ProcessPath(cleanScriptPath.string())); return true; } diff --git a/Src/runcpp2/IncludeManager.cpp b/Src/runcpp2/IncludeManager.cpp index f968d34..9481845 100644 --- a/Src/runcpp2/IncludeManager.cpp +++ b/Src/runcpp2/IncludeManager.cpp @@ -150,7 +150,8 @@ namespace runcpp2 { CO_OVERRIDE_MEMBER_IMPL(OverrideInstance, ghc::filesystem::path, (sourceFile)); - std::size_t pathHash = std::hash{}(sourceFile.string()); + ghc::filesystem::path cleanSourceFile = sourceFile.lexically_normal(); + std::size_t pathHash = std::hash{}(cleanSourceFile.string()); return IncludeRecordDir / (std::to_string(pathHash) + ".Includes"); } } From 041db0c0c72013a6a1589995750c4442fe5a7cce Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sun, 23 Feb 2025 13:46:48 +0000 Subject: [PATCH 2/5] Updating dependencies steps to output directly to console --- Src/runcpp2/DependenciesHelper.cpp | 22 +++++++++++++++------- Src/runcpp2/ProfileHelper.cpp | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Src/runcpp2/DependenciesHelper.cpp b/Src/runcpp2/DependenciesHelper.cpp index 2b01ec3..5ec1d36 100644 --- a/Src/runcpp2/DependenciesHelper.cpp +++ b/Src/runcpp2/DependenciesHelper.cpp @@ -248,7 +248,8 @@ namespace const std::unordered_map< PlatformName, runcpp2::Data::ProfilesCommands> steps, const std::string& dependenciesCopiedDirectory, - bool required) + bool required, + bool redirectIO) { ssLOG_FUNC_INFO(); @@ -291,18 +292,22 @@ namespace std::string output; if(!runcpp2::RunCommand(commands->at(k), - true, + redirectIO, processedDependencyPath, output, returnCode)) { ssLOG_ERROR("Failed to run command with result: " << returnCode); ssLOG_ERROR("Was trying to run: " << commands->at(k)); - ssLOG_ERROR("Output: \n" << output); + if(redirectIO) + ssLOG_ERROR("Output: \n" << output); return false; } else - ssLOG_INFO("Output: \n" << output); + { + if(redirectIO) + ssLOG_INFO("Output: \n" << output); + } } return true; @@ -499,6 +504,7 @@ bool runcpp2::CleanupDependencies( const runcpp2::Data::Profile& profile, if(!RunDependenciesSteps( profile, availableDependencies.at(i)->Cleanup, dependenciesLocalCopiesPaths.at(i), + false, false)) { ssLOG_ERROR("Failed to cleanup dependency " << availableDependencies.at(i)->Name); @@ -586,7 +592,8 @@ bool runcpp2::SetupDependenciesIfNeeded(const runcpp2::Data::Profile& profile, if(!RunDependenciesSteps( profile, availableDependencies.at(i)->Setup, dependenciesLocalCopiesPaths.at(i), - true)) + true, + false)) { ssLOG_ERROR("Failed to setup dependency " << availableDependencies.at(i)->Name); @@ -694,7 +701,8 @@ bool runcpp2::BuildDependencies(const runcpp2::Data::Profile& profile, if(!RunDependenciesSteps( profile, availableDependencies.at(i)->Build, dependenciesLocalCopiesPaths.at(i), - true)) + true, + false)) { ssLOG_ERROR("Failed to build dependency " << availableDependencies.at(i)->Name); return false; @@ -971,7 +979,7 @@ bool runcpp2::GatherDependenciesBinaries( const std::vector Date: Sun, 23 Feb 2025 13:47:50 +0000 Subject: [PATCH 3/5] Fixing include record being updated despite compile failure --- Src/runcpp2/runcpp2.cpp | 96 ++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/Src/runcpp2/runcpp2.cpp b/Src/runcpp2/runcpp2.cpp index d28517e..e7886f3 100644 --- a/Src/runcpp2/runcpp2.cpp +++ b/Src/runcpp2/runcpp2.cpp @@ -130,22 +130,6 @@ namespace } } - //Update the include records - runcpp2::SourceIncludeMap sourcesIncludes; - if(!runcpp2::GatherFilesIncludes(sourcesNeedGathering, includePaths, sourcesIncludes)) - return false; - - for(auto it = sourcesIncludes.cbegin(); it != sourcesIncludes.cend(); ++it) - { - ssLOG_DEBUG("Updating include record for " << it->first); - if(!includeManager.WriteIncludeRecord( ghc::filesystem::path(it->first), - it->second)) - { - ssLOG_ERROR("Failed to write include record for " << it->first); - return false; - } - } - return true; } @@ -456,10 +440,7 @@ runcpp2::StartPipeline( const std::string& scriptPath, configPreferredProfile); if(profileIndex == -1) - { - ssLOG_ERROR("Failed to find a profile to run"); return PipelineResult::NO_AVAILABLE_PROFILE; - } //Parsing the script, setting up dependencies, compiling and linking std::vector filesToCopyPaths; @@ -586,34 +567,6 @@ runcpp2::StartPipeline( const std::string& scriptPath, return PipelineResult::UNEXPECTED_FAILURE; } - //Update the include records - { - runcpp2::SourceIncludeMap sourcesIncludes; - if(!runcpp2::GatherFilesIncludes(sourceFiles, includePaths, sourcesIncludes)) - return PipelineResult::UNEXPECTED_FAILURE; - - for(int i = 0; i < sourceFiles.size(); ++i) - { - ssLOG_DEBUG("Updating include record for " << sourceFiles.at(i).string()); - if(!sourceHasCache.at(i)) - { - if(sourcesIncludes.count(sourceFiles.at(i)) == 0) - { - ssLOG_WARNING("Includes not gathered for " << sourceFiles.at(i).string()); - continue; - } - - if(!includeManager.WriteIncludeRecord( sourceFiles.at(i), - sourcesIncludes.at(sourceFiles.at(i)))) - { - ssLOG_ERROR("Failed to write include record for " << - sourceFiles.at(i).string()); - return PipelineResult::UNEXPECTED_FAILURE; - } - } - } - } - std::vector linkFilesPaths; SeparateDependencyFiles(profiles.at(profileIndex).FilesTypes, gatheredBinariesPaths, @@ -664,6 +617,49 @@ runcpp2::StartPipeline( const std::string& scriptPath, for(int i = 0; i < cachedObjectsFiles.size(); ++i) linkFilesPaths.push_back(cachedObjectsFiles.at(i)); + auto updateIncludeRecords = + [ + &sourceFiles, + &includePaths, + &sourceHasCache, + &includeManager + ] () -> PipelineResult + { + runcpp2::SourceIncludeMap sourcesIncludes; + if(!runcpp2::GatherFilesIncludes(sourceFiles, includePaths, sourcesIncludes)) + return PipelineResult::UNEXPECTED_FAILURE; + + for(int i = 0; i < sourceFiles.size(); ++i) + { + ssLOG_DEBUG("Updating include record for " << sourceFiles.at(i).string()); + if(!sourceHasCache.at(i)) + { + if(sourcesIncludes.count(sourceFiles.at(i)) == 0) + { + ssLOG_WARNING( "Includes not gathered for " << + sourceFiles.at(i).string()); + continue; + } + + if + ( + !includeManager.WriteIncludeRecord + ( + sourceFiles.at(i), + sourcesIncludes.at(sourceFiles.at(i)) + ) + ) + { + ssLOG_ERROR("Failed to write include record for " << + sourceFiles.at(i).string()); + return PipelineResult::UNEXPECTED_FAILURE; + } + } + } + + return PipelineResult::SUCCESS; + }; + if(currentOptions.count(CmdOptions::WATCH) > 0) { if(!CompileScriptOnly( buildDir, @@ -680,7 +676,7 @@ runcpp2::StartPipeline( const std::string& scriptPath, return PipelineResult::COMPILE_LINK_FAILED; } - return PipelineResult::SUCCESS; + return updateIncludeRecords(); } else if(!CompileAndLinkScript( buildDir, absoluteScriptPath, @@ -698,6 +694,10 @@ runcpp2::StartPipeline( const std::string& scriptPath, ssLOG_ERROR("Failed to compile or link script"); return PipelineResult::COMPILE_LINK_FAILED; } + + result = updateIncludeRecords(); + if(result != PipelineResult::SUCCESS) + return result; } } From f00862a28db46e4bb127c7bea2fbd6cbdec7c7a2 Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sun, 23 Feb 2025 13:47:59 +0000 Subject: [PATCH 4/5] Updating TODO doc --- mkdocs/docs/TODO.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkdocs/docs/TODO.md b/mkdocs/docs/TODO.md index d087e93..9f1a726 100644 --- a/mkdocs/docs/TODO.md +++ b/mkdocs/docs/TODO.md @@ -19,7 +19,8 @@ - Add ability to reference local YAML for user config - Add version for user config and prompt for update - Add wildcard support for filenames and extensions (Files Globbing) - +- Add the ability to query script build directory +- Add the ability to list script dependencies ## Not planned yet From afdd9aa7e31b8016fa74ce5d1da95c4cffe8e997 Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sun, 23 Feb 2025 13:48:25 +0000 Subject: [PATCH 5/5] Updating ssLogger --- External/ssLogger | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/External/ssLogger b/External/ssLogger index bb97084..50fa5b2 160000 --- a/External/ssLogger +++ b/External/ssLogger @@ -1 +1 @@ -Subproject commit bb97084ac47b2316d595afabd253c6b3dcbbd1d6 +Subproject commit 50fa5b277f5c5c1a6b1e0b59ee436280d8c2fe3e