summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomasz Śniatowski <tsniatowski@vewd.com>2021-02-15 13:06:30 +0100
committerTomasz Śniatowski <tsniatowski@vewd.com>2021-02-22 23:48:58 +0100
commitd0489c3863f6b2a0d0b0e15880217da3fd4e6d8f (patch)
treec06f68e990ecec121dcff0939287a0e8b1777858 /src
parentb0662970ba2cc69a64d7d2ebe3e07dcef948dabe (diff)
downloadninja-d0489c3863f6b2a0d0b0e15880217da3fd4e6d8f.tar.gz
Refactor depfile loading in preparation for the missingdeps tool
Extract an usable helper to load depfile dependencies without adding them to the graph.
Diffstat (limited to 'src')
-rw-r--r--src/graph.cc11
-rw-r--r--src/graph.h8
2 files changed, 15 insertions, 4 deletions
diff --git a/src/graph.cc b/src/graph.cc
index 78d0d49..90e8d08 100644
--- a/src/graph.cc
+++ b/src/graph.cc
@@ -588,13 +588,18 @@ bool ImplicitDepLoader::LoadDepFile(Edge* edge, const string& path,
}
}
+ return ProcessDepfileDeps(edge, &depfile.ins_, err);
+}
+
+bool ImplicitDepLoader::ProcessDepfileDeps(
+ Edge* edge, std::vector<StringPiece>* depfile_ins, std::string* err) {
// Preallocate space in edge->inputs_ to be filled in below.
vector<Node*>::iterator implicit_dep =
- PreallocateSpace(edge, depfile.ins_.size());
+ PreallocateSpace(edge, depfile_ins->size());
// Add all its in-edges.
- for (vector<StringPiece>::iterator i = depfile.ins_.begin();
- i != depfile.ins_.end(); ++i, ++implicit_dep) {
+ for (std::vector<StringPiece>::iterator i = depfile_ins->begin();
+ i != depfile_ins->end(); ++i, ++implicit_dep) {
uint64_t slash_bits;
if (!CanonicalizePath(const_cast<char*>(i->str_), &i->len_, &slash_bits,
err))
diff --git a/src/graph.h b/src/graph.h
index 8c51782..6756378 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -247,7 +247,13 @@ struct ImplicitDepLoader {
return deps_log_;
}
- private:
+ protected:
+ /// Process loaded implicit dependencies for \a edge and update the graph
+ /// @return false on error (without filling \a err if info is just missing)
+ virtual bool ProcessDepfileDeps(Edge* edge,
+ std::vector<StringPiece>* depfile_ins,
+ std::string* err);
+
/// Load implicit dependencies for \a edge from a depfile attribute.
/// @return false on error (without filling \a err if info is just missing).
bool LoadDepFile(Edge* edge, const std::string& path, std::string* err);