diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-05-24 11:00:20 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-05-24 11:30:24 (GMT) |
commit | 01e1cd5c1fc5e2684ec69d4916dd31ed23746055 (patch) | |
tree | 554d47feea8bc7a28abb753df88ab108c9997c9b /Source/cmState.cxx | |
parent | f69dcdfc380176a2c4365357c1ca85c0444087b0 (diff) | |
download | CMake-01e1cd5c1fc5e2684ec69d4916dd31ed23746055.zip CMake-01e1cd5c1fc5e2684ec69d4916dd31ed23746055.tar.gz CMake-01e1cd5c1fc5e2684ec69d4916dd31ed23746055.tar.bz2 |
cmState: Move snapshot creation to the cmake instance.
Don't create a snapshot in Initialize(), but leave the creation
responsibility to the cmake instance instead. Previously, the
cmState would Initialize() in its constructor, and the cmake instance
would re-Initialize() during Configure(). The end result was the
same and there would be one snapshot present. However, cmLocalGenerator
also created a snapshot on construction, and that one was used, leaving
the first snapshot unused, and potential for off-by-one errors.
Fix that by making the cmLocalGenerator use the existing snapshot
if it is top-level. Add a CurrentSnapshot to the cmake instance and
populated it while configuring a directory. This will eventually
replace the 'current local generator' concept. Fix the GetParent
implementation to be able to return the first snapshot.
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 4965ae3..389a316 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -22,7 +22,6 @@ cmState::cmState(cmake* cm) : CMakeInstance(cm), IsInTryCompile(false) { - this->Initialize(); } cmState::~cmState() @@ -190,19 +189,35 @@ void cmState::RemoveCacheEntryProperty(std::string const& key, ->GetCacheIterator(key.c_str()).SetProperty(propertyName, (void*)0); } -void cmState::Initialize() +void cmState::Reset() { this->GlobalProperties.clear(); this->PropertyDefinitions.clear(); - this->Locations.clear(); - this->OutputLocations.clear(); - this->ParentPositions.clear(); - this->CurrentSourceDirectoryComponents.clear(); - this->CurrentBinaryDirectoryComponents.clear(); - this->RelativePathTopSource.clear(); - this->RelativePathTopBinary.clear(); - - this->CreateSnapshot(Snapshot()); + + 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->DefineProperty ("RULE_LAUNCH_COMPILE", cmProperty::DIRECTORY, "", "", true); @@ -607,6 +622,7 @@ const char* cmState::Snapshot::GetCurrentSourceDirectory() const 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( @@ -681,15 +697,12 @@ bool cmState::Snapshot::IsValid() const cmState::Snapshot cmState::Snapshot::GetParent() const { Snapshot snapshot; - if (!this->State) + if (!this->State || this->Position == 0) { return snapshot; } PositionType parentPos = this->State->ParentPositions[this->Position]; - if (parentPos > 0) - { - snapshot = Snapshot(this->State, parentPos); - } + snapshot = Snapshot(this->State, parentPos); return snapshot; } |