blob: dd98810d18d1b9f34f51a154c00f10d5e00949fe [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 third_party/engine to the specified commit. Cherry-picks in several
# fixes that are necessary for the Fuchsia embedder to work currently.
#
# Usage:
# sync_engine_to_revision.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.
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
echo-info "Fetching 'upstream' for third_party/engine to ensure we have the commit..."
git -C "${embedder_engine_dir}"/flutter fetch upstream
echo-info "Checking out third_party/engine/src/flutter at ${engine_revision}..."
git -C "${embedder_engine_dir}"/flutter checkout "${engine_revision}"
echo-info "Updating third_party/engine/src/flutter's dependencies..."
pushd "${embedder_engine_dir}"
"${embedder_depot_tools}"/gclient sync -D
popd # "${embedder_engine_dir}"
# There are several unsubmitted hack fixes that we rely on
# to make the Fuchsia embedder currently.
# We should land all of these fixes and remove this logic.
echo-info "Cherry-picking Flutter Engine hacks that are necessary for the embedder to work..."
pushd "${embedder_engine_dir}"/build
buildroot_fix=c7deba3773ed645c29f4518cc3990bc02f0f53cd
if ! git merge-base --is-ancestor "${buildroot_fix}" HEAD
then
echo-info "... cherry-picking https://github.com/akbiggs/buildroot/commit/${buildroot_fix} into ${embedder_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 # "${embedder_engine_dir}"/build
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 ${embedder_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 "${embedder_engine_dir}"/flutter
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.."
async_msg_loop_fix=1275e614f23b46b5a77f39563b73acd038309428
get_engine_fix "bergkampben" "${async_msg_loop_fix}" "to get API change to fix the issue with multiple async::Loops for the main platform thread"
popd # "${embedder_engine_dir}"/flutter
echo "${engine_revision}" > "${FUCHSIA_EMBEDDER_DIR}"/src/embedder/engine/engine_revision
echo-info "Engine synced to ${engine_revision}!"
echo-info "To run an example with the updated engine code, run:"
echo '$FUCHSIA_EMBEDDER_DIR/scripts/build_and_run_example.sh --with-engine'