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

Builder wraps the build process: starting commands, updating status. More...

#include <build.h>

Public Member Functions

NodeAddTarget (const std::string &name, std::string *err)
 
bool AddTarget (Node *target, std::string *err)
 Add a target to the build, scanning dependencies. More...
 
bool AlreadyUpToDate () const
 Returns true if the build targets are already up to date. More...
 
bool Build (std::string *err)
 Run the build. More...
 
 Builder (State *state, const BuildConfig &config, BuildLog *build_log, DepsLog *deps_log, DiskInterface *disk_interface, Status *status, int64_t start_time_millis)
 
void Cleanup ()
 Clean up after interrupted commands by deleting output files. More...
 
bool FinishCommand (CommandRunner::Result *result, std::string *err)
 Update status ninja logs following a command termination. More...
 
bool LoadDyndeps (Node *node, std::string *err)
 Load the dyndep information provided by the given node. More...
 
void SetBuildLog (BuildLog *log)
 Used for tests. More...
 
bool StartEdge (Edge *edge, std::string *err)
 
 ~Builder ()
 

Public Attributes

std::auto_ptr< CommandRunnercommand_runner_
 
const BuildConfigconfig_
 
Plan plan_
 
Statestate_
 
Statusstatus_
 

Private Types

typedef std::map< const Edge *, int > RunningEdgeMap
 Map of running edge to time the edge started running. More...
 

Private Member Functions

 Builder (const Builder &other)
 
bool ExtractDeps (CommandRunner::Result *result, const std::string &deps_type, const std::string &deps_prefix, std::vector< Node *> *deps_nodes, std::string *err)
 
void operator= (const Builder &other)
 

Private Attributes

DiskInterfacedisk_interface_
 
RunningEdgeMap running_edges_
 
DependencyScan scan_
 
int64_t start_time_millis_
 Time the build started. More...
 

Detailed Description

Builder wraps the build process: starting commands, updating status.

Definition at line 178 of file build.h.

Member Typedef Documentation

◆ RunningEdgeMap

typedef std::map<const Edge*, int> Builder::RunningEdgeMap
private

Map of running edge to time the edge started running.

Definition at line 231 of file build.h.

Constructor & Destructor Documentation

◆ Builder() [1/2]

Builder::Builder ( State state,
const BuildConfig config,
BuildLog build_log,
DepsLog deps_log,
DiskInterface disk_interface,
Status status,
int64_t  start_time_millis 
)

Definition at line 513 of file build.cc.

◆ ~Builder()

Builder::~Builder ( )

Definition at line 523 of file build.cc.

References Cleanup().

◆ Builder() [2/2]

Builder::Builder ( const Builder other)
private

Member Function Documentation

◆ AddTarget() [1/2]

Node* Builder::AddTarget ( const std::string &  name,
std::string *  err 
)

◆ AddTarget() [2/2]

bool Builder::AddTarget ( Node target,
std::string *  err 
)

Add a target to the build, scanning dependencies.

Returns
false on error.

◆ AlreadyUpToDate()

bool Builder::AlreadyUpToDate ( ) const

Returns true if the build targets are already up to date.

Definition at line 595 of file build.cc.

References Plan::more_to_do(), and plan_.

Referenced by Build(), BuildTest::RebuildTarget(), TEST_F(), and TestPhonyUseCase().

◆ Build()

bool Builder::Build ( std::string *  err)

◆ Cleanup()

void Builder::Cleanup ( )

Clean up after interrupted commands by deleting output files.

Definition at line 527 of file build.cc.

References command_runner_, disk_interface_, Status::Error(), DiskInterface::RemoveFile(), DiskInterface::Stat(), and status_.

Referenced by Build(), and ~Builder().

◆ ExtractDeps()

bool Builder::ExtractDeps ( CommandRunner::Result result,
const std::string &  deps_type,
const std::string &  deps_prefix,
std::vector< Node *> *  deps_nodes,
std::string *  err 
)
private

◆ FinishCommand()

bool Builder::FinishCommand ( CommandRunner::Result result,
std::string *  err 
)

◆ LoadDyndeps()

bool Builder::LoadDyndeps ( Node node,
std::string *  err 
)

Load the dyndep information provided by the given node.

Definition at line 923 of file build.cc.

References Status::BuildLoadDyndeps(), Plan::command_edge_count(), Plan::DyndepsLoaded(), DependencyScan::LoadDyndeps(), plan_, Status::PlanHasTotalEdges(), scan_, and status_.

Referenced by Plan::NodeFinished().

◆ operator=()

void Builder::operator= ( const Builder other)
private

◆ SetBuildLog()

void Builder::SetBuildLog ( BuildLog log)
inline

Used for tests.

Definition at line 208 of file build.h.

References scan_, and DependencyScan::set_build_log().

◆ StartEdge()

bool Builder::StartEdge ( Edge edge,
std::string *  err 
)

Member Data Documentation

◆ command_runner_

std::auto_ptr<CommandRunner> Builder::command_runner_

Definition at line 219 of file build.h.

Referenced by Build(), Cleanup(), BuildTest::RebuildTarget(), StartEdge(), TEST_F(), and TestPhonyUseCase().

◆ config_

const BuildConfig& Builder::config_

Definition at line 216 of file build.h.

Referenced by Build(), ExtractDeps(), and FinishCommand().

◆ disk_interface_

DiskInterface* Builder::disk_interface_
private

Definition at line 237 of file build.h.

Referenced by Cleanup(), ExtractDeps(), FinishCommand(), and StartEdge().

◆ plan_

Plan Builder::plan_

Definition at line 217 of file build.h.

Referenced by AlreadyUpToDate(), Build(), FinishCommand(), and LoadDyndeps().

◆ running_edges_

RunningEdgeMap Builder::running_edges_
private

Definition at line 232 of file build.h.

Referenced by FinishCommand(), and StartEdge().

◆ scan_

DependencyScan Builder::scan_
private

Definition at line 238 of file build.h.

Referenced by Build(), FinishCommand(), LoadDyndeps(), and SetBuildLog().

◆ start_time_millis_

int64_t Builder::start_time_millis_
private

Time the build started.

Definition at line 235 of file build.h.

Referenced by FinishCommand(), and StartEdge().

◆ state_

State* Builder::state_

Definition at line 215 of file build.h.

Referenced by ExtractDeps().

◆ status_

Status* Builder::status_

Definition at line 223 of file build.h.

Referenced by Build(), Cleanup(), FinishCommand(), LoadDyndeps(), and StartEdge().


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