summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-10 18:20:29 (GMT)
committerPeter Kuemmel <syntheticpp@gmx.net>2012-06-10 18:20:29 (GMT)
commitba8d0db217399dede6d897c928b4dbf52e7e141b (patch)
tree5a0e167cdc7c98a26a3a5a52599ec6aa476674d4 /Source/cmGlobalNinjaGenerator.cxx
parent343ff7a72e7c08f3a63dde25bd1f06c8c3854f56 (diff)
downloadCMake-ba8d0db217399dede6d897c928b4dbf52e7e141b.zip
CMake-ba8d0db217399dede6d897c928b4dbf52e7e141b.tar.gz
CMake-ba8d0db217399dede6d897c928b4dbf52e7e141b.tar.bz2
Ninja: don't pollute the rules file with useless comments
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx20
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 648855c..4773c37 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -43,12 +43,13 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os,
std::string replace = comment;
std::string::size_type lpos = 0;
std::string::size_type rpos;
+ os << "\n#############################################\n";
while((rpos = replace.find('\n', lpos)) != std::string::npos)
{
os << "# " << replace.substr(lpos, rpos - lpos) << "\n";
lpos = rpos + 1;
}
- os << "# " << replace.substr(lpos) << "\n";
+ os << "# " << replace.substr(lpos) << "\n\n";
}
static bool IsIdentChar(char c)
@@ -318,6 +319,8 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
cmGlobalNinjaGenerator::Indent(os, 1);
os << "generator = 1\n";
}
+
+ os << "\n";
}
void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os,
@@ -374,12 +377,21 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator()
, CompileCommandsStream(0)
, Rules()
, AllDependencies()
+ , CommentStream(0)
{
// // Ninja is not ported to non-Unix OS yet.
// this->ForceUnixPaths = true;
this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";
+ this->ClearCommentStream();
+}
+
+void cmGlobalNinjaGenerator::ClearCommentStream()
+{
+ delete CommentStream;
+ CommentStream = new cmsys_ios::stringstream(std::ios::out);
}
+
//----------------------------------------------------------------------------
// Virtual public methods.
@@ -537,7 +549,13 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
{
// Do not add the same rule twice.
if (this->HasRule(name))
+ {
+ this->ClearCommentStream();
return;
+ }
+
+ *this->RulesFileStream << this->GetCommentStream().str();
+ this->ClearCommentStream();
this->Rules.insert(name);
cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream,