summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2022-01-16 14:04:05 +0100
committerMarc Chevrier <marc.chevrier@gmail.com>2022-01-16 16:21:12 +0100
commit0b65a2b2531b05abe1bc1f1950bb963af7a6d42f (patch)
treef030499394a3dd427ff56f1d30424307254ef705 /Source
parente04a352cca523eba2ac0d60063a3799f5bb1c69e (diff)
downloadcmake-0b65a2b2531b05abe1bc1f1950bb963af7a6d42f.tar.gz
add_custom_command(DEPFILE): ensure all dependencies are taken into account
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDependsCompiler.cxx9
-rw-r--r--Source/cmGccDepfileLexerHelper.cxx40
-rw-r--r--Source/cmTransformDepfile.cxx17
3 files changed, 36 insertions, 30 deletions
diff --git a/Source/cmDependsCompiler.cxx b/Source/cmDependsCompiler.cxx
index bf599ffaf0..0cc4946e48 100644
--- a/Source/cmDependsCompiler.cxx
+++ b/Source/cmDependsCompiler.cxx
@@ -4,6 +4,7 @@
#include "cmDependsCompiler.h"
#include <algorithm>
+#include <iterator>
#include <map>
#include <memory>
#include <string>
@@ -111,9 +112,13 @@ bool cmDependsCompiler::CheckDependencies(
// copy depends for each target, except first one, which can be
// moved
for (auto index = entry.rules.size() - 1; index > 0; --index) {
- dependencies[entry.rules[index]] = depends;
+ auto& rule_deps = dependencies[entry.rules[index]];
+ rule_deps.insert(rule_deps.end(), depends.cbegin(),
+ depends.cend());
}
- dependencies[entry.rules.front()] = std::move(depends);
+ auto& rule_deps = dependencies[entry.rules.front()];
+ std::move(depends.cbegin(), depends.cend(),
+ std::back_inserter(rule_deps));
}
} else {
if (format == "msvc"_s) {
diff --git a/Source/cmGccDepfileLexerHelper.cxx b/Source/cmGccDepfileLexerHelper.cxx
index afa8e9b26f..34c88248a0 100644
--- a/Source/cmGccDepfileLexerHelper.cxx
+++ b/Source/cmGccDepfileLexerHelper.cxx
@@ -113,6 +113,24 @@ void cmGccDepfileLexerHelper::addToCurrentPath(const char* s)
void cmGccDepfileLexerHelper::sanitizeContent()
{
for (auto it = this->Content.begin(); it != this->Content.end();) {
+ // Remove empty paths and normalize windows paths
+ for (auto pit = it->paths.begin(); pit != it->paths.end();) {
+ if (pit->empty()) {
+ pit = it->paths.erase(pit);
+ } else {
+#if defined(_WIN32)
+ // Unescape the colon following the drive letter.
+ // Some versions of GNU compilers can escape this character.
+ // c\:\path must be transformed to c:\path
+ if (pit->size() >= 3 && std::toupper((*pit)[0]) >= 'A' &&
+ std::toupper((*pit)[0]) <= 'Z' && (*pit)[1] == '\\' &&
+ (*pit)[2] == ':') {
+ pit->erase(1, 1);
+ }
+#endif
+ ++pit;
+ }
+ }
// Remove empty rules
for (auto rit = it->rules.begin(); rit != it->rules.end();) {
if (rit->empty()) {
@@ -121,28 +139,10 @@ void cmGccDepfileLexerHelper::sanitizeContent()
++rit;
}
}
- // Remove the entry if rules are empty
- if (it->rules.empty()) {
+ // Remove the entry if rules are empty or do not have any paths
+ if (it->rules.empty() || it->paths.empty()) {
it = this->Content.erase(it);
} else {
- // Remove empty paths and normalize windows paths
- for (auto pit = it->paths.begin(); pit != it->paths.end();) {
- if (pit->empty()) {
- pit = it->paths.erase(pit);
- } else {
-#if defined(_WIN32)
- // Unescape the colon following the drive letter.
- // Some versions of GNU compilers can escape this character.
- // c\:\path must be transformed to c:\path
- if (pit->size() >= 3 && std::toupper((*pit)[0]) >= 'A' &&
- std::toupper((*pit)[0]) <= 'Z' && (*pit)[1] == '\\' &&
- (*pit)[2] == ':') {
- pit->erase(1, 1);
- }
-#endif
- ++pit;
- }
- }
++it;
}
}
diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx
index 4032596b85..81a6507458 100644
--- a/Source/cmTransformDepfile.cxx
+++ b/Source/cmTransformDepfile.cxx
@@ -4,7 +4,6 @@
#include <algorithm>
#include <functional>
-#include <memory>
#include <string>
#include <type_traits>
#include <utility>
@@ -95,14 +94,16 @@ void WriteMSBuildAdditionalInputs(cmsys::ofstream& fout,
// Write the format expected by MSBuild CustomBuild AdditionalInputs.
const char* sep = "";
- for (std::string path : content.front().paths) {
- if (!cmSystemTools::FileIsFullPath(path)) {
- path =
- cmSystemTools::CollapseFullPath(path, lg.GetCurrentBinaryDirectory());
+ for (const auto& c : content) {
+ for (std::string path : c.paths) {
+ if (!cmSystemTools::FileIsFullPath(path)) {
+ path = cmSystemTools::CollapseFullPath(path,
+ lg.GetCurrentBinaryDirectory());
+ }
+ std::replace(path.begin(), path.end(), '/', '\\');
+ fout << sep << path;
+ sep = ";";
}
- std::replace(path.begin(), path.end(), '/', '\\');
- fout << sep << path;
- sep = ";";
}
fout << "\n";
}