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 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/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{}(sourceFile.string()); + ghc::filesystem::path cleanSourceFile = sourceFile.lexically_normal(); + std::size_t pathHash = std::hash{}(cleanSourceFile.string()); return IncludeRecordDir / (std::to_string(pathHash) + ".Includes"); } } diff --git a/Src/runcpp2/ProfileHelper.cpp b/Src/runcpp2/ProfileHelper.cpp index 838d0b2..bc67889 100644 --- a/Src/runcpp2/ProfileHelper.cpp +++ b/Src/runcpp2/ProfileHelper.cpp @@ -202,7 +202,7 @@ int runcpp2::GetPreferredProfileIndex( const std::string& scriptPath, if(availableProfiles.empty()) { - ssLOG_ERROR("No compilers/linkers found"); + ssLOG_ERROR("No compilers/linkers found that can be used for " << scriptPath); return -1; } 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; } } 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