Merge topic 'ninja-cmdLineLimit'
6332ba5
Ninja: also consider rule command length for rsp file0c42faf
Ninja: also consider variables when checking command line length
This commit is contained in:
commit
ada7fe248a
|
@ -160,34 +160,35 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
||||||
|
|
||||||
arguments << "\n";
|
arguments << "\n";
|
||||||
|
|
||||||
|
cmOStringStream build;
|
||||||
cmOStringStream builds;
|
|
||||||
|
|
||||||
// Write outputs files.
|
// Write outputs files.
|
||||||
builds << "build";
|
build << "build";
|
||||||
for(cmNinjaDeps::const_iterator i = outputs.begin();
|
for(cmNinjaDeps::const_iterator i = outputs.begin();
|
||||||
i != outputs.end();
|
i != outputs.end(); ++i)
|
||||||
++i)
|
build << " " << EncodeIdent(EncodePath(*i), os);
|
||||||
builds << " " << EncodeIdent(EncodePath(*i), os);
|
build << ":";
|
||||||
builds << ":";
|
|
||||||
|
|
||||||
|
|
||||||
// Write the rule.
|
// Write the rule.
|
||||||
builds << " " << rule;
|
build << " " << rule;
|
||||||
|
|
||||||
// check if a response file rule should be used
|
|
||||||
const std::string args = arguments.str();
|
|
||||||
if (cmdLineLimit > 0 &&
|
|
||||||
(args.size() + + builds.str().size()) > (size_t)cmdLineLimit)
|
|
||||||
builds << "_RSPFILE";
|
|
||||||
|
|
||||||
os << builds.str() << args;
|
|
||||||
|
|
||||||
// Write the variables bound to this build statement.
|
// Write the variables bound to this build statement.
|
||||||
|
cmOStringStream variable_assignments;
|
||||||
for(cmNinjaVars::const_iterator i = variables.begin();
|
for(cmNinjaVars::const_iterator i = variables.begin();
|
||||||
i != variables.end();
|
i != variables.end(); ++i)
|
||||||
++i)
|
cmGlobalNinjaGenerator::WriteVariable(variable_assignments,
|
||||||
cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1);
|
i->first, i->second, "", 1);
|
||||||
|
|
||||||
|
// check if a response file rule should be used
|
||||||
|
std::string buildstr = build.str();
|
||||||
|
const std::string assignments = variable_assignments.str();
|
||||||
|
const std::string args = arguments.str();
|
||||||
|
if (cmdLineLimit > 0
|
||||||
|
&& args.size() + buildstr.size() + assignments.size()
|
||||||
|
> (size_t) cmdLineLimit)
|
||||||
|
buildstr += "_RSPFILE";
|
||||||
|
|
||||||
|
os << buildstr << args << assignments;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os,
|
void cmGlobalNinjaGenerator::WritePhonyBuild(std::ostream& os,
|
||||||
|
@ -556,6 +557,8 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
|
||||||
rspfile,
|
rspfile,
|
||||||
restat,
|
restat,
|
||||||
generator);
|
generator);
|
||||||
|
|
||||||
|
this->RuleCmdLength[name] = command.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmGlobalNinjaGenerator::HasRule(const std::string &name)
|
bool cmGlobalNinjaGenerator::HasRule(const std::string &name)
|
||||||
|
|
|
@ -319,6 +319,8 @@ private:
|
||||||
|
|
||||||
std::string ninjaCmd() const;
|
std::string ninjaCmd() const;
|
||||||
|
|
||||||
|
int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The file containing the build statement. (the relation ship of the
|
/// The file containing the build statement. (the relation ship of the
|
||||||
/// compilation DAG).
|
/// compilation DAG).
|
||||||
|
@ -335,6 +337,9 @@ private:
|
||||||
/// The set of rules added to the generated build system.
|
/// The set of rules added to the generated build system.
|
||||||
RulesSetType Rules;
|
RulesSetType Rules;
|
||||||
|
|
||||||
|
/// Length of rule command, used by rsp file evaluation
|
||||||
|
std::map<std::string, int> RuleCmdLength;
|
||||||
|
|
||||||
/// The set of dependencies to add to the "all" target.
|
/// The set of dependencies to add to the "all" target.
|
||||||
cmNinjaDeps AllDependencies;
|
cmNinjaDeps AllDependencies;
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
|
||||||
// don't use POST_BUILD.
|
// don't use POST_BUILD.
|
||||||
if (cmdLines.empty())
|
if (cmdLines.empty())
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return "cd.";
|
return "cd .";
|
||||||
#else
|
#else
|
||||||
return ":";
|
return ":";
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -480,7 +480,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
|
||||||
|
|
||||||
int cmdLineLimit;
|
int cmdLineLimit;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cmdLineLimit = 8000;
|
cmdLineLimit = 8000 - this->GetGlobalGenerator()->
|
||||||
|
GetRuleCmdLength(this->LanguageLinkerRule());
|
||||||
#else
|
#else
|
||||||
cmdLineLimit = -1; // TODO
|
cmdLineLimit = -1; // TODO
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue