From 0c42faf63acadf320ea6371d42d03386e1c20176 Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Mon, 2 Jul 2012 00:01:41 +0200 Subject: [PATCH 1/2] Ninja: also consider variables when checking command line length --- Source/cmGlobalNinjaGenerator.cxx | 41 ++++++++++++++++--------------- Source/cmLocalNinjaGenerator.cxx | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c3989c046..6e8ce871f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -160,34 +160,35 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, arguments << "\n"; - - cmOStringStream builds; + cmOStringStream build; // Write outputs files. - builds << "build"; + build << "build"; for(cmNinjaDeps::const_iterator i = outputs.begin(); - i != outputs.end(); - ++i) - builds << " " << EncodeIdent(EncodePath(*i), os); - builds << ":"; - + i != outputs.end(); ++i) + build << " " << EncodeIdent(EncodePath(*i), os); + build << ":"; // Write the rule. - builds << " " << 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; + build << " " << rule; // Write the variables bound to this build statement. + cmOStringStream variable_assignments; for(cmNinjaVars::const_iterator i = variables.begin(); - i != variables.end(); - ++i) - cmGlobalNinjaGenerator::WriteVariable(os, i->first, i->second, "", 1); + i != variables.end(); ++i) + cmGlobalNinjaGenerator::WriteVariable(variable_assignments, + 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, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 9a496f294..ea9c406c0 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -272,7 +272,7 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( // don't use POST_BUILD. if (cmdLines.empty()) #ifdef _WIN32 - return "cd."; + return "cd ."; #else return ":"; #endif From 6332ba5a58f0114d1763c263950eae20b09eaa4b Mon Sep 17 00:00:00 2001 From: Peter Kuemmel Date: Mon, 2 Jul 2012 10:30:29 +0200 Subject: [PATCH 2/2] Ninja: also consider rule command length for rsp file --- Source/cmGlobalNinjaGenerator.cxx | 2 ++ Source/cmGlobalNinjaGenerator.h | 5 +++++ Source/cmNinjaNormalTargetGenerator.cxx | 3 ++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 6e8ce871f..23f42e440 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -557,6 +557,8 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, rspfile, restat, generator); + + this->RuleCmdLength[name] = command.size(); } bool cmGlobalNinjaGenerator::HasRule(const std::string &name) diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index e939f6149..e5f809930 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -319,6 +319,8 @@ private: std::string ninjaCmd() const; + int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; } + private: /// The file containing the build statement. (the relation ship of the /// compilation DAG). @@ -335,6 +337,9 @@ private: /// The set of rules added to the generated build system. RulesSetType Rules; + /// Length of rule command, used by rsp file evaluation + std::map RuleCmdLength; + /// The set of dependencies to add to the "all" target. cmNinjaDeps AllDependencies; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 01e8e737a..6befb051c 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -480,7 +480,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() int cmdLineLimit; #ifdef _WIN32 - cmdLineLimit = 8000; + cmdLineLimit = 8000 - this->GetGlobalGenerator()-> + GetRuleCmdLength(this->LanguageLinkerRule()); #else cmdLineLimit = -1; // TODO #endif