diff options
author | Brad King <brad.king@kitware.com> | 2023-11-07 14:07:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-11-07 14:07:46 (GMT) |
commit | 92cc1f3b62c149326cc535220f6233357ee5d749 (patch) | |
tree | 7edb4c4b54897b1f77ef91c81d4dec591acfb9fa /Source | |
parent | 4b92515182ce642a6f8f587d5c35f11f9e6a291c (diff) | |
parent | bb7a0497ef41540c75183acf4ee740656aa61dd9 (diff) | |
download | CMake-92cc1f3b62c149326cc535220f6233357ee5d749.zip CMake-92cc1f3b62c149326cc535220f6233357ee5d749.tar.gz CMake-92cc1f3b62c149326cc535220f6233357ee5d749.tar.bz2 |
Merge topic 'Ninja-use-depslog'
bb7a0497ef cmTransformDepfile: warn when a depfile is not written to
c22c473bde Tests/Ninja*/CustomCommandDepfile: check that deps are in the database
b0177003e1 cmGlobalNinjaGenerator: tell `ninja` to actually read the depfile
45eff9145e cmAddCustomCommandCommand: use `cmStrCat`
c6445c615b Tests/RunCMake/Ninja: fix subdir prefix check
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8911
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmAddCustomCommandCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 17 | ||||
-rw-r--r-- | Source/cmTransformDepfile.cxx | 7 |
3 files changed, 25 insertions, 3 deletions
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index b1589ff..ea97287 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -189,8 +189,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, } else if (copy == keyDEPFILE) { doing = doing_depfile; if (!mf.GetGlobalGenerator()->SupportsCustomCommandDepfile()) { - status.SetError("Option DEPFILE not supported by " + - mf.GetGlobalGenerator()->GetName()); + status.SetError(cmStrCat("Option DEPFILE not supported by ", + mf.GetGlobalGenerator()->GetName())); return false; } } else if (copy == keyJOB_POOL) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index fb5c5c6..9fac513 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -378,6 +378,15 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( } { + std::string ninjaDepfilePath; + bool depfileIsOutput = false; + if (!depfile.empty()) { + ninjaDepfilePath = this->ConvertToNinjaPath(depfile); + depfileIsOutput = + std::find(outputs.ExplicitOuts.begin(), outputs.ExplicitOuts.end(), + ninjaDepfilePath) != outputs.ExplicitOuts.end(); + } + cmNinjaBuild build("CUSTOM_COMMAND"); build.Comment = comment; build.Outputs = std::move(outputs.ExplicitOuts); @@ -405,7 +414,13 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( vars["pool"] = job_pool; } if (!depfile.empty()) { - vars["depfile"] = depfile; + vars["depfile"] = ninjaDepfilePath; + // Add the depfile to the `.ninja_deps` database. Since this (generally) + // removes the file, it cannot be declared as an output or byproduct of + // the command. + if (!depfileIsOutput) { + vars["deps"] = "gcc"; + } } if (config.empty()) { this->WriteBuild(*this->GetCommonFileStream(), build); diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx index 914172b..ffc4de9 100644 --- a/Source/cmTransformDepfile.cxx +++ b/Source/cmTransformDepfile.cxx @@ -16,6 +16,9 @@ #include "cmGccDepfileReaderTypes.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmMessageType.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" namespace { @@ -121,6 +124,10 @@ bool cmTransformDepfile(cmDepfileFormat format, const cmLocalGenerator& lg, return false; } content = *std::move(result); + } else { + lg.GetMakefile()->IssueMessage( + MessageType::WARNING, + cmStrCat("Expected depfile does not exist.\n ", infile)); } cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(outfile)); |