blob: 69a2a0929c8c7716f541b10f47745e44c2f67b7b [file] [log] [blame]
Dan Willemsenb82471a2018-05-17 16:37:09 -07001// Copyright 2018 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package terminal
16
17import (
Colin Cross097ed2a2019-06-08 21:48:58 -070018 "io"
19
Dan Willemsenb82471a2018-05-17 16:37:09 -070020 "android/soong/ui/status"
21)
22
Dan Willemsenb82471a2018-05-17 16:37:09 -070023// NewStatusOutput returns a StatusOutput that represents the
24// current build status similarly to Ninja's built-in terminal
25// output.
26//
27// statusFormat takes nearly all the same options as NINJA_STATUS.
28// %c is currently unsupported.
Colin Cross097ed2a2019-06-08 21:48:58 -070029func NewStatusOutput(w io.Writer, statusFormat string, quietBuild bool) status.StatusOutput {
Colin Crossce525352019-06-08 18:58:00 -070030 formatter := newFormatter(statusFormat, quietBuild)
Dan Willemsenb82471a2018-05-17 16:37:09 -070031
Colin Cross097ed2a2019-06-08 21:48:58 -070032 if isSmartTerminal(w) {
Colin Crossce525352019-06-08 18:58:00 -070033 return NewSmartStatusOutput(w, formatter)
Dan Willemsenb82471a2018-05-17 16:37:09 -070034 } else {
Colin Crossce525352019-06-08 18:58:00 -070035 return NewDumbStatusOutput(w, formatter)
Dan Willemsenb82471a2018-05-17 16:37:09 -070036 }
37}