diff options
author | Bruno Manganelli <bruno.manga95@gmail.com> | 2018-11-23 02:16:51 (GMT) |
---|---|---|
committer | Bruno Manganelli <bruno.manga95@gmail.com> | 2018-12-08 11:24:06 (GMT) |
commit | 33f08eec18b440eac1f24f6f18b971c6203307bd (patch) | |
tree | efb4e1304611ce92cd8b6312f4dffa1cad6d2045 /Source | |
parent | 87e810f223bad6fb889e7ae4ad08be98461bf6e2 (diff) | |
download | CMake-33f08eec18b440eac1f24f6f18b971c6203307bd.zip CMake-33f08eec18b440eac1f24f6f18b971c6203307bd.tar.gz CMake-33f08eec18b440eac1f24f6f18b971c6203307bd.tar.bz2 |
cmOutputConverter: Moved ContainedInDirectory to cmStateDirectory
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDependsFortran.cxx | 4 | ||||
-rw-r--r-- | Source/cmLinkLineComputer.cxx | 3 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmOutputConverter.cxx | 35 | ||||
-rw-r--r-- | Source/cmOutputConverter.h | 5 | ||||
-rw-r--r-- | Source/cmStateDirectory.cxx | 17 | ||||
-rw-r--r-- | Source/cmStateDirectory.h | 3 |
8 files changed, 27 insertions, 46 deletions
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index d218b60..310af2d 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -697,8 +697,8 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile, std::string cmDependsFortran::MaybeConvertToRelativePath( std::string const& base, std::string const& path) { - if (!cmOutputConverter::ContainedInDirectory( - base, path, this->LocalGenerator->GetStateSnapshot().GetDirectory())) { + if (!this->LocalGenerator->GetStateSnapshot().GetDirectory().ContainsBoth( + base, path)) { return path; } return cmSystemTools::ForceToRelativePath(base, path); diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index d756564..6643990 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -47,8 +47,7 @@ std::string cmLinkLineComputer::ConvertToLinkReference( { std::string relLib = lib; - if (cmOutputConverter::ContainedInDirectory( - this->StateDir.GetCurrentBinary(), lib, this->StateDir)) { + if (this->StateDir.ContainsBoth(this->StateDir.GetCurrentBinary(), lib)) { relLib = cmSystemTools::ForceToRelativePath( this->StateDir.GetCurrentBinary(), lib); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ee38cfb..707a1b5 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -2093,8 +2093,7 @@ void cmLocalUnixMakefileGenerator3::CreateCDCommand( std::string cmLocalUnixMakefileGenerator3::MaybeConvertToRelativePath( std::string const& base, std::string const& path) { - if (!cmOutputConverter::ContainedInDirectory( - base, path, this->GetStateSnapshot().GetDirectory())) { + if (!this->GetStateSnapshot().GetDirectory().ContainsBoth(base, path)) { return path; } return cmSystemTools::ForceToRelativePath(base, path); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index e6f9830..cb41c28 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1308,8 +1308,7 @@ public: private: std::string MaybeConvertToRelativePath(std::string const& obj) { - if (!cmOutputConverter::ContainedInDirectory( - this->StateDir.GetCurrentBinary(), obj, this->StateDir)) { + if (!this->StateDir.ContainsBoth(this->StateDir.GetCurrentBinary(), obj)) { return obj; } return cmSystemTools::ForceToRelativePath( diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 58d31b9..011c7d8 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -9,7 +9,6 @@ #include <string.h> #include <vector> -#include "cmAlgorithms.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmSystemTools.h" @@ -73,41 +72,11 @@ std::string cmOutputConverter::ConvertDirectorySeparatorsForShell( return result; } -static bool cmOutputConverterNotAbove(const char* a, const char* b) -{ - return (cmSystemTools::ComparePath(a, b) || - cmSystemTools::IsSubDirectory(a, b)); -} - -bool cmOutputConverter::ContainedInDirectory(std::string const& local_path, - std::string const& remote_path, - cmStateDirectory const& directory) -{ - const std::string& relativePathTopBinary = - directory.GetRelativePathTopBinary(); - const std::string& relativePathTopSource = - directory.GetRelativePathTopSource(); - - const bool bothInBinary = - cmOutputConverterNotAbove(local_path.c_str(), - relativePathTopBinary.c_str()) && - cmOutputConverterNotAbove(remote_path.c_str(), - relativePathTopBinary.c_str()); - - const bool bothInSource = - cmOutputConverterNotAbove(local_path.c_str(), - relativePathTopSource.c_str()) && - cmOutputConverterNotAbove(remote_path.c_str(), - relativePathTopSource.c_str()); - - return bothInSource || bothInBinary; -} - std::string cmOutputConverter::ConvertToRelativePath( std::string const& local_path, std::string const& remote_path) const { - if (!ContainedInDirectory(local_path, remote_path, - this->StateSnapshot.GetDirectory())) { + if (!this->StateSnapshot.GetDirectory().ContainsBoth(local_path, + remote_path)) { return remote_path; } diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 38102e8..5a4f879 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -10,7 +10,6 @@ #include "cmStateSnapshot.h" class cmState; -class cmStateDirectory; class cmOutputConverter { @@ -92,10 +91,6 @@ public: }; static FortranFormat GetFortranFormat(const char* value); - static bool ContainedInDirectory(std::string const& local_path, - std::string const& remote_path, - cmStateDirectory const& directory); - /** * Convert the given remote path to a relative path with respect to * the given local path. Both paths must use forward slashes and not diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index f94e714..40f694c 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -138,6 +138,23 @@ void cmStateDirectory::SetRelativePathTopBinary(const char* dir) this->DirectoryState->RelativePathTopBinary = dir; } +bool cmStateDirectory::ContainsBoth(std::string const& local_path, + std::string const& remote_path) const +{ + auto PathEqOrSubDir = [](std::string const& a, std::string const& b) { + return (cmSystemTools::ComparePath(a, b) || + cmSystemTools::IsSubDirectory(a, b)); + }; + + bool bothInBinary = PathEqOrSubDir(local_path, GetRelativePathTopBinary()) && + PathEqOrSubDir(remote_path, GetRelativePathTopBinary()); + + bool bothInSource = PathEqOrSubDir(local_path, GetRelativePathTopSource()) && + PathEqOrSubDir(remote_path, GetRelativePathTopSource()); + + return bothInBinary || bothInSource; +} + cmStateDirectory::cmStateDirectory( cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator iter, const cmStateSnapshot& snapshot) diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h index e5f4d05..c4b18ad 100644 --- a/Source/cmStateDirectory.h +++ b/Source/cmStateDirectory.h @@ -32,6 +32,9 @@ public: void SetRelativePathTopSource(const char* dir); void SetRelativePathTopBinary(const char* dir); + bool ContainsBoth(std::string const& local_path, + std::string const& remote_path) const; + cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesEntryBacktraces() const; void AppendIncludeDirectoriesEntry(std::string const& vec, |