Ninja
State Struct Reference

Global state (file status) for a single run. More...

#include <state.h>

Public Types

typedef ExternalStringHashMap< Node * >::Type Paths
 Mapping of path -> Node.
 

Public Member Functions

bool AddDefault (StringPiece path, std::string *error)
 
EdgeAddEdge (const Rule *rule)
 
void AddIn (Edge *edge, StringPiece path, uint64_t slash_bits)
 Add input / output / validation nodes to a given edge.
 
bool AddOut (Edge *edge, StringPiece path, uint64_t slash_bits, std::string *err)
 
void AddPool (Pool *pool)
 
void AddValidation (Edge *edge, StringPiece path, uint64_t slash_bits)
 
std::vector< Node * > DefaultNodes (std::string *error) const
 
void Dump ()
 Dump the nodes and Pools (useful for debugging).
 
NodeGetNode (StringPiece path, uint64_t slash_bits)
 
NodeLookupNode (StringPiece path) const
 
PoolLookupPool (const std::string &pool_name)
 
void Reset ()
 Reset state.
 
std::vector< Node * > RootNodes (std::string *error) const
 
NodeSpellcheckNode (const std::string &path)
 
 State ()
 

Public Attributes

BindingEnv bindings_
 
std::vector< Node * > defaults_
 
std::vector< Edge * > edges_
 All the edges of the graph.
 
Paths paths_
 
std::map< std::string, Pool * > pools_
 All the pools used in the graph.
 

Static Public Attributes

static Pool kConsolePool
 
static Pool kDefaultPool
 

Detailed Description

Global state (file status) for a single run.

Definition at line 95 of file state.h.

Member Typedef Documentation

◆ Paths

Mapping of path -> Node.

Definition at line 131 of file state.h.

Constructor & Destructor Documentation

◆ State()

State::State ( )

Definition at line 67 of file state.cc.

References AddPool(), bindings_, kConsolePool, kDefaultPool, and Rule::Phony().

Member Function Documentation

◆ AddDefault()

bool State::AddDefault ( StringPiece path,
std::string * error )

Definition at line 159 of file state.cc.

References StringPiece::AsString(), defaults_, and LookupNode().

◆ AddEdge()

Edge * State::AddEdge ( const Rule * rule)

Definition at line 85 of file state.cc.

References bindings_, edges_, Edge::env_, Edge::id_, kDefaultPool, Edge::pool_, and Edge::rule_.

◆ AddIn()

void State::AddIn ( Edge * edge,
StringPiece path,
uint64_t slash_bits )

Add input / output / validation nodes to a given edge.

This also ensures that the generated_by_dep_loader() flag for all these nodes is set to false, to indicate that they come from the input manifest.

Definition at line 128 of file state.cc.

References Node::AddOutEdge(), GetNode(), Edge::inputs_, and Node::set_generated_by_dep_loader().

◆ AddOut()

bool State::AddOut ( Edge * edge,
StringPiece path,
uint64_t slash_bits,
std::string * err )

◆ AddPool()

void State::AddPool ( Pool * pool)

Definition at line 73 of file state.cc.

References LookupPool(), Pool::name(), and pools_.

Referenced by State().

◆ AddValidation()

void State::AddValidation ( Edge * edge,
StringPiece path,
uint64_t slash_bits )

◆ DefaultNodes()

vector< Node * > State::DefaultNodes ( std::string * error) const

Definition at line 187 of file state.cc.

References defaults_, and RootNodes().

◆ Dump()

void State::Dump ( )

Dump the nodes and Pools (useful for debugging).

Definition at line 201 of file state.cc.

References Node::dirty(), Node::id(), Node::path(), paths_, pools_, and Node::status_known().

◆ GetNode()

Node * State::GetNode ( StringPiece path,
uint64_t slash_bits )

Definition at line 95 of file state.cc.

References StringPiece::AsString(), LookupNode(), Node::path(), and paths_.

Referenced by AddIn(), AddOut(), AddValidation(), DepsLog::Load(), and TEST_F().

◆ LookupNode()

Node * State::LookupNode ( StringPiece path) const

Definition at line 104 of file state.cc.

References paths_.

Referenced by AddDefault(), and GetNode().

◆ LookupPool()

Pool * State::LookupPool ( const std::string & pool_name)

Definition at line 78 of file state.cc.

References pools_.

Referenced by AddPool(), and TEST_F().

◆ Reset()

void State::Reset ( )

Reset state.

Keeps all nodes and edges, but restores them to the state where we haven't yet examined the disk for dirty state.

Definition at line 191 of file state.cc.

References edges_, paths_, and Edge::VisitNone.

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

◆ RootNodes()

vector< Node * > State::RootNodes ( std::string * error) const
Returns
the root node(s) of the graph. (Root nodes have no output edges).
Parameters
errorwhere to write the error message if somethings went wrong.

Definition at line 169 of file state.cc.

References edges_.

Referenced by DefaultNodes().

◆ SpellcheckNode()

Node * State::SpellcheckNode ( const std::string & path)

Definition at line 111 of file state.cc.

References EditDistance(), and paths_.

Member Data Documentation

◆ bindings_

BindingEnv State::bindings_

Definition at line 140 of file state.h.

Referenced by AddEdge(), ManifestParser::ManifestParser(), and State().

◆ defaults_

std::vector<Node*> State::defaults_

Definition at line 141 of file state.h.

Referenced by AddDefault(), and DefaultNodes().

◆ edges_

std::vector<Edge*> State::edges_

All the edges of the graph.

Definition at line 138 of file state.h.

Referenced by AddEdge(), LoadManifests(), Reset(), RootNodes(), TEST_F(), VerifyGraph(), and WriteTestData().

◆ kConsolePool

Pool State::kConsolePool
static

Definition at line 97 of file state.h.

Referenced by State(), and Edge::use_console().

◆ kDefaultPool

Pool State::kDefaultPool
static

Definition at line 96 of file state.h.

Referenced by AddEdge(), and State().

◆ paths_

Paths State::paths_

Definition at line 132 of file state.h.

Referenced by Dump(), GetNode(), LookupNode(), Reset(), SpellcheckNode(), and VerifyGraph().

◆ pools_

std::map<std::string, Pool*> State::pools_

All the pools used in the graph.

Definition at line 135 of file state.h.

Referenced by AddPool(), Dump(), and LookupPool().


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