Merge topic 'cmState-Directory'

9ebc7502 cmState: Extract a Directory class.
27ec21db cmState: Forward-declare a type earlier.
This commit is contained in:
Brad King 2015-07-21 09:22:19 -04:00 committed by CMake Topic Stage
commit ae64efa1ce
6 changed files with 142 additions and 102 deletions

View File

@ -70,7 +70,7 @@ void cmLocalGenerator::IssueMessage(cmake::MessageType t,
std::string const& text) const std::string const& text) const
{ {
cmListFileContext lfc; cmListFileContext lfc;
lfc.FilePath = this->StateSnapshot.GetCurrentSourceDirectory(); lfc.FilePath = this->StateSnapshot.GetDirectory().GetCurrentSource();
lfc.FilePath += "/CMakeLists.txt"; lfc.FilePath += "/CMakeLists.txt";
if(!this->GlobalGenerator->GetCMakeInstance()->GetIsInTryCompile()) if(!this->GlobalGenerator->GetCMakeInstance()->GetIsInTryCompile())
@ -161,7 +161,8 @@ void cmLocalGenerator::GenerateTestFiles()
const std::string& config = const std::string& config =
this->Makefile->GetConfigurations(configurationTypes, false); this->Makefile->GetConfigurations(configurationTypes, false);
std::string file = this->StateSnapshot.GetCurrentBinaryDirectory(); std::string file =
this->StateSnapshot.GetDirectory().GetCurrentBinary();
file += "/"; file += "/";
file += "CTestTestfile.cmake"; file += "CTestTestfile.cmake";
@ -170,9 +171,11 @@ void cmLocalGenerator::GenerateTestFiles()
fout << "# CMake generated Testfile for " << std::endl fout << "# CMake generated Testfile for " << std::endl
<< "# Source directory: " << "# Source directory: "
<< this->StateSnapshot.GetCurrentSourceDirectory() << std::endl << this->StateSnapshot.GetDirectory().GetCurrentSource()
<< std::endl
<< "# Build directory: " << "# Build directory: "
<< this->StateSnapshot.GetCurrentBinaryDirectory() << std::endl << this->StateSnapshot.GetDirectory().GetCurrentBinary()
<< std::endl
<< "# " << std::endl << "# " << std::endl
<< "# This file includes the relevant testing commands " << "# This file includes the relevant testing commands "
<< "required for " << std::endl << "required for " << std::endl
@ -286,7 +289,8 @@ void cmLocalGenerator::GenerateInstallRules()
} }
// Create the install script file. // Create the install script file.
std::string file = this->StateSnapshot.GetCurrentBinaryDirectory(); std::string file =
this->StateSnapshot.GetDirectory().GetCurrentBinary();
std::string homedir = this->GetState()->GetBinaryDirectory(); std::string homedir = this->GetState()->GetBinaryDirectory();
int toplevel_install = 0; int toplevel_install = 0;
if (file == homedir) if (file == homedir)
@ -299,7 +303,7 @@ void cmLocalGenerator::GenerateInstallRules()
// Write the header. // Write the header.
fout << "# Install script for directory: " fout << "# Install script for directory: "
<< this->StateSnapshot.GetCurrentSourceDirectory() << this->StateSnapshot.GetDirectory().GetCurrentSource()
<< std::endl << std::endl; << std::endl << std::endl;
fout << "# Set the install prefix" << std::endl fout << "# Set the install prefix" << std::endl
<< "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl << "if(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
@ -518,7 +522,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
source.GetFullPath(), source.GetFullPath(),
commandLines, commandLines,
comment.c_str(), comment.c_str(),
this->StateSnapshot.GetCurrentBinaryDirectory() this->StateSnapshot.GetDirectory().GetCurrentBinary()
); );
} }
@ -540,12 +544,13 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
!sf->GetPropertyAsBool("EXTERNAL_OBJECT")) !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
{ {
std::string dir_max; std::string dir_max;
dir_max += this->StateSnapshot.GetCurrentBinaryDirectory(); dir_max += this->StateSnapshot.GetDirectory().GetCurrentBinary();
dir_max += "/"; dir_max += "/";
std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max); std::string obj = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
if(!obj.empty()) if(!obj.empty())
{ {
std::string ofname = this->StateSnapshot.GetCurrentBinaryDirectory(); std::string ofname =
this->StateSnapshot.GetDirectory().GetCurrentBinary();
ofname += "/"; ofname += "/";
ofname += obj; ofname += obj;
objVector.push_back(ofname); objVector.push_back(ofname);
@ -615,7 +620,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
"", "",
commandLines, commandLines,
comment.c_str(), comment.c_str(),
this->StateSnapshot.GetCurrentBinaryDirectory() this->StateSnapshot.GetDirectory().GetCurrentBinary()
); );
this->Makefile->GetSource(targetFullPath); this->Makefile->GetSource(targetFullPath);
target.Target->AddSource(targetFullPath); target.Target->AddSource(targetFullPath);
@ -1369,20 +1374,20 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
// Store the automatic include paths. // Store the automatic include paths.
if(includeBinaryDir) if(includeBinaryDir)
{ {
if(emitted.find( std::string binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
this->StateSnapshot.GetCurrentBinaryDirectory()) == emitted.end()) if(emitted.find(binDir) == emitted.end())
{ {
dirs.push_back(this->StateSnapshot.GetCurrentBinaryDirectory()); dirs.push_back(binDir);
emitted.insert(this->StateSnapshot.GetCurrentBinaryDirectory()); emitted.insert(binDir);
} }
} }
if(includeSourceDir) if(includeSourceDir)
{ {
if(emitted.find( std::string srcDir = this->StateSnapshot.GetDirectory().GetCurrentSource();
this->StateSnapshot.GetCurrentSourceDirectory()) == emitted.end()) if(emitted.find(srcDir) == emitted.end())
{ {
dirs.push_back(this->StateSnapshot.GetCurrentSourceDirectory()); dirs.push_back(srcDir);
emitted.insert(this->StateSnapshot.GetCurrentSourceDirectory()); emitted.insert(srcDir);
} }
} }
@ -1983,7 +1988,7 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
// Treat the name as relative to the source directory in which it // Treat the name as relative to the source directory in which it
// was given. // was given.
dep = this->StateSnapshot.GetCurrentSourceDirectory(); dep = this->StateSnapshot.GetDirectory().GetCurrentSource();
dep += "/"; dep += "/";
dep += inName; dep += inName;
return true; return true;

View File

@ -530,10 +530,10 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile()
infoFileStream infoFileStream
<< "# Relative path conversion top directories.\n" << "# Relative path conversion top directories.\n"
<< "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \""
<< this->StateSnapshot.GetRelativePathTopSource() << this->StateSnapshot.GetDirectory().GetRelativePathTopSource()
<< "\")\n" << "\")\n"
<< "set(CMAKE_RELATIVE_PATH_TOP_BINARY \"" << "set(CMAKE_RELATIVE_PATH_TOP_BINARY \""
<< this->StateSnapshot.GetRelativePathTopBinary() << this->StateSnapshot.GetDirectory().GetRelativePathTopBinary()
<< "\")\n" << "\")\n"
<< "\n"; << "\n";
@ -1602,12 +1602,14 @@ cmLocalUnixMakefileGenerator3
if(const char* relativePathTopSource = if(const char* relativePathTopSource =
mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE"))
{ {
this->StateSnapshot.SetRelativePathTopSource(relativePathTopSource); this->StateSnapshot.GetDirectory()
.SetRelativePathTopSource(relativePathTopSource);
} }
if(const char* relativePathTopBinary = if(const char* relativePathTopBinary =
mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY"))
{ {
this->StateSnapshot.SetRelativePathTopBinary(relativePathTopBinary); this->StateSnapshot.GetDirectory()
.SetRelativePathTopBinary(relativePathTopBinary);
} }
} }
else else

View File

@ -1700,7 +1700,7 @@ public:
: Makefile(mf), ReportError(true) : Makefile(mf), ReportError(true)
{ {
std::string currentStart = std::string currentStart =
this->Makefile->StateSnapshot.GetCurrentSourceDirectory(); this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource();
currentStart += "/CMakeLists.txt"; currentStart += "/CMakeLists.txt";
this->Makefile->StateSnapshot.SetListFile(currentStart); this->Makefile->StateSnapshot.SetListFile(currentStart);
this->Makefile->PushPolicyBarrier(); this->Makefile->PushPolicyBarrier();
@ -1742,11 +1742,12 @@ void cmMakefile::Configure()
BuildsystemFileScope scope(this); BuildsystemFileScope scope(this);
// make sure the CMakeFiles dir is there // make sure the CMakeFiles dir is there
std::string filesDir = this->StateSnapshot.GetCurrentBinaryDirectory(); std::string filesDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
filesDir += cmake::GetCMakeFilesDirectory(); filesDir += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(filesDir.c_str()); cmSystemTools::MakeDirectory(filesDir.c_str());
std::string currentStart = this->StateSnapshot.GetCurrentSourceDirectory(); std::string currentStart =
this->StateSnapshot.GetDirectory().GetCurrentSource();
currentStart += "/CMakeLists.txt"; currentStart += "/CMakeLists.txt";
assert(cmSystemTools::FileExists(currentStart.c_str(), true)); assert(cmSystemTools::FileExists(currentStart.c_str(), true));
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str()); this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
@ -1878,27 +1879,27 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
void cmMakefile::SetCurrentSourceDirectory(const std::string& dir) void cmMakefile::SetCurrentSourceDirectory(const std::string& dir)
{ {
this->StateSnapshot.SetCurrentSourceDirectory(dir); this->StateSnapshot.GetDirectory().SetCurrentSource(dir);
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
this->StateSnapshot.GetCurrentSourceDirectory()); this->StateSnapshot.GetDirectory().GetCurrentSource());
} }
const char* cmMakefile::GetCurrentSourceDirectory() const const char* cmMakefile::GetCurrentSourceDirectory() const
{ {
return this->StateSnapshot.GetCurrentSourceDirectory(); return this->StateSnapshot.GetDirectory().GetCurrentSource();
} }
void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir) void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir)
{ {
this->StateSnapshot.SetCurrentBinaryDirectory(dir); this->StateSnapshot.GetDirectory().SetCurrentBinary(dir);
const char* binDir = this->StateSnapshot.GetCurrentBinaryDirectory(); const char* binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
cmSystemTools::MakeDirectory(binDir); cmSystemTools::MakeDirectory(binDir);
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", binDir); this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", binDir);
} }
const char* cmMakefile::GetCurrentBinaryDirectory() const const char* cmMakefile::GetCurrentBinaryDirectory() const
{ {
return this->StateSnapshot.GetCurrentBinaryDirectory(); return this->StateSnapshot.GetDirectory().GetCurrentBinary();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -4245,7 +4246,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
this->StateSnapshot.GetBuildsystemDirectoryParent(); this->StateSnapshot.GetBuildsystemDirectoryParent();
if(parent.IsValid()) if(parent.IsValid())
{ {
return parent.GetCurrentSourceDirectory(); return parent.GetDirectory().GetCurrentSource();
} }
return ""; return "";
} }

