From 1e7e47f597754e800673b158ce1bd59c8b6c566a Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 30 May 2019 14:52:17 +0200 Subject: Ninja: Use cmNinjaBuild instead of WritePhonyBuild --- Source/cmGlobalNinjaGenerator.cxx | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 2d84271..87a9dac 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1258,23 +1258,26 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os) knownDependencies.begin(), knownDependencies.end(), std::back_inserter(unknownExplicitDepends)); - std::string const rootBuildDirectory = - this->GetCMakeInstance()->GetHomeOutputDirectory(); - bool const inSourceBuild = - (rootBuildDirectory == this->GetCMakeInstance()->GetHomeDirectory()); std::vector warnExplicitDepends; - for (std::string const& i : unknownExplicitDepends) { - // verify the file is in the build directory - std::string const absDepPath = - cmSystemTools::CollapseFullPath(i, rootBuildDirectory); - bool const inBuildDir = - cmSystemTools::IsSubDirectory(absDepPath, rootBuildDirectory); - if (inBuildDir) { - cmNinjaDeps deps(1, i); - this->WritePhonyBuild(os, "", deps, cmNinjaDeps()); - if (this->PolicyCMP0058 == cmPolicies::WARN && !inSourceBuild && - warnExplicitDepends.size() < 10) { - warnExplicitDepends.push_back(i); + if (!unknownExplicitDepends.empty()) { + cmake* cmk = this->GetCMakeInstance(); + std::string const& buildRoot = cmk->GetHomeOutputDirectory(); + bool const inSource = (buildRoot == cmk->GetHomeDirectory()); + bool const warn = (!inSource && (this->PolicyCMP0058 == cmPolicies::WARN)); + cmNinjaBuild build("phony"); + build.Outputs.emplace_back(""); + for (std::string const& ued : unknownExplicitDepends) { + // verify the file is in the build directory + std::string const absDepPath = + cmSystemTools::CollapseFullPath(ued, buildRoot); + if (cmSystemTools::IsSubDirectory(absDepPath, buildRoot)) { + // Generate phony build statement + build.Outputs[0] = ued; + this->WriteBuild(os, build); + // Add to warning on demand + if (warn && warnExplicitDepends.size() < 10) { + warnExplicitDepends.push_back(ued); + } } } } -- cgit v0.12