cmState::Snapshot: Store components for current directories.

Remove this responsibility from cmLocalGenerator.
This commit is contained in:
Stephen Kelly 2015-05-04 23:08:19 +02:00
parent 57bdc1a2f7
commit 991f5e4968
4 changed files with 38 additions and 36 deletions

View File

@ -67,7 +67,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
this->Configured = false;
this->EmitUniversalBinaryFlags = true;
this->RelativePathsConfigured = false;
this->PathConversionsSetup = false;
this->BackwardsCompatibility = 0;
this->BackwardsCompatibilityFinal = false;
}
@ -196,22 +195,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->StateSnapshot.GetCurrentSourceDirectory());
cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath
(this->StateSnapshot.GetCurrentBinaryDirectory());
cmSystemTools::SplitPath(outdir,
this->StartOutputDirectoryComponents);
}
void cmLocalGenerator::ConfigureFinalPass()
{
this->Makefile->ConfigureFinalPass();
@ -2698,13 +2681,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;
@ -2719,20 +2695,18 @@ std::string cmLocalGenerator::Convert(const std::string& source,
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(
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);

View File

@ -443,7 +443,6 @@ protected:
void ConfigureRelativePaths();
std::string FindRelativePathTopSource();
std::string FindRelativePathTopBinary();
void SetupPathConversions();
virtual std::string ConvertToLinkReference(std::string const& lib,
OutputFormat format = SHELL);
@ -458,8 +457,6 @@ protected:
cmMakefile *Makefile;
cmState::Snapshot StateSnapshot;
cmGlobalGenerator *GlobalGenerator;
std::vector<std::string> StartDirectoryComponents;
std::vector<std::string> StartOutputDirectoryComponents;
cmLocalGenerator* Parent;
std::vector<cmLocalGenerator*> Children;
std::map<std::string, std::string> UniqueObjectNamesMap;
@ -484,7 +481,6 @@ protected:
std::string RelativePathTopSource;
std::string RelativePathTopBinary;
bool RelativePathsConfigured;
bool PathConversionsSetup;
cmIML_INT_uint64_t BackwardsCompatibility;
bool BackwardsCompatibilityFinal;

View File

@ -197,6 +197,8 @@ void cmState::Initialize()
this->Locations.clear();
this->OutputLocations.clear();
this->ParentPositions.clear();
this->CurrentSourceDirectoryComponents.clear();
this->CurrentBinaryDirectoryComponents.clear();
this->CreateSnapshot(Snapshot());
this->DefineProperty
@ -500,6 +502,10 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
this->ParentPositions.push_back(originSnapshot.Position);
this->Locations.resize(this->Locations.size() + 1);
this->OutputLocations.resize(this->OutputLocations.size() + 1);
this->CurrentSourceDirectoryComponents.resize(
this->CurrentSourceDirectoryComponents.size() + 1);
this->CurrentBinaryDirectoryComponents.resize(
this->CurrentBinaryDirectoryComponents.size() + 1);
return cmState::Snapshot(this, pos);
}
@ -523,6 +529,10 @@ void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
this->State->Locations[this->Position]);
this->State->Locations[this->Position] =
cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
cmSystemTools::SplitPath(
this->State->Locations[this->Position],
this->State->CurrentSourceDirectoryComponents[this->Position]);
}
const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
@ -539,6 +549,22 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
this->State->OutputLocations[this->Position] =
cmSystemTools::CollapseFullPath(
this->State->OutputLocations[this->Position]);
cmSystemTools::SplitPath(
this->State->OutputLocations[this->Position],
this->State->CurrentBinaryDirectoryComponents[this->Position]);
}
std::vector<std::string> const&
cmState::Snapshot::GetCurrentSourceDirectoryComponents()
{
return this->State->CurrentSourceDirectoryComponents[this->Position];
}
std::vector<std::string> const&
cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
{
return this->State->CurrentBinaryDirectoryComponents[this->Position];
}
bool cmState::Snapshot::IsValid() const

View File

@ -36,6 +36,9 @@ public:
const char* GetCurrentBinaryDirectory() const;
void SetCurrentBinaryDirectory(std::string const& dir);
std::vector<std::string> const& GetCurrentSourceDirectoryComponents();
std::vector<std::string> const& GetCurrentBinaryDirectoryComponents();
bool IsValid() const;
Snapshot GetParent() const;
@ -136,6 +139,9 @@ private:
std::vector<std::string> OutputLocations;
std::vector<PositionType> ParentPositions;
std::vector<std::vector<std::string> > CurrentSourceDirectoryComponents;
std::vector<std::vector<std::string> > CurrentBinaryDirectoryComponents;
std::vector<std::string> SourceDirectoryComponents;
std::vector<std::string> BinaryDirectoryComponents;
std::string SourceDirectory;