| #!/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. |
| # |
| # Sets up the Flutter Engine repo. |
| # |
| # This takes a bit of time and is only necessary if you want to test |
| # Flutter Engine changes or upgrade the version of Flutter Engine used by this |
| # repository, so it's a separate script from bootstrap.sh. |
| # |
| # TODO(akbiggs): It would simplify the workflow significantly to |
| # make third_party/engine a git submodule (we could get rid of setup_engine.sh), |
| # however I think the Engine source needs to be fetched using |
| # gclient in order for building to work per |
| # https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment. |
| # |
| # Usage: |
| # setup_engine.sh --github-username <github_username> |
| # |
| # Arguments: |
| # --github-username: Your GitHub username where your fork of Flutter Engine |
| # lives. Required. |
| |
| set -e # Fail on any error. |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/helpers.sh || exit $? |
| |
| ensure-embedder-dir |
| |
| # Parse arguments. |
| github_username="" |
| while [[ $# -gt 0 ]]; do |
| case $1 in |
| --github-username) |
| shift # past argument |
| github_username=$1 |
| shift # past value |
| ;; |
| *) |
| echo-error "Unknown argument: $1" |
| exit 1 |
| ;; |
| esac |
| done |
| |
| if [[ -z "${github_username}" ]] |
| then |
| echo-error "Usage: $0 --github-username <github_username>" |
| exit 1 |
| fi |
| |
| engine_revision="$(cat ${FUCHSIA_EMBEDDER_DIR}/third_party/dart-pkg/internal/flutter/flutter/bin/internal/engine.version)" |
| |
| if [[ -d "${embedder_engine_dir}" ]] |
| then |
| echo-error "${embedder_engine_dir} already exists." |
| echo-error "If you're trying to create it from scratch, delete that folder first and" |
| echo-error "then re-run this script." |
| exit 1 |
| fi |
| |
| echo-info "Initializing gclient..." |
| "${embedder_depot_tools}"/gclient |
| |
| echo-info "Fetching flutter/engine into ${embedder_engine_dir}..." |
| mkdir "${FUCHSIA_EMBEDDER_DIR}"/third_party/engine |
| cp "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/setup_engine_gclient_template "${FUCHSIA_EMBEDDER_DIR}"/third_party/engine/.gclient |
| sed -i "s/<your_name_here>/$github_username/g" "${FUCHSIA_EMBEDDER_DIR}"/third_party/engine/.gclient |
| |
| pushd "${FUCHSIA_EMBEDDER_DIR}"/third_party/engine |
| |
| "${embedder_depot_tools}"/gclient sync |
| |
| echo-info "Adding 'upstream' remote to ${embedder_engine_dir}/flutter..." |
| git -C "${embedder_engine_dir}"/flutter remote add upstream git@github.com:flutter/engine.git |
| |
| popd # "${FUCHSIA_EMBEDDER_DIR}"/third_party/engine |
| |
| echo-info "Syncing ${embedder_engine_dir}/flutter to ${engine_revision}..." |
| "${FUCHSIA_EMBEDDER_DIR}"/scripts/sync_engine_to_revision.sh "${engine_revision}" |
| |
| echo-info "Done! You can now build and test Flutter Engine changes locally by following" |
| echo-info "https://fuchsia.googlesource.com/flutter-embedder/+/refs/heads/main/docs/making_engine_changes.md#workflow" |