summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx20
-rw-r--r--Source/cmGlobalNinjaGenerator.h10
-rw-r--r--Source/cmLocalNinjaGenerator.cxx2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx5
-rw-r--r--Source/cmNinjaTargetGenerator.cxx3
5 files changed, 35 insertions, 5 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,
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 0c740e8..b2c2aa8 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -16,6 +16,8 @@
# include "cmGlobalGenerator.h"
# include "cmNinjaTypes.h"
+//#define NINJA_GEN_VERBOSE_FILES
+
class cmLocalGenerator;
class cmGeneratedFileStream;
class cmGeneratorTarget;
@@ -215,6 +217,11 @@ public:
cmGeneratedFileStream* GetRulesFileStream() const
{ return this->RulesFileStream; }
+ void ClearCommentStream();
+ cmsys_ios::stringstream& GetCommentStream() const
+ { return *this->CommentStream; }
+
+
void AddCXXCompileCommand(const std::string &commandLine,
const std::string &sourceFile);
@@ -346,6 +353,9 @@ private:
static cmLocalGenerator* LocalGenerator;
static bool UsingMinGW;
+
+ cmsys_ios::stringstream* CommentStream;
+
};
#endif // ! cmGlobalNinjaGenerator_h
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index a0141cf..5d193cd 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -46,7 +46,9 @@ void cmLocalNinjaGenerator::Generate()
this->SetConfigName();
this->WriteProcessedMakefile(this->GetBuildFileStream());
+#ifdef NINJA_GEN_VERBOSE_FILES
this->WriteProcessedMakefile(this->GetRulesFileStream());
+#endif
this->WriteBuildFileTop();
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index ddf96eb..e377706 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -96,13 +96,11 @@ void cmNinjaNormalTargetGenerator::Generate()
#endif
this->WriteLinkStatement();
}
-
- this->GetBuildFileStream() << "\n";
- this->GetRulesFileStream() << "\n";
}
void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
{
+#ifdef NINJA_GEN_VERBOSE_FILES
cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream());
this->GetRulesFileStream()
<< "# Rules for each languages for "
@@ -110,6 +108,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
<< " target "
<< this->GetTargetName()
<< "\n\n";
+#endif
std::set<cmStdString> languages;
this->GetTarget()->GetLanguages(languages);
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 40fdc8b..f66d1d3 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -309,10 +309,11 @@ void
cmNinjaTargetGenerator
::WriteLanguageRules(const std::string& language)
{
+#ifdef NINJA_GEN_VERBOSE_FILES
this->GetRulesFileStream()
<< "# Rules for language " << language << "\n\n";
+#endif
this->WriteCompileRule(language);
- this->GetRulesFileStream() << "\n";
}
void