summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-05-19 15:09:39 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-05-19 15:09:39 (GMT)
commitbe248ab435b4a538f29337b8d136729436a816b4 (patch)
tree3c4588a3f490b5c5ec38f0867075711d38263ba9 /Source/cmLocalGenerator.cxx
parent0cbc69b9ea97a44280350a58a365c617896e4589 (diff)
parentfa9eb814b36894635e22ffdcac3103ee980b0398 (diff)
downloadCMake-be248ab435b4a538f29337b8d136729436a816b4.zip
CMake-be248ab435b4a538f29337b8d136729436a816b4.tar.gz
CMake-be248ab435b4a538f29337b8d136729436a816b4.tar.bz2
Merge topic 'refactor-cmLocalGenerator'
fa9eb814 cmLocalGenerator: Remove redundant path access. 1933f3d1 cmLocalGenerator: Remove redundant path conversions. 9e4b6cc2 cmState: Store computed relative paths to to current directories. 991f5e49 cmState::Snapshot: Store components for current directories. 57bdc1a2 cmState: Compute and store directory components.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx162
1 files changed, 13 insertions, 149 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 29990af..0f18225 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -65,8 +65,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
this->UseRelativePaths = false;
this->Configured = false;
this->EmitUniversalBinaryFlags = true;
- this->RelativePathsConfigured = false;
- this->PathConversionsSetup = false;
this->BackwardsCompatibility = 0;
this->BackwardsCompatibilityFinal = false;
}
@@ -195,29 +193,6 @@ void cmLocalGenerator::ReadInputFile()
this->Makefile->ProcessBuildsystemFile(currentStart.c_str());
}
-void cmLocalGenerator::SetupPathConversions()
-{
- // Setup the current output directory components for use by
- // Convert
- std::string outdir;
- outdir =
- cmSystemTools::CollapseFullPath(this->GetState()->GetSourceDirectory());
- cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents);
- outdir = cmSystemTools::CollapseFullPath(
- this->StateSnapshot.GetCurrentSourceDirectory());
- cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
-
- outdir = cmSystemTools::CollapseFullPath
- (this->GetState()->GetBinaryDirectory());
- cmSystemTools::SplitPath(outdir,
- this->HomeOutputDirectoryComponents);
-
- outdir = cmSystemTools::CollapseFullPath
- (this->StateSnapshot.GetCurrentBinaryDirectory());
- cmSystemTools::SplitPath(outdir,
- this->StartOutputDirectoryComponents);
-}
-
void cmLocalGenerator::ConfigureFinalPass()
{
this->Makefile->ConfigureFinalPass();
@@ -389,12 +364,8 @@ void cmLocalGenerator::GenerateInstallRules()
// Create the install script file.
std::string file = this->StateSnapshot.GetCurrentBinaryDirectory();
std::string homedir = this->GetState()->GetBinaryDirectory();
- std::string currdir = this->StateSnapshot.GetCurrentBinaryDirectory();
- cmSystemTools::ConvertToUnixSlashes(file);
- cmSystemTools::ConvertToUnixSlashes(homedir);
- cmSystemTools::ConvertToUnixSlashes(currdir);
int toplevel_install = 0;
- if ( currdir == homedir )
+ if (file == homedir)
{
toplevel_install = 1;
}
@@ -2704,13 +2675,6 @@ std::string cmLocalGenerator::Convert(const std::string& source,
OutputFormat output,
bool optional)
{
- // Make sure the relative path conversion components are set.
- if(!this->PathConversionsSetup)
- {
- this->SetupPathConversions();
- this->PathConversionsSetup = true;
- }
-
// Convert the path to a relative path.
std::string result = source;
@@ -2720,25 +2684,23 @@ std::string cmLocalGenerator::Convert(const std::string& source,
{
case HOME:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->GetState()->GetSourceDirectoryComponents(), result);
break;
case START:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result = this->ConvertToRelativePath(this->StartDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result);
break;
case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result =
- this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->GetState()->GetBinaryDirectoryComponents(), result);
break;
case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
- result =
- this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
- result);
+ result = this->ConvertToRelativePath(
+ this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result);
break;
case FULL:
result = cmSystemTools::CollapseFullPath(result);
@@ -2811,97 +2773,6 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::FindRelativePathTopSource()
-{
- cmState::Snapshot snapshot = this->StateSnapshot;
- std::vector<cmState::Snapshot> snapshots;
- snapshots.push_back(snapshot);
- while (true)
- {
- snapshot = snapshot.GetParent();
- if (snapshot.IsValid())
- {
- snapshots.push_back(snapshot);
- }
- else
- {
- break;
- }
- }
-
- std::string result = snapshots.front().GetCurrentSourceDirectory();
-
- for (std::vector<cmState::Snapshot>::const_iterator it =
- snapshots.begin() + 1; it != snapshots.end(); ++it)
- {
- std::string currentSource = it->GetCurrentSourceDirectory();
- if(cmSystemTools::IsSubDirectory(result, currentSource))
- {
- result = currentSource;
- }
- }
-
- return result;
-}
-
-//----------------------------------------------------------------------------
-std::string cmLocalGenerator::FindRelativePathTopBinary()
-{
- cmState::Snapshot snapshot = this->StateSnapshot;
- std::vector<cmState::Snapshot> snapshots;
- snapshots.push_back(snapshot);
- while (true)
- {
- snapshot = snapshot.GetParent();
- if (snapshot.IsValid())
- {
- snapshots.push_back(snapshot);
- }
- else
- {
- break;
- }
- }
-
- std::string result = snapshots.front().GetCurrentBinaryDirectory();
-
- for (std::vector<cmState::Snapshot>::const_iterator it =
- snapshots.begin() + 1; it != snapshots.end(); ++it)
- {
- std::string currentBinary = it->GetCurrentBinaryDirectory();
- if(cmSystemTools::IsSubDirectory(result, currentBinary))
- {
- result = currentBinary;
- }
- }
-
- return result;
-}
-
-//----------------------------------------------------------------------------
-void cmLocalGenerator::ConfigureRelativePaths()
-{
- // Relative path conversion inside the source tree is not used to
- // construct relative paths passed to build tools so it is safe to
- // even when the source is a network path.
- std::string source = this->FindRelativePathTopSource();
- this->RelativePathTopSource = source;
-
- // The current working directory on Windows cannot be a network
- // path. Therefore relative paths cannot work when the binary tree
- // is a network path.
- std::string binary = this->FindRelativePathTopBinary();
- if(binary.size() < 2 || binary.substr(0, 2) != "//")
- {
- this->RelativePathTopBinary = binary;
- }
- else
- {
- this->RelativePathTopBinary = "";
- }
-}
-
-//----------------------------------------------------------------------------
static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
{
return (cmSystemTools::ComparePath(a, b) ||
@@ -2926,26 +2797,19 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
return in_remote;
}
- // Make sure relative path conversion is configured.
- if(!this->RelativePathsConfigured)
- {
- this->ConfigureRelativePaths();
- this->RelativePathsConfigured = true;
- }
-
if(!force)
{
// Skip conversion if the path and local are not both in the source
// or both in the binary tree.
std::string local_path = cmSystemTools::JoinPath(local);
if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
- this->RelativePathTopBinary.c_str()) &&
+ this->StateSnapshot.GetRelativePathTopBinary()) &&
cmLocalGeneratorNotAbove(in_remote.c_str(),
- this->RelativePathTopBinary.c_str())) ||
+ this->StateSnapshot.GetRelativePathTopBinary())) ||
(cmLocalGeneratorNotAbove(local_path.c_str(),
- this->RelativePathTopSource.c_str()) &&
+ this->StateSnapshot.GetRelativePathTopSource()) &&
cmLocalGeneratorNotAbove(in_remote.c_str(),
- this->RelativePathTopSource.c_str()))))
+ this->StateSnapshot.GetRelativePathTopSource()))))
{
return in_remote;
}