diff options
author | Evan Martin <martine@danga.com> | 2012-12-21 01:48:25 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-12-21 01:48:25 (GMT) |
commit | 1a31682e41cbd5aafc4f7f012c0a7bfbdbfc0c94 (patch) | |
tree | 541c00b7b34b4c847dd481654a28d82fd85796f2 | |
parent | e3bbbd995b04e5ad930f6f55f8060d680af07cb5 (diff) | |
parent | 6943f0537299e0d572b38b7d1e0562f0c13cb68e (diff) | |
download | Ninja-1a31682e41cbd5aafc4f7f012c0a7bfbdbfc0c94.zip Ninja-1a31682e41cbd5aafc4f7f012c0a7bfbdbfc0c94.tar.gz Ninja-1a31682e41cbd5aafc4f7f012c0a7bfbdbfc0c94.tar.bz2 |
Merge pull request #474 from yannicklm/master
NINJA_STATUS: add support of `%p` for percentage
-rw-r--r-- | doc/manual.asciidoc | 1 | ||||
-rw-r--r-- | src/build.cc | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/doc/manual.asciidoc b/doc/manual.asciidoc index 666f0a5..42e5452 100644 --- a/doc/manual.asciidoc +++ b/doc/manual.asciidoc @@ -215,6 +215,7 @@ Ninja supports one environment variable to control its behavior. Several placeholders are available: * `%s`: The number of started edges. * `%t`: The total number of edges that must be run to complete the build. +* `%p`: The percentage of started edges. * `%r`: The number of currently running edges. * `%u`: The number of remaining edges to start. * `%f`: The number of finished edges. diff --git a/src/build.cc b/src/build.cc index 93ab10d..e5429cf 100644 --- a/src/build.cc +++ b/src/build.cc @@ -179,6 +179,7 @@ string BuildStatus::FormatProgressStatus( const char* progress_status_format) const { string out; char buf[32]; + int percent; for (const char* s = progress_status_format; *s != '\0'; ++s) { if (*s == '%') { ++s; @@ -231,6 +232,13 @@ string BuildStatus::FormatProgressStatus( out += buf; break; + // Percentage + case 'p': + percent = (100 * started_edges_) / total_edges_; + snprintf(buf, sizeof(buf), "%3i%%", percent); + out += buf; + break; + default: Fatal("unknown placeholder '%%%c' in $NINJA_STATUS", *s); return ""; |