BUG: cd into local directory to reduce link line length
This commit is contained in:
parent
66e50573c1
commit
6b444ee345
@ -1304,9 +1304,9 @@ cmLocalUnixMakefileGenerator3
|
|||||||
|
|
||||||
// Convert to the output path to use in constructing commands.
|
// Convert to the output path to use in constructing commands.
|
||||||
std::string targetOutPath =
|
std::string targetOutPath =
|
||||||
this->Convert(targetFullPath.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(targetFullPath.c_str(),START_OUTPUT,MAKEFILE);
|
||||||
std::string targetOutPathReal =
|
std::string targetOutPathReal =
|
||||||
this->Convert(targetFullPathReal.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(targetFullPathReal.c_str(),START_OUTPUT,MAKEFILE);
|
||||||
|
|
||||||
// Get the language to use for linking this executable.
|
// Get the language to use for linking this executable.
|
||||||
const char* linkLanguage =
|
const char* linkLanguage =
|
||||||
@ -1330,35 +1330,7 @@ cmLocalUnixMakefileGenerator3
|
|||||||
// Build a list of compiler flags and linker flags.
|
// Build a list of compiler flags and linker flags.
|
||||||
std::string flags;
|
std::string flags;
|
||||||
std::string linkFlags;
|
std::string linkFlags;
|
||||||
#if 0
|
|
||||||
// Loop over all libraries and see if all are shared
|
|
||||||
const cmTarget::LinkLibraries& tlibs = target.GetLinkLibraries();
|
|
||||||
int AllShared = 2; // 0 = false, 1 = true, 2 = unknown
|
|
||||||
for(cmTarget::LinkLibraries::const_iterator lib = tlibs.begin();
|
|
||||||
lib != tlibs.end(); ++lib)
|
|
||||||
{
|
|
||||||
// look up the target if there is one
|
|
||||||
cmTarget *libtgt = m_GlobalGenerator->FindTarget(0,lib->first.c_str());
|
|
||||||
if (libtgt)
|
|
||||||
{
|
|
||||||
if (libtgt->GetType() != cmTarget::SHARED_LIBRARY)
|
|
||||||
{
|
|
||||||
AllShared = 0;
|
|
||||||
}
|
|
||||||
else if (AllShared == 2)
|
|
||||||
{
|
|
||||||
AllShared = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if all libs were shared then add the special borland flag for linking an
|
|
||||||
// executable to only shared libs
|
|
||||||
if(AllShared == 1)
|
|
||||||
{
|
|
||||||
this->AppendFlags
|
|
||||||
(linkFlags,m_Makefile->GetDefinition("CMAKE_SHARED_BUILD_CXX_FLAGS"));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Add flags to deal with shared libraries. Any library being
|
// Add flags to deal with shared libraries. Any library being
|
||||||
// linked in might be shared, so always use shared flags for an
|
// linked in might be shared, so always use shared flags for an
|
||||||
// executable.
|
// executable.
|
||||||
@ -1368,7 +1340,6 @@ cmLocalUnixMakefileGenerator3
|
|||||||
this->AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS");
|
this->AddConfigVariableFlags(linkFlags, "CMAKE_EXE_LINKER_FLAGS");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(target.GetPropertyAsBool("WIN32_EXECUTABLE"))
|
if(target.GetPropertyAsBool("WIN32_EXECUTABLE"))
|
||||||
{
|
{
|
||||||
this->AppendFlags(linkFlags,
|
this->AppendFlags(linkFlags,
|
||||||
@ -1415,8 +1386,12 @@ cmLocalUnixMakefileGenerator3
|
|||||||
std::string linkRuleVar = "CMAKE_";
|
std::string linkRuleVar = "CMAKE_";
|
||||||
linkRuleVar += linkLanguage;
|
linkRuleVar += linkLanguage;
|
||||||
linkRuleVar += "_LINK_EXECUTABLE";
|
linkRuleVar += "_LINK_EXECUTABLE";
|
||||||
std::string linkRule = m_Makefile->GetRequiredDefinition(linkRuleVar.c_str());
|
std::string linkRule =
|
||||||
cmSystemTools::ExpandListArgument(linkRule, commands);
|
m_Makefile->GetRequiredDefinition(linkRuleVar.c_str());
|
||||||
|
std::vector<std::string> commands1;
|
||||||
|
cmSystemTools::ExpandListArgument(linkRule, commands1);
|
||||||
|
this->CreateCDCommand(commands1);
|
||||||
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
||||||
|
|
||||||
// Add a rule to create necessary symlinks for the library.
|
// Add a rule to create necessary symlinks for the library.
|
||||||
if(targetOutPath != targetOutPathReal)
|
if(targetOutPath != targetOutPathReal)
|
||||||
@ -1670,13 +1645,13 @@ cmLocalUnixMakefileGenerator3
|
|||||||
// Construct the output path version of the names for use in command
|
// Construct the output path version of the names for use in command
|
||||||
// arguments.
|
// arguments.
|
||||||
std::string targetOutPath =
|
std::string targetOutPath =
|
||||||
this->Convert(targetFullPath.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(targetFullPath.c_str(),START_OUTPUT,MAKEFILE);
|
||||||
std::string targetOutPathSO =
|
std::string targetOutPathSO =
|
||||||
this->Convert(targetFullPathSO.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(targetFullPathSO.c_str(),START_OUTPUT,MAKEFILE);
|
||||||
std::string targetOutPathReal =
|
std::string targetOutPathReal =
|
||||||
this->Convert(targetFullPathReal.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(targetFullPathReal.c_str(),START_OUTPUT,MAKEFILE);
|
||||||
std::string targetOutPathBase =
|
std::string targetOutPathBase =
|
||||||
this->Convert(targetFullPathBase.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(targetFullPathBase.c_str(),START_OUTPUT,MAKEFILE);
|
||||||
|
|
||||||
// Add the link message.
|
// Add the link message.
|
||||||
std::string buildEcho = "Linking ";
|
std::string buildEcho = "Linking ";
|
||||||
@ -1743,7 +1718,10 @@ cmLocalUnixMakefileGenerator3
|
|||||||
|
|
||||||
// Construct the main link rule.
|
// Construct the main link rule.
|
||||||
std::string linkRule = m_Makefile->GetRequiredDefinition(linkRuleVar);
|
std::string linkRule = m_Makefile->GetRequiredDefinition(linkRuleVar);
|
||||||
cmSystemTools::ExpandListArgument(linkRule, commands);
|
std::vector<std::string> commands1;
|
||||||
|
cmSystemTools::ExpandListArgument(linkRule, commands1);
|
||||||
|
this->CreateCDCommand(commands1);
|
||||||
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
||||||
|
|
||||||
// Add a rule to create necessary symlinks for the library.
|
// Add a rule to create necessary symlinks for the library.
|
||||||
if(targetOutPath != targetOutPathReal)
|
if(targetOutPath != targetOutPathReal)
|
||||||
@ -1832,12 +1810,11 @@ cmLocalUnixMakefileGenerator3
|
|||||||
ruleFileStream
|
ruleFileStream
|
||||||
<< "# Object files for target " << target.GetName() << "\n"
|
<< "# Object files for target " << target.GetName() << "\n"
|
||||||
<< variableName.c_str() << " =";
|
<< variableName.c_str() << " =";
|
||||||
std::string relPath = this->GetHomeRelativeOutputPath();
|
|
||||||
std::string object;
|
std::string object;
|
||||||
for(std::vector<std::string>::const_iterator i = objects.begin();
|
for(std::vector<std::string>::const_iterator i = objects.begin();
|
||||||
i != objects.end(); ++i)
|
i != objects.end(); ++i)
|
||||||
{
|
{
|
||||||
object = relPath;
|
object.clear();
|
||||||
object += *i;
|
object += *i;
|
||||||
ruleFileStream
|
ruleFileStream
|
||||||
<< " \\\n"
|
<< " \\\n"
|
||||||
@ -1857,7 +1834,7 @@ cmLocalUnixMakefileGenerator3
|
|||||||
for(std::vector<std::string>::const_iterator i = external_objects.begin();
|
for(std::vector<std::string>::const_iterator i = external_objects.begin();
|
||||||
i != external_objects.end(); ++i)
|
i != external_objects.end(); ++i)
|
||||||
{
|
{
|
||||||
object = this->Convert(i->c_str(),HOME_OUTPUT);
|
object = this->Convert(i->c_str(),START_OUTPUT);
|
||||||
ruleFileStream
|
ruleFileStream
|
||||||
<< " \\\n"
|
<< " \\\n"
|
||||||
<< this->ConvertToQuotedOutputPath(object.c_str());
|
<< this->ConvertToQuotedOutputPath(object.c_str());
|
||||||
@ -2340,8 +2317,6 @@ cmLocalUnixMakefileGenerator3
|
|||||||
::AppendCustomCommand(std::vector<std::string>& commands,
|
::AppendCustomCommand(std::vector<std::string>& commands,
|
||||||
const cmCustomCommand& cc)
|
const cmCustomCommand& cc)
|
||||||
{
|
{
|
||||||
// TODO: Convert outputs/dependencies (arguments?) to relative paths.
|
|
||||||
|
|
||||||
std::vector<std::string> commands1;
|
std::vector<std::string> commands1;
|
||||||
|
|
||||||
// Add each command line to the set of commands.
|
// Add each command line to the set of commands.
|
||||||
@ -2372,43 +2347,9 @@ cmLocalUnixMakefileGenerator3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stick this group of commands into a cd of the proper path
|
|
||||||
// Build the jump-and-build command list.
|
|
||||||
if(m_WindowsShell)
|
|
||||||
{
|
|
||||||
// On Windows we must perform each step separately and then jump
|
|
||||||
// back because the shell keeps the working directory between
|
|
||||||
// commands.
|
|
||||||
std::string cmd = "cd ";
|
|
||||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetStartOutputDirectory());
|
|
||||||
commands.push_back(cmd);
|
|
||||||
|
|
||||||
// push back the custom commands
|
// push back the custom commands
|
||||||
|
this->CreateCDCommand(commands1);
|
||||||
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
||||||
|
|
||||||
// Jump back to the home directory.
|
|
||||||
cmd = "cd ";
|
|
||||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetHomeOutputDirectory());
|
|
||||||
commands.push_back(cmd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// On UNIX we must construct a single shell command to jump and
|
|
||||||
// build because make resets the directory between each command.
|
|
||||||
std::string cmd = "cd ";
|
|
||||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetStartOutputDirectory());
|
|
||||||
|
|
||||||
// add the commands
|
|
||||||
unsigned int i;
|
|
||||||
for (i = 0; i < commands1.size(); ++i)
|
|
||||||
{
|
|
||||||
cmd += " && ";
|
|
||||||
cmd += commands1[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the command as a single line.
|
|
||||||
commands.push_back(cmd);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -2990,9 +2931,7 @@ void cmLocalUnixMakefileGenerator3
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmLocalUnixMakefileGenerator3
|
void cmLocalUnixMakefileGenerator3
|
||||||
::CreateJumpCommand(std::vector<std::string>& commands,
|
::CreateCDCommand(std::vector<std::string>& commands)
|
||||||
const char *MakefileName,
|
|
||||||
std::string& localName)
|
|
||||||
{
|
{
|
||||||
if(m_WindowsShell)
|
if(m_WindowsShell)
|
||||||
{
|
{
|
||||||
@ -3001,18 +2940,12 @@ void cmLocalUnixMakefileGenerator3
|
|||||||
// commands.
|
// commands.
|
||||||
std::string cmd = "cd ";
|
std::string cmd = "cd ";
|
||||||
cmd += this->ConvertToOutputForExisting
|
cmd += this->ConvertToOutputForExisting
|
||||||
(m_Makefile->GetHomeOutputDirectory());
|
(m_Makefile->GetStartOutputDirectory());
|
||||||
commands.push_back(cmd);
|
commands.insert(commands.begin(),cmd);
|
||||||
|
|
||||||
// Build the target for this pass.
|
|
||||||
commands.push_back(this->GetRecursiveMakeCall
|
|
||||||
(MakefileName,localName.c_str()));
|
|
||||||
|
|
||||||
// Change back to the starting directory. Any trailing slash must be
|
// Change back to the starting directory. Any trailing slash must be
|
||||||
// removed to avoid problems with Borland Make.
|
// removed to avoid problems with Borland Make.
|
||||||
std::string back =
|
std::string back = m_Makefile->GetHomeOutputDirectory();
|
||||||
cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(),
|
|
||||||
m_Makefile->GetStartOutputDirectory());
|
|
||||||
if(back.size() && back[back.size()-1] == '/')
|
if(back.size() && back[back.size()-1] == '/')
|
||||||
{
|
{
|
||||||
back = back.substr(0, back.size()-1);
|
back = back.substr(0, back.size()-1);
|
||||||
@ -3026,17 +2959,29 @@ void cmLocalUnixMakefileGenerator3
|
|||||||
// On UNIX we must construct a single shell command to change
|
// On UNIX we must construct a single shell command to change
|
||||||
// directory and build because make resets the directory between
|
// directory and build because make resets the directory between
|
||||||
// each command.
|
// each command.
|
||||||
|
std::vector<std::string>::iterator i = commands.begin();
|
||||||
|
for (; i != commands.end(); ++i)
|
||||||
|
{
|
||||||
std::string cmd = "cd ";
|
std::string cmd = "cd ";
|
||||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetHomeOutputDirectory());
|
cmd += this->ConvertToOutputForExisting(m_Makefile->GetStartOutputDirectory());
|
||||||
|
|
||||||
// Build the target for this pass.
|
|
||||||
cmd += " && ";
|
cmd += " && ";
|
||||||
cmd += this->GetRecursiveMakeCall(MakefileName,localName.c_str());
|
cmd += *i;
|
||||||
|
*i = cmd;
|
||||||
// Add the command as a single line.
|
|
||||||
commands.push_back(cmd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmLocalUnixMakefileGenerator3
|
||||||
|
::CreateJumpCommand(std::vector<std::string>& commands,
|
||||||
|
const char *MakefileName,
|
||||||
|
std::string& localName)
|
||||||
|
{
|
||||||
|
// Build the target for this pass.
|
||||||
|
commands.push_back(this->GetRecursiveMakeCall
|
||||||
|
(MakefileName,localName.c_str()));
|
||||||
|
|
||||||
|
this->CreateCDCommand(commands);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf,
|
void cmLocalUnixMakefileGenerator3::CheckDependencies(cmMakefile* mf,
|
||||||
|
@ -170,8 +170,11 @@ protected:
|
|||||||
const char *MakefileName,
|
const char *MakefileName,
|
||||||
std::string & localName);
|
std::string & localName);
|
||||||
|
|
||||||
// these two methods just compute reasonable values for m_LibraryOutputPath and
|
// create a command that cds to the start dir then runs the commands
|
||||||
// m_ExecutableOutputPath
|
void CreateCDCommand(std::vector<std::string>& commands);
|
||||||
|
|
||||||
|
// these two methods just compute reasonable values for m_LibraryOutputPath
|
||||||
|
// and m_ExecutableOutputPath
|
||||||
void ConfigureOutputPaths();
|
void ConfigureOutputPaths();
|
||||||
void FormatOutputPath(std::string& path, const char* name);
|
void FormatOutputPath(std::string& path, const char* name);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user