blob: 95eca4277462257cbe4910952d7529e47b1ea8e0 [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.
#
# Syncs the Flutter Engine artifacts in this repository to artifacts built
# at a specified commit. Cherry-picks in several fixes that are necessary
# for the embedder to work currently.
#
# Usage:
# sync_engine_artifacts_to_commit.sh <engine_commit>
#
# Requirements:
# 1. You don't have any uncommited changes to your Engine code.
#
# Arguments:
# The first argument is the Flutter Engine commit to sync to.
# All other arguments are forwarded to build_and_copy_engine_artifacts.sh.
set -e # Fail on any error.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/helpers.sh || exit $?
ensure-embedder-dir
ensure-engine-dir
engine_revision=$1
function get_engine_fix() {
user=$1
fix=$2
reason=$3
if ! git merge-base --is-ancestor "${fix}" HEAD
then
echo-info "Cherry-picking https://github.com/$user/engine/commit/${fix} into ${ENGINE_DIR}/flutter ${reason}"
git remote add "${user}" "https://github.com/${user}/engine" || true # since this will error if the remote was already added
git fetch "${user}"
git cherry-pick -c "${fix}"
fi
}
pushd "${ENGINE_DIR}"
# Sync Flutter to specified revision.
echo-info "Syncing ${ENGINE_DIR}/flutter to ${engine_revision}..."
pushd flutter
git fetch upstream
git checkout "${engine_revision}"
popd # flutter
echo-info "Syncing ${ENGINE_DIR} dependencies..."
gclient sync -D
# Get buildroot fix.
# TODO(akbiggs): Submit this fix.
buildroot_fix=c7deba3773ed645c29f4518cc3990bc02f0f53cd
pushd build
if ! git merge-base --is-ancestor "${buildroot_fix}" HEAD
then
echo-info "Cherry-picking https://github.com/akbiggs/buildroot/commit/${buildroot_fix} into ${ENGINE_DIR}/build to fix embedder build for Fuchsia..."
git remote add akbiggs https://github.com/akbiggs/buildroot || true # since this will error if the remote was already added
git fetch akbiggs
git cherry-pick -c "${buildroot_fix}"
fi
popd # build
pushd flutter
# TODO(akbiggs): Submit these Flutter Engine fixes.
inspect_node_fix=3cbcbb20321f6cda60d28ebc8c2e0b2da285a58d
get_engine_fix "akbiggs" "${inspect_node_fix}" "to set Dart VM inspect node for Fuchsia..."
acquire_software_surface_fix=dadf7a7b06b60f36fdce66759bfd74c01d74e27b
get_engine_fix "akbiggs" "${acquire_software_surface_fix}" "to get API for acquiring software surface..."
font_initialization_data_fix=2aa6de94a2d16a50982b0b8ab5a09fa4bc0443b5
get_engine_fix "naudzghebre" "${font_initialization_data_fix}" "to get API change to embedder.h for setting font_initialization_data.."
popd # flutter
# Build and copy over the artifacts we need and update our
# revision.
shift # so "$@" doesn't include the engine revision
"${FUCHSIA_EMBEDDER_DIR}"/scripts/build_and_copy_engine_artifacts.sh "$@"
echo "${engine_revision}" > "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine/engine_revision
echo-info "Done! Engine artifacts updated to ${engine_revision}."
popd # ${ENGINE_DIR}