Make a Builder optionally available to Plan

In order to later support dynamic updates to the build plan while
building, the Plan will need access to its Builder.  Since this access
will be needed only for specific features we can avoid updating all Plan
constructions in the test suite by making this access optional.
This commit is contained in:
Brad King 2015-06-19 11:47:21 -04:00
parent 083a9e2e7a
commit b08f3fb869
2 changed files with 11 additions and 3 deletions

View File

@ -288,7 +288,11 @@ void BuildStatus::PrintStatus(Edge* edge, EdgeStatus status) {
force_full_command ? LinePrinter::FULL : LinePrinter::ELIDE);
}
Plan::Plan() : command_edges_(0), wanted_edges_(0) {}
Plan::Plan(Builder* builder)
: builder_(builder)
, command_edges_(0)
, wanted_edges_(0)
{}
void Plan::Reset() {
command_edges_ = 0;
@ -572,7 +576,8 @@ bool RealCommandRunner::WaitForCommand(Result* result) {
Builder::Builder(State* state, const BuildConfig& config,
BuildLog* build_log, DepsLog* deps_log,
DiskInterface* disk_interface)
: state_(state), config_(config), disk_interface_(disk_interface),
: state_(state), config_(config),
plan_(this), disk_interface_(disk_interface),
scan_(state, build_log, deps_log, disk_interface,
&config_.depfile_parser_options) {
status_ = new BuildStatus(config);

View File

@ -32,6 +32,7 @@
struct BuildLog;
struct BuildStatus;
struct Builder;
struct DiskInterface;
struct Edge;
struct Node;
@ -40,7 +41,7 @@ struct State;
/// Plan stores the state of a build plan: what we intend to build,
/// which steps we're ready to execute.
struct Plan {
Plan();
Plan(Builder* builder = NULL);
/// Add a target to our plan (including all its dependencies).
/// Returns false if we don't need to build this target; may
@ -112,6 +113,8 @@ private:
set<Edge*> ready_;
Builder* builder_;
/// Total number of edges that have commands (not phony).
int command_edges_;