Ninja
|
Builder wraps the build process: starting commands, updating status. More...
#include <build.h>
Public Member Functions | |
Node * | AddTarget (const string &name, string *err) |
bool | AddTarget (Node *target, string *err) |
Add a target to the build, scanning dependencies. | |
bool | AlreadyUpToDate () const |
Returns true if the build targets are already up to date. | |
bool | Build (string *err) |
Run the build. | |
Builder (State *state, const BuildConfig &config, BuildLog *build_log, DepsLog *deps_log, DiskInterface *disk_interface) | |
void | Cleanup () |
Clean up after interrupted commands by deleting output files. | |
void | FinishCommand (CommandRunner::Result *result) |
void | SetBuildLog (BuildLog *log) |
Used for tests. | |
bool | StartEdge (Edge *edge, string *err) |
~Builder () | |
Public Attributes | |
auto_ptr< CommandRunner > | command_runner_ |
const BuildConfig & | config_ |
Plan | plan_ |
State * | state_ |
BuildStatus * | status_ |
Private Member Functions | |
Builder (const Builder &other) | |
bool | ExtractDeps (CommandRunner::Result *result, const string &deps_type, vector< Node * > *deps_nodes, string *err) |
void | operator= (const Builder &other) |
Private Attributes | |
DiskInterface * | disk_interface_ |
DependencyScan | scan_ |
Builder wraps the build process: starting commands, updating status.
Builder::Builder | ( | State * | state, |
const BuildConfig & | config, | ||
BuildLog * | build_log, | ||
DepsLog * | deps_log, | ||
DiskInterface * | disk_interface | ||
) |
Builder::Builder | ( | const Builder & | other | ) | [private] |
Node * Builder::AddTarget | ( | const string & | name, |
string * | err | ||
) |
Definition at line 563 of file build.cc.
References State::LookupNode(), and state_.
Referenced by TEST_F().
bool Builder::AddTarget | ( | Node * | target, |
string * | err | ||
) |
Add a target to the build, scanning dependencies.
Definition at line 574 of file build.cc.
References Plan::AddTarget(), disk_interface_, Node::in_edge(), plan_, DependencyScan::RecomputeDirty(), scan_, and Node::StatIfNecessary().
bool Builder::AlreadyUpToDate | ( | ) | const |
Returns true if the build targets are already up to date.
Definition at line 589 of file build.cc.
References Plan::more_to_do(), and plan_.
Referenced by Build().
bool Builder::Build | ( | string * | err | ) |
Run the build.
Returns false on error. It is an error to call this function when AlreadyUpToDate() is true.
Definition at line 593 of file build.cc.
References AlreadyUpToDate(), BuildStatus::BuildFinished(), Plan::command_edge_count(), command_runner_, config_, BuildConfig::dry_run, Plan::EdgeFinished(), ExitInterrupted, BuildConfig::failures_allowed, Plan::FindWork(), FinishCommand(), Edge::is_phony(), Plan::more_to_do(), plan_, BuildStatus::PlanHasTotalEdges(), StartEdge(), CommandRunner::Result::status, status_, and CommandRunner::Result::success().
Referenced by TEST_F().
void Builder::Cleanup | ( | ) |
Clean up after interrupted commands by deleting output files.
Definition at line 535 of file build.cc.
References command_runner_, disk_interface_, DiskInterface::RemoveFile(), and DiskInterface::Stat().
Referenced by ~Builder().
bool Builder::ExtractDeps | ( | CommandRunner::Result * | result, |
const string & | deps_type, | ||
vector< Node * > * | deps_nodes, | ||
string * | err | ||
) | [private] |
Definition at line 799 of file build.cc.
References CanonicalizePath(), disk_interface_, CommandRunner::Result::edge, Fatal(), Edge::GetBinding(), State::GetNode(), CLParser::includes_, DepfileParser::ins_, CommandRunner::Result::output, DepfileParser::Parse(), CLParser::Parse(), DiskInterface::ReadFile(), DiskInterface::RemoveFile(), and state_.
Referenced by FinishCommand().
void Builder::FinishCommand | ( | CommandRunner::Result * | result | ) |
Definition at line 707 of file build.cc.
References DependencyScan::build_log(), BuildStatus::BuildEdgeFinished(), Plan::CleanNode(), Plan::command_edge_count(), config_, DependencyScan::deps_log(), disk_interface_, BuildConfig::dry_run, CommandRunner::Result::edge, Plan::EdgeFinished(), ExitFailure, ExtractDeps(), Edge::GetBinding(), Edge::GetBindingBool(), Edge::inputs_, METRIC_RECORD, Edge::order_only_deps_, CommandRunner::Result::output, Edge::outputs_, plan_, BuildStatus::PlanHasTotalEdges(), BuildLog::RecordCommand(), DepsLog::RecordDeps(), DiskInterface::RemoveFile(), scan_, DiskInterface::Stat(), CommandRunner::Result::status, status_, and CommandRunner::Result::success().
Referenced by Build().
void Builder::operator= | ( | const Builder & | other | ) | [private] |
void Builder::SetBuildLog | ( | BuildLog * | log | ) | [inline] |
Used for tests.
Definition at line 169 of file build.h.
References scan_, and DependencyScan::set_build_log().
Referenced by BuildWithLogTest::BuildWithLogTest().
bool Builder::StartEdge | ( | Edge * | edge, |
string * | err | ||
) |
Definition at line 674 of file build.cc.
References BuildStatus::BuildEdgeStarted(), command_runner_, disk_interface_, Edge::EvaluateCommand(), Edge::GetBinding(), Edge::is_phony(), DiskInterface::MakeDirs(), METRIC_RECORD, Edge::outputs_, status_, and DiskInterface::WriteFile().
Referenced by Build().
auto_ptr<CommandRunner> Builder::command_runner_ |
Definition at line 176 of file build.h.
Referenced by Build(), Cleanup(), BuildTest::SetUp(), StartEdge(), TEST_F(), and BuildTest::~BuildTest().
const BuildConfig& Builder::config_ |
Definition at line 174 of file build.h.
Referenced by Build(), and FinishCommand().
DiskInterface* Builder::disk_interface_ [private] |
Definition at line 183 of file build.h.
Referenced by AddTarget(), Cleanup(), ExtractDeps(), FinishCommand(), and StartEdge().
Definition at line 175 of file build.h.
Referenced by AddTarget(), AlreadyUpToDate(), Build(), and FinishCommand().
DependencyScan Builder::scan_ [private] |
Definition at line 184 of file build.h.
Referenced by AddTarget(), FinishCommand(), and SetBuildLog().
Definition at line 173 of file build.h.
Referenced by AddTarget(), and ExtractDeps().
Definition at line 177 of file build.h.
Referenced by Build(), Builder(), FinishCommand(), and StartEdge().