blob: 255fb066233d28538bcd67062aae34fc2e42bb55 [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.
#
# Builds and copies artifacts for the Flutter embedder from your
# local source of the Flutter Engine repository.
#
# Usage:
# build_and_copy_engine_artifacts.sh
#
# Prerequisites:
# 1. $ENGINE_DIR is set to the src/ directory of your flutter/engine checkout.
# 2. $FUCHSIA_EMBEDDER_DIR is set to your flutter-embedder.git checkout.
# 3. $DEPOT_TOOLS is set to your depot_tools directory.
# Returns true if colors are supported.
function is-stderr-tty {
[[ -t 2 ]]
}
# 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-info "Building the Flutter Engine embedding for Fuchsia (libflutter_engine.so)..."
"${ENGINE_DIR}"/flutter/tools/gn --fuchsia --embedder-for-target --unopt
out_dir="${ENGINE_DIR}"/out/fuchsia_debug_unopt_x64
"${DEPOT_TOOLS}"/ninja -C "${out_dir}"
echo-info "Copying Flutter Engine artifacts to ${FUCHSIA_EMBEDDER_DIR}/src/embedder..."
cp "${out_dir}"/libflutter_engine.so "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine/libflutter_engine.so
cp "${ENGINE_DIR}"/flutter/shell/platform/embedder/embedder.h "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine/embedder.h