View File

@ -81,11 +81,15 @@ const char* cmOutputConverter::GetRelativeRootPath(RelativeRoot relroot) const
{ {
switch (relroot) switch (relroot)
{ {
case HOME: return this->GetState()->GetSourceDirectory(); case HOME:
case START: return this->StateSnapshot.GetCurrentSourceDirectory(); return this->GetState()->GetSourceDirectory();
case HOME_OUTPUT: return this->GetState()->GetBinaryDirectory(); case START:
case START_OUTPUT: return this->StateSnapshot.GetCurrentBinaryDirectory(); return this->StateSnapshot.GetDirectory().GetCurrentSource();
default: break; case HOME_OUTPUT:
return this->GetState()->GetBinaryDirectory();
case START_OUTPUT:
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
default: break;
} }
return 0; return 0;
} }
@ -105,7 +109,8 @@ std::string cmOutputConverter::Convert(const std::string& source,
break; break;
case START: case START:
result = this->ConvertToRelativePath( result = this->ConvertToRelativePath(
this->StateSnapshot.GetCurrentSourceDirectoryComponents(), result); this->StateSnapshot.GetDirectory().GetCurrentSourceComponents(),
result);
break; break;
case HOME_OUTPUT: case HOME_OUTPUT:
result = this->ConvertToRelativePath( result = this->ConvertToRelativePath(
@ -113,7 +118,8 @@ std::string cmOutputConverter::Convert(const std::string& source,
break; break;
case START_OUTPUT: case START_OUTPUT:
result = this->ConvertToRelativePath( result = this->ConvertToRelativePath(
this->StateSnapshot.GetCurrentBinaryDirectoryComponents(), result); this->StateSnapshot.GetDirectory().GetCurrentBinaryComponents(),
result);
break; break;
case FULL: case FULL:
result = cmSystemTools::CollapseFullPath(result); result = cmSystemTools::CollapseFullPath(result);
@ -213,13 +219,13 @@ cmOutputConverter::ConvertToRelativePath(const std::vector<std::string>& local,
// or both in the binary tree. // or both in the binary tree.
std::string local_path = cmSystemTools::JoinPath(local); std::string local_path = cmSystemTools::JoinPath(local);
if(!((cmOutputConverterNotAbove(local_path.c_str(), if(!((cmOutputConverterNotAbove(local_path.c_str(),
this->StateSnapshot.GetRelativePathTopBinary()) && this->StateSnapshot.GetDirectory().GetRelativePathTopBinary())
cmOutputConverterNotAbove(in_remote.c_str(), && cmOutputConverterNotAbove(in_remote.c_str(),
this->StateSnapshot.GetRelativePathTopBinary())) || this->StateSnapshot.GetDirectory().GetRelativePathTopBinary()))
(cmOutputConverterNotAbove(local_path.c_str(), || (cmOutputConverterNotAbove(local_path.c_str(),
this->StateSnapshot.GetRelativePathTopSource()) && this->StateSnapshot.GetDirectory().GetRelativePathTopSource())
cmOutputConverterNotAbove(in_remote.c_str(), && cmOutputConverterNotAbove(in_remote.c_str(),
this->StateSnapshot.GetRelativePathTopSource())))) this->StateSnapshot.GetDirectory().GetRelativePathTopSource()))))
{ {
return in_remote; return in_remote;
} }

View File

@ -609,13 +609,13 @@ std::vector<std::string> const& cmState::GetBinaryDirectoryComponents() const
return this->BinaryDirectoryComponents; return this->BinaryDirectoryComponents;
} }
void cmState::Snapshot::ComputeRelativePathTopSource() void cmState::Directory::ComputeRelativePathTopSource()
{ {
// Relative path conversion inside the source tree is not used to // Relative path conversion inside the source tree is not used to
// construct relative paths passed to build tools so it is safe to use // construct relative paths passed to build tools so it is safe to use
// even when the source is a network path. // even when the source is a network path.
cmState::Snapshot snapshot = *this; cmState::Snapshot snapshot = this->Snapshot_;
std::vector<cmState::Snapshot> snapshots; std::vector<cmState::Snapshot> snapshots;
snapshots.push_back(snapshot); snapshots.push_back(snapshot);
while (true) while (true)
@ -631,23 +631,23 @@ void cmState::Snapshot::ComputeRelativePathTopSource()
} }
} }
std::string result = snapshots.front().GetCurrentSourceDirectory(); std::string result = snapshots.front().GetDirectory().GetCurrentSource();
for (std::vector<cmState::Snapshot>::const_iterator it = for (std::vector<cmState::Snapshot>::const_iterator it =
snapshots.begin() + 1; it != snapshots.end(); ++it) snapshots.begin() + 1; it != snapshots.end(); ++it)
{ {
std::string currentSource = it->GetCurrentSourceDirectory(); std::string currentSource = it->GetDirectory().GetCurrentSource();
if(cmSystemTools::IsSubDirectory(result, currentSource)) if(cmSystemTools::IsSubDirectory(result, currentSource))
{ {
result = currentSource; result = currentSource;
} }
} }
this->Position->BuildSystemDirectory->RelativePathTopSource = result; this->DirectoryState->RelativePathTopSource = result;
} }
void cmState::Snapshot::ComputeRelativePathTopBinary() void cmState::Directory::ComputeRelativePathTopBinary()
{ {
cmState::Snapshot snapshot = *this; cmState::Snapshot snapshot = this->Snapshot_;
std::vector<cmState::Snapshot> snapshots; std::vector<cmState::Snapshot> snapshots;
snapshots.push_back(snapshot); snapshots.push_back(snapshot);
while (true) while (true)
@ -664,12 +664,12 @@ void cmState::Snapshot::ComputeRelativePathTopBinary()
} }
std::string result = std::string result =
snapshots.front().GetCurrentBinaryDirectory(); snapshots.front().GetDirectory().GetCurrentBinary();
for (std::vector<cmState::Snapshot>::const_iterator it = for (std::vector<cmState::Snapshot>::const_iterator it =
snapshots.begin() + 1; it != snapshots.end(); ++it) snapshots.begin() + 1; it != snapshots.end(); ++it)
{ {
std::string currentBinary = it->GetCurrentBinaryDirectory(); std::string currentBinary = it->GetDirectory().GetCurrentBinary();
if(cmSystemTools::IsSubDirectory(result, currentBinary)) if(cmSystemTools::IsSubDirectory(result, currentBinary))
{ {
result = currentBinary; result = currentBinary;
@ -681,11 +681,11 @@ void cmState::Snapshot::ComputeRelativePathTopBinary()
// is a network path. // is a network path.
if(result.size() < 2 || result.substr(0, 2) != "//") if(result.size() < 2 || result.substr(0, 2) != "//")
{ {
this->Position->BuildSystemDirectory->RelativePathTopBinary = result; this->DirectoryState->RelativePathTopBinary = result;
} }
else else
{ {
this->Position->BuildSystemDirectory->RelativePathTopBinary = ""; this->DirectoryState->RelativePathTopBinary = "";
} }
} }
@ -810,40 +810,39 @@ cmState::Snapshot::Snapshot(cmState* state, PositionType position)
} }
const char* cmState::Snapshot::GetCurrentSourceDirectory() const const char* cmState::Directory::GetCurrentSource() const
{ {
return this->Position->BuildSystemDirectory->Location.c_str(); return this->DirectoryState->Location.c_str();
} }
void cmState::Snapshot::SetCurrentSourceDirectory(std::string const& dir) void cmState::Directory::SetCurrentSource(std::string const& dir)
{ {
assert(this->State); std::string& loc = this->DirectoryState->Location;
std::string& loc = this->Position->BuildSystemDirectory->Location;
loc = dir; loc = dir;
cmSystemTools::ConvertToUnixSlashes(loc); cmSystemTools::ConvertToUnixSlashes(loc);
loc = cmSystemTools::CollapseFullPath(loc); loc = cmSystemTools::CollapseFullPath(loc);
cmSystemTools::SplitPath( cmSystemTools::SplitPath(
loc, loc,
this->Position->BuildSystemDirectory->CurrentSourceDirectoryComponents); this->DirectoryState->CurrentSourceDirectoryComponents);
this->ComputeRelativePathTopSource(); this->ComputeRelativePathTopSource();
} }
const char* cmState::Snapshot::GetCurrentBinaryDirectory() const const char* cmState::Directory::GetCurrentBinary() const
{ {
return this->Position->BuildSystemDirectory->OutputLocation.c_str(); return this->DirectoryState->OutputLocation.c_str();
} }
void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir) void cmState::Directory::SetCurrentBinary(std::string const& dir)
{ {
std::string& loc = this->Position->BuildSystemDirectory->OutputLocation; std::string& loc = this->DirectoryState->OutputLocation;
loc = dir; loc = dir;
cmSystemTools::ConvertToUnixSlashes(loc); cmSystemTools::ConvertToUnixSlashes(loc);
loc = cmSystemTools::CollapseFullPath(loc); loc = cmSystemTools::CollapseFullPath(loc);
cmSystemTools::SplitPath( cmSystemTools::SplitPath(
loc, loc,
this->Position->BuildSystemDirectory->CurrentBinaryDirectoryComponents); this->DirectoryState->CurrentBinaryDirectoryComponents);
this->ComputeRelativePathTopBinary(); this->ComputeRelativePathTopBinary();
} }
@ -853,37 +852,35 @@ void cmState::Snapshot::SetListFile(const std::string& listfile)
} }
std::vector<std::string> const& std::vector<std::string> const&
cmState::Snapshot::GetCurrentSourceDirectoryComponents() const cmState::Directory::GetCurrentSourceComponents() const
{ {
return this->Position->BuildSystemDirectory return this->DirectoryState->CurrentSourceDirectoryComponents;
->CurrentSourceDirectoryComponents;
} }
std::vector<std::string> const& std::vector<std::string> const&
cmState::Snapshot::GetCurrentBinaryDirectoryComponents() const cmState::Directory::GetCurrentBinaryComponents() const
{ {
return this->Position->BuildSystemDirectory return this->DirectoryState->CurrentBinaryDirectoryComponents;
->CurrentBinaryDirectoryComponents;
} }
const char* cmState::Snapshot::GetRelativePathTopSource() const const char* cmState::Directory::GetRelativePathTopSource() const
{ {
return this->Position->BuildSystemDirectory->RelativePathTopSource.c_str(); return this->DirectoryState->RelativePathTopSource.c_str();
} }
const char* cmState::Snapshot::GetRelativePathTopBinary() const const char* cmState::Directory::GetRelativePathTopBinary() const
{ {
return this->Position->BuildSystemDirectory->RelativePathTopBinary.c_str(); return this->DirectoryState->RelativePathTopBinary.c_str();
} }
void cmState::Snapshot::SetRelativePathTopSource(const char* dir) void cmState::Directory::SetRelativePathTopSource(const char* dir)
{ {
this->Position->BuildSystemDirectory->RelativePathTopSource = dir; this->DirectoryState->RelativePathTopSource = dir;
} }
void cmState::Snapshot::SetRelativePathTopBinary(const char* dir) void cmState::Directory::SetRelativePathTopBinary(const char* dir)
{ {
this->Position->BuildSystemDirectory->RelativePathTopBinary = dir; this->DirectoryState->RelativePathTopBinary = dir;
} }
std::string cmState::Snapshot::GetExecutionListFile() const std::string cmState::Snapshot::GetExecutionListFile() const
@ -950,3 +947,16 @@ cmState* cmState::Snapshot::GetState() const
{ {
return this->State; return this->State;
} }
cmState::Directory cmState::Snapshot::GetDirectory() const
{
return Directory(this->Position->BuildSystemDirectory, *this);
}
cmState::Directory::Directory(
cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
const cmState::Snapshot& snapshot)
: DirectoryState(iter), Snapshot_(snapshot)
{
}

