Makefiles: Port to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-18 23:20:47 +02:00
parent 80de856bb5
commit 4bc65d76f1
11 changed files with 48 additions and 48 deletions

View File

@ -18,7 +18,6 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h"
cmCommonTargetGenerator::cmCommonTargetGenerator( cmCommonTargetGenerator::cmCommonTargetGenerator(
cmOutputConverter::RelativeRoot wd, cmOutputConverter::RelativeRoot wd,
@ -26,7 +25,6 @@ cmCommonTargetGenerator::cmCommonTargetGenerator(
) )
: WorkingDirectory(wd) : WorkingDirectory(wd)
, GeneratorTarget(gt) , GeneratorTarget(gt)
, Target(gt->Target)
, Makefile(gt->Makefile) , Makefile(gt->Makefile)
, LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator)) , LocalGenerator(static_cast<cmLocalCommonGenerator*>(gt->LocalGenerator))
, GlobalGenerator(static_cast<cmGlobalCommonGenerator*>( , GlobalGenerator(static_cast<cmGlobalCommonGenerator*>(

View File

@ -21,7 +21,6 @@ class cmGlobalCommonGenerator;
class cmLocalCommonGenerator; class cmLocalCommonGenerator;
class cmMakefile; class cmMakefile;
class cmSourceFile; class cmSourceFile;
class cmTarget;
/** \class cmCommonTargetGenerator /** \class cmCommonTargetGenerator
* \brief Common infrastructure for Makefile and Ninja per-target generators * \brief Common infrastructure for Makefile and Ninja per-target generators
@ -49,7 +48,6 @@ protected:
cmOutputConverter::RelativeRoot WorkingDirectory; cmOutputConverter::RelativeRoot WorkingDirectory;
cmGeneratorTarget* GeneratorTarget; cmGeneratorTarget* GeneratorTarget;
cmTarget* Target;
cmMakefile* Makefile; cmMakefile* Makefile;
cmLocalCommonGenerator* LocalGenerator; cmLocalCommonGenerator* LocalGenerator;
cmGlobalCommonGenerator* GlobalGenerator; cmGlobalCommonGenerator* GlobalGenerator;

View File

@ -16,7 +16,6 @@
#include "cmake.h" #include "cmake.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h"
#include "cmGeneratorTarget.h" #include "cmGeneratorTarget.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
@ -742,7 +741,7 @@ cmGlobalUnixMakefileGenerator3
makefileName = localName; makefileName = localName;
makefileName += "/build.make"; makefileName += "/build.make";
bool needRequiresStep = this->NeedRequiresStep(*gtarget->Target); bool needRequiresStep = this->NeedRequiresStep(gtarget);
lg->WriteDivider(ruleFileStream); lg->WriteDivider(ruleFileStream);
ruleFileStream ruleFileStream
@ -1129,19 +1128,19 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
bool cmGlobalUnixMakefileGenerator3 bool cmGlobalUnixMakefileGenerator3
::NeedRequiresStep(cmTarget const& target) ::NeedRequiresStep(const cmGeneratorTarget* target)
{ {
std::set<std::string> languages; std::set<std::string> languages;
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target); target->GetLanguages(languages,
gtgt->GetLanguages(languages, target->Target->GetMakefile()
target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE")); ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::set<std::string>::const_iterator l = languages.begin(); for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l) l != languages.end(); ++l)
{ {
std::string var = "CMAKE_NEEDS_REQUIRES_STEP_"; std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
var += *l; var += *l;
var += "_FLAG"; var += "_FLAG";
if(target.GetMakefile()->GetDefinition(var)) if(target->Target->GetMakefile()->GetDefinition(var))
{ {
return true; return true;
} }

View File

@ -154,7 +154,7 @@ protected:
cmGeneratorTarget* target); cmGeneratorTarget* target);
// does this generator need a requires step for any of its targets // does this generator need a requires step for any of its targets
bool NeedRequiresStep(cmTarget const&); bool NeedRequiresStep(cmGeneratorTarget const*);
// Target name hooks for superclass. // Target name hooks for superclass.
const char* GetAllTargetName() const { return "all"; } const char* GetAllTargetName() const { return "all"; }

View File

@ -1977,7 +1977,7 @@ void cmLocalUnixMakefileGenerator3
cmGeneratorTarget* target) cmGeneratorTarget* target)
{ {
ImplicitDependLanguageMap const& implicitLangs = ImplicitDependLanguageMap const& implicitLangs =
this->GetImplicitDepends(*target->Target); this->GetImplicitDepends(target);
// list the languages // list the languages
cmakefileStream cmakefileStream
@ -2292,19 +2292,20 @@ cmLocalUnixMakefileGenerator3
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3::ImplicitDependLanguageMap const& cmLocalUnixMakefileGenerator3::ImplicitDependLanguageMap const&
cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt) cmLocalUnixMakefileGenerator3::GetImplicitDepends(
const cmGeneratorTarget* tgt)
{ {
return this->ImplicitDepends[tgt.GetName()]; return this->ImplicitDepends[tgt->GetName()];
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void
cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt, cmLocalUnixMakefileGenerator3::AddImplicitDepends(const cmGeneratorTarget* tgt,
const std::string& lang, const std::string& lang,
const char* obj, const char* obj,
const char* src) const char* src)
{ {
this->ImplicitDepends[tgt.GetName()][lang][obj].push_back(src); this->ImplicitDepends[tgt->GetName()][lang][obj].push_back(src);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -21,7 +21,6 @@ class cmCustomCommand;
class cmCustomCommandGenerator; class cmCustomCommandGenerator;
class cmDepends; class cmDepends;
class cmMakefileTargetGenerator; class cmMakefileTargetGenerator;
class cmTarget;
class cmSourceFile; class cmSourceFile;
/** \class cmLocalUnixMakefileGenerator3 /** \class cmLocalUnixMakefileGenerator3
@ -141,9 +140,11 @@ public:
public std::map<std::string, ImplicitDependFileMap> {}; public std::map<std::string, ImplicitDependFileMap> {};
struct ImplicitDependTargetMap: struct ImplicitDependTargetMap:
public std::map<std::string, ImplicitDependLanguageMap> {}; public std::map<std::string, ImplicitDependLanguageMap> {};
ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt); ImplicitDependLanguageMap const&
GetImplicitDepends(cmGeneratorTarget const* tgt);
void AddImplicitDepends(cmTarget const& tgt, const std::string& lang, void AddImplicitDepends(cmGeneratorTarget const* tgt,
const std::string& lang,
const char* obj, const char* src); const char* obj, const char* src);
// write the target rules for the local Makefile into the stream // write the target rules for the local Makefile into the stream
@ -197,12 +198,12 @@ protected:
const std::string& helpTarget); const std::string& helpTarget);
void WriteTargetDependRule(std::ostream& ruleFileStream, void WriteTargetDependRule(std::ostream& ruleFileStream,
cmTarget& target); cmGeneratorTarget* target);
void WriteTargetCleanRule(std::ostream& ruleFileStream, void WriteTargetCleanRule(std::ostream& ruleFileStream,
cmTarget& target, cmGeneratorTarget* target,
const std::vector<std::string>& files); const std::vector<std::string>& files);
void WriteTargetRequiresRule(std::ostream& ruleFileStream, void WriteTargetRequiresRule(std::ostream& ruleFileStream,
cmTarget& target, cmGeneratorTarget* target,
const std::vector<std::string>& objects); const std::vector<std::string>& objects);
void AppendRuleDepend(std::vector<std::string>& depends, void AppendRuleDepend(std::vector<std::string>& depends,

View File

@ -16,7 +16,6 @@
#include "cmLocalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h"
#include "cmake.h" #include "cmake.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -279,11 +278,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
if(!relink) if(!relink)
{ {
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), ->AppendCustomCommands(commands,
this->GeneratorTarget); this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget);
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), ->AppendCustomCommands(commands,
this->GeneratorTarget); this->GeneratorTarget->Target->GetPreLinkCommands(),
this->GeneratorTarget);
} }
// Determine whether a link script will be used. // Determine whether a link script will be used.
@ -448,8 +449,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
if(!relink) if(!relink)
{ {
this->LocalGenerator-> this->LocalGenerator->
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), AppendCustomCommands(commands,
this->GeneratorTarget); this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget);
} }
// Write the build rule. // Write the build rule.

View File

@ -16,7 +16,6 @@
#include "cmLocalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h"
#include "cmake.h" #include "cmake.h"
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
@ -114,7 +113,8 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
// Add post-build rules. // Add post-build rules.
this->LocalGenerator-> this->LocalGenerator->
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), AppendCustomCommands(commands,
this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget); this->GeneratorTarget);
// Depend on the object files. // Depend on the object files.
@ -457,11 +457,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
if(!relink) if(!relink)
{ {
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreBuildCommands(), ->AppendCustomCommands(commands,
this->GeneratorTarget); this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget);
this->LocalGenerator this->LocalGenerator
->AppendCustomCommands(commands, this->Target->GetPreLinkCommands(), ->AppendCustomCommands(commands,
this->GeneratorTarget); this->GeneratorTarget->Target->GetPreLinkCommands(),
this->GeneratorTarget);
} }
// Determine whether a link script will be used. // Determine whether a link script will be used.
@ -811,8 +813,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
if(!relink) if(!relink)
{ {
this->LocalGenerator-> this->LocalGenerator->
AppendCustomCommands(commands, this->Target->GetPostBuildCommands(), AppendCustomCommands(commands,
this->GeneratorTarget); this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget);
} }
// Compute the list of outputs. // Compute the list of outputs.

View File

@ -18,7 +18,6 @@
#include "cmLocalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h"
#include "cmake.h" #include "cmake.h"
#include "cmState.h" #include "cmState.h"
#include "cmComputeLinkInformation.h" #include "cmComputeLinkInformation.h"
@ -432,7 +431,7 @@ void cmMakefileTargetGenerator
std::string srcFullPath = std::string srcFullPath =
this->Convert(source.GetFullPath(), cmLocalGenerator::FULL); this->Convert(source.GetFullPath(), cmLocalGenerator::FULL);
this->LocalGenerator-> this->LocalGenerator->
AddImplicitDepends(*this->Target, lang, AddImplicitDepends(this->GeneratorTarget, lang,
objFullPath.c_str(), objFullPath.c_str(),
srcFullPath.c_str()); srcFullPath.c_str());
} }
@ -1241,7 +1240,7 @@ void cmMakefileTargetGenerator
std::string srcFullPath = std::string srcFullPath =
this->Convert(idi->second, cmLocalGenerator::FULL); this->Convert(idi->second, cmLocalGenerator::FULL);
this->LocalGenerator-> this->LocalGenerator->
AddImplicitDepends(*this->Target, idi->first, AddImplicitDepends(this->GeneratorTarget, idi->first,
objFullPath.c_str(), objFullPath.c_str(),
srcFullPath.c_str()); srcFullPath.c_str());
} }

View File

@ -24,7 +24,6 @@ class cmGeneratedFileStream;
class cmGlobalUnixMakefileGenerator3; class cmGlobalUnixMakefileGenerator3;
class cmLocalUnixMakefileGenerator3; class cmLocalUnixMakefileGenerator3;
class cmMakefile; class cmMakefile;
class cmTarget;
class cmSourceFile; class cmSourceFile;
/** \class cmMakefileTargetGenerator /** \class cmMakefileTargetGenerator
@ -51,7 +50,6 @@ public:
std::string GetProgressFileNameFull() std::string GetProgressFileNameFull()
{ return this->ProgressFileNameFull; } { return this->ProgressFileNameFull; }
cmTarget* GetTarget() { return this->Target;}
cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;}
protected: protected:

View File

@ -16,7 +16,6 @@
#include "cmLocalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmSourceFile.h" #include "cmSourceFile.h"
#include "cmTarget.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmMakefileUtilityTargetGenerator cmMakefileUtilityTargetGenerator
@ -68,19 +67,21 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
// Utility targets store their rules in pre- and post-build commands. // Utility targets store their rules in pre- and post-build commands.
this->LocalGenerator->AppendCustomDepends this->LocalGenerator->AppendCustomDepends
(depends, this->Target->GetPreBuildCommands()); (depends, this->GeneratorTarget->Target->GetPreBuildCommands());
this->LocalGenerator->AppendCustomDepends this->LocalGenerator->AppendCustomDepends
(depends, this->Target->GetPostBuildCommands()); (depends, this->GeneratorTarget->Target->GetPostBuildCommands());
this->LocalGenerator->AppendCustomCommands this->LocalGenerator->AppendCustomCommands
(commands, this->Target->GetPreBuildCommands(), this->GeneratorTarget); (commands, this->GeneratorTarget->Target->GetPreBuildCommands(),
this->GeneratorTarget);
// Depend on all custom command outputs for sources // Depend on all custom command outputs for sources
this->DriveCustomCommands(depends); this->DriveCustomCommands(depends);
this->LocalGenerator->AppendCustomCommands this->LocalGenerator->AppendCustomCommands
(commands, this->Target->GetPostBuildCommands(), this->GeneratorTarget); (commands, this->GeneratorTarget->Target->GetPostBuildCommands(),
this->GeneratorTarget);
// Add dependencies on targets that must be built first. // Add dependencies on targets that must be built first.
this->AppendTargetDepends(depends); this->AppendTargetDepends(depends);