Ninja
Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | List of all members
Node Struct Reference

Information about a node in the dependency graph: the file, whether it's dirty, mtime, etc. More...

#include <graph.h>

Public Member Functions

void AddOutEdge (Edge *edge)
 
void AddValidationOutEdge (Edge *edge)
 
bool dirty () const
 
void Dump (const char *prefix="") const
 
bool dyndep_pending () const
 
bool exists () const
 
int id () const
 
Edgein_edge () const
 
void MarkDirty ()
 
void MarkMissing ()
 Mark the Node as already-stat()ed and missing. More...
 
TimeStamp mtime () const
 
 Node (const std::string &path, uint64_t slash_bits)
 
const std::vector< Edge * > & out_edges () const
 
const std::string & path () const
 
std::string PathDecanonicalized () const
 Get |path()| but use slash_bits to convert back to original slash styles. More...
 
void ResetState ()
 Mark as not-yet-stat()ed and not dirty. More...
 
void set_dirty (bool dirty)
 
void set_dyndep_pending (bool pending)
 
void set_id (int id)
 
void set_in_edge (Edge *edge)
 
uint64_t slash_bits () const
 
bool Stat (DiskInterface *disk_interface, std::string *err)
 Return false on error. More...
 
bool StatIfNecessary (DiskInterface *disk_interface, std::string *err)
 Return false on error. More...
 
bool status_known () const
 
void UpdatePhonyMtime (TimeStamp mtime)
 If the file doesn't exist, set the mtime_ from its dependencies. More...
 
const std::vector< Edge * > & validation_out_edges () const
 

Static Public Member Functions

static std::string PathDecanonicalized (const std::string &path, uint64_t slash_bits)
 

Private Types

enum  ExistenceStatus { ExistenceStatusUnknown, ExistenceStatusMissing, ExistenceStatusExists }
 

Private Attributes

bool dirty_
 Dirty is true when the underlying file is out-of-date. More...
 
bool dyndep_pending_
 Store whether dyndep information is expected from this node but has not yet been loaded. More...
 
ExistenceStatus exists_
 
int id_
 A dense integer id for the node, assigned and used by DepsLog. More...
 
Edgein_edge_
 The Edge that produces this Node, or NULL when there is no known edge to produce it. More...
 
TimeStamp mtime_
 Possible values of mtime_: -1: file hasn't been examined 0: we looked, and file doesn't exist >0: actual file's mtime, or the latest mtime of its dependencies if it doesn't exist. More...
 
std::vector< Edge * > out_edges_
 All Edges that use this Node as an input. More...
 
std::string path_
 
uint64_t slash_bits_
 Set bits starting from lowest for backslashes that were normalized to forward slashes by CanonicalizePath. More...
 
std::vector< Edge * > validation_out_edges_
 All Edges that use this Node as a validation. More...
 

Detailed Description

Information about a node in the dependency graph: the file, whether it's dirty, mtime, etc.

Definition at line 39 of file graph.h.

Member Enumeration Documentation

◆ ExistenceStatus

enum Node::ExistenceStatus
private
Enumerator
ExistenceStatusUnknown 

The file hasn't been examined.

ExistenceStatusMissing 

The file doesn't exist. mtime_ will be the latest mtime of its dependencies.

ExistenceStatusExists 

The path is an actual file. mtime_ will be the file's mtime.

Definition at line 130 of file graph.h.

Constructor & Destructor Documentation

◆ Node()

Node::Node ( const std::string &  path,
uint64_t  slash_bits 
)
inline

Definition at line 40 of file graph.h.

Member Function Documentation

◆ AddOutEdge()

void Node::AddOutEdge ( Edge edge)
inline

◆ AddValidationOutEdge()

void Node::AddValidationOutEdge ( Edge edge)
inline

Definition at line 113 of file graph.h.

References validation_out_edges_.

Referenced by State::AddValidation().

◆ dirty()

bool Node::dirty ( ) const
inline

◆ Dump()

void Node::Dump ( const char *  prefix = "") const

Definition at line 574 of file graph.cc.

References PRId64.

◆ dyndep_pending()

bool Node::dyndep_pending ( ) const
inline

◆ exists()

bool Node::exists ( ) const
inline

◆ id()

int Node::id ( ) const
inline

Definition at line 107 of file graph.h.

References id_.

Referenced by State::Dump(), DepsLog::GetDeps(), DepsLog::Load(), DepsLog::RecordDeps(), and set_id().

◆ in_edge()

Edge* Node::in_edge ( ) const
inline

◆ MarkDirty()

void Node::MarkDirty ( )
inline

Definition at line 99 of file graph.h.

References dirty_.

Referenced by BuildTest::Dirty(), DependencyScan::RecomputeNodeDirty(), and TEST_F().

◆ MarkMissing()

void Node::MarkMissing ( )
inline

Mark the Node as already-stat()ed and missing.

Definition at line 71 of file graph.h.

References ExistenceStatusMissing, exists_, and mtime_.

Referenced by BuildTest::Dirty().

◆ mtime()

TimeStamp Node::mtime ( ) const
inline

◆ out_edges()

const std::vector<Edge*>& Node::out_edges ( ) const
inline

◆ path()

const std::string& Node::path ( ) const
inline

◆ PathDecanonicalized() [1/2]

std::string Node::PathDecanonicalized ( ) const
inline

