Commit 52b3f856 authored by Brad King's avatar Brad King
Browse files

ENH: Enable use of link script whenever incremental archive construction rules...

ENH: Enable use of link script whenever incremental archive construction rules are available.  Enable use of archive construction rules on MSYS.
parent 66e0b421
......@@ -50,6 +50,7 @@ cmLocalGenerator::cmLocalGenerator()
this->MinGWMake = false;
this->NMake = false;
this->MSYSShell = false;
this->LinkScriptShell = false;
this->IgnoreLibPrefix = false;
this->UseRelativePaths = false;
this->Configured = false;
......@@ -1995,7 +1996,7 @@ std::string cmLocalGenerator::Convert(const char* source,
// For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to
// avoid problems with the shell path translation.
if(this->MSYSShell)
if(this->MSYSShell && !this->LinkScriptShell)
{
if(result.size() > 2 && result[1] == ':')
{
......
......@@ -210,6 +210,9 @@ public:
const char* Defines;
};
/** Set whether to treat conversions to SHELL as a link script shell. */
void SetLinkScriptShell(bool b) { this->LinkScriptShell = b; }
/** Escape the given string to be used as a command line argument in
the native build system shell. Optionally allow the build
system to replace make variable references. Optionally adjust
......@@ -346,6 +349,7 @@ protected:
bool NMake;
bool ForceUnixPath;
bool MSYSShell;
bool LinkScriptShell;
bool UseRelativePaths;
bool IgnoreLibPrefix;
bool Configured;
......
......@@ -367,6 +367,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Expand the rule variables.
{
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
// Collect up flags to link in needed libraries.
cmOStringStream linklibs;
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
......@@ -428,6 +431,9 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
this->LocalGenerator->ExpandRuleVariables(*i, vars);
}
this->LocalGenerator->TargetImplib = "";
// Restore path conversion to normal shells.
this->LocalGenerator->SetLinkScriptShell(false);
}
// Optionally convert the build rule to use a script to avoid long
......
......@@ -673,7 +673,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::vector<std::string> archiveAppendCommands;
std::vector<std::string> archiveFinishCommands;
std::string::size_type archiveCommandLimit = std::string::npos;
if(useLinkScript && this->Target->GetType() == cmTarget::STATIC_LIBRARY)
if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
{
std::string arCreateVar = "CMAKE_";
arCreateVar += linkLanguage;
......@@ -696,18 +696,28 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
}
}
// Decide whether to use archiving rules.
bool useArchiveRules =
!archiveCreateCommands.empty() && !archiveAppendCommands.empty();
if(useArchiveRules)
{
// Archiving rules are always run with a link script.
useLinkScript = true;
// Limit the length of individual object lists to less than the
// 32K command line length limit on Windows. We could make this a
// platform file variable but this should work everywhere.
archiveCommandLimit = 30000;
}
bool useArchiveRules =
!archiveCreateCommands.empty() && !archiveAppendCommands.empty();
// Expand the rule variables.
std::vector<std::string> real_link_commands;
{
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
// Collect up flags to link in needed libraries.
cmOStringStream linklibs;
this->LocalGenerator->OutputLinkLibraries(linklibs, *this->Target, relink);
......@@ -864,6 +874,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
}
this->LocalGenerator->TargetImplib = "";
// Restore path conversion to normal shells.
this->LocalGenerator->SetLinkScriptShell(false);
}
// Optionally convert the build rule to use a script to avoid long
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment