summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-04-08 13:01:50 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-04-08 13:01:50 (GMT)
commit2369f19a7a2fceacad32e137f1eb61bebcf9c608 (patch)
tree154896e85728761486bca702a909714131c47276 /Source
parent2f76effd0a8fd7bb25941891ca9603d27f1c571f (diff)
parent7731e44f87ca9f70335f211a4ef64a1ea68c7f10 (diff)
downloadCMake-2369f19a7a2fceacad32e137f1eb61bebcf9c608.zip
CMake-2369f19a7a2fceacad32e137f1eb61bebcf9c608.tar.gz
CMake-2369f19a7a2fceacad32e137f1eb61bebcf9c608.tar.bz2
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
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx7
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx6
-rw-r--r--Source/cmNinjaTargetGenerator.cxx35
-rw-r--r--Source/cmNinjaTargetGenerator.h2
5 files changed, 40 insertions, 12 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index f12396f..fadb0cf 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -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);
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 3023a95..3093a11 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -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);
/**
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index c34df3c..322f37d 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -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()));
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5ff4fdb..753a5ae 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -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);
+}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index e3ec423..371bc3c 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -152,6 +152,8 @@ protected:
cmGeneratorTarget* target,
cmNinjaVars& vars);
+ bool ForceResponseFile();
+
private:
cmLocalNinjaGenerator* LocalGenerator;
/// List of object files for this target.