summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileLibraryTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-06-15 20:17:11 (GMT)
committerBrad King <brad.king@kitware.com>2006-06-15 20:17:11 (GMT)
commit0bbcb49f65eb92daafc5ad87162f1ecedc3438dc (patch)
tree4889b6c00d1b1fb55a0e55c1ec17cb16edf0a4ab /Source/cmMakefileLibraryTargetGenerator.cxx
parent6438bec4c9355960f47e4b853f27b548a55ec5e0 (diff)
downloadCMake-0bbcb49f65eb92daafc5ad87162f1ecedc3438dc.zip
CMake-0bbcb49f65eb92daafc5ad87162f1ecedc3438dc.tar.gz
CMake-0bbcb49f65eb92daafc5ad87162f1ecedc3438dc.tar.bz2
ENH: Added generation of link rules into script files executed by a cmake -E command in order to support longer link lines. This is needed only on platforms without response file support and that may have weak shells.
Diffstat (limited to 'Source/cmMakefileLibraryTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx82
1 files changed, 73 insertions, 9 deletions
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index a292605..c2de260 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -24,6 +24,8 @@
#include "cmTarget.h"
#include "cmake.h"
+#include <memory> // auto_ptr
+
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteRuleFiles()
{
@@ -376,9 +378,41 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
->AppendCustomCommands(commands, this->Target->GetPreLinkCommands());
}
+ // Open the link script if it will be used.
+ bool useLinkScript = false;
+ std::string linkScriptName;
+ std::auto_ptr<cmGeneratedFileStream> linkScriptStream;
+ if(this->GlobalGenerator->GetUseLinkScript() &&
+ (this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
+ this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
+ this->Target->GetType() == cmTarget::MODULE_LIBRARY))
+ {
+ useLinkScript = true;
+ linkScriptName = this->TargetBuildDirectoryFull;
+ linkScriptName += "/link.txt";
+ std::auto_ptr<cmGeneratedFileStream> lss(
+ new cmGeneratedFileStream(linkScriptName.c_str()));
+ linkScriptStream = lss;
+ }
+
+ std::vector<std::string> link_script_commands;
+
// Construct the main link rule.
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
- cmSystemTools::ExpandListArgument(linkRule, commands1);
+ if(useLinkScript)
+ {
+ cmSystemTools::ExpandListArgument(linkRule, link_script_commands);
+ std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
+ link_command += this->Convert(linkScriptName.c_str(),
+ cmLocalGenerator::START_OUTPUT,
+ cmLocalGenerator::SHELL);
+ link_command += " --verbose=$(VERBOSE)";
+ commands1.push_back(link_command);
+ }
+ else
+ {
+ cmSystemTools::ExpandListArgument(linkRule, commands1);
+ }
this->LocalGenerator->CreateCDCommand
(commands1,
this->Makefile->GetStartOutputDirectory(),
@@ -418,11 +452,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string variableName;
std::string variableNameExternal;
this->WriteObjectsVariable(variableName, variableNameExternal);
- std::string buildObjs = "$(";
- buildObjs += variableName;
- buildObjs += ") $(";
- buildObjs += variableNameExternal;
- buildObjs += ")";
+ std::string buildObjs;
+ if(useLinkScript)
+ {
+ this->WriteObjectsString(buildObjs);
+ }
+ else
+ {
+ buildObjs = "$(";
+ buildObjs += variableName;
+ buildObjs += ") $(";
+ buildObjs += variableNameExternal;
+ buildObjs += ")";
+ }
std::string cleanObjs = "$(";
cleanObjs += variableName;
cleanObjs += ")";
@@ -493,13 +535,35 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
vars.LanguageCompileFlags = langFlags.c_str();
// Expand placeholders in the commands.
this->LocalGenerator->TargetImplib = targetOutPathImport;
- for(std::vector<std::string>::iterator i = commands.begin();
- i != commands.end(); ++i)
+ if(useLinkScript)
+ {
+ for(std::vector<std::string>::iterator i = link_script_commands.begin();
+ i != link_script_commands.end(); ++i)
+ {
+ this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ }
+ }
+ else
{
- this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ for(std::vector<std::string>::iterator i = commands.begin();
+ i != commands.end(); ++i)
+ {
+ this->LocalGenerator->ExpandRuleVariables(*i, vars);
+ }
}
this->LocalGenerator->TargetImplib = "";
+ // Optionally convert the build rule to use a script to avoid long
+ // command lines in the make shell.
+ if(useLinkScript)
+ {
+ for(std::vector<std::string>::iterator cmd = link_script_commands.begin();
+ cmd != link_script_commands.end(); ++cmd)
+ {
+ (*linkScriptStream) << *cmd << "\n";
+ }
+ }
+
// Write the build rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
targetFullPathReal.c_str(),