summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-05-30 10:06:25 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-05-30 16:21:40 (GMT)
commitb6dc977ff17b451b43d8a67584400c3b53c7eb8f (patch)
treed4010240f36446a98def1f121883caf57bc2e6f3 /Source/cmNinjaTargetGenerator.cxx
parent846b4b1062cc83b420ad1405fd74186c33bb1513 (diff)
downloadCMake-b6dc977ff17b451b43d8a67584400c3b53c7eb8f.zip
CMake-b6dc977ff17b451b43d8a67584400c3b53c7eb8f.tar.gz
CMake-b6dc977ff17b451b43d8a67584400c3b53c7eb8f.tar.bz2
Ninja: Embrace temporary objects in scopes
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx145
1 files changed, 80 insertions, 65 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 5b8ed90..140730b 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -796,78 +796,93 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
const std::string& config =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- std::vector<cmSourceFile const*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands, config);
- for (cmSourceFile const* sf : customCommands) {
- cmCustomCommand const* cc = sf->GetCustomCommand();
- this->GetLocalGenerator()->AddCustomCommandTarget(
- cc, this->GetGeneratorTarget());
- // Record the custom commands for this target. The container is used
- // in WriteObjectBuildStatement when called in a loop below.
- this->CustomCommands.push_back(cc);
+ {
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ for (cmSourceFile const* sf : customCommands) {
+ cmCustomCommand const* cc = sf->GetCustomCommand();
+ this->GetLocalGenerator()->AddCustomCommandTarget(
+ cc, this->GetGeneratorTarget());
+ // Record the custom commands for this target. The container is used
+ // in WriteObjectBuildStatement when called in a loop below.
+ this->CustomCommands.push_back(cc);
+ }
}
- std::vector<cmSourceFile const*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources, config);
- this->OSXBundleGenerator->GenerateMacOSXContentStatements(
- headerSources, this->MacOSXContentGenerator.get());
- std::vector<cmSourceFile const*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources, config);
- this->OSXBundleGenerator->GenerateMacOSXContentStatements(
- extraSources, this->MacOSXContentGenerator.get());
- std::vector<cmSourceFile const*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects, config);
- for (cmSourceFile const* sf : externalObjects) {
- this->Objects.push_back(this->GetSourceFilePath(sf));
+ {
+ std::vector<cmSourceFile const*> headerSources;
+ this->GeneratorTarget->GetHeaderSources(headerSources, config);
+ this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+ headerSources, this->MacOSXContentGenerator.get());
}
-
- cmNinjaDeps orderOnlyDeps;
- this->GetLocalGenerator()->AppendTargetDepends(
- this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering);
-
- // Add order-only dependencies on other files associated with the target.
- cmAppend(orderOnlyDeps, this->ExtraFiles);
-
- // Add order-only dependencies on custom command outputs.
- for (cmCustomCommand const* cc : this->CustomCommands) {
- cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
- this->GetLocalGenerator());
- const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
- const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
- std::transform(ccoutputs.begin(), ccoutputs.end(),
- std::back_inserter(orderOnlyDeps), MapToNinjaPath());
- std::transform(ccbyproducts.begin(), ccbyproducts.end(),
- std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ {
+ std::vector<cmSourceFile const*> extraSources;
+ this->GeneratorTarget->GetExtraSources(extraSources, config);
+ this->OSXBundleGenerator->GenerateMacOSXContentStatements(
+ extraSources, this->MacOSXContentGenerator.get());
}
-
- std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end());
- orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()),
- orderOnlyDeps.end());
-
- // The phony target must depend on at least one input or ninja will explain
- // that "output ... of phony edge with no inputs doesn't exist" and consider
- // the phony output "dirty".
- if (orderOnlyDeps.empty()) {
- // Any path that always exists will work here. It would be nice to
- // use just "." but that is not supported by Ninja < 1.7.
- std::string tgtDir;
- tgtDir += this->LocalGenerator->GetCurrentBinaryDirectory();
- tgtDir += "/";
- tgtDir += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir));
+ {
+ std::vector<cmSourceFile const*> externalObjects;
+ this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+ for (cmSourceFile const* sf : externalObjects) {
+ this->Objects.push_back(this->GetSourceFilePath(sf));
+ }
}
{
- cmNinjaDeps orderOnlyTarget;
- orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
- this->GetGlobalGenerator()->WritePhonyBuild(
- this->GetBuildFileStream(),
- "Order-only phony target for " + this->GetTargetName(), orderOnlyTarget,
- cmNinjaDeps(), cmNinjaDeps(), orderOnlyDeps);
+ cmNinjaDeps orderOnlyDeps;
+ this->GetLocalGenerator()->AppendTargetDepends(
+ this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering);
+
+ // Add order-only dependencies on other files associated with the target.
+ cmAppend(orderOnlyDeps, this->ExtraFiles);
+
+ // Add order-only dependencies on custom command outputs.
+ for (cmCustomCommand const* cc : this->CustomCommands) {
+ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
+ this->GetLocalGenerator());
+ const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
+ const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
+ std::transform(ccoutputs.begin(), ccoutputs.end(),
+ std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ std::transform(ccbyproducts.begin(), ccbyproducts.end(),
+ std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ }
+
+ std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end());
+ orderOnlyDeps.erase(
+ std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()),
+ orderOnlyDeps.end());
+
+ // The phony target must depend on at least one input or ninja will explain
+ // that "output ... of phony edge with no inputs doesn't exist" and
+ // consider the phony output "dirty".
+ if (orderOnlyDeps.empty()) {
+ // Any path that always exists will work here. It would be nice to
+ // use just "." but that is not supported by Ninja < 1.7.
+ std::string tgtDir;
+ tgtDir += this->LocalGenerator->GetCurrentBinaryDirectory();
+ tgtDir += "/";
+ tgtDir +=
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+ orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir));
+ }
+
+ {
+ cmNinjaDeps orderOnlyTarget;
+ orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());
+ this->GetGlobalGenerator()->WritePhonyBuild(
+ this->GetBuildFileStream(),
+ "Order-only phony target for " + this->GetTargetName(),
+ orderOnlyTarget, cmNinjaDeps(), cmNinjaDeps(), orderOnlyDeps);
+ }
}
- std::vector<cmSourceFile const*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources, config);
- for (cmSourceFile const* sf : objectSources) {
- this->WriteObjectBuildStatement(sf);
+
+ {
+ std::vector<cmSourceFile const*> objectSources;
+ this->GeneratorTarget->GetObjectSources(objectSources, config);
+ for (cmSourceFile const* sf : objectSources) {
+ this->WriteObjectBuildStatement(sf);
+ }
}
for (auto const& langDDIFiles : this->DDIFiles) {