| #!/bin/bash |
| # |
| # Copyright 2022 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Returns true if colors are supported. |
| function is-stderr-tty { |
| [[ -t 2 ]] |
| } |
| |
| # echo-info prints a line to stderr with a green INFO: prefix. |
| function echo-info { |
| if is-stderr-tty; then |
| echo -e >&2 "\033[1;32mINFO:\033[0m $*" |
| else |
| echo -e >&2 "INFO: $*" |
| fi |
| } |
| |
| # echo-warning prints a line to stderr with a yellow WARNING: prefix. |
| function echo-warning { |
| if is-stderr-tty; then |
| echo -e >&2 "\033[1;33mWARNING:\033[0m $*" |
| else |
| echo -e >&2 "WARNING: $*" |
| fi |
| } |
| |
| # echo-error prints a line to stderr with a red ERROR: prefix. |
| function echo-error { |
| if is-stderr-tty; then |
| echo -e >&2 "\033[1;31mERROR:\033[0m $*" |
| else |
| echo -e >&2 "ERROR: $*" |
| fi |
| } |
| |
| function ensure-embedder-dir { |
| if [[ -z "${FUCHSIA_EMBEDDER_DIR}" ]]; then |
| echo-error '$FUCHSIA_EMBEDDER_DIR must be set to your flutter-embedder folder before running this script.' |
| echo-error 'Add this line to your shell profile:' |
| echo-error "export FUCHSIA_EMBEDDER_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && cd .. && pwd)" |
| exit 1 |
| fi |
| } |
| |
| function ensure-engine-dir { |
| if [[ -z "${ENGINE_DIR}" ]]; then |
| echo-error '$ENGINE_DIR must be set to the src/ folder of your Flutter Engine checkout before running this script.' |
| echo-error 'For example if your Flutter Engine checkout is $HOME/engine, add this line to your shell profile:' |
| echo-error 'export ENGINE_DIR=$HOME/engine/src' |
| exit 1 |
| fi |
| } |
| |
| function ensure-ninja { |
| if ! [ -x "$(command -v ninja)" ]; then |
| echo-error '`ninja` is not in your $PATH. Do you have depot_tools installed and in your $PATH? https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up' |
| exit 1 |
| fi |
| } |