From 23a1645c79b4aff52caf07545892c46e193fdbb6 Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sat, 16 Nov 2024 11:09:11 +0000 Subject: [PATCH 1/2] Adding IncludePaths for script info --- DefaultYAMLs/DefaultScriptInfo.yaml | 11 +- Examples/test.cpp | 9 +- Include/runcpp2/CompilingLinking.hpp | 2 + Include/runcpp2/Data/ScriptInfo.hpp | 1 + Include/runcpp2/PipelineSteps.hpp | 11 ++ Src/Tests/Data/ScriptInfoTest.cpp | 19 ++- Src/runcpp2/CompilingLinking.cpp | 20 ++- Src/runcpp2/Data/ScriptInfo.cpp | 38 ++++++ Src/runcpp2/PipelineSteps.cpp | 195 ++++++++++++++++++++++++++- Src/runcpp2/runcpp2.cpp | 102 +++----------- 10 files changed, 303 insertions(+), 105 deletions(-) diff --git a/DefaultYAMLs/DefaultScriptInfo.yaml b/DefaultYAMLs/DefaultScriptInfo.yaml index 034fe31..66d2782 100644 --- a/DefaultYAMLs/DefaultScriptInfo.yaml +++ b/DefaultYAMLs/DefaultScriptInfo.yaml @@ -57,13 +57,22 @@ OtherFilesToBeCompiled: DefaultProfile: - "./AnotherSourceFile.cpp" +# (Optional) Include paths (relative to script file path) for each platform and profile +IncludePaths: + # Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix) + DefaultPlatform: + # Target Profile (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile) + DefaultProfile: + - "./include" + - "./src/include" + # (Optional) Define cross-compiler defines for each platform and profile. # Defines can be specified as just a name or as a name-value pair. Defines: # Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix) DefaultPlatform: # Profile name (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile) - "DefaultProfile": + DefaultProfile: - "EXAMPLE_DEFINE" # Define without a value - "VERSION_MAJOR=1" # Define with a value diff --git a/Examples/test.cpp b/Examples/test.cpp index ed5e846..00cda4b 100755 --- a/Examples/test.cpp +++ b/Examples/test.cpp @@ -17,6 +17,11 @@ PassScriptPath: true "msvc": - "./OtherSources/AnotherSourceFileMSVC.cpp" +IncludePaths: + DefaultPlatform: + DefaultProfile: + - "./OtherSources" + Defines: DefaultPlatform: # Turns into `TEST_DEF=\"Test Define Working\"` in shell @@ -104,11 +109,11 @@ PassScriptPath: true #include "System2.hpp" #if defined(__GNUC__) - #include "./OtherSources/AnotherSourceFileGcc.hpp" + #include "AnotherSourceFileGcc.hpp" #endif #if defined(_MSC_VER) - #include "./OtherSources/AnotherSourceFileMSVC.hpp" + #include "AnotherSourceFileMSVC.hpp" #endif #include diff --git a/Include/runcpp2/CompilingLinking.hpp b/Include/runcpp2/CompilingLinking.hpp index 33cda54..8481112 100644 --- a/Include/runcpp2/CompilingLinking.hpp +++ b/Include/runcpp2/CompilingLinking.hpp @@ -14,6 +14,7 @@ namespace runcpp2 const ghc::filesystem::path& scriptPath, const std::vector& sourceFiles, const std::vector& sourceHasCache, + const std::vector& includePaths, const Data::ScriptInfo& scriptInfo, const std::vector& availableDependencies, const Data::Profile& profile, @@ -25,6 +26,7 @@ namespace runcpp2 const std::string& outputName, const std::vector& sourceFiles, const std::vector& sourceHasCache, + const std::vector& includePaths, const Data::ScriptInfo& scriptInfo, const std::vector& availableDependencies, const Data::Profile& profile, diff --git a/Include/runcpp2/Data/ScriptInfo.hpp b/Include/runcpp2/Data/ScriptInfo.hpp index 66eeb2e..132b839 100644 --- a/Include/runcpp2/Data/ScriptInfo.hpp +++ b/Include/runcpp2/Data/ScriptInfo.hpp @@ -27,6 +27,7 @@ namespace runcpp2 std::unordered_map OverrideLinkFlags; std::unordered_map OtherFilesToBeCompiled; + std::unordered_map IncludePaths; std::vector Dependencies; diff --git a/Include/runcpp2/PipelineSteps.hpp b/Include/runcpp2/PipelineSteps.hpp index 6400412..b3f78e1 100644 --- a/Include/runcpp2/PipelineSteps.hpp +++ b/Include/runcpp2/PipelineSteps.hpp @@ -105,6 +105,17 @@ namespace runcpp2 const Data::Profile& profile, const std::unordered_map& currentOptions, ghc::filesystem::path& outTarget); + + bool GatherSourceFiles( const ghc::filesystem::path& absoluteScriptPath, + const Data::ScriptInfo& scriptInfo, + const Data::Profile& currentProfile, + std::vector& outSourcePaths); + + bool GatherIncludePaths(const ghc::filesystem::path& scriptDirectory, + const Data::ScriptInfo& scriptInfo, + const Data::Profile& currentProfile, + const std::vector& dependencies, + std::vector& outIncludePaths); } diff --git a/Src/Tests/Data/ScriptInfoTest.cpp b/Src/Tests/Data/ScriptInfoTest.cpp index 310c089..196f36d 100644 --- a/Src/Tests/Data/ScriptInfoTest.cpp +++ b/Src/Tests/Data/ScriptInfoTest.cpp @@ -37,6 +37,10 @@ int main(int argc, char** argv) MSVC: - src/extra.cpp - src/debug.cpp + IncludePaths: + Windows: + MSVC: + - include Defines: Windows: MSVC: @@ -152,12 +156,21 @@ int main(int argc, char** argv) //Verify OtherFilesToBeCompiled ssTEST_OUTPUT_SETUP ( - const std::vector& msvcFiles = + const std::vector& msvcCompileFiles = scriptInfo.OtherFilesToBeCompiled.at("Windows").CompilesFiles.at("MSVC"); ); - ssTEST_OUTPUT_ASSERT("MSVC files count", msvcFiles.size() == 2); - ssTEST_OUTPUT_ASSERT("MSVC first file", msvcFiles.at(0) == "src/extra.cpp"); + ssTEST_OUTPUT_ASSERT("MSVC files count", msvcCompileFiles.size() == 2); + ssTEST_OUTPUT_ASSERT("MSVC first file", msvcCompileFiles.at(0) == "src/extra.cpp"); + //Verify IncludePaths + ssTEST_OUTPUT_SETUP + ( + const std::vector& msvcIncludeFiles = + scriptInfo.IncludePaths.at("Windows").CompilesFiles.at("MSVC"); + ); + ssTEST_OUTPUT_ASSERT("IncludePaths count", msvcIncludeFiles.size() == 1); + ssTEST_OUTPUT_ASSERT("IncludePaths first path", msvcIncludeFiles.at(0) == "include"); + //Verify Defines ssTEST_OUTPUT_SETUP ( diff --git a/Src/runcpp2/CompilingLinking.cpp b/Src/runcpp2/CompilingLinking.cpp index adbc38a..ef6ba69 100644 --- a/Src/runcpp2/CompilingLinking.cpp +++ b/Src/runcpp2/CompilingLinking.cpp @@ -69,6 +69,7 @@ namespace bool CompileScript( const ghc::filesystem::path& buildDir, const ghc::filesystem::path& scriptPath, const std::vector& sourceFiles, + const std::vector& includePaths, const runcpp2::Data::ScriptInfo& scriptInfo, const std::vector& availableDependencies, const runcpp2::Data::Profile& profile, @@ -100,18 +101,11 @@ namespace substitutionMapTemplate["{CompileFlags}"] = {compileFlags}; } - //Include Directories + //Add script and dependency include paths + for(const ghc::filesystem::path& includePath : includePaths) { - for(int i = 0; i < availableDependencies.size(); ++i) - { - for(int j = 0; j < availableDependencies.at(i)->AbsoluteIncludePaths.size(); ++j) - { - const std::string& currentIncludePath = - availableDependencies.at(i)->AbsoluteIncludePaths.at(j); - - substitutionMapTemplate["{IncludeDirectoryPath}"].push_back(currentIncludePath); - } - } + std::string processedInclude = runcpp2::ProcessPath(includePath.string()); + substitutionMapTemplate["{IncludeDirectoryPath}"].push_back(processedInclude); } // Add defines @@ -643,6 +637,7 @@ bool runcpp2::CompileScriptOnly(const ghc::filesystem::path& buildDir, const ghc::filesystem::path& scriptPath, const std::vector& sourceFiles, const std::vector& sourceHasCache, + const std::vector& includePaths, const Data::ScriptInfo& scriptInfo, const std::vector& availableDependencies, const Data::Profile& profile, @@ -667,6 +662,7 @@ bool runcpp2::CompileScriptOnly(const ghc::filesystem::path& buildDir, if(!CompileScript( buildDir, scriptPath, sourceFilesNeededToCompile, + includePaths, scriptInfo, availableDependencies, profile, @@ -685,6 +681,7 @@ bool runcpp2::CompileAndLinkScript( const ghc::filesystem::path& buildDir, const std::string& outputName, const std::vector& sourceFiles, const std::vector& sourceHasCache, + const std::vector& includePaths, const Data::ScriptInfo& scriptInfo, const std::vector& availableDependencies, const Data::Profile& profile, @@ -711,6 +708,7 @@ bool runcpp2::CompileAndLinkScript( const ghc::filesystem::path& buildDir, if(!CompileScript( buildDir, scriptPath, sourceFilesNeededToCompile, + includePaths, scriptInfo, availableDependencies, profile, diff --git a/Src/runcpp2/Data/ScriptInfo.cpp b/Src/runcpp2/Data/ScriptInfo.cpp index 4ab6bff..39ecd23 100644 --- a/Src/runcpp2/Data/ScriptInfo.cpp +++ b/Src/runcpp2/Data/ScriptInfo.cpp @@ -17,6 +17,7 @@ bool runcpp2::Data::ScriptInfo::ParseYAML_Node(ryml::ConstNodeRef& node) NodeRequirement("OverrideCompileFlags", ryml::NodeType_e::MAP, false, true), NodeRequirement("OverrideLinkFlags", ryml::NodeType_e::MAP, false, true), NodeRequirement("OtherFilesToBeCompiled", ryml::NodeType_e::MAP, false, true), + NodeRequirement("IncludePaths", ryml::NodeType_e::MAP, false, true), NodeRequirement("Dependencies", ryml::NodeType_e::SEQ, false, true), NodeRequirement("Defines", ryml::NodeType_e::MAP, false, true), NodeRequirement("Setup", ryml::NodeType_e::MAP, false, true), @@ -126,6 +127,23 @@ bool runcpp2::Data::ScriptInfo::ParseYAML_Node(ryml::ConstNodeRef& node) OtherFilesToBeCompiled[platform] = compilesFiles; } } + + if(ExistAndHasChild(node, "IncludePaths")) + { + for(int i = 0; i < node["IncludePaths"].num_children(); ++i) + { + ProfilesCompilesFiles includePaths; + ryml::ConstNodeRef currentProfileMapNode = node["IncludePaths"][i]; + PlatformName platform = GetKey(currentProfileMapNode); + + if(!includePaths.ParseYAML_Node(currentProfileMapNode)) + { + ssLOG_ERROR("ScriptInfo: Failed to parse IncludePaths."); + return false; + } + IncludePaths[platform] = includePaths; + } + } if(ExistAndHasChild(node, "Dependencies")) { @@ -290,6 +308,16 @@ std::string runcpp2::Data::ScriptInfo::ToString(std::string indentation) const out += it->second.ToString(indentation + " "); } } + + if(!IncludePaths.empty()) + { + out += indentation + "IncludePaths:\n"; + for(auto it = IncludePaths.begin(); it != IncludePaths.end(); ++it) + { + out += indentation + " " + it->first + ":\n"; + out += it->second.ToString(indentation + " "); + } + } if(!Dependencies.empty()) { @@ -365,6 +393,7 @@ bool runcpp2::Data::ScriptInfo::Equals(const ScriptInfo& other) const OverrideCompileFlags.size() != other.OverrideCompileFlags.size() || OverrideLinkFlags.size() != other.OverrideLinkFlags.size() || OtherFilesToBeCompiled.size() != other.OtherFilesToBeCompiled.size() || + IncludePaths.size() != other.IncludePaths.size() || Dependencies.size() != other.Dependencies.size() || Defines.size() != other.Defines.size() || Setup.size() != other.Setup.size() || @@ -412,6 +441,15 @@ bool runcpp2::Data::ScriptInfo::Equals(const ScriptInfo& other) const } } + for(const auto& it : IncludePaths) + { + if( other.IncludePaths.count(it.first) == 0 || + !other.IncludePaths.at(it.first).Equals(it.second)) + { + return false; + } + } + for(size_t i = 0; i < Dependencies.size(); ++i) { if(!Dependencies[i].Equals(other.Dependencies[i])) diff --git a/Src/runcpp2/PipelineSteps.cpp b/Src/runcpp2/PipelineSteps.cpp index b6e84e5..d72b9b8 100644 --- a/Src/runcpp2/PipelineSteps.cpp +++ b/Src/runcpp2/PipelineSteps.cpp @@ -274,7 +274,7 @@ runcpp2::PipelineResult runcpp2::ValidateInputs(const std::string& scriptPath, return PipelineResult::INVALID_SCRIPT_PATH; } - outAbsoluteScriptPath = ghc::filesystem::absolute(scriptPath); + outAbsoluteScriptPath = ghc::filesystem::absolute(ghc::filesystem::canonical(scriptPath, _)); outScriptDirectory = outAbsoluteScriptPath.parent_path(); outScriptName = outAbsoluteScriptPath.stem().string(); @@ -591,6 +591,35 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir, ssLOG_DEBUG("Wrote current script info to " << lastScriptInfoFilePath.string()); } + //Check if include paths have changed + std::vector currentIncludePaths; + if(!GatherIncludePaths( scriptDirectory, + scriptInfo, + profile, + {}, //Empty dependencies since we're just comparing paths + currentIncludePaths)) + { + ssLOG_ERROR("Failed to gather current include paths"); + return PipelineResult::UNEXPECTED_FAILURE; + } + + std::vector lastIncludePaths; + if(lastScriptInfo && !GatherIncludePaths( scriptDirectory, + *lastScriptInfo, + profile, + {}, // Empty dependencies + lastIncludePaths)) + { + ssLOG_ERROR("Failed to gather last include paths"); + return PipelineResult::UNEXPECTED_FAILURE; + } + + if(currentIncludePaths != lastIncludePaths) + { + ssLOG_INFO("Include paths have changed"); + outRecompileNeeded = true; + } + return PipelineResult::SUCCESS; } @@ -875,3 +904,167 @@ runcpp2::GetTargetPath( const ghc::filesystem::path& buildDir, return PipelineResult::SUCCESS; } + +bool runcpp2::GatherSourceFiles(const ghc::filesystem::path& absoluteScriptPath, + const Data::ScriptInfo& scriptInfo, + const Data::Profile& currentProfile, + std::vector& outSourcePaths) +{ + if(!currentProfile.FileExtensions.count(absoluteScriptPath.extension())) + { + ssLOG_ERROR("File extension of script doesn't match profile"); + return false; + } + + if(!absoluteScriptPath.is_absolute()) + { + ssLOG_ERROR("Script path is not absolute: " << absoluteScriptPath); + return false; + } + + outSourcePaths.clear(); + outSourcePaths.push_back(absoluteScriptPath); + + const Data::ProfilesCompilesFiles* compileFiles = + GetValueFromPlatformMap(scriptInfo.OtherFilesToBeCompiled); + + if(compileFiles == nullptr) + { + ssLOG_INFO("No other files to be compiled files current platform"); + + if(!scriptInfo.OtherFilesToBeCompiled.empty()) + { + ssLOG_WARNING( "Other source files are present, " + "but none are included for current configuration. Is this intended?"); + } + return true; + } + + const std::vector* profileCompileFiles = + GetValueFromProfileMap(currentProfile, compileFiles->CompilesFiles); + + if(!profileCompileFiles) + { + ssLOG_INFO("No other files to be compiled for current profile"); + return true; + } + + //TODO: Allow filepaths to contain wildcards as follows + //* as directory or filename wildcard + //i.e. "./*/test/*.cpp" will match "./moduleA/test/a.cpp" and "./moduleB/test/b.cpp" + + //** as recursive directory wildcard + //i.e. "./**/*.cpp" will match any .cpp files + //i.e. "./**/test.cpp" will match any files named "test.cpp" + + //For the time being, each entry will represent a path + { + const ghc::filesystem::path scriptDirectory = + ghc::filesystem::path(absoluteScriptPath).parent_path(); + + for(int i = 0; i < profileCompileFiles->size(); ++i) + { + ghc::filesystem::path currentPath = profileCompileFiles->at(i); + if(currentPath.is_relative()) + currentPath = scriptDirectory / currentPath; + + if(currentPath.is_relative()) + { + ssLOG_ERROR("Failed to process compile path: " << profileCompileFiles->at(i)); + ssLOG_ERROR("Try to append path to script directory but failed"); + ssLOG_ERROR("Final appended path: " << currentPath); + return false; + } + + std::error_code e; + if(ghc::filesystem::is_directory(currentPath, e)) + { + ssLOG_ERROR("Directory is found instead of file: " << + profileCompileFiles->at(i)); + return false; + } + + if(!ghc::filesystem::exists(currentPath, e)) + { + ssLOG_ERROR("File doesn't exist: " << profileCompileFiles->at(i)); + return false; + } + + outSourcePaths.push_back(currentPath); + } + } + + return true; +} + +bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory, + const Data::ScriptInfo& scriptInfo, + const Data::Profile& currentProfile, + const std::vector& dependencies, + std::vector& outIncludePaths) +{ + ssLOG_FUNC_DEBUG(); + outIncludePaths.clear(); + + if(!scriptDirectory.is_absolute()) + { + ssLOG_ERROR("Script directory is not absolute: " << scriptDirectory); + return false; + } + + //Get include paths from script + const Data::ProfilesCompilesFiles* includePaths = + GetValueFromPlatformMap(scriptInfo.IncludePaths); + + outIncludePaths.push_back(scriptDirectory); + + if(includePaths != nullptr) + { + const std::vector* profileIncludePaths = + GetValueFromProfileMap(currentProfile, includePaths->CompilesFiles); + + if(profileIncludePaths != nullptr) + { + for(const auto& currentPath : *profileIncludePaths) + { + ghc::filesystem::path resolvedPath = currentPath; + if(currentPath.is_relative()) + resolvedPath = scriptDirectory / currentPath; + + if(resolvedPath.is_relative()) + { + ssLOG_ERROR("Failed to process include path: " << currentPath); + ssLOG_ERROR("Try to append path to script directory but failed"); + ssLOG_ERROR("Final appended path: " << resolvedPath); + return false; + } + + std::error_code e; + if(!ghc::filesystem::exists(resolvedPath, e)) + { + ssLOG_ERROR("Include path doesn't exist: " << currentPath); + ssLOG_ERROR("Fullpath: " << resolvedPath); + return false; + } + + if(!ghc::filesystem::is_directory(resolvedPath, e)) + { + ssLOG_ERROR("Include path is not a directory: " << currentPath); + ssLOG_ERROR("Fullpath: " << resolvedPath); + return false; + } + + outIncludePaths.push_back(resolvedPath); + } + } + } + + //Get include paths from dependencies + for(const Data::DependencyInfo* dependency : dependencies) + { + for(const std::string& includePath : dependency->AbsoluteIncludePaths) + outIncludePaths.push_back(ghc::filesystem::path(includePath)); + } + + return true; +} diff --git a/Src/runcpp2/runcpp2.cpp b/Src/runcpp2/runcpp2.cpp index 8103278..fa2de69 100644 --- a/Src/runcpp2/runcpp2.cpp +++ b/Src/runcpp2/runcpp2.cpp @@ -27,92 +27,6 @@ extern "C" const size_t DefaultScriptInfo_size; namespace { - bool GatherSourceFiles( ghc::filesystem::path absoluteScriptPath, - const runcpp2::Data::ScriptInfo& scriptInfo, - const runcpp2::Data::Profile& currentProfile, - std::vector& outSourcePaths) - { - if(!currentProfile.FileExtensions.count(absoluteScriptPath.extension())) - { - ssLOG_ERROR("File extension of script doesn't match profile"); - return false; - } - - outSourcePaths.clear(); - outSourcePaths.push_back(absoluteScriptPath); - - const runcpp2::Data::ProfilesCompilesFiles* compileFiles = - runcpp2::GetValueFromPlatformMap(scriptInfo.OtherFilesToBeCompiled); - - if(compileFiles == nullptr) - { - ssLOG_INFO("No other files to be compiled files current platform"); - - if(!scriptInfo.OtherFilesToBeCompiled.empty()) - { - ssLOG_WARNING( "Other source files are present, " - "but none are included for current configuration. Is this intended?"); - } - return true; - } - - const std::vector* profileCompileFiles = - runcpp2::GetValueFromProfileMap(currentProfile, compileFiles->CompilesFiles); - - if(!profileCompileFiles) - { - ssLOG_INFO("No other files to be compiled for current profile"); - return true; - } - - //TODO: Allow filepaths to contain wildcards as follows - //* as directory or filename wildcard - //i.e. "./*/test/*.cpp" will match "./moduleA/test/a.cpp" and "./moduleB/test/b.cpp" - - //** as recursive directory wildcard - //i.e. "./**/*.cpp" will match any .cpp files - //i.e. "./**/test.cpp" will match any files named "test.cpp" - - //For the time being, each entry will represent a path - { - const ghc::filesystem::path scriptDirectory = - ghc::filesystem::path(absoluteScriptPath).parent_path(); - - for(int i = 0; i < profileCompileFiles->size(); ++i) - { - ghc::filesystem::path currentPath = profileCompileFiles->at(i); - if(currentPath.is_relative()) - currentPath = scriptDirectory / currentPath; - - if(currentPath.is_relative()) - { - ssLOG_ERROR("Failed to process compile path: " << profileCompileFiles->at(i)); - ssLOG_ERROR("Try to append path to script directory but failed"); - ssLOG_ERROR("Final appended path: " << currentPath); - return false; - } - - std::error_code e; - if(ghc::filesystem::is_directory(currentPath, e)) - { - ssLOG_ERROR("Directory is found instead of file: " << - profileCompileFiles->at(i)); - return false; - } - - if(!ghc::filesystem::exists(currentPath, e)) - { - ssLOG_ERROR("File doesn't exist: " << profileCompileFiles->at(i)); - return false; - } - - outSourcePaths.push_back(currentPath); - } - } - - return true; - } - bool HasCompiledCache( const ghc::filesystem::path& scriptPath, const std::vector& sourceFiles, const ghc::filesystem::path& buildDir, @@ -466,7 +380,19 @@ runcpp2::StartPipeline( const std::string& scriptPath, { return PipelineResult::INVALID_SCRIPT_INFO; } - + + //Get all include paths + std::vector includePaths; + if(!GatherIncludePaths( scriptDirectory, + scriptInfo, + profiles.at(profileIndex), + availableDependencies, + includePaths)) + { + ssLOG_ERROR("Failed to gather include paths"); + return PipelineResult::INVALID_SCRIPT_INFO; + } + //Check if we have already compiled before. std::vector sourceHasCache; std::vector cachedObjectsFiles; @@ -539,6 +465,7 @@ runcpp2::StartPipeline( const std::string& scriptPath, absoluteScriptPath, sourceFiles, sourceHasCache, + includePaths, scriptInfo, availableDependencies, profiles.at(profileIndex), @@ -552,6 +479,7 @@ runcpp2::StartPipeline( const std::string& scriptPath, ghc::filesystem::path(absoluteScriptPath).stem(), sourceFiles, sourceHasCache, + includePaths, scriptInfo, availableDependencies, profiles.at(profileIndex), From 4e09bebcc7e32ccc7fcf57621a714a5af8cbfa0a Mon Sep 17 00:00:00 2001 From: Neko Box Coder Date: Sat, 16 Nov 2024 11:27:15 +0000 Subject: [PATCH 2/2] Renaming ProfilesCompilesFiles to ProfilesProcessPaths --- CMakeLists.txt | 2 +- ...ilesFiles.hpp => ProfilesProcessPaths.hpp} | 10 ++++---- Include/runcpp2/Data/ScriptInfo.hpp | 6 ++--- Src/Tests/CMakeLists.txt | 2 +- ...sTest.cpp => ProfilesProcessPathsTest.cpp} | 22 ++++++++--------- Src/Tests/Data/ScriptInfoTest.cpp | 4 ++-- Src/Tests/RunAllTests.bat | 2 +- Src/Tests/RunAllTests.sh | 2 +- ...ilesFiles.cpp => ProfilesProcessPaths.cpp} | 24 +++++++++---------- Src/runcpp2/Data/ScriptInfo.cpp | 4 ++-- Src/runcpp2/PipelineSteps.cpp | 12 +++++----- 11 files changed, 45 insertions(+), 45 deletions(-) rename Include/runcpp2/Data/{ProfilesCompilesFiles.hpp => ProfilesProcessPaths.hpp} (65%) rename Src/Tests/Data/{ProfilesCompilesFilesTest.cpp => ProfilesProcessPathsTest.cpp} (66%) rename Src/runcpp2/Data/{ProfilesCompilesFiles.cpp => ProfilesProcessPaths.cpp} (58%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03a983f..f5d39f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,7 @@ add_library(runcpp2 STATIC "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCommands.cpp" "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesFlagsOverride.cpp" "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ScriptInfo.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesCompilesFiles.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesProcessPaths.cpp" "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesTypesInfo.cpp" "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/StageInfo.cpp" "${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesDefines.cpp" diff --git a/Include/runcpp2/Data/ProfilesCompilesFiles.hpp b/Include/runcpp2/Data/ProfilesProcessPaths.hpp similarity index 65% rename from Include/runcpp2/Data/ProfilesCompilesFiles.hpp rename to Include/runcpp2/Data/ProfilesProcessPaths.hpp index 3d83040..9f1bea8 100644 --- a/Include/runcpp2/Data/ProfilesCompilesFiles.hpp +++ b/Include/runcpp2/Data/ProfilesProcessPaths.hpp @@ -1,5 +1,5 @@ -#ifndef RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP -#define RUNCPP2_DATA_PROFILES_COMPILES_FILES_HPP +#ifndef RUNCPP2_DATA_PROFILES_PROCESS_PATHS_HPP +#define RUNCPP2_DATA_PROFILES_PROCESS_PATHS_HPP #include "runcpp2/Data/ParseCommon.hpp" @@ -14,14 +14,14 @@ namespace runcpp2 { namespace Data { - class ProfilesCompilesFiles + class ProfilesProcessPaths { public: - std::unordered_map> CompilesFiles; + std::unordered_map> Paths; bool ParseYAML_Node(ryml::ConstNodeRef& node); std::string ToString(std::string indentation) const; - bool Equals(const ProfilesCompilesFiles& other) const; + bool Equals(const ProfilesProcessPaths& other) const; }; } } diff --git a/Include/runcpp2/Data/ScriptInfo.hpp b/Include/runcpp2/Data/ScriptInfo.hpp index 132b839..c42b40d 100644 --- a/Include/runcpp2/Data/ScriptInfo.hpp +++ b/Include/runcpp2/Data/ScriptInfo.hpp @@ -4,7 +4,7 @@ #include "runcpp2/Data/DependencyInfo.hpp" #include "runcpp2/Data/ProfilesFlagsOverride.hpp" #include "runcpp2/Data/ParseCommon.hpp" -#include "runcpp2/Data/ProfilesCompilesFiles.hpp" +#include "runcpp2/Data/ProfilesProcessPaths.hpp" #include "runcpp2/Data/ProfilesDefines.hpp" #include "runcpp2/Data/ProfilesCommands.hpp" @@ -26,8 +26,8 @@ namespace runcpp2 std::unordered_map OverrideCompileFlags; std::unordered_map OverrideLinkFlags; - std::unordered_map OtherFilesToBeCompiled; - std::unordered_map IncludePaths; + std::unordered_map OtherFilesToBeCompiled; + std::unordered_map IncludePaths; std::vector Dependencies; diff --git a/Src/Tests/CMakeLists.txt b/Src/Tests/CMakeLists.txt index c073075..2208f5e 100644 --- a/Src/Tests/CMakeLists.txt +++ b/Src/Tests/CMakeLists.txt @@ -23,7 +23,7 @@ create_data_test(FlagsOverrideInfoTest) create_data_test(DependencySourceTest) create_data_test(FilesToCopyInfoTest) create_data_test(ProfilesCommandsTest) -create_data_test(ProfilesCompilesFilesTest) +create_data_test(ProfilesProcessPathsTest) create_data_test(ProfilesDefinesTest) create_data_test(DependencyLinkPropertyTest) create_data_test(FilesTypesInfoTest) diff --git a/Src/Tests/Data/ProfilesCompilesFilesTest.cpp b/Src/Tests/Data/ProfilesProcessPathsTest.cpp similarity index 66% rename from Src/Tests/Data/ProfilesCompilesFilesTest.cpp rename to Src/Tests/Data/ProfilesProcessPathsTest.cpp index 6f948a9..cd5de6d 100644 --- a/Src/Tests/Data/ProfilesCompilesFilesTest.cpp +++ b/Src/Tests/Data/ProfilesProcessPathsTest.cpp @@ -1,4 +1,4 @@ -#include "runcpp2/Data/ProfilesCompilesFiles.hpp" +#include "runcpp2/Data/ProfilesProcessPaths.hpp" #include "ssTest.hpp" #include "runcpp2/YamlLib.hpp" #include "runcpp2/runcpp2.hpp" @@ -9,7 +9,7 @@ int main(int argc, char** argv) ssTEST_INIT_TEST_GROUP(); - ssTEST("ProfilesCompilesFiles Should Parse Valid YAML") + ssTEST("ProfilesProcessPaths Should Parse Valid YAML") { ssTEST_OUTPUT_SETUP ( @@ -25,42 +25,42 @@ int main(int argc, char** argv) ryml::Tree tree = ryml::parse_in_arena(c4::to_csubstr(yamlStr)); ryml::ConstNodeRef root = tree.rootref(); - runcpp2::Data::ProfilesCompilesFiles profilesCompilesFiles; + runcpp2::Data::ProfilesProcessPaths profilesProcessPaths; ); ssTEST_OUTPUT_EXECUTION ( ryml::ConstNodeRef nodeRef = root; - bool parseResult = profilesCompilesFiles.ParseYAML_Node(nodeRef); + bool parseResult = profilesProcessPaths.ParseYAML_Node(nodeRef); ); ssTEST_OUTPUT_ASSERT("ParseYAML_Node should succeed", parseResult); //Verify parsed values ssTEST_OUTPUT_ASSERT( "MSVC files count", - profilesCompilesFiles.CompilesFiles.at("MSVC").size() == 2); + profilesProcessPaths.Paths.at("MSVC").size() == 2); ssTEST_OUTPUT_ASSERT( "GCC files count", - profilesCompilesFiles.CompilesFiles.at("GCC").size() == 2); + profilesProcessPaths.Paths.at("GCC").size() == 2); ssTEST_OUTPUT_ASSERT( "MSVC first file", - profilesCompilesFiles.CompilesFiles.at("MSVC").at(0) == + profilesProcessPaths.Paths.at("MSVC").at(0) == "src/main.cpp"); ssTEST_OUTPUT_ASSERT( "GCC last file", - profilesCompilesFiles.CompilesFiles.at("GCC").at(1) == + profilesProcessPaths.Paths.at("GCC").at(1) == "src/optimized.cpp"); //Test ToString() and Equals() ssTEST_OUTPUT_EXECUTION ( - std::string yamlOutput = profilesCompilesFiles.ToString(""); + std::string yamlOutput = profilesProcessPaths.ToString(""); ryml::Tree outputTree = ryml::parse_in_arena(ryml::to_csubstr(yamlOutput)); - runcpp2::Data::ProfilesCompilesFiles parsedOutput; + runcpp2::Data::ProfilesProcessPaths parsedOutput; nodeRef = outputTree.rootref(); parsedOutput.ParseYAML_Node(nodeRef); ); ssTEST_OUTPUT_ASSERT( "Parsed output should equal original", - profilesCompilesFiles.Equals(parsedOutput)); + profilesProcessPaths.Equals(parsedOutput)); }; ssTEST_END_TEST_GROUP(); diff --git a/Src/Tests/Data/ScriptInfoTest.cpp b/Src/Tests/Data/ScriptInfoTest.cpp index 196f36d..ba755ff 100644 --- a/Src/Tests/Data/ScriptInfoTest.cpp +++ b/Src/Tests/Data/ScriptInfoTest.cpp @@ -157,7 +157,7 @@ int main(int argc, char** argv) ssTEST_OUTPUT_SETUP ( const std::vector& msvcCompileFiles = - scriptInfo.OtherFilesToBeCompiled.at("Windows").CompilesFiles.at("MSVC"); + scriptInfo.OtherFilesToBeCompiled.at("Windows").Paths.at("MSVC"); ); ssTEST_OUTPUT_ASSERT("MSVC files count", msvcCompileFiles.size() == 2); ssTEST_OUTPUT_ASSERT("MSVC first file", msvcCompileFiles.at(0) == "src/extra.cpp"); @@ -166,7 +166,7 @@ int main(int argc, char** argv) ssTEST_OUTPUT_SETUP ( const std::vector& msvcIncludeFiles = - scriptInfo.IncludePaths.at("Windows").CompilesFiles.at("MSVC"); + scriptInfo.IncludePaths.at("Windows").Paths.at("MSVC"); ); ssTEST_OUTPUT_ASSERT("IncludePaths count", msvcIncludeFiles.size() == 1); ssTEST_OUTPUT_ASSERT("IncludePaths first path", msvcIncludeFiles.at(0) == "include"); diff --git a/Src/Tests/RunAllTests.bat b/Src/Tests/RunAllTests.bat index b2bf57f..88785ec 100644 --- a/Src/Tests/RunAllTests.bat +++ b/Src/Tests/RunAllTests.bat @@ -43,7 +43,7 @@ CALL :RUN_TEST "%~dp0\%MODE%FlagsOverrideInfoTest.exe" CALL :RUN_TEST "%~dp0\%MODE%DependencySourceTest.exe" CALL :RUN_TEST "%~dp0\%MODE%ProfilesCommandsTest.exe" CALL :RUN_TEST "%~dp0\%MODE%FilesToCopyInfoTest.exe" -CALL :RUN_TEST "%~dp0\%MODE%ProfilesCompilesFilesTest.exe" +CALL :RUN_TEST "%~dp0\%MODE%ProfilesProcessPathsTest.exe" CALL :RUN_TEST "%~dp0\%MODE%ProfilesDefinesTest.exe" CALL :RUN_TEST "%~dp0\%MODE%DependencyLinkPropertyTest.exe" CALL :RUN_TEST "%~dp0\%MODE%FilesTypesInfoTest.exe" diff --git a/Src/Tests/RunAllTests.sh b/Src/Tests/RunAllTests.sh index 209dc41..97b904c 100755 --- a/Src/Tests/RunAllTests.sh +++ b/Src/Tests/RunAllTests.sh @@ -19,7 +19,7 @@ runTest ./FlagsOverrideInfoTest runTest ./DependencySourceTest runTest ./ProfilesCommandsTest runTest ./FilesToCopyInfoTest -runTest ./ProfilesCompilesFilesTest +runTest ./ProfilesProcessPathsTest runTest ./ProfilesDefinesTest runTest ./DependencyLinkPropertyTest runTest ./FilesTypesInfoTest diff --git a/Src/runcpp2/Data/ProfilesCompilesFiles.cpp b/Src/runcpp2/Data/ProfilesProcessPaths.cpp similarity index 58% rename from Src/runcpp2/Data/ProfilesCompilesFiles.cpp rename to Src/runcpp2/Data/ProfilesProcessPaths.cpp index 3c26ecf..7aa2839 100644 --- a/Src/runcpp2/Data/ProfilesCompilesFiles.cpp +++ b/Src/runcpp2/Data/ProfilesProcessPaths.cpp @@ -1,8 +1,8 @@ -#include "runcpp2/Data/ProfilesCompilesFiles.hpp" +#include "runcpp2/Data/ProfilesProcessPaths.hpp" #include "runcpp2/ParseUtil.hpp" #include "ssLogger/ssLog.hpp" -bool runcpp2::Data::ProfilesCompilesFiles::ParseYAML_Node(ryml::ConstNodeRef& node) +bool runcpp2::Data::ProfilesProcessPaths::ParseYAML_Node(ryml::ConstNodeRef& node) { ssLOG_FUNC_DEBUG(); @@ -10,7 +10,7 @@ bool runcpp2::Data::ProfilesCompilesFiles::ParseYAML_Node(ryml::ConstNodeRef& no if(!node.is_map()) { - ssLOG_ERROR("ProfilesCompilesFiles: Not a map type"); + ssLOG_ERROR("ProfilesProcessPaths: Not a map type"); return false; } @@ -18,7 +18,7 @@ bool runcpp2::Data::ProfilesCompilesFiles::ParseYAML_Node(ryml::ConstNodeRef& no { if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node[i].type().type, ryml::NodeType_e::SEQ)) { - ssLOG_ERROR("ProfilesCompilesFiles: CompileFiles type requires a list"); + ssLOG_ERROR("ProfilesProcessPaths: Paths type requires a list"); return false; } @@ -26,7 +26,7 @@ bool runcpp2::Data::ProfilesCompilesFiles::ParseYAML_Node(ryml::ConstNodeRef& no ProfileName profile = GetKey(currentProfilePathsNode); for(int j = 0; j < currentProfilePathsNode.num_children(); ++j) - CompilesFiles[profile].push_back(GetValue(currentProfilePathsNode[j])); + Paths[profile].push_back(GetValue(currentProfilePathsNode[j])); } return true; @@ -34,14 +34,14 @@ bool runcpp2::Data::ProfilesCompilesFiles::ParseYAML_Node(ryml::ConstNodeRef& no INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false); } -std::string runcpp2::Data::ProfilesCompilesFiles::ToString(std::string indentation) const +std::string runcpp2::Data::ProfilesProcessPaths::ToString(std::string indentation) const { std::string out; - if(CompilesFiles.empty()) + if(Paths.empty()) return out; - for(auto it = CompilesFiles.begin(); it != CompilesFiles.end(); ++it) + for(auto it = Paths.begin(); it != Paths.end(); ++it) { if(it->second.empty()) out += indentation + it->first + ": []\n"; @@ -56,14 +56,14 @@ std::string runcpp2::Data::ProfilesCompilesFiles::ToString(std::string indentati return out; } -bool runcpp2::Data::ProfilesCompilesFiles::Equals(const ProfilesCompilesFiles& other) const +bool runcpp2::Data::ProfilesProcessPaths::Equals(const ProfilesProcessPaths& other) const { - if(CompilesFiles.size() != other.CompilesFiles.size()) + if(Paths.size() != other.Paths.size()) return false; - for(const auto& it : CompilesFiles) + for(const auto& it : Paths) { - if(other.CompilesFiles.count(it.first) == 0 || other.CompilesFiles.at(it.first) != it.second) + if(other.Paths.count(it.first) == 0 || other.Paths.at(it.first) != it.second) return false; } diff --git a/Src/runcpp2/Data/ScriptInfo.cpp b/Src/runcpp2/Data/ScriptInfo.cpp index 39ecd23..bed17ff 100644 --- a/Src/runcpp2/Data/ScriptInfo.cpp +++ b/Src/runcpp2/Data/ScriptInfo.cpp @@ -115,7 +115,7 @@ bool runcpp2::Data::ScriptInfo::ParseYAML_Node(ryml::ConstNodeRef& node) { for(int i = 0; i < node["OtherFilesToBeCompiled"].num_children(); ++i) { - ProfilesCompilesFiles compilesFiles; + ProfilesProcessPaths compilesFiles; ryml::ConstNodeRef currentProfileMapNode = node["OtherFilesToBeCompiled"][i]; PlatformName platform = GetKey(currentProfileMapNode); @@ -132,7 +132,7 @@ bool runcpp2::Data::ScriptInfo::ParseYAML_Node(ryml::ConstNodeRef& node) { for(int i = 0; i < node["IncludePaths"].num_children(); ++i) { - ProfilesCompilesFiles includePaths; + ProfilesProcessPaths includePaths; ryml::ConstNodeRef currentProfileMapNode = node["IncludePaths"][i]; PlatformName platform = GetKey(currentProfileMapNode); diff --git a/Src/runcpp2/PipelineSteps.cpp b/Src/runcpp2/PipelineSteps.cpp index d72b9b8..53747fb 100644 --- a/Src/runcpp2/PipelineSteps.cpp +++ b/Src/runcpp2/PipelineSteps.cpp @@ -540,9 +540,9 @@ runcpp2::CheckScriptInfoChanges(const ghc::filesystem::path& buildDir, const Data::ProfilesFlagsOverride* currentCompileFlags = runcpp2::GetValueFromPlatformMap(scriptInfo.OverrideCompileFlags); - const Data::ProfilesCompilesFiles* lastCompileFiles = + const Data::ProfilesProcessPaths* lastCompileFiles = runcpp2::GetValueFromPlatformMap(lastInfo->OtherFilesToBeCompiled); - const Data::ProfilesCompilesFiles* currentCompileFiles = + const Data::ProfilesProcessPaths* currentCompileFiles = runcpp2::GetValueFromPlatformMap(scriptInfo.OtherFilesToBeCompiled); const Data::ProfilesDefines* lastDefines = @@ -925,7 +925,7 @@ bool runcpp2::GatherSourceFiles(const ghc::filesystem::path& absoluteScriptPath, outSourcePaths.clear(); outSourcePaths.push_back(absoluteScriptPath); - const Data::ProfilesCompilesFiles* compileFiles = + const Data::ProfilesProcessPaths* compileFiles = GetValueFromPlatformMap(scriptInfo.OtherFilesToBeCompiled); if(compileFiles == nullptr) @@ -941,7 +941,7 @@ bool runcpp2::GatherSourceFiles(const ghc::filesystem::path& absoluteScriptPath, } const std::vector* profileCompileFiles = - GetValueFromProfileMap(currentProfile, compileFiles->CompilesFiles); + GetValueFromProfileMap(currentProfile, compileFiles->Paths); if(!profileCompileFiles) { @@ -1013,7 +1013,7 @@ bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory } //Get include paths from script - const Data::ProfilesCompilesFiles* includePaths = + const Data::ProfilesProcessPaths* includePaths = GetValueFromPlatformMap(scriptInfo.IncludePaths); outIncludePaths.push_back(scriptDirectory); @@ -1021,7 +1021,7 @@ bool runcpp2::GatherIncludePaths( const ghc::filesystem::path& scriptDirectory if(includePaths != nullptr) { const std::vector* profileIncludePaths = - GetValueFromProfileMap(currentProfile, includePaths->CompilesFiles); + GetValueFromProfileMap(currentProfile, includePaths->Paths); if(profileIncludePaths != nullptr) {