blob: e43f3b612b394fd670ed7c659acfd631c5a61a08 [file] [log] [blame]
#!/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 command.'
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
}
embedder_depot_tools="${FUCHSIA_EMBEDDER_DIR}"/third_party/depot_tools
embedder_engine_dir="${FUCHSIA_EMBEDDER_DIR}"/third_party/engine/src
function ensure-engine-dir {
if [ ! -d "${embedder_engine_dir}" ]
then
echo-error 'You must set up your Engine development environment before running this command.'
echo-error 'To do this, run:'
echo -e >&2 '$FUCHSIA_EMBEDDER_DIR/scripts/setup_engine.sh --github-username my_username'
exit 1
fi
}
function ensure-local-fuchsia-platform-build {
if [[ -z "${LOCAL_FUCHSIA_PLATFORM_BUILD}" ]]
then
echo-error '$LOCAL_FUCHSIA_PLATFORM_BUILD must be set to a Fuchsia out/ directory before running this command.'
echo-error 'For example:'
echo -e >&2 'export LOCAL_FUCHSIA_PLATFORM_BUILD=$FUCHSIA_DIR/out/default'
exit 1
fi
}