summaryrefslogtreecommitdiffstats
path: root/Source/cmState.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r--Source/cmState.cxx144
1 files changed, 71 insertions, 73 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 3278d56..6ca875d 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -18,6 +18,30 @@
#include <assert.h>
+struct cmState::SnapshotDataType
+{
+ cmState::PositionType DirectoryParent;
+ cmState::SnapshotType SnapshotType;
+ cmLinkedTree<cmState::BuildsystemDirectoryStateType>::iterator
+ BuildSystemDirectory;
+};
+
+struct cmState::BuildsystemDirectoryStateType
+{
+ std::string Location;
+ std::string OutputLocation;
+
+ std::vector<std::string> CurrentSourceDirectoryComponents;
+ std::vector<std::string> CurrentBinaryDirectoryComponents;
+ // The top-most directories for relative path conversion. Both the
+ // source and destination location of a relative path conversion
+ // must be underneath one of these directories (both under source or
+ // both under binary) in order for the relative path to be evaluated
+ // safely by the build tools.
+ std::string RelativePathTopSource;
+ std::string RelativePathTopBinary;
+};
+
cmState::cmState(cmake* cm)
: CMakeInstance(cm),
IsInTryCompile(false),
@@ -200,29 +224,8 @@ void cmState::Reset()
this->GlobalProperties.clear();
this->PropertyDefinitions.clear();
- assert(this->Locations.size() > 0);
- assert(this->OutputLocations.size() > 0);
- assert(this->ParentPositions.size() > 0);
- assert(this->CurrentSourceDirectoryComponents.size() > 0);
- assert(this->CurrentBinaryDirectoryComponents.size() > 0);
- assert(this->RelativePathTopSource.size() > 0);
- assert(this->RelativePathTopBinary.size() > 0);
-
- this->Locations.erase(this->Locations.begin() + 1, this->Locations.end());
- this->OutputLocations.erase(this->OutputLocations.begin() + 1,
- this->OutputLocations.end());
- this->ParentPositions.erase(this->ParentPositions.begin() + 1,
- this->ParentPositions.end());
- this->CurrentSourceDirectoryComponents.erase(
- this->CurrentSourceDirectoryComponents.begin() + 1,
- this->CurrentSourceDirectoryComponents.end());
- this->CurrentBinaryDirectoryComponents.erase(
- this->CurrentBinaryDirectoryComponents.begin() + 1,
- this->CurrentBinaryDirectoryComponents.end());
- this->RelativePathTopSource.erase(this->RelativePathTopSource.begin() + 1,
- this->RelativePathTopSource.end());
- this->RelativePathTopBinary.erase(this->RelativePathTopBinary.begin() + 1,
- this->RelativePathTopBinary.end());
+ this->BuildsystemDirectory.Truncate();
+ this->SnapshotData.Truncate();
this->DefineProperty
("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY,
@@ -612,7 +615,7 @@ void cmState::Snapshot::ComputeRelativePathTopSource()
result = currentSource;
}
}
- this->State->RelativePathTopSource[this->Position] = result;
+ this->Position->BuildSystemDirectory->RelativePathTopSource = result;
}
void cmState::Snapshot::ComputeRelativePathTopBinary()
@@ -651,24 +654,21 @@ void cmState::Snapshot::ComputeRelativePathTopBinary()
// is a network path.
if(result.size() < 2 || result.substr(0, 2) != "//")
{
- this->State->RelativePathTopBinary[this->Position] = result;
+ this->Position->BuildSystemDirectory->RelativePathTopBinary = result;
}
else
{
- this->State->RelativePathTopBinary[this->Position] = "";
+ this->Position->BuildSystemDirectory->RelativePathTopBinary = "";
}
}
cmState::Snapshot cmState::CreateBaseSnapshot()
{
- PositionType pos = 0;
- this->ParentPositions.push_back(pos);
- this->Locations.resize(1);
- this->OutputLocations.resize(1);
- this->CurrentSourceDirectoryComponents.resize(1);
- this->CurrentBinaryDirectoryComponents.resize(1);
- this->RelativePathTopSource.resize(1);
- this->RelativePathTopBinary.resize(1);
+ PositionType pos = this->SnapshotData.Extend(this->SnapshotData.Root());
+ pos->DirectoryParent = this->SnapshotData.Root();
+ pos->SnapshotType = BuildsystemDirectoryType;
+ pos->BuildSystemDirectory =
+ this->BuildsystemDirectory.Extend(this->BuildsystemDirectory.Root());
return cmState::Snapshot(this, pos);
}
@@ -676,16 +676,12 @@ cmState::Snapshot
cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot)
{
assert(originSnapshot.IsValid());
- PositionType pos = this->ParentPositions.size();
- 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);
- this->RelativePathTopSource.resize(this->RelativePathTopSource.size() + 1);
- this->RelativePathTopBinary.resize(this->RelativePathTopBinary.size() + 1);
+ PositionType pos = this->SnapshotData.Extend(originSnapshot.Position);
+ pos->DirectoryParent = originSnapshot.Position;
+ pos->SnapshotType = BuildsystemDirectoryType;
+ pos->BuildSystemDirectory =
+ this->BuildsystemDirectory.Extend(
+ originSnapshot.Position->BuildSystemDirectory);
return cmState::Snapshot(this, pos);
}
@@ -698,92 +694,94 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position)
const char* cmState::Snapshot::GetCurrentSourceDirectory() const
{
- return this->State->Locations[this->Position].c_str();
+ return this->Position->BuildSystemDirectory->Location.c_str();
}
void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir)
{
assert(this->State);
- assert(this->State->Locations.size() > this->Position);
- this->State->Locations[this->Position] = dir;
- cmSystemTools::ConvertToUnixSlashes(
- this->State->Locations[this->Position]);
- this->State->Locations[this->Position] =
- cmSystemTools::CollapseFullPath(this->State->Locations[this->Position]);
+ std::string& loc = this->Position->BuildSystemDirectory->Location;
+ loc = dir;
+ cmSystemTools::ConvertToUnixSlashes(loc);
+ loc = cmSystemTools::CollapseFullPath(loc);
cmSystemTools::SplitPath(
- this->State->Locations[this->Position],
- this->State->CurrentSourceDirectoryComponents[this->Position]);
+ loc,
+ this->Position->BuildSystemDirectory->CurrentSourceDirectoryComponents);
this->ComputeRelativePathTopSource();
}
const char* cmState::Snapshot::GetCurrentBinaryDirectory() const
{
- return this->State->OutputLocations[this->Position].c_str();
+ return this->Position->BuildSystemDirectory->OutputLocation.c_str();
}
void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir)
{
- assert(this->State->OutputLocations.size() > this->Position);
- this->State->OutputLocations[this->Position] = dir;
- cmSystemTools::ConvertToUnixSlashes(
- this->State->OutputLocations[this->Position]);
- this->State->OutputLocations[this->Position] =
- cmSystemTools::CollapseFullPath(
- this->State->OutputLocations[this->Position]);
+ std::string& loc = this->Position->BuildSystemDirectory->OutputLocation;
+ loc = dir;
+ cmSystemTools::ConvertToUnixSlashes(loc);
+ loc = cmSystemTools::CollapseFullPath(loc);
cmSystemTools::SplitPath(
- this->State->OutputLocations[this->Position],
- this->State->CurrentBinaryDirectoryComponents[this->Position]);
+ loc,
+ this->Position->BuildSystemDirectory->CurrentBinaryDirectoryComponents);
this->ComputeRelativePathTopBinary();
}
std::vector<std::string> const&
cmState::Snapshot::GetCurrentSourceDirectoryComponents()
{
- return this->State->CurrentSourceDirectoryComponents[this->Position];
+ return this->Position->BuildSystemDirectory
+ ->CurrentSourceDirectoryComponents;
}
std::vector<std::string> const&
cmState::Snapshot::GetCurrentBinaryDirectoryComponents()
{
- return this->State->CurrentBinaryDirectoryComponents[this->Position];
+ return this->Position->BuildSystemDirectory
+ ->CurrentBinaryDirectoryComponents;
}
const char* cmState::Snapshot::GetRelativePathTopSource() const
{
- return this->State->RelativePathTopSource[this->Position].c_str();
+ return this->Position->BuildSystemDirectory->RelativePathTopSource.c_str();
}
const char* cmState::Snapshot::GetRelativePathTopBinary() const
{
- return this->State->RelativePathTopBinary[this->Position].c_str();
+ return this->Position->BuildSystemDirectory->RelativePathTopBinary.c_str();
}
void cmState::Snapshot::SetRelativePathTopSource(const char* dir)
{
- this->State->RelativePathTopSource[this->Position] = dir;
+ this->Position->BuildSystemDirectory->RelativePathTopSource = dir;
}
void cmState::Snapshot::SetRelativePathTopBinary(const char* dir)
{
- this->State->RelativePathTopBinary[this->Position] = dir;
+ this->Position->BuildSystemDirectory->RelativePathTopBinary = dir;
}
bool cmState::Snapshot::IsValid() const
{
- return this->State ? true : false;
+ return this->State && this->Position.IsValid()
+ ? this->Position != this->State->SnapshotData.Root()
+ : false;
}
cmState::Snapshot cmState::Snapshot::GetBuildsystemDirectoryParent() const
{
Snapshot snapshot;
- if (!this->State || this->Position == 0)
+ if (!this->State || this->Position == this->State->SnapshotData.Root())
{
return snapshot;
}
- PositionType parentPos = this->State->ParentPositions[this->Position];
- snapshot = Snapshot(this->State, parentPos);
+ PositionType parentPos = this->Position->DirectoryParent;
+ if (parentPos != this->State->SnapshotData.Root())
+ {
+ snapshot = Snapshot(this->State, parentPos);
+ }
return snapshot;
}