| #!/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. |
| # |
| # Usage: |
| # sync_engine_artifacts_to_commit.sh <engine_commit> |
| # |
| # 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. |
| # 4. You don't have any uncommited changes to your Engine code. |
| |
| # 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 |
| } |
| |
| engine_revision=$1 |
| |
| pushd "${ENGINE_DIR}" |
| |
| # Sync Flutter to specified revision. |
| echo-info "Syncing ${ENGINE_DIR}/flutter to ${engine_revision}..." |
| pushd flutter |
| 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/flutter/buildroot/pull/552 into ${ENGINE_DIR}/build to fix embedder build for Fuchsia..." |
| |
| git remote add akbiggs https://github.com/akbiggs/buildroot |
| git fetch akbiggs |
| git cherry-pick -c "${buildroot_fix}" |
| fi |
| popd # build |
| |
| pushd flutter |
| |
| # Get JIT snapshot fix. |
| # TODO(akbiggs): Submit this fix. |
| jit_snapshot_fix=d79531e15a1b04d5e68c7ad87775cb594727d7b0 |
| if ! git merge-base --is-ancestor "${jit_snapshot_fix}" HEAD |
| then |
| echo-info "Cherry-picking https://github.com/flutter/engine/pull/33189 into ${ENGINE_DIR}/flutter to work around JIT snapshot loading issue..." |
| git remote add akbiggs https://github.com/akbiggs/engine |
| git fetch akbiggs |
| git cherry-pick -c "${jit_snapshot_fix}" |
| fi |
| |
| # Get inspect node fix. |
| # TODO(akbiggs): Submit this fix. |
| inspect_node_fix=3b8de94b1347d2f7c3e5e33933866ba8140abdc1 |
| if ! git merge-base --is-ancestor "${inspect_node_fix}" HEAD |
| then |
| echo-info "Cherry-picking https://github.com/flutter/engine/pull/33472 into ${ENGINE_DIR}/flutter to set Dart VM inspect node for Fuchsia..." |
| git remote add akbiggs https://github.com/akbiggs/engine |
| git fetch akbiggs |
| git cherry-pick -c "${inspect_node_fix}" |
| fi |
| |
| popd # flutter |
| |
| # Fail on any error. |
| # We start failing here because the previous commands throw errors even |
| # when things are fine. |
| set -e |
| |
| # 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} |