Ninja
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.
 
bool AlreadyUpToDate () const
 Returns true if the build targets are already up to date.
 
ExitStatus Build (std::string *err)
 Run the build.
 
 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.
 
bool FinishCommand (CommandRunner::Result *result, std::string *err)
 Update status ninja logs following a command termination.
 
ExitStatus GetExitCode () const
 Returns ExitStatus or the exit code of the last failed job (doesn't need to be an enum value of ExitStatus)
 
bool LoadDyndeps (Node *node, std::string *err)
 Load the dyndep information provided by the given node.
 
void SetBuildLog (BuildLog *log)
 Used for tests.
 
void SetJobserverClient (std::unique_ptr< Jobserver::Client > jobserver_client)
 Set Jobserver client instance for this builder.
 
bool StartEdge (Edge *edge, std::string *err)
 
 ~Builder ()
 

Public Attributes

std::unique_ptr< CommandRunnercommand_runner_
 
const BuildConfigconfig_
 
std::unique_ptr< Jobserver::Clientjobserver_
 
Plan plan_
 
Statestate_
 
Statusstatus_
 

Private Types

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

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)
 
void SetFailureCode (ExitStatus code)
 

Private Attributes

DiskInterfacedisk_interface_
 
ExitStatus exit_code_ = ExitSuccess
 Keep the global exit code for the build.
 
std::unique_ptr< Explanationsexplanations_
 
std::string lock_file_path_
 
RunningEdgeMap running_edges_
 
DependencyScan scan_
 
int64_t start_time_millis_
 Time the build started.
 

Detailed Description

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

Definition at line 197 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 255 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 )

◆ ~Builder()

Builder::~Builder ( )

Definition at line 622 of file build.cc.

References Cleanup(), and status_.

◆ Builder() [2/2]

Builder::Builder ( const Builder & other)
private

References Builder().

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 699 of file build.cc.

References plan_.

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

◆ Build()

◆ Cleanup()

void Builder::Cleanup ( )

Clean up after interrupted commands by deleting output files.

Definition at line 627 of file build.cc.

References command_runner_, disk_interface_, lock_file_path_, 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 )

◆ GetExitCode()

ExitStatus Builder::GetExitCode ( ) const
inline

Returns ExitStatus or the exit code of the last failed job (doesn't need to be an enum value of ExitStatus)

Definition at line 247 of file build.h.

References exit_code_.

Referenced by Build().

◆ LoadDyndeps()

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

Load the dyndep information provided by the given node.

Definition at line 1050 of file build.cc.

References plan_, and scan_.

◆ operator=()

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

References Builder().

◆ SetBuildLog()

void Builder::SetBuildLog ( BuildLog * log)
inline

Used for tests.

Definition at line 231 of file build.h.

References scan_.

◆ SetFailureCode()

void Builder::SetFailureCode ( ExitStatus code)
private

Definition at line 1063 of file build.cc.

References exit_code_, and ExitSuccess.

Referenced by Build().

◆ SetJobserverClient()

void Builder::SetJobserverClient ( std::unique_ptr< Jobserver::Client > jobserver_client)
inline

Set Jobserver client instance for this builder.

Definition at line 204 of file build.h.

References jobserver_.

◆ StartEdge()

Member Data Documentation

◆ command_runner_

std::unique_ptr<CommandRunner> Builder::command_runner_

◆ config_

const BuildConfig& Builder::config_

Definition at line 239 of file build.h.

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

◆ disk_interface_

DiskInterface* Builder::disk_interface_
private

Definition at line 262 of file build.h.

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

◆ exit_code_

ExitStatus Builder::exit_code_ = ExitSuccess
private

Keep the global exit code for the build.

Definition at line 270 of file build.h.

Referenced by GetExitCode(), and SetFailureCode().

◆ explanations_

std::unique_ptr<Explanations> Builder::explanations_
private

Definition at line 265 of file build.h.

Referenced by Builder().

◆ jobserver_

std::unique_ptr<Jobserver::Client> Builder::jobserver_

Definition at line 241 of file build.h.

Referenced by Build(), and SetJobserverClient().

◆ lock_file_path_

std::string Builder::lock_file_path_
private

Definition at line 261 of file build.h.

Referenced by Builder(), Cleanup(), and StartEdge().

◆ plan_

Plan Builder::plan_

Definition at line 240 of file build.h.

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

◆ running_edges_

RunningEdgeMap Builder::running_edges_
private

Definition at line 256 of file build.h.

Referenced by FinishCommand(), and StartEdge().

◆ scan_

DependencyScan Builder::scan_
private

Definition at line 267 of file build.h.

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

◆ start_time_millis_

int64_t Builder::start_time_millis_
private

Time the build started.

Definition at line 259 of file build.h.

Referenced by Builder(), FinishCommand(), and StartEdge().

◆ state_

State* Builder::state_

Definition at line 238 of file build.h.

Referenced by Builder(), and ExtractDeps().

◆ status_

Status* Builder::status_

Definition at line 243 of file build.h.

Referenced by Build(), Builder(), Cleanup(), FinishCommand(), StartEdge(), and ~Builder().


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