summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorPeter Kümmel <syntheticpp@gmx.net>2013-11-23 09:49:36 (GMT)
committerPeter Kümmel <syntheticpp@gmx.net>2013-11-25 21:23:24 (GMT)
commit7605e37aabae2678e5696a75e84aced2e84f9037 (patch)
treedced8cd0e0baf12da23f2e2221abca2483fba313 /Source
parentda6b86f4f031b189768dc474721145a1b99f71ea (diff)
downloadCMake-7605e37aabae2678e5696a75e84aced2e84f9037.zip
CMake-7605e37aabae2678e5696a75e84aced2e84f9037.tar.gz
CMake-7605e37aabae2678e5696a75e84aced2e84f9037.tar.bz2
Ninja: job pool support for compiling and linking
Could be tested by setting the environment variable NINJA_STATUS=[%r]
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalNinjaGenerator.cxx35
-rw-r--r--Source/cmLocalNinjaGenerator.h1
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx13
-rw-r--r--Source/cmNinjaTargetGenerator.h5
-rw-r--r--Source/cmTarget.cxx3
6 files changed, 58 insertions, 1 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 158d714..5d2fb50 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -53,6 +53,8 @@ void cmLocalNinjaGenerator::Generate()
{
this->WriteBuildFileTop();
+ this->WritePools(this->GetRulesFileStream());
+
const std::string showIncludesPrefix = this->GetMakefile()
->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
if (!showIncludesPrefix.empty())
@@ -200,6 +202,39 @@ void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
}
+void cmLocalNinjaGenerator::WritePools(std::ostream& os)
+{
+ cmGlobalNinjaGenerator::WriteDivider(os);
+
+ const char* jobpools = this->GetCMakeInstance()
+ ->GetProperty("JOB_POOLS", cmProperty::GLOBAL);
+ if (jobpools)
+ {
+ cmGlobalNinjaGenerator::WriteComment(os,
+ "Pools defined by global property JOB_POOLS");
+ std::vector<std::string> pools;
+ cmSystemTools::ExpandListArgument(jobpools, pools);
+ for (size_t i = 0; i < pools.size(); ++i)
+ {
+ const std::string pool = pools[i];
+ const std::string::size_type eq = pool.find("=");
+ unsigned int jobs;
+ if (eq != std::string::npos &&
+ sscanf(pool.c_str() + eq, "=%u", &jobs) == 1)
+ {
+ os << "pool " << pool.substr(0, eq) << std::endl;
+ os << " depth = " << jobs << std::endl;
+ os << std::endl;
+ }
+ else
+ {
+ cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': ",
+ pool.c_str());
+ }
+ }
+ }
+}
+
void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 8eb63c5..ea854c6 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -112,6 +112,7 @@ private:
void WriteProjectHeader(std::ostream& os);
void WriteNinjaFilesInclusion(std::ostream& os);
void WriteProcessedMakefile(std::ostream& os);
+ void WritePools(std::ostream& os);
void SetConfigName();
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 2c96ede..73ba815 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -464,6 +464,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
linkPath,
this->GetGeneratorTarget());
+ this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);
+
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
vars["LINK_FLAGS"] = cmGlobalNinjaGenerator
::EncodeLiteral(vars["LINK_FLAGS"]);
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index b132db6..f40532c 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -572,6 +572,8 @@ cmNinjaTargetGenerator
ConvertToNinjaPath(objectDir.c_str()).c_str(),
cmLocalGenerator::SHELL);
+ this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars);
+
this->SetMsvcTargetPdbVariable(vars);
if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS"))
@@ -725,3 +727,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
// Add as a dependency of all target so that it gets called.
this->Generator->GetGlobalGenerator()->AddDependencyToAll(output);
}
+
+void cmNinjaTargetGenerator::addPoolNinjaVariable(const char* pool_property,
+ cmTarget* target,
+ cmNinjaVars& vars)
+{
+ const char* pool = target->GetProperty(pool_property);
+ if (pool)
+ {
+ vars["pool"] = pool;
+ }
+}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index e377a78..2ce1ed7 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -136,12 +136,15 @@ protected:
};
friend struct MacOSXContentGeneratorType;
-protected:
+
MacOSXContentGeneratorType* MacOSXContentGenerator;
// Properly initialized by sub-classes.
cmOSXBundleGenerator* OSXBundleGenerator;
std::set<cmStdString> MacContentFolders;
+ void addPoolNinjaVariable(const char* pool_property,
+ cmTarget* target,
+ cmNinjaVars& vars);
private:
cmTarget* Target;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 120a666..c05bb23 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -379,6 +379,9 @@ void cmTarget::SetMakefile(cmMakefile* mf)
// so ensure that the conditions don't lead to nonsense.
this->PolicyStatusCMP0022 = cmPolicies::NEW;
}
+
+ this->SetPropertyDefault("JOB_POOL_COMPILE", 0);
+ this->SetPropertyDefault("JOB_POOL_LINK", 0);
}
//----------------------------------------------------------------------------