diff options
author | Brad King <brad.king@kitware.com> | 2016-09-21 12:47:42 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-09-21 12:47:42 (GMT) |
commit | 63fbcd6799e9d2786c6862a6cb41931543bfbff2 (patch) | |
tree | 959e66c19a098e0172d50dec5a693f1416627d66 /Source | |
parent | 0ebd7554bc836009e405ac818f367ff175ce9fc5 (diff) | |
parent | 501f9c93671cdbed546bb92382240cc704cf6e6a (diff) | |
download | CMake-63fbcd6799e9d2786c6862a6cb41931543bfbff2.zip CMake-63fbcd6799e9d2786c6862a6cb41931543bfbff2.tar.gz CMake-63fbcd6799e9d2786c6862a6cb41931543bfbff2.tar.bz2 |
Merge topic 'ninja-implicit-outputs'
501f9c93 cmGlobalNinjaGenerator: Add API to check for implicit outputs support
144a24dc cmGlobalNinjaGenerator: Teach WriteBuild about implicit outputs
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 34 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 5 |
4 files changed, 39 insertions, 12 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index bd65366..b913621 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -140,10 +140,10 @@ std::string cmGlobalNinjaGenerator::EncodeDepfileSpace(const std::string& path) void cmGlobalNinjaGenerator::WriteBuild( std::ostream& os, const std::string& comment, const std::string& rule, - const cmNinjaDeps& outputs, const cmNinjaDeps& explicitDeps, - const cmNinjaDeps& implicitDeps, const cmNinjaDeps& orderOnlyDeps, - const cmNinjaVars& variables, const std::string& rspfile, int cmdLineLimit, - bool* usedResponseFile) + const cmNinjaDeps& outputs, const cmNinjaDeps& implicitOuts, + const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps, + const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables, + const std::string& rspfile, int cmdLineLimit, bool* usedResponseFile) { // Make sure there is a rule. if (rule.empty()) { @@ -204,6 +204,13 @@ void cmGlobalNinjaGenerator::WriteBuild( this->CombinedBuildOutputs.insert(EncodePath(*i)); } } + if (!implicitOuts.empty()) { + build += " |"; + for (cmNinjaDeps::const_iterator i = implicitOuts.begin(); + i != implicitOuts.end(); ++i) { + build += " " + EncodeIdent(EncodePath(*i), os); + } + } build += ":"; // Write the rule. @@ -244,7 +251,8 @@ void cmGlobalNinjaGenerator::WritePhonyBuild( const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps, const cmNinjaDeps& orderOnlyDeps, const cmNinjaVars& variables) { - this->WriteBuild(os, comment, "phony", outputs, explicitDeps, implicitDeps, + this->WriteBuild(os, comment, "phony", outputs, + /*implicitOuts=*/cmNinjaDeps(), explicitDeps, implicitDeps, orderOnlyDeps, variables); } @@ -288,7 +296,8 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( vars["depfile"] = depfile; } this->WriteBuild(*this->BuildFileStream, comment, "CUSTOM_COMMAND", outputs, - deps, cmNinjaDeps(), orderOnly, vars); + /*implicitOuts=*/cmNinjaDeps(), deps, cmNinjaDeps(), + orderOnly, vars); if (this->ComputingUnknownDependencies) { // we need to track every dependency that comes in, since we are trying @@ -330,7 +339,8 @@ void cmGlobalNinjaGenerator::WriteMacOSXContentBuild(const std::string& input, cmNinjaVars vars; this->WriteBuild(*this->BuildFileStream, "", "COPY_OSX_CONTENT", outputs, - deps, cmNinjaDeps(), cmNinjaDeps(), cmNinjaVars()); + /*implicitOuts=*/cmNinjaDeps(), deps, cmNinjaDeps(), + cmNinjaDeps(), cmNinjaVars()); } void cmGlobalNinjaGenerator::WriteRule( @@ -1271,6 +1281,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) this->WriteBuild(os, "Re-run CMake if any of its inputs changed.", "RERUN_CMAKE", /*outputs=*/cmNinjaDeps(1, ninjaBuildFile), + /*implicitOuts=*/cmNinjaDeps(), /*explicitDeps=*/cmNinjaDeps(), implicitDeps, /*orderOnlyDeps=*/cmNinjaDeps(), variables); @@ -1295,6 +1306,13 @@ bool cmGlobalNinjaGenerator::SupportsConsolePool() const RequiredNinjaVersionForConsolePool().c_str()); } +bool cmGlobalNinjaGenerator::SupportsImplicitOuts() const +{ + return !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + this->RequiredNinjaVersionForImplicitOuts().c_str()); +} + void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) { WriteRule(*this->RulesFileStream, "CLEAN", ninjaCmd() + " -t clean", @@ -1308,6 +1326,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) /*generator=*/false); WriteBuild(os, "Clean all the built files.", "CLEAN", /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("clean")), + /*implicitOuts=*/cmNinjaDeps(), /*explicitDeps=*/cmNinjaDeps(), /*implicitDeps=*/cmNinjaDeps(), /*orderOnlyDeps=*/cmNinjaDeps(), @@ -1327,6 +1346,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) /*generator=*/false); WriteBuild(os, "Print all primary targets available.", "HELP", /*outputs=*/cmNinjaDeps(1, this->NinjaOutputPath("help")), + /*implicitOuts=*/cmNinjaDeps(), /*explicitDeps=*/cmNinjaDeps(), /*implicitDeps=*/cmNinjaDeps(), /*orderOnlyDeps=*/cmNinjaDeps(), diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index a0fad64..0201685 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -106,6 +106,7 @@ public: */ void WriteBuild(std::ostream& os, const std::string& comment, const std::string& rule, const cmNinjaDeps& outputs, + const cmNinjaDeps& implicitOuts, const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps, const cmNinjaDeps& orderOnlyDeps, @@ -338,7 +339,9 @@ public: // Ninja generator uses 'deps' and 'msvc_deps_prefix' introduced in 1.3 static std::string RequiredNinjaVersion() { return "1.3"; } static std::string RequiredNinjaVersionForConsolePool() { return "1.5"; } + static std::string RequiredNinjaVersionForImplicitOuts() { return "1.7"; } bool SupportsConsolePool() const; + bool SupportsImplicitOuts() const; std::string NinjaOutputPath(std::string const& path); bool HasOutputPathPrefix() const { return !this->OutputPathPrefix.empty(); } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index f87a788..dbd84cb 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -691,7 +691,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Write the build statement for this target. bool usedResponseFile = false; globalGen.WriteBuild(this->GetBuildFileStream(), comment.str(), - this->LanguageLinkerRule(), outputs, explicitDeps, + this->LanguageLinkerRule(), outputs, + /*implicitOuts=*/cmNinjaDeps(), explicitDeps, implicitDeps, orderOnlyDeps, vars, rspfile, commandLineLengthLimit, &usedResponseFile); this->WriteLinkRule(usedResponseFile); @@ -702,7 +703,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() this->GetBuildFileStream(), "Create executable symlink " + targetOutput, "CMAKE_SYMLINK_EXECUTABLE", cmNinjaDeps(1, targetOutput), - cmNinjaDeps(1, targetOutputReal), emptyDeps, emptyDeps, symlinkVars); + /*implicitOuts=*/cmNinjaDeps(), cmNinjaDeps(1, targetOutputReal), + emptyDeps, emptyDeps, symlinkVars); } else { cmNinjaDeps symlinks; std::string const soName = @@ -717,7 +719,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() symlinks.push_back(targetOutput); globalGen.WriteBuild( this->GetBuildFileStream(), "Create library symlink " + targetOutput, - "CMAKE_SYMLINK_LIBRARY", symlinks, cmNinjaDeps(1, targetOutputReal), + "CMAKE_SYMLINK_LIBRARY", symlinks, + /*implicitOuts=*/cmNinjaDeps(), cmNinjaDeps(1, targetOutputReal), emptyDeps, emptyDeps, symlinkVars); } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 6ac59d5..fb09bfe 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -607,8 +607,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( std::string const rspfile = objectFileName + ".rsp"; this->GetGlobalGenerator()->WriteBuild( - this->GetBuildFileStream(), comment, rule, outputs, explicitDeps, - implicitDeps, orderOnlyDeps, vars, rspfile, commandLineLengthLimit); + this->GetBuildFileStream(), comment, rule, outputs, + /*implicitOuts=*/cmNinjaDeps(), explicitDeps, implicitDeps, orderOnlyDeps, + vars, rspfile, commandLineLengthLimit); if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) { std::vector<std::string> outputList; |