Simplify cmMakefileTargetGenerator using cmGeneratorTarget

Replace the classification of source files in this generator
using that computed by cmGeneratorTarget.
This commit is contained in:
Brad King 2012-03-07 11:54:52 -05:00
parent 4b24558091
commit 45c2f93240
2 changed files with 45 additions and 56 deletions

View File

@ -11,6 +11,7 @@
============================================================================*/ ============================================================================*/
#include "cmMakefileTargetGenerator.h" #include "cmMakefileTargetGenerator.h"
#include "cmGeneratorTarget.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmGlobalUnixMakefileGenerator3.h" #include "cmGlobalUnixMakefileGenerator3.h"
@ -42,6 +43,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmTarget* target)
this->GlobalGenerator = this->GlobalGenerator =
static_cast<cmGlobalUnixMakefileGenerator3*>( static_cast<cmGlobalUnixMakefileGenerator3*>(
this->LocalGenerator->GetGlobalGenerator()); this->LocalGenerator->GetGlobalGenerator());
this->GeneratorTarget = this->GlobalGenerator->GetGeneratorTarget(target);
cmake* cm = this->GlobalGenerator->GetCMakeInstance(); cmake* cm = this->GlobalGenerator->GetCMakeInstance();
this->NoRuleMessages = false; this->NoRuleMessages = false;
if(const char* ruleStatus = cm->GetProperty("RULE_MESSAGES")) if(const char* ruleStatus = cm->GetProperty("RULE_MESSAGES"))
@ -131,57 +133,45 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// First generate the object rule files. Save a list of all object // First generate the object rule files. Save a list of all object
// files for this target. // files for this target.
const std::vector<cmSourceFile*>& sources = this->Target->GetSourceFiles(); for(std::vector<cmSourceFile*>::const_iterator
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); si = this->GeneratorTarget->CustomCommands.begin();
source != sources.end(); ++source) si != this->GeneratorTarget->CustomCommands.end(); ++si)
{
cmCustomCommand const* cc = (*si)->GetCustomCommand();
this->GenerateCustomRuleFile(*cc);
if (clean)
{
const std::vector<std::string>& outputs = cc->GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o)
{
this->CleanFiles.push_back
(this->Convert(o->c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
}
}
for(std::vector<cmSourceFile*>::const_iterator
si = this->GeneratorTarget->OSXContent.begin();
si != this->GeneratorTarget->OSXContent.end(); ++si)
{ {
cmTarget::SourceFileFlags tsFlags = cmTarget::SourceFileFlags tsFlags =
this->Target->GetTargetSourceFileFlags(*source); this->Target->GetTargetSourceFileFlags(*si);
if(cmCustomCommand* cc = (*source)->GetCustomCommand()) this->WriteMacOSXContentRules(**si, tsFlags.MacFolder);
{ }
this->GenerateCustomRuleFile(*cc); for(std::vector<cmSourceFile*>::const_iterator
if (clean) si = this->GeneratorTarget->ExternalObjects.begin();
{ si != this->GeneratorTarget->ExternalObjects.end(); ++si)
const std::vector<std::string>& outputs = cc->GetOutputs(); {
for(std::vector<std::string>::const_iterator o = outputs.begin(); this->ExternalObjects.push_back((*si)->GetFullPath());
o != outputs.end(); ++o) }
{ for(std::vector<cmSourceFile*>::const_iterator
this->CleanFiles.push_back si = this->GeneratorTarget->ObjectSources.begin();
(this->Convert(o->c_str(), si != this->GeneratorTarget->ObjectSources.end(); ++si)
cmLocalGenerator::START_OUTPUT, {
cmLocalGenerator::UNCHANGED)); // Generate this object file's rule file.
} this->WriteObjectRuleFiles(**si);
}
}
else if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
{
this->WriteMacOSXContentRules(*(*source), tsFlags.MacFolder);
}
else if(!(*source)->GetPropertyAsBool("HEADER_FILE_ONLY"))
{
if(!this->GlobalGenerator->IgnoreFile
((*source)->GetExtension().c_str()))
{
// Generate this object file's rule file.
this->WriteObjectRuleFiles(*(*source));
}
else if((*source)->GetPropertyAsBool("EXTERNAL_OBJECT"))
{
// This is an external object file. Just add it.
this->ExternalObjects.push_back((*source)->GetFullPath());
}
else if(cmSystemTools::UpperCase((*source)->GetExtension()) == "DEF")
{
this->ModuleDefinitionFile = (*source)->GetFullPath();
}
else
{
// We only get here if a source file is not an external object
// and has an extension that is listed as an ignored file type
// for this language. No message or diagnosis should be
// given.
}
}
} }
} }
@ -1633,9 +1623,9 @@ void cmMakefileTargetGenerator
this->BuildFileNameFull.c_str()); this->BuildFileNameFull.c_str());
// Add a dependency on the link definitions file, if any. // Add a dependency on the link definitions file, if any.
if(!this->ModuleDefinitionFile.empty()) if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
{ {
depends.push_back(this->ModuleDefinitionFile); depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
} }
// Add dependencies on the external object files. // Add dependencies on the external object files.
@ -1971,7 +1961,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags) void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{ {
if(this->ModuleDefinitionFile.empty()) if(this->GeneratorTarget->ModuleDefinitionFile.empty())
{ {
return; return;
} }
@ -1988,7 +1978,7 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// vs6's "cl -link" pass it to the linker. // vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag; std::string flag = defFileFlag;
flag += (this->LocalGenerator->ConvertToLinkReference( flag += (this->LocalGenerator->ConvertToLinkReference(
this->ModuleDefinitionFile.c_str())); this->GeneratorTarget->ModuleDefinitionFile.c_str()));
this->LocalGenerator->AppendFlags(flags, flag.c_str()); this->LocalGenerator->AppendFlags(flags, flag.c_str());
} }

View File

@ -17,6 +17,7 @@
class cmCustomCommand; class cmCustomCommand;
class cmDependInformation; class cmDependInformation;
class cmDepends; class cmDepends;
class cmGeneratorTarget;
class cmGeneratedFileStream; class cmGeneratedFileStream;
class cmGlobalUnixMakefileGenerator3; class cmGlobalUnixMakefileGenerator3;
class cmLocalUnixMakefileGenerator3; class cmLocalUnixMakefileGenerator3;
@ -157,6 +158,7 @@ protected:
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang, void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
std::string& linkFlags); std::string& linkFlags);
cmTarget *Target; cmTarget *Target;
cmGeneratorTarget* GeneratorTarget;
cmLocalUnixMakefileGenerator3 *LocalGenerator; cmLocalUnixMakefileGenerator3 *LocalGenerator;
cmGlobalUnixMakefileGenerator3 *GlobalGenerator; cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
cmMakefile *Makefile; cmMakefile *Makefile;
@ -198,9 +200,6 @@ protected:
std::vector<std::string> Objects; std::vector<std::string> Objects;
std::vector<std::string> ExternalObjects; std::vector<std::string> ExternalObjects;
// The windows module definition source file (.def), if any.
std::string ModuleDefinitionFile;
// Set of object file names that will be built in this directory. // Set of object file names that will be built in this directory.
std::set<cmStdString> ObjectFiles; std::set<cmStdString> ObjectFiles;