summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-10-01 16:25:01 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-10-01 16:25:13 (GMT)
commit62d65286e71c58c88646f2f851edf7669fd40a41 (patch)
treee2ac0c77e9ba02a7fd80f1963617a5b5f00a22e9 /Source/cmGlobalNinjaGenerator.cxx
parentec16afc9e8aed8aebd387c416af5b5eef4ad337a (diff)
parent8a15e75fe351579314f92dd9d9e2c6faeac5ad71 (diff)
downloadCMake-62d65286e71c58c88646f2f851edf7669fd40a41.zip
CMake-62d65286e71c58c88646f2f851edf7669fd40a41.tar.gz
CMake-62d65286e71c58c88646f2f851edf7669fd40a41.tar.bz2
Merge topic 'fix-EXCLUDE_FROM_ALL-subdir-all'
8a15e75fe3 Tests: Cover EXCLUDE_FROM_ALL OFF on sub/sub/tgt in sub/all 7420843370 Makefiles: Fix EXCLUDE_FROM_ALL OFF on sub/sub/tgt in sub/all d713bcb642 Ninja: Factor out per-dir "all" target computation into common generator a75586c775 Ninja: Simplify top-level "all" target generation a49cd4d1a7 Ninja: Fix EXCLUDE_FROM_ALL OFF on sub/sub/tgt in sub/all 0733a94f64 Ninja,Makefile: Fix subdir "all" with nested EXCLUDE_FROM_ALL subdir 11fb377eb9 cmLocalUnixMakefileGenerator3: Mark GetRelativeTargetDirectory const be7857f40d cmLocalCommonGenerator: Mark GetConfigName as const ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3869
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx96
1 files changed, 28 insertions, 68 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 7bba874..d8fe258 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -20,6 +20,7 @@
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmGeneratorTarget.h"
+#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmLocalNinjaGenerator.h"
@@ -888,16 +889,6 @@ void cmGlobalNinjaGenerator::WriteDisclaimer(std::ostream& os)
<< cmVersion::GetMinorVersion() << "\n\n";
}
-void cmGlobalNinjaGenerator::AddDependencyToAll(cmGeneratorTarget* target)
-{
- this->AppendTargetOutputs(target, this->AllDependencies);
-}
-
-void cmGlobalNinjaGenerator::AddDependencyToAll(const std::string& input)
-{
- this->AllDependencies.push_back(input);
-}
-
void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
{
for (auto const& asd : this->AssumedSourceDependencies) {
@@ -1096,59 +1087,32 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Folder targets.\n\n";
- std::string const& rootBinaryDir =
- this->LocalGenerators[0]->GetBinaryDirectory();
+ std::map<std::string, DirectoryTarget> dirTargets =
+ this->ComputeDirectoryTargets();
- std::map<std::string, cmNinjaDeps> targetsPerFolder;
- for (cmLocalGenerator const* lg : this->LocalGenerators) {
- std::string const& currentBinaryFolder(
- lg->GetStateSnapshot().GetDirectory().GetCurrentBinary());
-
- // Do not generate a rule for the root binary dir.
- if (currentBinaryFolder == rootBinaryDir) {
- continue;
- }
-
- // The directory-level rule should depend on the target-level rules
- // for all targets in the directory.
- cmNinjaDeps& folderTargets = targetsPerFolder[currentBinaryFolder];
- for (auto gt : lg->GetGeneratorTargets()) {
- cmStateEnums::TargetType const type = gt->GetType();
- if ((type == cmStateEnums::EXECUTABLE ||
- type == cmStateEnums::STATIC_LIBRARY ||
- type == cmStateEnums::SHARED_LIBRARY ||
- type == cmStateEnums::MODULE_LIBRARY ||
- type == cmStateEnums::OBJECT_LIBRARY ||
- type == cmStateEnums::UTILITY) &&
- !gt->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
- folderTargets.push_back(gt->GetName());
+ for (auto const& it : dirTargets) {
+ cmNinjaBuild build("phony");
+ cmGlobalNinjaGenerator::WriteDivider(os);
+ std::string const& currentBinaryDir = it.first;
+ DirectoryTarget const& dt = it.second;
+
+ // Setup target
+ build.Comment = "Folder: " + currentBinaryDir;
+ build.Outputs.emplace_back(
+ this->ConvertToNinjaPath(currentBinaryDir + "/all"));
+ for (DirectoryTarget::Target const& t : dt.Targets) {
+ if (!t.ExcludeFromAll) {
+ this->AppendTargetOutputs(t.GT, build.ExplicitDeps);
}
}
-
- // The directory-level rule should depend on the directory-level
- // rules of the subdirectories.
- for (cmStateSnapshot const& state : lg->GetStateSnapshot().GetChildren()) {
- std::string const& currentBinaryDir =
- state.GetDirectory().GetCurrentBinary();
- folderTargets.push_back(
- this->ConvertToNinjaPath(currentBinaryDir + "/all"));
- }
- }
-
- if (!targetsPerFolder.empty()) {
- cmNinjaBuild build("phony");
- build.Outputs.emplace_back("");
- for (auto& it : targetsPerFolder) {
- cmGlobalNinjaGenerator::WriteDivider(os);
- std::string const& currentBinaryDir = it.first;
-
- // Setup target
- build.Comment = "Folder: " + currentBinaryDir;
- build.Outputs[0] = this->ConvertToNinjaPath(currentBinaryDir + "/all");
- build.ExplicitDeps = std::move(it.second);
- // Write target
- this->WriteBuild(os, build);
+ for (DirectoryTarget::Dir const& d : dt.Children) {
+ if (!d.ExcludeFromAll) {
+ build.ExplicitDeps.emplace_back(
+ this->ConvertToNinjaPath(d.Path + "/all"));
+ }
}
+ // Write target
+ this->WriteBuild(os, build);
}
}
@@ -1281,22 +1245,18 @@ void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
cmGlobalNinjaGenerator::WriteDivider(os);
os << "# Built-in targets\n\n";
- this->WriteTargetAll(os);
+ this->WriteTargetDefault(os);
this->WriteTargetRebuildManifest(os);
this->WriteTargetClean(os);
this->WriteTargetHelp(os);
}
-void cmGlobalNinjaGenerator::WriteTargetAll(std::ostream& os)
+void cmGlobalNinjaGenerator::WriteTargetDefault(std::ostream& os)
{
- cmNinjaBuild build("phony");
- build.Comment = "The main all target.";
- build.Outputs.push_back(this->TargetAll);
- build.ExplicitDeps = this->AllDependencies;
- this->WriteBuild(os, build);
-
if (!this->HasOutputPathPrefix()) {
- cmGlobalNinjaGenerator::WriteDefault(os, build.Outputs,
+ cmNinjaDeps all;
+ all.push_back(this->TargetAll);
+ cmGlobalNinjaGenerator::WriteDefault(os, all,
"Make the all target the default.");
}
}