summaryrefslogtreecommitdiffstats
path: root/src/graph.h
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-11-15 01:13:16 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2020-10-30 09:58:36 (GMT)
commit03cbfc65220e8f98548684e785d95bf5734c3f59 (patch)
treeb01c4024f41a1558374a9578b710770cca27412c /src/graph.h
parentd45ff8ebf88ef4add46a80ccdfc2d97a8b4b091b (diff)
downloadNinja-03cbfc65220e8f98548684e785d95bf5734c3f59.zip
Ninja-03cbfc65220e8f98548684e785d95bf5734c3f59.tar.gz
Ninja-03cbfc65220e8f98548684e785d95bf5734c3f59.tar.bz2
Add unique IDs to edges
Edges are nominally ordered by order in the build manifest, but in fact are ordered by memory address. In most cases the memory address will be monontonically increasing. Since serialized build output will need unique IDs, add a monotonically increasing ID to edges, and use that for sorting instead of memory address.
Diffstat (limited to 'src/graph.h')
-rw-r--r--src/graph.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/graph.h b/src/graph.h
index 4833f49..8c51782 100644
--- a/src/graph.h
+++ b/src/graph.h
@@ -15,6 +15,7 @@
#ifndef NINJA_GRAPH_H_
#define NINJA_GRAPH_H_
+#include <set>
#include <string>
#include <vector>
@@ -143,10 +144,11 @@ struct Edge {
VisitDone
};
- Edge() : rule_(NULL), pool_(NULL), dyndep_(NULL), env_(NULL),
- mark_(VisitNone), outputs_ready_(false), deps_loaded_(false),
- deps_missing_(false), implicit_deps_(0), order_only_deps_(0),
- implicit_outs_(0) {}
+ Edge()
+ : rule_(NULL), pool_(NULL), dyndep_(NULL), env_(NULL), mark_(VisitNone),
+ id_(0), outputs_ready_(false), deps_loaded_(false),
+ deps_missing_(false), implicit_deps_(0), order_only_deps_(0),
+ implicit_outs_(0) {}
/// Return true if all inputs' in-edges are ready.
bool AllInputsReady() const;
@@ -176,6 +178,7 @@ struct Edge {
Node* dyndep_;
BindingEnv* env_;
VisitMark mark_;
+ size_t id_;
bool outputs_ready_;
bool deps_loaded_;
bool deps_missing_;
@@ -218,6 +221,13 @@ struct Edge {
bool maybe_phonycycle_diagnostic() const;
};
+struct EdgeCmp {
+ bool operator()(const Edge* a, const Edge* b) const {
+ return a->id_ < b->id_;
+ }
+};
+
+typedef std::set<Edge*, EdgeCmp> EdgeSet;
/// ImplicitDepLoader loads implicit dependencies, as referenced via the
/// "depfile" attribute in build files.