diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileCommand.cxx | 34 | ||||
-rw-r--r-- | Source/cmRuntimeDependencyArchive.cxx | 70 | ||||
-rw-r--r-- | Source/cmRuntimeDependencyArchive.h | 8 |
3 files changed, 72 insertions, 40 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 1088347..f2d4cda 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3041,6 +3041,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, std::vector<std::string> PreExcludeRegexes; std::vector<std::string> PostIncludeRegexes; std::vector<std::string> PostExcludeRegexes; + std::vector<std::string> PostIncludeFiles; + std::vector<std::string> PostExcludeFiles; + std::vector<std::string> PostExcludeFilesStrict; }; static auto const parser = @@ -3058,7 +3061,10 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, .Bind("PRE_INCLUDE_REGEXES"_s, &Arguments::PreIncludeRegexes) .Bind("PRE_EXCLUDE_REGEXES"_s, &Arguments::PreExcludeRegexes) .Bind("POST_INCLUDE_REGEXES"_s, &Arguments::PostIncludeRegexes) - .Bind("POST_EXCLUDE_REGEXES"_s, &Arguments::PostExcludeRegexes); + .Bind("POST_EXCLUDE_REGEXES"_s, &Arguments::PostExcludeRegexes) + .Bind("POST_INCLUDE_FILES"_s, &Arguments::PostIncludeFiles) + .Bind("POST_EXCLUDE_FILES"_s, &Arguments::PostExcludeFiles) + .Bind("POST_EXCLUDE_FILES_STRICT"_s, &Arguments::PostExcludeFilesStrict); std::vector<std::string> unrecognizedArguments; std::vector<std::string> keywordsMissingValues; @@ -3072,14 +3078,19 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, return false; } - const std::vector<std::string> LIST_ARGS = { "DIRECTORIES", - "EXECUTABLES", - "LIBRARIES", - "MODULES", - "POST_EXCLUDE_REGEXES", - "POST_INCLUDE_REGEXES", - "PRE_EXCLUDE_REGEXES", - "PRE_INCLUDE_REGEXES" }; + const std::vector<std::string> LIST_ARGS = { + "DIRECTORIES", + "EXECUTABLES", + "LIBRARIES", + "MODULES", + "POST_EXCLUDE_FILES", + "POST_EXCLUDE_FILES_STRICT", + "POST_EXCLUDE_REGEXES", + "POST_INCLUDE_FILES", + "POST_INCLUDE_REGEXES", + "PRE_EXCLUDE_REGEXES", + "PRE_INCLUDE_REGEXES", + }; auto kwbegin = keywordsMissingValues.cbegin(); auto kwend = cmRemoveMatching(keywordsMissingValues, LIST_ARGS); if (kwend != kwbegin) { @@ -3092,7 +3103,10 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args, cmRuntimeDependencyArchive archive( status, parsedArgs.Directories, parsedArgs.BundleExecutable, parsedArgs.PreIncludeRegexes, parsedArgs.PreExcludeRegexes, - parsedArgs.PostIncludeRegexes, parsedArgs.PostExcludeRegexes); + parsedArgs.PostIncludeRegexes, parsedArgs.PostExcludeRegexes, + std::move(parsedArgs.PostIncludeFiles), + std::move(parsedArgs.PostExcludeFiles), + std::move(parsedArgs.PostExcludeFilesStrict)); if (!archive.Prepare()) { cmSystemTools::SetFatalErrorOccured(); return false; diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 472f234..a6ed523 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -115,7 +115,10 @@ cmRuntimeDependencyArchive::cmRuntimeDependencyArchive( const std::vector<std::string>& preIncludeRegexes, const std::vector<std::string>& preExcludeRegexes, const std::vector<std::string>& postIncludeRegexes, - const std::vector<std::string>& postExcludeRegexes) + const std::vector<std::string>& postExcludeRegexes, + std::vector<std::string> postIncludeFiles, + std::vector<std::string> postExcludeFiles, + std::vector<std::string> postExcludeFilesStrict) : Status(status) , SearchDirectories(std::move(searchDirectories)) , BundleExecutable(std::move(bundleExecutable)) @@ -123,6 +126,9 @@ cmRuntimeDependencyArchive::cmRuntimeDependencyArchive( , PreExcludeRegexes(preExcludeRegexes.size()) , PostIncludeRegexes(postIncludeRegexes.size()) , PostExcludeRegexes(postExcludeRegexes.size()) + , PostIncludeFiles(std::move(postIncludeFiles)) + , PostExcludeFiles(std::move(postExcludeFiles)) + , PostExcludeFilesStrict(std::move(postExcludeFilesStrict)) { std::transform(preIncludeRegexes.begin(), preIncludeRegexes.end(), this->PreIncludeRegexes.begin(), TransformCompile); @@ -306,39 +312,45 @@ bool cmRuntimeDependencyArchive::GetGetRuntimeDependenciesCommand( bool cmRuntimeDependencyArchive::IsPreExcluded(const std::string& name) { cmsys::RegularExpressionMatch match; - - for (auto const& regex : this->PreIncludeRegexes) { - if (regex.find(name.c_str(), match)) { - return false; - } - } - - for (auto const& regex : this->PreExcludeRegexes) { - if (regex.find(name.c_str(), match)) { - return true; - } - } - - return false; + auto const regexMatch = + [&match, name](const cmsys::RegularExpression& regex) -> bool { + return regex.find(name.c_str(), match); + }; + auto const regexSearch = + [®exMatch]( + const std::vector<cmsys::RegularExpression>& regexes) -> bool { + return std::any_of(regexes.begin(), regexes.end(), regexMatch); + }; + + return !regexSearch(this->PreIncludeRegexes) && + regexSearch(this->PreExcludeRegexes); } bool cmRuntimeDependencyArchive::IsPostExcluded(const std::string& name) { cmsys::RegularExpressionMatch match; - - for (auto const& regex : this->PostIncludeRegexes) { - if (regex.find(name.c_str(), match)) { - return false; - } - } - - for (auto const& regex : this->PostExcludeRegexes) { - if (regex.find(name.c_str(), match)) { - return true; - } - } - - return false; + auto const regexMatch = + [&match, name](const cmsys::RegularExpression& regex) -> bool { + return regex.find(name.c_str(), match); + }; + auto const regexSearch = + [®exMatch]( + const std::vector<cmsys::RegularExpression>& regexes) -> bool { + return std::any_of(regexes.begin(), regexes.end(), regexMatch); + }; + auto const fileMatch = [name](const std::string& file) -> bool { + return cmSystemTools::SameFile(file, name); + }; + auto const fileSearch = + [&fileMatch](const std::vector<std::string>& files) -> bool { + return std::any_of(files.begin(), files.end(), fileMatch); + }; + + return fileSearch(this->PostExcludeFilesStrict) || + (!(regexSearch(this->PostIncludeRegexes) || + fileSearch(this->PostIncludeFiles)) && + (regexSearch(this->PostExcludeRegexes) || + fileSearch(this->PostExcludeFiles))); } void cmRuntimeDependencyArchive::AddResolvedPath(const std::string& name, diff --git a/Source/cmRuntimeDependencyArchive.h b/Source/cmRuntimeDependencyArchive.h index 7f3b8e9..1dc3261 100644 --- a/Source/cmRuntimeDependencyArchive.h +++ b/Source/cmRuntimeDependencyArchive.h @@ -25,7 +25,10 @@ public: const std::vector<std::string>& preIncludeRegexes, const std::vector<std::string>& preExcludeRegexes, const std::vector<std::string>& postIncludeRegexes, - const std::vector<std::string>& postExcludeRegexes); + const std::vector<std::string>& postExcludeRegexes, + std::vector<std::string> postIncludeFiles, + std::vector<std::string> postExcludeFiles, + std::vector<std::string> postExcludeFilesStrict); bool Prepare(); bool GetRuntimeDependencies(const std::vector<std::string>& executables, const std::vector<std::string>& libraries, @@ -62,6 +65,9 @@ private: std::vector<cmsys::RegularExpression> PreExcludeRegexes; std::vector<cmsys::RegularExpression> PostIncludeRegexes; std::vector<cmsys::RegularExpression> PostExcludeRegexes; + std::vector<std::string> PostIncludeFiles; + std::vector<std::string> PostExcludeFiles; + std::vector<std::string> PostExcludeFilesStrict; std::map<std::string, std::set<std::string>> ResolvedPaths; std::set<std::string> UnresolvedPaths; }; |