View File

@ -23,6 +23,7 @@ class cmCommand;
class cmState class cmState
{ {
struct SnapshotDataType; struct SnapshotDataType;
struct BuildsystemDirectoryStateType;
typedef cmLinkedTree<SnapshotDataType>::iterator PositionType; typedef cmLinkedTree<SnapshotDataType>::iterator PositionType;
friend class Snapshot; friend class Snapshot;
public: public:
@ -38,27 +39,14 @@ public:
InlineListFileType InlineListFileType
}; };
class Directory;
class Snapshot { class Snapshot {
public: public:
Snapshot(cmState* state = 0, PositionType position = PositionType()); Snapshot(cmState* state = 0, PositionType position = PositionType());
const char* GetCurrentSourceDirectory() const;
void SetCurrentSourceDirectory(std::string const& dir);
const char* GetCurrentBinaryDirectory() const;
void SetCurrentBinaryDirectory(std::string const& dir);
void SetListFile(std::string const& listfile); void SetListFile(std::string const& listfile);
std::vector<std::string> const&
GetCurrentSourceDirectoryComponents() const;
std::vector<std::string> const&
GetCurrentBinaryDirectoryComponents() const;
const char* GetRelativePathTopSource() const;
const char* GetRelativePathTopBinary() const;
void SetRelativePathTopSource(const char* dir);
void SetRelativePathTopBinary(const char* dir);
std::string GetExecutionListFile() const; std::string GetExecutionListFile() const;
std::string GetEntryPointCommand() const; std::string GetEntryPointCommand() const;
long GetEntryPointLine() const; long GetEntryPointLine() const;
@ -69,14 +57,43 @@ public:
cmState* GetState() const; cmState* GetState() const;
Directory GetDirectory() const;
private:
friend class cmState;
friend class Directory;
cmState* State;
cmState::PositionType Position;
};
class Directory
{
Directory(cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
Snapshot const& snapshot);
public:
const char* GetCurrentSource() const;
void SetCurrentSource(std::string const& dir);
const char* GetCurrentBinary() const;
void SetCurrentBinary(std::string const& dir);
std::vector<std::string> const&
GetCurrentSourceComponents() const;
std::vector<std::string> const&
GetCurrentBinaryComponents() const;
const char* GetRelativePathTopSource() const;
const char* GetRelativePathTopBinary() const;
void SetRelativePathTopSource(const char* dir);
void SetRelativePathTopBinary(const char* dir);
private: private:
void ComputeRelativePathTopSource(); void ComputeRelativePathTopSource();
void ComputeRelativePathTopBinary(); void ComputeRelativePathTopBinary();
private: private:
friend class cmState; cmLinkedTree<BuildsystemDirectoryStateType>::iterator DirectoryState;
cmState* State; Snapshot Snapshot_;
cmState::PositionType Position; friend class Snapshot;
}; };
Snapshot CreateBaseSnapshot(); Snapshot CreateBaseSnapshot();
@ -203,7 +220,6 @@ private:
cmPropertyMap GlobalProperties; cmPropertyMap GlobalProperties;
cmake* CMakeInstance; cmake* CMakeInstance;
struct BuildsystemDirectoryStateType;
cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory; cmLinkedTree<BuildsystemDirectoryStateType> BuildsystemDirectory;
cmLinkedTree<std::string> ExecutionListFiles; cmLinkedTree<std::string> ExecutionListFiles;