|
|
@@ -30,7 +30,6 @@
|
|
|
#include "cmDyndepCollation.h"
|
|
|
#include "cmFortranParser.h"
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
-#include "cmGeneratorExpressionEvaluationFile.h"
|
|
|
#include "cmGeneratorTarget.h"
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
#include "cmLinkLineComputer.h"
|
|
|
@@ -243,9 +242,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|
|
// Write explicit outputs
|
|
|
for (std::string const& output : build.Outputs) {
|
|
|
buildStr = cmStrCat(buildStr, ' ', this->EncodePath(output));
|
|
|
- if (this->ComputingUnknownDependencies) {
|
|
|
- this->CombinedBuildOutputs.insert(output);
|
|
|
- }
|
|
|
}
|
|
|
// Write implicit outputs
|
|
|
if (!build.ImplicitOuts.empty()) {
|
|
|
@@ -254,9 +250,6 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
|
|
buildStr = cmStrCat(buildStr, " |");
|
|
|
for (std::string const& implicitOut : build.ImplicitOuts) {
|
|
|
buildStr = cmStrCat(buildStr, ' ', this->EncodePath(implicitOut));
|
|
|
- if (this->ComputingUnknownDependencies) {
|
|
|
- this->CombinedBuildOutputs.insert(implicitOut);
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -371,14 +364,6 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild(
|
|
|
{
|
|
|
this->AddCustomCommandRule();
|
|
|
|
|
|
- if (this->ComputingUnknownDependencies) {
|
|
|
- // we need to track every dependency that comes in, since we are trying
|
|
|
- // to find dependencies that are side effects of build commands
|
|
|
- for (std::string const& dep : explicitDeps) {
|
|
|
- this->CombinedCustomCommandExplicitDependencies.insert(dep);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
{
|
|
|
std::string ninjaDepfilePath;
|
|
|
bool depfileIsOutput = false;
|
|
|
@@ -641,19 +626,11 @@ void cmGlobalNinjaGenerator::Generate()
|
|
|
this->ClangTidyExportFixesDirs.clear();
|
|
|
this->ClangTidyExportFixesFiles.clear();
|
|
|
|
|
|
- this->PolicyCMP0058 =
|
|
|
- this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus(
|
|
|
- cmPolicies::CMP0058);
|
|
|
- this->ComputingUnknownDependencies =
|
|
|
- (this->PolicyCMP0058 == cmPolicies::OLD ||
|
|
|
- this->PolicyCMP0058 == cmPolicies::WARN);
|
|
|
-
|
|
|
this->cmGlobalGenerator::Generate();
|
|
|
|
|
|
this->WriteAssumedSourceDependencies();
|
|
|
this->WriteTargetAliases(*this->GetCommonFileStream());
|
|
|
this->WriteFolderTargets(*this->GetCommonFileStream());
|
|
|
- this->WriteUnknownExplicitDependencies(*this->GetCommonFileStream());
|
|
|
this->WriteBuiltinTargets(*this->GetCommonFileStream());
|
|
|
|
|
|
if (cmSystemTools::GetErrorOccurredFlag()) {
|
|
|
@@ -1227,10 +1204,6 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
|
|
|
if (!this->CompileCommandsStream) {
|
|
|
std::string buildFilePath =
|
|
|
cmStrCat(buildFileDir, "/compile_commands.json");
|
|
|
- if (this->ComputingUnknownDependencies) {
|
|
|
- this->CombinedBuildOutputs.insert(
|
|
|
- this->NinjaOutputPath("compile_commands.json"));
|
|
|
- }
|
|
|
|
|
|
// Get a stream where to generate things.
|
|
|
this->CompileCommandsStream =
|
|
|
@@ -1779,128 +1752,6 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
|
|
|
-{
|
|
|
- if (!this->ComputingUnknownDependencies) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // We need to collect the set of known build outputs.
|
|
|
- // Start with those generated by WriteBuild calls.
|
|
|
- // No other method needs this so we can take ownership
|
|
|
- // of the set locally and throw it out when we are done.
|
|
|
- std::set<std::string> knownDependencies;
|
|
|
- knownDependencies.swap(this->CombinedBuildOutputs);
|
|
|
-
|
|
|
- // now write out the unknown explicit dependencies.
|
|
|
-
|
|
|
- // union the configured files, evaluations files and the
|
|
|
- // CombinedBuildOutputs,
|
|
|
- // and then difference with CombinedExplicitDependencies to find the explicit
|
|
|
- // dependencies that we have no rule for
|
|
|
-
|
|
|
- cmGlobalNinjaGenerator::WriteDivider(os);
|
|
|
- /* clang-format off */
|
|
|
- os << "# Unknown Build Time Dependencies.\n"
|
|
|
- << "# Tell Ninja that they may appear as side effects of build rules\n"
|
|
|
- << "# otherwise ordered by order-only dependencies.\n\n";
|
|
|
- /* clang-format on */
|
|
|
-
|
|
|
- // get the list of files that cmake itself has generated as a
|
|
|
- // product of configuration.
|
|
|
-
|
|
|
- for (const auto& lg : this->LocalGenerators) {
|
|
|
- // get the vector of files created by this makefile and convert them
|
|
|
- // to ninja paths, which are all relative in respect to the build directory
|
|
|
- for (std::string const& file : lg->GetMakefile()->GetOutputFiles()) {
|
|
|
- knownDependencies.insert(this->ConvertToNinjaPath(file));
|
|
|
- }
|
|
|
- if (!this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
|
|
|
- // get list files which are implicit dependencies as well and will be
|
|
|
- // phony for rebuild manifest
|
|
|
- for (std::string const& j : lg->GetMakefile()->GetListFiles()) {
|
|
|
- knownDependencies.insert(this->ConvertToNinjaPath(j));
|
|
|
- }
|
|
|
- }
|
|
|
- for (const auto& li : lg->GetMakefile()->GetEvaluationFiles()) {
|
|
|
- // get all the files created by generator expressions and convert them
|
|
|
- // to ninja paths
|
|
|
- for (std::string const& evaluationFile : li->GetFiles()) {
|
|
|
- knownDependencies.insert(this->ConvertToNinjaPath(evaluationFile));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- knownDependencies.insert(this->CMakeCacheFile);
|
|
|
-
|
|
|
- for (auto const& ta : this->TargetAliases) {
|
|
|
- knownDependencies.insert(this->ConvertToNinjaPath(ta.first));
|
|
|
- }
|
|
|
-
|
|
|
- // remove all source files we know will exist.
|
|
|
- for (auto const& i : this->AssumedSourceDependencies) {
|
|
|
- knownDependencies.insert(this->ConvertToNinjaPath(i.first));
|
|
|
- }
|
|
|
-
|
|
|
- // now we difference with CombinedCustomCommandExplicitDependencies to find
|
|
|
- // the list of items we know nothing about.
|
|
|
- // We have encoded all the paths in CombinedCustomCommandExplicitDependencies
|
|
|
- // and knownDependencies so no matter if unix or windows paths they
|
|
|
- // should all match now.
|
|
|
-
|
|
|
- std::vector<std::string> unknownExplicitDepends;
|
|
|
- this->CombinedCustomCommandExplicitDependencies.erase(this->TargetAll);
|
|
|
-
|
|
|
- std::set_difference(this->CombinedCustomCommandExplicitDependencies.begin(),
|
|
|
- this->CombinedCustomCommandExplicitDependencies.end(),
|
|
|
- knownDependencies.begin(), knownDependencies.end(),
|
|
|
- std::back_inserter(unknownExplicitDepends));
|
|
|
-
|
|
|
- std::vector<std::string> warnExplicitDepends;
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (!warnExplicitDepends.empty()) {
|
|
|
- std::ostringstream w;
|
|
|
- /* clang-format off */
|
|
|
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0058) << "\n"
|
|
|
- "This project specifies custom command DEPENDS on files "
|
|
|
- "in the build tree that are not specified as the OUTPUT or "
|
|
|
- "BYPRODUCTS of any add_custom_command or add_custom_target:\n"
|
|
|
- " " << cmJoin(warnExplicitDepends, "\n ") <<
|
|
|
- "\n"
|
|
|
- "For compatibility with versions of CMake that did not have "
|
|
|
- "the BYPRODUCTS option, CMake is generating phony rules for "
|
|
|
- "such files to convince 'ninja' to build."
|
|
|
- "\n"
|
|
|
- "Project authors should add the missing BYPRODUCTS or OUTPUT "
|
|
|
- "options to the custom commands that produce these files."
|
|
|
- ;
|
|
|
- /* clang-format on */
|
|
|
- this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
|
|
|
- w.str());
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
void cmGlobalNinjaGenerator::WriteBuiltinTargets(std::ostream& os)
|
|
|
{
|
|
|
// Write headers.
|