From b6a53822176d120d1daa2fef5e261186767ab007 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 10 Feb 2023 18:42:02 -0500 Subject: Ninja: depend on language module information files directly Now that `GetLinkedTargetDirectories` can get the exact dependencies, use them to simplify the collation dependency graph. --- Source/cmNinjaTargetGenerator.cxx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 6f9bdbd..8663f46 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1146,6 +1146,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( cmNinjaBuild build(this->LanguageDyndepRule(language, config)); build.Outputs.push_back(this->GetDyndepFilePath(language, config)); + build.ImplicitOuts.push_back( + cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', + this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), + this->GetGlobalGenerator()->ConfigDirectory(config), '/', + language, "Modules.json")); for (auto const& scanFiles : scanningFiles) { if (!scanFiles.ScanningOutput.empty()) { build.ExplicitDeps.push_back(scanFiles.ScanningOutput); @@ -1157,17 +1162,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements( this->WriteTargetDependInfo(language, config); - // Make sure dyndep files for all our dependencies have already - // been generated so that the 'Modules.json' files they - // produced as side-effects are available for us to read. - // Ideally we should depend on the 'Modules.json' files - // from our dependencies directly, but we don't know which of - // our dependencies produces them. Fixing this will require - // refactoring the Ninja generator to generate targets in - // dependency order so that we can collect the needed information. - this->GetLocalGenerator()->AppendTargetDepends( - this->GeneratorTarget, build.OrderOnlyDeps, config, fileConfig, - DependOnTargetArtifact); + for (std::string const& l : + this->GetLinkedTargetDirectories(language, config)) { + build.ImplicitDeps.push_back(cmStrCat(l, '/', language, "Modules.json")); + } this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig), build); -- cgit v0.12