diff options
author | Brad King <brad.king@kitware.com> | 2021-05-25 14:40:15 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-25 14:48:26 (GMT) |
commit | eb98d4511146db844029c809fde81982d3928e54 (patch) | |
tree | 6d2272125b57cd9f729f92a92bb9dd84a05c4933 /Source/cmGlobalNinjaGenerator.cxx | |
parent | 48471cfd18d5b2b6b4fd7270d21732335156d086 (diff) | |
download | CMake-eb98d4511146db844029c809fde81982d3928e54.zip CMake-eb98d4511146db844029c809fde81982d3928e54.tar.gz CMake-eb98d4511146db844029c809fde81982d3928e54.tar.bz2 |
Ninja: Handle depfiles with absolute paths to generated files in Ninja < 1.7
Extend the change from commit 2725ecff38 (Ninja: Handle depfiles with
absolute paths to generated files, 2021-05-19) to work on versions of
Ninja that do not support implicit outputs. Specify the absolute paths
as normal outputs on such versions.
Issue: #13894, #21865
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 09cbaec..a8a49a0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -222,7 +222,9 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, } } // Write implicit outputs - if (!build.ImplicitOuts.empty() || !build.WorkDirOuts.empty()) { + if (!build.ImplicitOuts.empty()) { + // Assume Ninja is new enough to support implicit outputs. + // Callers should not populate this field otherwise. buildStr = cmStrCat(buildStr, " |"); for (std::string const& implicitOut : build.ImplicitOuts) { buildStr = cmStrCat(buildStr, ' ', this->EncodePath(implicitOut)); @@ -230,11 +232,18 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, this->CombinedBuildOutputs.insert(implicitOut); } } + } + + // Repeat some outputs, but expressed as absolute paths. + // This helps Ninja handle absolute paths found in a depfile. + // FIXME: Unfortunately this causes Ninja to stat the file twice. + // We could avoid this if Ninja Issue 1251 were fixed. + if (!build.WorkDirOuts.empty()) { + if (this->SupportsImplicitOuts() && build.ImplicitOuts.empty()) { + // Make them implicit outputs if supported by this version of Ninja. + buildStr = cmStrCat(buildStr, " |"); + } for (std::string const& workdirOut : build.WorkDirOuts) { - // Repeat some outputs, but expressed as absolute paths. - // This helps Ninja handle absolute paths found in a depfile. - // FIXME: Unfortunately this causes Ninja to stat the file twice. - // We could avoid this if Ninja Issue 1251 were fixed. buildStr = cmStrCat(buildStr, " ${cmake_ninja_workdir}", this->EncodePath(workdirOut)); } @@ -322,8 +331,7 @@ void cmGlobalNinjaGenerator::CCOutputs::Add( { for (std::string const& path : paths) { std::string out = this->GG->ConvertToNinjaPath(path); - if (this->GG->SupportsImplicitOuts() && - !cmSystemTools::FileIsFullPath(out)) { + if (!cmSystemTools::FileIsFullPath(out)) { // This output is expressed as a relative path. Repeat it, // but expressed as an absolute path for Ninja Issue 1251. this->WorkDirOuts.emplace_back(out); |