15 #ifndef NINJA_BUILD_H_ 16 #define NINJA_BUILD_H_ 105 virtual bool CanRunMore() = 0;
106 virtual bool StartCommand(
Edge* edge) = 0;
117 virtual bool WaitForCommand(
Result* result) = 0;
125 BuildConfig() : verbosity(NORMAL), dry_run(false), parallelism(1),
126 failures_allowed(1), max_load_average(-0.0f) {}
159 bool AlreadyUpToDate()
const;
163 bool Build(
string* err);
165 bool StartEdge(
Edge* edge,
string* err);
173 scan_.set_build_log(log);
184 const string& deps_prefix, vector<Node*>* deps_nodes,
192 void operator=(
const Builder &other);
198 void PlanHasTotalEdges(
int total);
199 void BuildEdgeStarted(
Edge* edge);
200 void BuildEdgeFinished(
Edge* edge,
bool success,
const string& output,
201 int* start_time,
int* end_time);
202 void BuildFinished();
208 string FormatProgressStatus(
const char* progress_status_format)
const;
211 void PrintStatus(
Edge* edge);
231 void snprinfRate(
double rate,
char(&buf)[S],
const char* format)
const {
232 if (rate == -1) snprintf(buf, S,
"?");
233 else snprintf(buf, S, format, rate);
240 double Elapsed()
const {
return stopwatch_.Elapsed(); }
241 double rate() {
return rate_; }
244 if (edges && stopwatch_.Elapsed())
245 rate_ = edges / stopwatch_.Elapsed();
257 double rate() {
return rate_; }
260 if (update_hint == last_update_)
262 last_update_ = update_hint;
264 if (times_.size() == N)
266 times_.push(stopwatch_.Elapsed());
267 if (times_.back() != times_.front())
268 rate_ = times_.size() / (times_.back() - times_.front());
283 #endif // NINJA_BUILD_H_
CommandRunner is an interface that wraps running the build subcommands.
double max_load_average
The maximum load average we must not exceed.
Plan stores the state of a build plan: what we intend to build, which steps we're ready to execute...
bool more_to_do() const
Returns true if there's more work to be done.
SlidingRateInfo current_rate_
void UpdateRate(int edges)
bool AddSubTarget(Node *node, vector< Node * > *stack, string *err)
The result of waiting for a command.
bool AddTarget(Node *node, string *err)
Add a target to our plan (including all its dependencies).
Information about a node in the dependency graph: the file, whether it's dirty, mtime, etc.
void ResumeDelayedJobs(Edge *edge)
Allows jobs blocking on |edge| to potentially resume.
void ScheduleWork(Edge *edge)
Submits a ready edge as a candidate for execution.
Interface for accessing the disk.
const BuildConfig & config_
const BuildConfig & config_
void CleanNode(DependencyScan *scan, Node *node)
Clean the given node during the build.
An edge in the dependency graph; links between Nodes using Rules.
void UpdateRate(int update_hint)
Store a log of every command ran for every build.
DiskInterface * disk_interface_
int command_edge_count() const
Number of edges with commands to run.
void EdgeFinished(Edge *edge)
Mark an edge as done building.
As build commands run they can output extra dependency information (e.g.
signed long long int64_t
A 64-bit integer type.
map< Edge *, bool > want_
Keep track of which edges we want to build in this plan.
int64_t start_time_millis_
Time the build started.
int wanted_edges_
Total remaining number of wanted edges.
auto_ptr< CommandRunner > command_runner_
void SetBuildLog(BuildLog *log)
Used for tests.
Builder wraps the build process: starting commands, updating status.
void NodeFinished(Node *node)
bool CheckDependencyCycle(Node *node, vector< Node * > *stack, string *err)
map< Edge *, int > RunningEdgeMap
Map of running edge to time the edge started running.
Tracks the status of a build: completion fraction, printing updates.
const char * progress_status_format_
The custom progress status format to use.
virtual vector< Edge * > GetActiveEdges()
DependencyScan manages the process of scanning the files in a graph and updating the dirty/outputs_re...
Options (e.g. verbosity, parallelism) passed to a build.
Global state (file status, loaded rules) for a single run.
Prints lines of text, possibly overprinting previously printed lines if the terminal supports it...
void Dump()
Dumps the current state of the plan.
RunningEdgeMap running_edges_
LinePrinter printer_
Prints progress output.
A simple stopwatch which returns the time in seconds since Restart() was called.
int command_edges_
Total number of edges that have commands (not phony).
void snprinfRate(double rate, char(&buf)[S], const char *format) const