blob: 2ad174feee5762009a4299d97356d01b55b56186 [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 Cross3c0fe0e2021-02-10 13:11:18 -080029func NewStatusOutput(w io.Writer, statusFormat string, forceSimpleOutput, quietBuild, forceKeepANSI bool) status.StatusOutput {
Colin Crossce525352019-06-08 18:58:00 -070030 formatter := newFormatter(statusFormat, quietBuild)
Dan Willemsenb82471a2018-05-17 16:37:09 -070031
Patrice Arrudaf445ba12020-07-28 17:49:01 +000032 if !forceSimpleOutput && isSmartTerminal(w) {
Colin Crossce525352019-06-08 18:58:00 -070033 return NewSmartStatusOutput(w, formatter)
Dan Willemsenb82471a2018-05-17 16:37:09 -070034 } else {
Colin Cross3c0fe0e2021-02-10 13:11:18 -080035 return NewSimpleStatusOutput(w, formatter, forceKeepANSI)
Dan Willemsenb82471a2018-05-17 16:37:09 -070036 }
37}