Merge topic 'refactor-current-dir-initialization'
28749903
cmState: Internalize the initialization of a snapshot from its parent.6c02f62f
Remove now-unused directory setters.360e4e1d
Set the current dirs on the snapshot before creating the cmMakefile.f716460e
cmMakefile: Move invokation to initialize snapshot.
This commit is contained in:
commit
db266aaade
|
@ -318,16 +318,13 @@ void cmCTestScriptHandler::CreateCMake()
|
||||||
this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
|
this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
|
||||||
|
|
||||||
cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
|
cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
|
||||||
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
||||||
|
snapshot.GetDirectory().SetCurrentSource(cwd);
|
||||||
|
snapshot.GetDirectory().SetCurrentBinary(cwd);
|
||||||
this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
|
this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
|
||||||
|
|
||||||
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
|
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
|
||||||
|
|
||||||
// Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR.
|
|
||||||
// Also, some commands need Makefile->GetCurrentSourceDirectory().
|
|
||||||
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
|
||||||
this->Makefile->SetCurrentSourceDirectory(cwd);
|
|
||||||
this->Makefile->SetCurrentBinaryDirectory(cwd);
|
|
||||||
|
|
||||||
// remove all cmake commands which are not scriptable, since they can't be
|
// remove all cmake commands which are not scriptable, since they can't be
|
||||||
// used in ctest scripts
|
// used in ctest scripts
|
||||||
this->CMake->GetState()->RemoveUnscriptableCommands();
|
this->CMake->GetState()->RemoveUnscriptableCommands();
|
||||||
|
|
|
@ -1108,16 +1108,16 @@ void cmGlobalGenerator::Configure()
|
||||||
this->FirstTimeProgress = 0.0f;
|
this->FirstTimeProgress = 0.0f;
|
||||||
this->ClearGeneratorMembers();
|
this->ClearGeneratorMembers();
|
||||||
|
|
||||||
cmMakefile* dirMf =
|
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
|
||||||
new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot());
|
|
||||||
this->Makefiles.push_back(dirMf);
|
|
||||||
|
|
||||||
// set the Start directories
|
snapshot.GetDirectory().SetCurrentSource
|
||||||
dirMf->SetCurrentSourceDirectory
|
|
||||||
(this->CMakeInstance->GetHomeDirectory());
|
(this->CMakeInstance->GetHomeDirectory());
|
||||||
dirMf->SetCurrentBinaryDirectory
|
snapshot.GetDirectory().SetCurrentBinary
|
||||||
(this->CMakeInstance->GetHomeOutputDirectory());
|
(this->CMakeInstance->GetHomeOutputDirectory());
|
||||||
|
|
||||||
|
cmMakefile* dirMf = new cmMakefile(this, snapshot);
|
||||||
|
this->Makefiles.push_back(dirMf);
|
||||||
|
|
||||||
this->BinaryDirectories.insert(
|
this->BinaryDirectories.insert(
|
||||||
this->CMakeInstance->GetHomeOutputDirectory());
|
this->CMakeInstance->GetHomeOutputDirectory());
|
||||||
|
|
||||||
|
|
|
@ -585,12 +585,11 @@ void cmGlobalUnixMakefileGenerator3
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
|
cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
|
||||||
mf = new cmMakefile(this, snapshot);
|
snapshot.GetDirectory().SetCurrentSource
|
||||||
// set the Start directories
|
|
||||||
mf->SetCurrentSourceDirectory
|
|
||||||
(this->CMakeInstance->GetHomeDirectory());
|
(this->CMakeInstance->GetHomeDirectory());
|
||||||
mf->SetCurrentBinaryDirectory
|
snapshot.GetDirectory().SetCurrentBinary
|
||||||
(this->CMakeInstance->GetHomeOutputDirectory());
|
(this->CMakeInstance->GetHomeOutputDirectory());
|
||||||
|
mf = new cmMakefile(this, snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tname = targetName;
|
std::string tname = targetName;
|
||||||
|
|
|
@ -120,15 +120,34 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
|
||||||
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
this->AddSourceGroup("Object Files", "\\.(lo|o|obj)$");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
this->AddDefinition("CMAKE_SOURCE_DIR",
|
||||||
|
this->GetCMakeInstance()->GetHomeDirectory());
|
||||||
|
this->AddDefinition("CMAKE_BINARY_DIR",
|
||||||
|
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
||||||
{
|
{
|
||||||
const char* dir = this->GetCMakeInstance()->GetHomeDirectory();
|
const char* dir = this->StateSnapshot.GetDirectory().GetCurrentSource();
|
||||||
this->AddDefinition("CMAKE_SOURCE_DIR", dir);
|
if (dir)
|
||||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
|
{
|
||||||
|
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", dir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
||||||
|
this->GetCMakeInstance()->GetHomeDirectory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const char* dir = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
const char* dir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
||||||
this->AddDefinition("CMAKE_BINARY_DIR", dir);
|
if (dir)
|
||||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
|
{
|
||||||
|
cmSystemTools::MakeDirectory(dir);
|
||||||
|
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", dir);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
|
||||||
|
this->GetCMakeInstance()->GetHomeOutputDirectory());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1472,13 +1491,6 @@ void cmMakefile::AddLinkLibrary(const std::string& lib)
|
||||||
|
|
||||||
void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
void cmMakefile::InitializeFromParent(cmMakefile* parent)
|
||||||
{
|
{
|
||||||
this->StateSnapshot.InitializeFromParent();
|
|
||||||
|
|
||||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
|
||||||
this->GetCurrentSourceDirectory());
|
|
||||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
|
|
||||||
this->GetCurrentBinaryDirectory());
|
|
||||||
|
|
||||||
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
this->SystemIncludeDirectories = parent->SystemIncludeDirectories;
|
||||||
|
|
||||||
// define flags
|
// define flags
|
||||||
|
@ -1749,12 +1761,12 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
|
||||||
this->ContextStack.back()->Name,
|
this->ContextStack.back()->Name,
|
||||||
this->ContextStack.back()->Line);
|
this->ContextStack.back()->Line);
|
||||||
|
|
||||||
|
newSnapshot.GetDirectory().SetCurrentSource(srcPath);
|
||||||
|
newSnapshot.GetDirectory().SetCurrentBinary(binPath);
|
||||||
|
|
||||||
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
|
cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
|
||||||
this->GetGlobalGenerator()->AddMakefile(subMf);
|
this->GetGlobalGenerator()->AddMakefile(subMf);
|
||||||
|
|
||||||
// set the subdirs start dirs
|
|
||||||
subMf->SetCurrentSourceDirectory(srcPath);
|
|
||||||
subMf->SetCurrentBinaryDirectory(binPath);
|
|
||||||
if(excludeFromAll)
|
if(excludeFromAll)
|
||||||
{
|
{
|
||||||
subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
|
||||||
|
@ -1770,26 +1782,11 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::SetCurrentSourceDirectory(const std::string& dir)
|
|
||||||
{
|
|
||||||
this->StateSnapshot.GetDirectory().SetCurrentSource(dir);
|
|
||||||
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
|
|
||||||
this->StateSnapshot.GetDirectory().GetCurrentSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* cmMakefile::GetCurrentSourceDirectory() const
|
const char* cmMakefile::GetCurrentSourceDirectory() const
|
||||||
{
|
{
|
||||||
return this->StateSnapshot.GetDirectory().GetCurrentSource();
|
return this->StateSnapshot.GetDirectory().GetCurrentSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmMakefile::SetCurrentBinaryDirectory(const std::string& dir)
|
|
||||||
{
|
|
||||||
this->StateSnapshot.GetDirectory().SetCurrentBinary(dir);
|
|
||||||
const char* binDir = this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
|
||||||
cmSystemTools::MakeDirectory(binDir);
|
|
||||||
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", binDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* cmMakefile::GetCurrentBinaryDirectory() const
|
const char* cmMakefile::GetCurrentBinaryDirectory() const
|
||||||
{
|
{
|
||||||
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
return this->StateSnapshot.GetDirectory().GetCurrentBinary();
|
||||||
|
|
|
@ -353,9 +353,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetArgcArgv(const std::vector<std::string>& args);
|
void SetArgcArgv(const std::vector<std::string>& args);
|
||||||
|
|
||||||
void SetCurrentSourceDirectory(const std::string& dir);
|
|
||||||
const char* GetCurrentSourceDirectory() const;
|
const char* GetCurrentSourceDirectory() const;
|
||||||
void SetCurrentBinaryDirectory(const std::string& dir);
|
|
||||||
const char* GetCurrentBinaryDirectory() const;
|
const char* GetCurrentBinaryDirectory() const;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
|
@ -178,9 +178,10 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
|
||||||
cmGlobalGenerator gg(&cm);
|
cmGlobalGenerator gg(&cm);
|
||||||
|
|
||||||
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
|
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
|
||||||
|
snapshot.GetDirectory().SetCurrentBinary(targetDirectory);
|
||||||
|
snapshot.GetDirectory().SetCurrentSource(targetDirectory);
|
||||||
|
|
||||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
|
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
|
||||||
mf->SetCurrentBinaryDirectory(targetDirectory);
|
|
||||||
mf->SetCurrentSourceDirectory(targetDirectory);
|
|
||||||
gg.SetCurrentMakefile(mf.get());
|
gg.SetCurrentMakefile(mf.get());
|
||||||
|
|
||||||
this->ReadAutogenInfoFile(mf.get(), targetDirectory, config);
|
this->ReadAutogenInfoFile(mf.get(), targetDirectory, config);
|
||||||
|
|
|
@ -805,8 +805,10 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
|
||||||
pos->Parent = origin;
|
pos->Parent = origin;
|
||||||
pos->Root = origin;
|
pos->Root = origin;
|
||||||
pos->Vars = this->VarTree.Extend(origin);
|
pos->Vars = this->VarTree.Extend(origin);
|
||||||
|
|
||||||
cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
|
cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
|
||||||
originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
|
originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
|
||||||
|
snapshot.InitializeFromParent();
|
||||||
return snapshot;
|
return snapshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,6 @@ public:
|
||||||
Snapshot GetCallStackParent() const;
|
Snapshot GetCallStackParent() const;
|
||||||
SnapshotType GetType() const;
|
SnapshotType GetType() const;
|
||||||
|
|
||||||
void InitializeFromParent();
|
|
||||||
|
|
||||||
void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
|
void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
|
||||||
cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const;
|
cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id) const;
|
||||||
bool HasDefinedPolicyCMP0011();
|
bool HasDefinedPolicyCMP0011();
|
||||||
|
@ -105,6 +103,9 @@ public:
|
||||||
friend class cmState;
|
friend class cmState;
|
||||||
friend class Directory;
|
friend class Directory;
|
||||||
friend struct StrictWeakOrder;
|
friend struct StrictWeakOrder;
|
||||||
|
|
||||||
|
void InitializeFromParent();
|
||||||
|
|
||||||
cmState* State;
|
cmState* State;
|
||||||
cmState::PositionType Position;
|
cmState::PositionType Position;
|
||||||
};
|
};
|
||||||
|
|
|
@ -377,11 +377,11 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
|
||||||
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
||||||
|
snapshot.GetDirectory().SetCurrentBinary
|
||||||
|
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
|
snapshot.GetDirectory().SetCurrentSource
|
||||||
|
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
||||||
mf->SetCurrentBinaryDirectory
|
|
||||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
|
||||||
mf->SetCurrentSourceDirectory
|
|
||||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
|
||||||
if (this->GetWorkingMode() != NORMAL_MODE)
|
if (this->GetWorkingMode() != NORMAL_MODE)
|
||||||
{
|
{
|
||||||
std::string file(cmSystemTools::CollapseFullPath(path));
|
std::string file(cmSystemTools::CollapseFullPath(path));
|
||||||
|
@ -418,13 +418,13 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
|
||||||
this->SetGlobalGenerator(gg);
|
this->SetGlobalGenerator(gg);
|
||||||
|
|
||||||
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
cmState::Snapshot snapshot = this->GetCurrentSnapshot();
|
||||||
|
snapshot.GetDirectory().SetCurrentBinary
|
||||||
|
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
|
snapshot.GetDirectory().SetCurrentSource
|
||||||
|
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
// read in the list file to fill the cache
|
// read in the list file to fill the cache
|
||||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
|
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
|
||||||
mf->SetCurrentBinaryDirectory
|
|
||||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
|
||||||
mf->SetCurrentSourceDirectory
|
|
||||||
(cmSystemTools::GetCurrentWorkingDirectory());
|
|
||||||
|
|
||||||
mf->SetArgcArgv(args);
|
mf->SetArgcArgv(args);
|
||||||
|
|
||||||
|
|
|
@ -769,11 +769,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
cm.SetGlobalGenerator(ggd);
|
cm.SetGlobalGenerator(ggd);
|
||||||
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
|
cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
|
||||||
|
snapshot.GetDirectory().SetCurrentBinary
|
||||||
|
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
|
snapshot.GetDirectory().SetCurrentSource
|
||||||
|
(cmSystemTools::GetCurrentWorkingDirectory());
|
||||||
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
|
cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
|
||||||
cmsys::auto_ptr<cmLocalGenerator> lgd(
|
cmsys::auto_ptr<cmLocalGenerator> lgd(
|
||||||
ggd->CreateLocalGenerator(mf.get()));
|
ggd->CreateLocalGenerator(mf.get()));
|
||||||
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
|
|
||||||
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);
|
|
||||||
|
|
||||||
// Actually scan dependencies.
|
// Actually scan dependencies.
|
||||||
return lgd->UpdateDependencies(depInfo.c_str(),
|
return lgd->UpdateDependencies(depInfo.c_str(),
|
||||||
|
|
Loading…
Reference in New Issue