From d0489c3863f6b2a0d0b0e15880217da3fd4e6d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Aniatowski?= Date: Mon, 15 Feb 2021 13:06:30 +0100 Subject: Refactor depfile loading in preparation for the missingdeps tool Extract an usable helper to load depfile dependencies without adding them to the graph. --- src/graph.cc | 11 ++++++++--- src/graph.h | 8 +++++++- 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* depfile_ins, std::string* err) { // Preallocate space in edge->inputs_ to be filled in below. vector::iterator implicit_dep = - PreallocateSpace(edge, depfile.ins_.size()); + PreallocateSpace(edge, depfile_ins->size()); // Add all its in-edges. - for (vector::iterator i = depfile.ins_.begin(); - i != depfile.ins_.end(); ++i, ++implicit_dep) { + for (std::vector::iterator i = depfile_ins->begin(); + i != depfile_ins->end(); ++i, ++implicit_dep) { uint64_t slash_bits; if (!CanonicalizePath(const_cast(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* 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); -- cgit v0.12