blob: 810e3c93d66f3cd65952ec99928fb832d6470c20 [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 {
Jeongik Cha0ba68e42023-11-30 09:03:38 +090030 useSmartStatus := !forceSimpleOutput && isSmartTerminal(w)
31 formatter := newFormatter(statusFormat, quietBuild, useSmartStatus)
Dan Willemsenb82471a2018-05-17 16:37:09 -070032
Jeongik Cha0ba68e42023-11-30 09:03:38 +090033 if useSmartStatus {
Sasha Smundak827aead2021-11-19 11:22:54 -080034 return NewSmartStatusOutput(w, formatter)
Sasha Smundak2cec8df2022-05-06 16:04:44 -070035 } else {
36 return NewSimpleStatusOutput(w, formatter, forceKeepANSI)
Dan Willemsenb82471a2018-05-17 16:37:09 -070037 }
38}