summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx79
1 files changed, 58 insertions, 21 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 0e89fab..6717c3f 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -89,7 +89,10 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path)
{
std::string result = path;
#ifdef _WIN32
- cmSystemTools::ReplaceString(result, "/", "\\");
+ if(UsingMinGW)
+ cmSystemTools::ReplaceString(result, "\\", "/");
+ else
+ cmSystemTools::ReplaceString(result, "/", "\\");
#endif
return EncodeLiteral(result);
}
@@ -101,7 +104,8 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
const cmNinjaDeps& explicitDeps,
const cmNinjaDeps& implicitDeps,
const cmNinjaDeps& orderOnlyDeps,
- const cmNinjaVars& variables)
+ const cmNinjaVars& variables,
+ int cmdLineLimit)
{
// Make sure there is a rule.
if(rule.empty())
@@ -123,50 +127,59 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
cmGlobalNinjaGenerator::WriteComment(os, comment);
- std::ostringstream builds;
+ std::stringstream arguments;
// TODO: Better formatting for when there are multiple input/output files.
- // Write outputs files.
- builds << "build";
- for(cmNinjaDeps::const_iterator i = outputs.begin();
- i != outputs.end();
- ++i)
- builds << " " << EncodeIdent(EncodePath(*i), os);
- builds << ":";
-
- // Write the rule.
- builds << " " << rule;
-
// Write explicit dependencies.
for(cmNinjaDeps::const_iterator i = explicitDeps.begin();
i != explicitDeps.end();
++i)
- builds << " " << EncodeIdent(EncodePath(*i), os);
+ arguments << " " << EncodeIdent(EncodePath(*i), os);
// Write implicit dependencies.
if(!implicitDeps.empty())
{
- builds << " |";
+ arguments << " |";
for(cmNinjaDeps::const_iterator i = implicitDeps.begin();
i != implicitDeps.end();
++i)
- builds << " " << EncodeIdent(EncodePath(*i), os);
+ arguments << " " << EncodeIdent(EncodePath(*i), os);
}
// Write order-only dependencies.
if(!orderOnlyDeps.empty())
{
- builds << " ||";
+ arguments << " ||";
for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin();
i != orderOnlyDeps.end();
++i)
- builds << " " << EncodeIdent(EncodePath(*i), os);
+ arguments << " " << EncodeIdent(EncodePath(*i), os);
}
- builds << "\n";
+ arguments << "\n";
+
+
+ std::ostringstream builds;
+
+ // Write outputs files.
+ builds << "build";
+ for(cmNinjaDeps::const_iterator i = outputs.begin();
+ i != outputs.end();
+ ++i)
+ builds << " " << EncodeIdent(EncodePath(*i), os);
+ builds << ":";
+
+
+ // 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() > (size_t)cmdLineLimit)
+ builds << "_RSPFILE";
- os << builds.str();
+ os << builds.str() << args;
// Write the variables bound to this build statement.
for(cmNinjaVars::const_iterator i = variables.begin();
@@ -200,6 +213,7 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
"$DESC",
"Rule for running custom commands.",
/*depfile*/ "",
+ /*rspfile*/ "",
/*restat*/ true);
}
@@ -233,6 +247,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
const std::string& description,
const std::string& comment,
const std::string& depfile,
+ const std::string& rspfile,
bool restat,
bool generator)
{
@@ -277,6 +292,14 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
os << "description = " << description << "\n";
}
+ if(!rspfile.empty())
+ {
+ cmGlobalNinjaGenerator::Indent(os, 1);
+ os << "rspfile = " << rspfile << "\n";
+ cmGlobalNinjaGenerator::Indent(os, 1);
+ os << "rspfile_content = $in" << "\n";
+ }
+
if(restat)
{
cmGlobalNinjaGenerator::Indent(os, 1);
@@ -424,8 +447,17 @@ void cmGlobalNinjaGenerator
}
this->ResolveLanguageCompiler(*l, mf, optional);
}
+
+ // check for mingw
+ std::string cc = mf->GetDefinition("CMAKE_C_COMPILER");
+ if(cc.find("gcc.exe") != std::string::npos)
+ {
+ UsingMinGW = true;
+ }
}
+bool cmGlobalNinjaGenerator::UsingMinGW = false;
+
// Implemented by:
// cmGlobalUnixMakefileGenerator3
// cmGlobalVisualStudio10Generator
@@ -483,6 +515,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
const std::string& description,
const std::string& comment,
const std::string& depfile,
+ const std::string& rspfile,
bool restat,
bool generator)
{
@@ -497,6 +530,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
description,
comment,
depfile,
+ rspfile,
restat,
generator);
}
@@ -841,6 +875,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
"Re-running CMake...",
"Rule for re-running cmake.",
/*depfile=*/ "",
+ /*rspfile=*/ "",
/*restat=*/ false,
/*generator=*/ true);
@@ -878,6 +913,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
"Cleaning all built files...",
"Rule for cleaning all built files.",
/*depfile=*/ "",
+ /*rspfile=*/ "",
/*restat=*/ false,
/*generator=*/ false);
WriteBuild(os,
@@ -898,6 +934,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
"All primary targets available:",
"Rule for printing all primary targets available.",
/*depfile=*/ "",
+ /*rspfile=*/ "",
/*restat=*/ false,
/*generator=*/ false);
WriteBuild(os,