mirror of
https://github.com/reactos/CMake.git
synced 2024-11-28 05:50:42 +00:00
cmOutputConverter: Moved ContainedInDirectory to cmStateDirectory
This commit is contained in:
parent
87e810f223
commit
33f08eec18
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user