Ninja: Avoid re-running CMake on next build after regeneration

In commit 4a6397a7 (Ninja: Track configured files so we can regenerate
them, 2013-06-17) we accidentally started listing files generated by
CMake as inputs to the configuration process instead of outputs from it.
Move the list of files generated by CMake to the regeneration rule
outputs section and tell Ninja to restat after running it.
This commit is contained in:
Robert Maynard 2014-01-09 13:18:18 -05:00 committed by Brad King
parent c515dc5748
commit 6fac24d750
1 changed files with 24 additions and 5 deletions

View File

@ -1086,27 +1086,46 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
/*depfile=*/ "",
/*rspfile=*/ "",
/*rspcontent*/ "",
/*restat=*/ false,
/*restat=*/ true,
/*generator=*/ true);
cmNinjaDeps implicitDeps;
cmNinjaDeps implicitDeps, outputs, temp;
outputs.push_back(NINJA_BUILD_FILE);
for (std::vector<cmLocalGenerator *>::const_iterator i =
this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) {
const std::vector<std::string>& lf = (*i)->GetMakefile()->GetListFiles();
implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end());
const std::vector<std::string>& of = (*i)->GetMakefile()->GetOutputFiles();
implicitDeps.insert(implicitDeps.end(), of.begin(), of.end());
temp.insert(temp.end(), of.begin(), of.end());
}
//Add the CMakeCache.txt file to the implicit depends so that we catch
//when somebody manually modifies the file.
implicitDeps.push_back("CMakeCache.txt");
//make sure nothing is in implicit depends twice
std::sort(implicitDeps.begin(), implicitDeps.end());
implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()),
implicitDeps.end());
implicitDeps.push_back("CMakeCache.txt");
//make sure nothing is in outputs depends twice
std::sort(temp.begin(), temp.end());
temp.erase(std::unique(temp.begin(), temp.end()),
temp.end());
//make sure that anything that is in implicitDeps is also NOT in outputs
std::set_difference(temp.begin(),
temp.end(),
implicitDeps.begin(),
implicitDeps.end(),
std::back_inserter(outputs));
this->WriteBuild(os,
"Re-run CMake if any of its inputs changed.",
"RERUN_CMAKE",
/*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE),
outputs,
/*explicitDeps=*/ cmNinjaDeps(),
implicitDeps,
/*orderOnlyDeps=*/ cmNinjaDeps(),