Refactor Makefile/Ninja tool working directory storage

Move cmCommonTargetGenerator::WorkingDirectory to cmLocalCommonGenerator
and add an access method.
This commit is contained in:
Brad King 2016-06-16 10:54:20 -04:00
parent 9e47255604
commit 0392f72bef
8 changed files with 23 additions and 16 deletions

View File

@ -19,10 +19,8 @@
#include "cmSourceFile.h"
#include "cmSystemTools.h"
cmCommonTargetGenerator::cmCommonTargetGenerator(
cmOutputConverter::RelativeRoot wd, cmGeneratorTarget* gt)
: WorkingDirectory(wd)
, GeneratorTarget(gt)
cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
: GeneratorTarget(gt)
, Makefile(gt->Makefile)
, LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
, GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(
@ -140,7 +138,8 @@ void cmCommonTargetGenerator::AddFortranFlags(std::string& flags)
std::string mod_dir = this->GetFortranModuleDirectory();
if (!mod_dir.empty()) {
mod_dir =
this->Convert(mod_dir, this->WorkingDirectory, cmOutputConverter::SHELL);
this->Convert(mod_dir, this->LocalGenerator->GetWorkingDirectory(),
cmOutputConverter::SHELL);
} else {
mod_dir =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_MODDIR_DEFAULT");
@ -308,7 +307,8 @@ std::string cmCommonTargetGenerator::GetManifests()
for (std::vector<cmSourceFile const*>::iterator mi = manifest_srcs.begin();
mi != manifest_srcs.end(); ++mi) {
manifests.push_back(this->Convert(
(*mi)->GetFullPath(), this->WorkingDirectory, cmOutputConverter::SHELL));
(*mi)->GetFullPath(), this->LocalGenerator->GetWorkingDirectory(),
cmOutputConverter::SHELL));
}
return cmJoin(manifests, " ");

View File

@ -28,8 +28,7 @@ class cmSourceFile;
class cmCommonTargetGenerator
{
public:
cmCommonTargetGenerator(cmOutputConverter::RelativeRoot wd,
cmGeneratorTarget* gt);
cmCommonTargetGenerator(cmGeneratorTarget* gt);
virtual ~cmCommonTargetGenerator();
std::string const& GetConfigName() const;
@ -45,7 +44,6 @@ protected:
// Helper to add flag for windows .def file.
void AddModuleDefinitionFlag(std::string& flags);
cmOutputConverter::RelativeRoot WorkingDirectory;
cmGeneratorTarget* GeneratorTarget;
cmMakefile* Makefile;
cmLocalCommonGenerator* LocalGenerator;

View File

@ -13,9 +13,10 @@
#include "cmMakefile.h"
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
cmMakefile* mf)
cmLocalCommonGenerator::cmLocalCommonGenerator(
cmGlobalGenerator* gg, cmMakefile* mf, cmOutputConverter::RelativeRoot wd)
: cmLocalGenerator(gg, mf)
, WorkingDirectory(wd)
{
}

View File

@ -22,12 +22,20 @@ class cmCommonTargetGenerator;
class cmLocalCommonGenerator : public cmLocalGenerator
{
public:
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf,
cmOutputConverter::RelativeRoot wd);
~cmLocalCommonGenerator();
std::string const& GetConfigName() { return this->ConfigName; }
cmOutputConverter::RelativeRoot GetWorkingDirectory() const
{
return this->WorkingDirectory;
}
protected:
cmOutputConverter::RelativeRoot WorkingDirectory;
void SetConfigName();
std::string ConfigName;

View File

@ -25,7 +25,7 @@
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
cmMakefile* mf)
: cmLocalCommonGenerator(gg, mf)
: cmLocalCommonGenerator(gg, mf, cmOutputConverter::HOME_OUTPUT)
, HomeRelativeOutputPath("")
{
this->TargetImplib = "$TARGET_IMPLIB";

View File

@ -84,7 +84,7 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3(
cmGlobalGenerator* gg, cmMakefile* mf)
: cmLocalCommonGenerator(gg, mf)
: cmLocalCommonGenerator(gg, mf, cmOutputConverter::START_OUTPUT)
{
this->MakefileVariableSize = 0;
this->ColorMakefile = false;

View File

@ -32,7 +32,7 @@
#include <ctype.h>
cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(cmOutputConverter::START_OUTPUT, target)
: cmCommonTargetGenerator(target)
, OSXBundleGenerator(0)
, MacOSXContentGenerator(0)
{

View File

@ -58,7 +58,7 @@ cmNinjaTargetGenerator* cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
}
cmNinjaTargetGenerator::cmNinjaTargetGenerator(cmGeneratorTarget* target)
: cmCommonTargetGenerator(cmOutputConverter::HOME_OUTPUT, target)
: cmCommonTargetGenerator(target)
, MacOSXContentGenerator(0)
, OSXBundleGenerator(0)
, MacContentFolders()