Get |path()| but use slash_bits to convert back to original slash styles.

Definition at line 88 of file graph.h.

References path_, and slash_bits_.

◆ PathDecanonicalized() [2/2]

static std::string Node::PathDecanonicalized ( const std::string &  path,
uint64_t  slash_bits 
)
static

◆ ResetState()

void Node::ResetState ( )
inline

Mark as not-yet-stat()ed and not dirty.

Definition at line 64 of file graph.h.

References dirty_, ExistenceStatusUnknown, exists_, and mtime_.

◆ set_dirty()

void Node::set_dirty ( bool  dirty)
inline

Definition at line 98 of file graph.h.

References dirty(), and dirty_.

Referenced by Plan::CleanNode(), and DependencyScan::RecomputeNodeDirty().

◆ set_dyndep_pending()

void Node::set_dyndep_pending ( bool  pending)
inline

Definition at line 102 of file graph.h.

References dyndep_pending_.

Referenced by DyndepLoader::LoadDyndeps(), and ManifestParser::ParseEdge().

◆ set_id()

void Node::set_id ( int  id)
inline

Definition at line 108 of file graph.h.

References id(), and id_.

Referenced by DepsLog::Load(), and DepsLog::RecordId().

◆ set_in_edge()

void Node::set_in_edge ( Edge edge)
inline

Definition at line 105 of file graph.h.

References in_edge_.

Referenced by State::AddOut(), and ImplicitDepLoader::CreatePhonyInEdge().

◆ slash_bits()

uint64_t Node::slash_bits ( ) const
inline

Definition at line 93 of file graph.h.

References slash_bits_.

◆ Stat()

bool Node::Stat ( DiskInterface disk_interface,
std::string *  err 
)

Return false on error.

Definition at line 34 of file graph.cc.

References METRIC_RECORD, and DiskInterface::Stat().

Referenced by StatIfNecessary(), TEST_F(), and TestPhonyUseCase().

◆ StatIfNecessary()

bool Node::StatIfNecessary ( DiskInterface disk_interface,
std::string *  err 
)
inline

Return false on error.

Definition at line 57 of file graph.h.

References Stat(), and status_known().

Referenced by DependencyScan::RecomputeNodeDirty().

◆ status_known()

bool Node::status_known ( ) const
inline

Definition at line 82 of file graph.h.

References ExistenceStatusUnknown, and exists_.

Referenced by State::Dump(), DependencyScan::RecomputeNodeDirty(), and StatIfNecessary().

◆ UpdatePhonyMtime()

void Node::UpdatePhonyMtime ( TimeStamp  mtime)

If the file doesn't exist, set the mtime_ from its dependencies.

Definition at line 44 of file graph.cc.

Referenced by DependencyScan::RecomputeOutputDirty().

◆ validation_out_edges()

const std::vector<Edge*>& Node::validation_out_edges ( ) const
inline

Definition at line 111 of file graph.h.

References validation_out_edges_.

Member Data Documentation

◆ dirty_

bool Node::dirty_
private

Dirty is true when the underlying file is out-of-date.

But note that Edge::outputs_ready_ is also used in judging which edges to build.

Definition at line 143 of file graph.h.

Referenced by dirty(), MarkDirty(), ResetState(), and set_dirty().

◆ dyndep_pending_

bool Node::dyndep_pending_
private

Store whether dyndep information is expected from this node but has not yet been loaded.

Definition at line 147 of file graph.h.

Referenced by dyndep_pending(), and set_dyndep_pending().

◆ exists_

ExistenceStatus Node::exists_
private

Definition at line 138 of file graph.h.

Referenced by exists(), MarkMissing(), ResetState(), and status_known().

◆ id_

int Node::id_
private

A dense integer id for the node, assigned and used by DepsLog.

Definition at line 160 of file graph.h.

Referenced by id(), and set_id().

◆ in_edge_

Edge* Node::in_edge_
private

The Edge that produces this Node, or NULL when there is no known edge to produce it.

Definition at line 151 of file graph.h.

Referenced by in_edge(), and set_in_edge().

◆ mtime_

TimeStamp Node::mtime_
private

Possible values of mtime_: -1: file hasn't been examined 0: we looked, and file doesn't exist >0: actual file's mtime, or the latest mtime of its dependencies if it doesn't exist.

Definition at line 128 of file graph.h.

Referenced by MarkMissing(), mtime(), and ResetState().

◆ out_edges_

std::vector<Edge*> Node::out_edges_
private

All Edges that use this Node as an input.

Definition at line 154 of file graph.h.

Referenced by AddOutEdge(), and out_edges().

◆ path_

std::string Node::path_
private

Definition at line 118 of file graph.h.

Referenced by path(), and PathDecanonicalized().

◆ slash_bits_

uint64_t Node::slash_bits_
private

Set bits starting from lowest for backslashes that were normalized to forward slashes by CanonicalizePath.

See |PathDecanonicalized|.

Definition at line 122 of file graph.h.

Referenced by PathDecanonicalized(), and slash_bits().

◆ validation_out_edges_

std::vector<Edge*> Node::validation_out_edges_
private

All Edges that use this Node as a validation.

Definition at line 157 of file graph.h.

Referenced by AddValidationOutEdge(), and validation_out_edges().


The documentation for this struct was generated from the following files: