ENH: Factor out listing of objects on command line

Previously generation of object file lists for linker and cleaning
command lines was duplicated for library and executable target
generators.  This combines the implementations.
This commit is contained in:
Brad King 2008-10-15 10:21:14 -04:00
parent cd1528279c
commit 07454a39f1
4 changed files with 48 additions and 55 deletions

View File

@ -353,33 +353,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Construct object file lists that may be needed to expand the
// rule.
std::string variableName;
std::string variableNameExternal;
this->WriteObjectsVariable(variableName, variableNameExternal);
std::string buildObjs;
if(useResponseFile)
{
std::string objects;
this->WriteObjectsString(objects);
std::string objects_rsp =
this->CreateResponseFile("objects.rsp", objects, depends);
buildObjs = "@";
buildObjs += this->Convert(objects_rsp.c_str(),
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
}
else if(useLinkScript)
{
this->WriteObjectsString(buildObjs);
}
else
{
buildObjs = "$(";
buildObjs += variableName;
buildObjs += ") $(";
buildObjs += variableNameExternal;
buildObjs += ")";
}
this->CreateObjectLists(useLinkScript, false, useResponseFile,
buildObjs, depends);
cmLocalGenerator::RuleVariables vars;
vars.Language = linkLanguage;

View File

@ -687,36 +687,10 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Construct object file lists that may be needed to expand the
// rule.
std::string variableName;
std::string variableNameExternal;
this->WriteObjectsVariable(variableName, variableNameExternal);
std::string buildObjs;
if(useResponseFile)
{
std::string objects;
this->WriteObjectsString(objects);
std::string objects_rsp =
this->CreateResponseFile("objects.rsp", objects, depends);
buildObjs = "@";
buildObjs += this->Convert(objects_rsp.c_str(),
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
}
else if(useLinkScript)
{
if(!useArchiveRules)
{
this->WriteObjectsString(buildObjs);
}
}
else
{
buildObjs = "$(";
buildObjs += variableName;
buildObjs += ") $(";
buildObjs += variableNameExternal;
buildObjs += ")";
}
this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile,
buildObjs, depends);
cmLocalGenerator::RuleVariables vars;
vars.TargetPDB = targetOutPathPDB.c_str();

View File

@ -1622,6 +1622,44 @@ cmMakefileTargetGenerator
return responseFileName;
}
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
std::vector<std::string>& makefile_depends)
{
std::string variableName;
std::string variableNameExternal;
this->WriteObjectsVariable(variableName, variableNameExternal);
if(useResponseFile)
{
std::string objects;
this->WriteObjectsString(objects);
std::string objects_rsp =
this->CreateResponseFile("objects.rsp", objects, makefile_depends);
buildObjs = "@";
buildObjs += this->Convert(objects_rsp.c_str(),
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
}
else if(useLinkScript)
{
if(!useArchiveRules)
{
this->WriteObjectsString(buildObjs);
}
}
else
{
buildObjs = "$(";
buildObjs += variableName;
buildObjs += ") $(";
buildObjs += variableNameExternal;
buildObjs += ")";
}
}
//----------------------------------------------------------------------------
const char* cmMakefileTargetGenerator::GetFortranModuleDirectory()
{

View File

@ -144,6 +144,11 @@ protected:
std::string const& options,
std::vector<std::string>& makefile_depends);
/** Create lists of object files for linking and cleaning. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
std::vector<std::string>& makefile_depends);
virtual void CloseFileStreams();
void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
std::string& linkFlags);