|
Ninja
|
Builder wraps the build process: starting commands, updating status. More...
#include <build.h>
Public Member Functions | |
| Node * | AddTarget (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< CommandRunner > | command_runner_ |
| const BuildConfig & | config_ |
| Plan | plan_ |
| State * | state_ |
| Status * | status_ |
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 | |
| DiskInterface * | disk_interface_ |
| RunningEdgeMap | running_edges_ |
| DependencyScan | scan_ |
| int64_t | start_time_millis_ |
| Time the build started. More... | |
Builder wraps the build process: starting commands, updating status.
|
private |
| Builder::Builder | ( | State * | state, |
| const BuildConfig & | config, | ||
| BuildLog * | build_log, | ||
| DepsLog * | deps_log, | ||
| DiskInterface * | disk_interface, | ||
| Status * | status, | ||
| int64_t | start_time_millis | ||
| ) |
|
private |
| Node* Builder::AddTarget | ( | const std::string & | name, |
| std::string * | err | ||
| ) |
Referenced by BuildTest::RebuildTarget(), TEST_F(), and TestPhonyUseCase().
| bool Builder::AddTarget | ( | Node * | target, |
| std::string * | err | ||
| ) |
Add a target to the build, scanning dependencies.
| 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().
| bool Builder::Build | ( | std::string * | err | ) |
Run the build.
Returns false on error. It is an error to call this function when AlreadyUpToDate() is true.
Definition at line 599 of file build.cc.
References AlreadyUpToDate(), DependencyScan::build_log(), Status::BuildFinished(), Status::BuildStarted(), Cleanup(), BuildLog::Close(), Plan::command_edge_count(), command_runner_, config_, BuildConfig::dry_run, Plan::EdgeFinished(), ExitInterrupted, BuildConfig::failures_allowed, Plan::FindWork(), FinishCommand(), Edge::GetBindingBool(), Edge::is_phony(), Plan::kEdgeSucceeded, Plan::more_to_do(), plan_, Status::PlanHasTotalEdges(), scan_, StartEdge(), CommandRunner::Result::status, status_, and CommandRunner::Result::success().
Referenced by BuildTest::RebuildTarget(), TEST_F(), and TestPhonyUseCase().
| 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().
|
private |
Definition at line 857 of file build.cc.
References CanonicalizePath(), config_, BuildConfig::depfile_parser_options, disk_interface_, CommandRunner::Result::edge, Fatal(), g_keep_depfile, State::GetNode(), Edge::GetUnescapedDepfile(), CLParser::includes_, DepfileParser::ins_, FileReader::NotFound, FileReader::Okay, FileReader::OtherError, CommandRunner::Result::output, DepfileParser::Parse(), CLParser::Parse(), FileReader::ReadFile(), DiskInterface::RemoveFile(), and state_.
Referenced by FinishCommand().
| bool Builder::FinishCommand | ( | CommandRunner::Result * | result, |
| std::string * | err | ||
| ) |
Update status ninja logs following a command termination.
Definition at line 733 of file build.cc.
References DependencyScan::build_log(), Status::BuildEdgeFinished(), Plan::CleanNode(), Plan::command_edge_count(), config_, DependencyScan::deps_log(), disk_interface_, BuildConfig::dry_run, CommandRunner::Result::edge, Plan::EdgeFinished(), ExitFailure, ExtractDeps(), g_keep_rsp, Edge::GetBinding(), Edge::GetBindingBool(), GetTimeMillis(), Edge::GetUnescapedDepfile(), Edge::GetUnescapedRspfile(), Edge::inputs_, Plan::kEdgeFailed, Plan::kEdgeSucceeded, METRIC_RECORD, Edge::order_only_deps_, CommandRunner::Result::output, Edge::outputs_, plan_, Status::PlanHasTotalEdges(), BuildLog::RecordCommand(), DepsLog::RecordDeps(), DiskInterface::RemoveFile(), running_edges_, scan_, start_time_millis_, DiskInterface::Stat(), CommandRunner::Result::status, status_, and CommandRunner::Result::success().
Referenced by Build().
| 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().
|
private |
|
inline |
Used for tests.
Definition at line 208 of file build.h.
References scan_, and DependencyScan::set_build_log().
| bool Builder::StartEdge | ( | Edge * | edge, |
| std::string * | err | ||
| ) |
Definition at line 697 of file build.cc.
References Status::BuildEdgeStarted(), command_runner_, disk_interface_, Edge::EvaluateCommand(), Edge::GetBinding(), GetTimeMillis(), Edge::GetUnescapedRspfile(), Edge::is_phony(), DiskInterface::MakeDirs(), METRIC_RECORD, Edge::outputs_, running_edges_, start_time_millis_, status_, and DiskInterface::WriteFile().
Referenced by Build().
| 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().
| const BuildConfig& Builder::config_ |
Definition at line 216 of file build.h.
Referenced by Build(), ExtractDeps(), and FinishCommand().
|
private |
Definition at line 237 of file build.h.
Referenced by Cleanup(), ExtractDeps(), FinishCommand(), and StartEdge().
| Plan Builder::plan_ |
Definition at line 217 of file build.h.
Referenced by AlreadyUpToDate(), Build(), FinishCommand(), and LoadDyndeps().
|
private |
Definition at line 232 of file build.h.
Referenced by FinishCommand(), and StartEdge().
|
private |
Definition at line 238 of file build.h.
Referenced by Build(), FinishCommand(), LoadDyndeps(), and SetBuildLog().
|
private |
Time the build started.
Definition at line 235 of file build.h.
Referenced by FinishCommand(), and StartEdge().
| State* Builder::state_ |
Definition at line 215 of file build.h.
Referenced by ExtractDeps().
| Status* Builder::status_ |
Definition at line 223 of file build.h.
Referenced by Build(), Cleanup(), FinishCommand(), LoadDyndeps(), and StartEdge().
1.8.14