diff options
author | Evan Martin <martine@danga.com> | 2012-04-26 03:23:26 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-04-26 03:23:26 (GMT) |
commit | 496f7729009c46691a3210fcb67c418aa102da96 (patch) | |
tree | 7cbbb34ada96929eb2af1af0be266375445a9000 /src/build.h | |
parent | 3fda08c34d4c91a4d16855ce40a2d0ab13a4d768 (diff) | |
parent | eeb572aa84564768311b70e14c5b5354a31bfd29 (diff) | |
download | Ninja-496f7729009c46691a3210fcb67c418aa102da96.zip Ninja-496f7729009c46691a3210fcb67c418aa102da96.tar.gz Ninja-496f7729009c46691a3210fcb67c418aa102da96.tar.bz2 |
Merge branch 'custom_ninja_status' of git://github.com/polrop/ninja
Diffstat (limited to 'src/build.h')
-rw-r--r-- | src/build.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/build.h b/src/build.h index 179fca6..8078910 100644 --- a/src/build.h +++ b/src/build.h @@ -149,4 +149,62 @@ private: void operator=(const Builder &other); // DO NOT IMPLEMENT }; +/// Tracks the status of a build: completion fraction, printing updates. +struct BuildStatus { + BuildStatus(const BuildConfig& config); + void PlanHasTotalEdges(int total); + void BuildEdgeStarted(Edge* edge); + void BuildEdgeFinished(Edge* edge, bool success, const string& output, + int* start_time, int* end_time); + void BuildFinished(); + + /// Format the progress status string by replacing the placeholders. + /// See the user manual for more information about the available + /// placeholders. + /// @param progress_status_format_ The format of the progress status. + /// @param buffer The buffer where is stored the formatted progress status. + /// @param buffer_size The size of the given @a buffer. + /// @param err The error message if -1 is returned. + /// @return The number of characters inserted in @a buffer and -1 on error. + int FormatProgressStatus(const char* progress_status_format, + char* buffer, + const int buffer_size, + string* err) const; + + private: + void PrintStatus(Edge* edge); + + /// Print the progress status. + /// + /// Get the status from the NINJA_STATUS environment variable if defined. + /// + /// @return The number of printed characters. + int PrintProgressStatus() const; + + const BuildConfig& config_; + + /// Time the build started. + int64_t start_time_millis_; + /// Time we last printed an update. + int64_t last_update_millis_; + + int started_edges_, finished_edges_, total_edges_; + + bool have_blank_line_; + + /// Map of running edge to time the edge started running. + typedef map<Edge*, int> RunningEdgeMap; + RunningEdgeMap running_edges_; + + /// Whether we can do fancy terminal control codes. + bool smart_terminal_; + + /// The custom progress status format to use. + const char* progress_status_format_; + +#ifdef _WIN32 + HANDLE console_; +#endif +}; + #endif // NINJA_BUILD_H_ |