blob: 1247d1db612e6f8c35545533221e5d2533fc7192 [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
#
# Arguments:
# --goma: Uses goma to accelerate the Flutter Engine build.
# For Googlers only, sorry. :(
#
# All other arguments are forwarded to Flutter Engine's GN.
set -e # Fail on any error.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/helpers.sh || exit $?
ensure-engine-dir
ensure-ninja
# Parse arguments.
goma=0
goma_flags=""
ninja_cmd="ninja"
extra_gn_args=()
while [[ $# -gt 0 ]]; do
case $1 in
--goma)
goma=1
goma_flags="--goma"
ninja_cmd="autoninja"
shift # past argument
;;
*)
extra_gn_args+=("$1") # forward argument
shift # past argument
;;
esac
done
all_gn_args="--fuchsia --embedder-for-target --unopt ${goma_flags} ${extra_gn_args[@]}"
echo-info "Building the debug Flutter Engine embedding for Fuchsia (libflutter_engine.so)..."
echo-info "... GN args: ${all_gn_args}"
"${ENGINE_DIR}"/flutter/tools/gn ${all_gn_args}
debug_out_dir="${ENGINE_DIR}"/out/fuchsia_debug_unopt_x64
${ninja_cmd} -C "${debug_out_dir}"
echo-info "Copying debug Flutter Engine artifacts to ${FUCHSIA_EMBEDDER_DIR}/src/embedder/engine/debug_x64..."
cp "${debug_out_dir}"/libflutter_engine.so "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine/debug_x64/libflutter_engine.so
echo-info "Copying embedder.h to ${FUCHSIA_EMBEDDER_DIR}/src/embedder/engine..."
cp "${ENGINE_DIR}"/flutter/shell/platform/embedder/embedder.h "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine