Merge topic 'ninja-object-rsp'

7731e44f Ninja: Honor CMAKE_NINJA_FORCE_RESPONSE_FILE for compile rules
f9644a2d cmGlobalNinjaGenerator: Clarify logic for forcing use of response files
24c9106b cmNinjaTargetGenerator: Factor out helper for forced response file check
This commit is contained in:
Brad King 2016-04-08 09:01:50 -04:00 committed by CMake Topic Stage
commit 2369f19a7a
5 changed files with 40 additions and 12 deletions

View File

@ -230,9 +230,10 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
std::string assignments = variable_assignments.str();
const std::string& args = arguments;
bool useResponseFile = false;
if (cmdLineLimit > 0
&& args.size() + buildstr.size() + assignments.size()
> (size_t) cmdLineLimit) {
if (cmdLineLimit < 0 ||
(cmdLineLimit > 0 &&
(args.size() + buildstr.size() + assignments.size())
> static_cast<size_t>(cmdLineLimit))) {
variable_assignments.str(std::string());
cmGlobalNinjaGenerator::WriteVariable(variable_assignments,
"RSP_FILE", rspfile, "", 1);

View File

@ -94,7 +94,7 @@ public:
const cmNinjaDeps& orderOnlyDeps,
const cmNinjaVars& variables,
const std::string& rspfile = std::string(),
int cmdLineLimit = -1,
int cmdLineLimit = 0,
bool* usedResponseFile = 0);
/**

View File

@ -697,10 +697,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
int commandLineLengthLimit = 1;
const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
if (!mf->IsDefinitionSet(forceRspFile) &&
cmSystemTools::GetEnv(forceRspFile) == 0)
int commandLineLengthLimit = -1;
if (!this->ForceResponseFile())
{
commandLineLengthLimit = calculateCommandLineLengthLimit(
globalGen.GetRuleCmdLength(this->LanguageLinkerRule()));

View File

@ -341,11 +341,25 @@ cmNinjaTargetGenerator
cmMakefile* mf = this->GetMakefile();
std::string flags = "$FLAGS";
std::string rspfile;
std::string rspcontent;
std::string responseFlag;
if (this->ForceResponseFile())
{
rspfile = "$RSP_FILE";
responseFlag = "@" + rspfile;
rspcontent = " $DEFINES $INCLUDES $FLAGS";
flags = responseFlag;
vars.Defines = "";
vars.Includes = "";
}
// Tell ninja dependency format so all deps can be loaded into a database
std::string deptype;
std::string depfile;
std::string cldeps;
std::string flags = "$FLAGS";
if (this->NeedDepTypeMSVC(lang))
{
deptype = "msvc";
@ -460,8 +474,8 @@ cmNinjaTargetGenerator
comment.str(),
depfile,
deptype,
/*rspfile*/ "",
/*rspcontent*/ "",
rspfile,
rspcontent,
/*restat*/ "",
/*generator*/ false);
}
@ -641,6 +655,9 @@ cmNinjaTargetGenerator
this->SetMsvcTargetPdbVariable(vars);
int const commandLineLengthLimit = this->ForceResponseFile() ? -1 : 0;
std::string const rspfile = objectFileName + ".rsp";
this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(),
comment,
rule,
@ -648,7 +665,10 @@ cmNinjaTargetGenerator
explicitDeps,
implicitDeps,
orderOnlyDeps,
vars);
vars,
rspfile,
commandLineLengthLimit);
if(const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
std::vector<std::string> outputList;
@ -795,3 +815,10 @@ void cmNinjaTargetGenerator::addPoolNinjaVariable(
vars["pool"] = pool;
}
}
bool cmNinjaTargetGenerator::ForceResponseFile()
{
static std::string const forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
return (this->GetMakefile()->IsDefinitionSet(forceRspFile) ||
cmSystemTools::GetEnv(forceRspFile) != 0);
}

View File

@ -152,6 +152,8 @@ protected:
cmGeneratorTarget* target,
cmNinjaVars& vars);
bool ForceResponseFile();
private:
cmLocalNinjaGenerator* LocalGenerator;
/// List of object files for this target.