summaryrefslogtreecommitdiff
path: root/ui/status/status.go
diff options
context:
space:
mode:
author Jeongik Cha <jeongik@google.com> 2023-11-27 11:00:52 +0900
committer Jeongik Cha <jeongik@google.com> 2023-11-29 09:57:35 +0900
commit3622b3464b4c23e39548c82ba88c23f2cc934482 (patch)
treecdcd72254d0166176ae8d93e18b915d7a8d310d1 /ui/status/status.go
parenta4291d572a97f886e34b527cd5325c8d05b5e6c9 (diff)
Show estimated build end time during build
Ninja delivers estimated total build time and critical path time from previous ninja log. Bug: 292304818 Test: check if ETA shows Change-Id: I014caaa3e8222a53c8822616b2ae31b88a3b0310
Diffstat (limited to 'ui/status/status.go')
-rw-r--r--ui/status/status.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/status/status.go b/ui/status/status.go
index f3e58b660..da78994ef 100644
--- a/ui/status/status.go
+++ b/ui/status/status.go
@@ -19,6 +19,7 @@ package status
import (
"sync"
+ "time"
)
// Action describes an action taken (or as Ninja calls them, Edges).
@@ -107,6 +108,8 @@ type Counts struct {
// FinishedActions are the number of actions that have been finished
// with FinishAction.
FinishedActions int
+
+ EstimatedTime time.Time
}
// ToolStatus is the interface used by tools to report on their Actions, and to
@@ -118,6 +121,7 @@ type ToolStatus interface {
// This call be will ignored if it sets a number that is less than the
// current number of started actions.
SetTotalActions(total int)
+ SetEstimatedTime(estimatedTime time.Time)
// StartAction specifies that the associated action has been started by
// the tool.
@@ -267,6 +271,13 @@ func (s *Status) updateTotalActions(diff int) {
s.counts.TotalActions += diff
}
+func (s *Status) SetEstimatedTime(estimatedTime time.Time) {
+ s.lock.Lock()
+ defer s.lock.Unlock()
+
+ s.counts.EstimatedTime = estimatedTime
+}
+
func (s *Status) startAction(action *Action) {
s.lock.Lock()
defer s.lock.Unlock()
@@ -329,6 +340,10 @@ func (d *toolStatus) SetTotalActions(total int) {
}
}
+func (d *toolStatus) SetEstimatedTime(estimatedTime time.Time) {
+ d.status.SetEstimatedTime(estimatedTime)
+}
+
func (d *toolStatus) StartAction(action *Action) {
totalDiff := 0