Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 1 | // 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 | |
| 15 | package terminal |
| 16 | |
| 17 | import ( |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 18 | "android/soong/ui/status" |
| 19 | ) |
| 20 | |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 21 | // NewStatusOutput returns a StatusOutput that represents the |
| 22 | // current build status similarly to Ninja's built-in terminal |
| 23 | // output. |
| 24 | // |
| 25 | // statusFormat takes nearly all the same options as NINJA_STATUS. |
| 26 | // %c is currently unsupported. |
Sasha Smundak | c0c9ef9 | 2019-01-23 09:52:57 -0800 | [diff] [blame] | 27 | func NewStatusOutput(w Writer, statusFormat string, quietBuild bool) status.StatusOutput { |
Colin Cross | ce52535 | 2019-06-08 18:58:00 -0700 | [diff] [blame^] | 28 | formatter := newFormatter(statusFormat, quietBuild) |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 29 | |
Colin Cross | ce52535 | 2019-06-08 18:58:00 -0700 | [diff] [blame^] | 30 | if w.isSmartTerminal() { |
| 31 | return NewSmartStatusOutput(w, formatter) |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 32 | } else { |
Colin Cross | ce52535 | 2019-06-08 18:58:00 -0700 | [diff] [blame^] | 33 | return NewDumbStatusOutput(w, formatter) |
Dan Willemsen | b82471a | 2018-05-17 16:37:09 -0700 | [diff] [blame] | 34 | } |
| 35 | } |