Merge topic 'ninja-console-pool'

9f32a241 Ninja: Use 'console' pool for CMake re-run if possible (#14915)
This commit is contained in:
Brad King 2014-10-06 09:41:18 -04:00 committed by CMake Topic Stage
commit b1531431dd
4 changed files with 50 additions and 2 deletions

View File

@ -1128,6 +1128,16 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()),
implicitDeps.end()); implicitDeps.end());
cmNinjaVars variables;
// Use 'console' pool to get non buffered output of the CMake re-run call
// Available since Ninja 1.5
if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
ninjaVersion().c_str(),
"1.5") == false)
{
variables["pool"] = "console";
}
this->WriteBuild(os, this->WriteBuild(os,
"Re-run CMake if any of its inputs changed.", "Re-run CMake if any of its inputs changed.",
"RERUN_CMAKE", "RERUN_CMAKE",
@ -1135,7 +1145,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
/*explicitDeps=*/ cmNinjaDeps(), /*explicitDeps=*/ cmNinjaDeps(),
implicitDeps, implicitDeps,
/*orderOnlyDeps=*/ cmNinjaDeps(), /*orderOnlyDeps=*/ cmNinjaDeps(),
/*variables=*/ cmNinjaVars()); variables);
this->WritePhonyBuild(os, this->WritePhonyBuild(os,
"A missing CMake input file is not an error.", "A missing CMake input file is not an error.",
@ -1154,6 +1164,17 @@ std::string cmGlobalNinjaGenerator::ninjaCmd() const
return "ninja"; return "ninja";
} }
std::string cmGlobalNinjaGenerator::ninjaVersion() const
{
std::string version;
std::string command = ninjaCmd() + " --version";
cmSystemTools::RunSingleCommand(command.c_str(),
&version, 0, 0,
cmSystemTools::OUTPUT_NONE);
return version;
}
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
{ {
WriteRule(*this->RulesFileStream, WriteRule(*this->RulesFileStream,

View File

@ -297,6 +297,8 @@ public:
void AddTargetAlias(const std::string& alias, cmTarget* target); void AddTargetAlias(const std::string& alias, cmTarget* target);
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
std::string ninjaVersion() const;
protected: protected:
/// Overloaded methods. @see cmGlobalGenerator::Generate() /// Overloaded methods. @see cmGlobalGenerator::Generate()
@ -335,7 +337,6 @@ private:
std::string ninjaCmd() const; std::string ninjaCmd() const;
/// The file containing the build statement. (the relation ship of the /// The file containing the build statement. (the relation ship of the
/// compilation DAG). /// compilation DAG).
cmGeneratedFileStream* BuildFileStream; cmGeneratedFileStream* BuildFileStream;

View File

@ -189,6 +189,7 @@ void cmLocalNinjaGenerator::WriteBuildFileTop()
{ {
// For the build file. // For the build file.
this->WriteProjectHeader(this->GetBuildFileStream()); this->WriteProjectHeader(this->GetBuildFileStream());
this->WriteNinjaRequiredVersion(this->GetBuildFileStream());
this->WriteNinjaFilesInclusion(this->GetBuildFileStream()); this->WriteNinjaFilesInclusion(this->GetBuildFileStream());
// For the rule file. // For the rule file.
@ -205,6 +206,30 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os); cmGlobalNinjaGenerator::WriteDivider(os);
} }
void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
{
// Default required version
// Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3
std::string requiredVersion = "1.3";
// Ninja generator uses the 'console' pool if available (>= 1.5)
std::string usedVersion = this->GetGlobalNinjaGenerator()->ninjaVersion();
if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
usedVersion.c_str(),
"1.5") == false)
{
requiredVersion = "1.5";
}
cmGlobalNinjaGenerator::WriteComment(os,
"Minimal version of Ninja required by this file");
os
<< "ninja_required_version = "
<< requiredVersion
<< std::endl << std::endl
;
}
void cmLocalNinjaGenerator::WritePools(std::ostream& os) void cmLocalNinjaGenerator::WritePools(std::ostream& os)
{ {
cmGlobalNinjaGenerator::WriteDivider(os); cmGlobalNinjaGenerator::WriteDivider(os);

View File

@ -117,6 +117,7 @@ private:
void WriteBuildFileTop(); void WriteBuildFileTop();
void WriteProjectHeader(std::ostream& os); void WriteProjectHeader(std::ostream& os);
void WriteNinjaRequiredVersion(std::ostream& os);
void WriteNinjaFilesInclusion(std::ostream& os); void WriteNinjaFilesInclusion(std::ostream& os);
void WriteProcessedMakefile(std::ostream& os); void WriteProcessedMakefile(std::ostream& os);
void WritePools(std::ostream& os); void WritePools(std::ostream& os);