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->Configured = false;
this->EmitUniversalBinaryFlags = true; this->EmitUniversalBinaryFlags = true;
this->RelativePathsConfigured = false; this->RelativePathsConfigured = false;
this->PathConversionsSetup = false;
this->BackwardsCompatibility = 0; this->BackwardsCompatibility = 0;
this->BackwardsCompatibilityFinal = false; this->BackwardsCompatibilityFinal = false;
} }
@ -196,22 +195,6 @@ void cmLocalGenerator::ReadInputFile()
this->Makefile->ProcessBuildsystemFile(currentStart.c_str()); 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() void cmLocalGenerator::ConfigureFinalPass()
{ {
this->Makefile->ConfigureFinalPass(); this->Makefile->ConfigureFinalPass();
@ -2698,13 +2681,6 @@ std::string cmLocalGenerator::Convert(const std::string& source,
OutputFormat output, OutputFormat output,
bool optional) 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. // Convert the path to a relative path.
std::string result = source; std::string result = source;
@ -2719,20 +2695,18 @@ std::string cmLocalGenerator::Convert(const std::string& source,
break; break;
case START: case START:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->ConvertToRelativePath(this->StartDirectoryComponents, result = this->ConvertToRelativePath(
result); this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result);
break; break;
case HOME_OUTPUT: case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = result = this->ConvertToRelativePath(
this->ConvertToRelativePath( this->GetState()->GetBinaryDirectoryComponents(), result);
this->GetState()->GetBinaryDirectoryComponents(), result);
break; break;
case START_OUTPUT: case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = result = this->ConvertToRelativePath(
this->ConvertToRelativePath(this->StartOutputDirectoryComponents, this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result);
result);
break; break;
case FULL: case FULL:
result = cmSystemTools::CollapseFullPath(result); result = cmSystemTools::CollapseFullPath(result);

View File

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

View File

@ -197,6 +197,8 @@ void cmState::Initialize()
this->Locations.clear(); this->Locations.clear();
this->OutputLocations.clear(); this->OutputLocations.clear();
this->ParentPositions.clear(); this->ParentPositions.clear();
this->CurrentSourceDirectoryComponents.clear();
this->CurrentBinaryDirectoryComponents.clear();
this->CreateSnapshot(Snapshot()); this->CreateSnapshot(Snapshot());
this->DefineProperty this->DefineProperty
@ -500,6 +502,10 @@ cmState::Snapshot cmState::CreateSnapshot(Snapshot originSnapshot)
this->ParentPositions.push_back(originSnapshot.Position); this->ParentPositions.push_back(originSnapshot.Position);
this->Locations.resize(this->Locations.size() + 1); this->Locations.resize(this->Locations.size() + 1);
this->OutputLocations.resize(this->OutputLocations.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); 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]);
this->State->Locations[this->Position] = this->State->Locations[this->Position] =
cmSystemTools::CollapseFullPath(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 const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
@ -539,6 +549,22 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
this->State->OutputLocations[this->Position] = this->State->OutputLocations[this->Position] =
cmSystemTools::CollapseFullPath( cmSystemTools::CollapseFullPath(
this->State->OutputLocations[this->Position]); 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 bool cmState::Snapshot::IsValid() const

View File

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