| #!/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. $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. |
| # 4. You don't have any uncommited changes to your Engine code. |
| |
| set -e # Fail on any error. |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/echo_helpers.sh || exit $? |
| |
| 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. |
| jit_snapshot_fix=d79531e15a1b04d5e68c7ad87775cb594727d7b0 |
| get_engine_fix "akbiggs" "${jit_snapshot_fix}" "to work around JIT snapshot loading issue..." |
| |
| 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. |
| "${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} |