blob: be43bf7cee5e89bc2d827b513ba1af6c7ffd64c5 [file] [log] [blame]
# 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.
# Updates the version of ffx used by this repository to the latest
# version.
# Usage:
# Requirements:
# 1. $FUCHSIA_EMBEDDER_DIR is set to your flutter-embedder.git checkout.
# Arguments:
# --cleanup: Removes old product bundles and shuts down old emulators.
# Default: false
# --no-version-bump: Does all the cleanup that comes with updating the SDK version without
# changing the SDK version. You usually want to pass --cleanup with this.
# Default: false
set -e # Fail on any error.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/ || exit $?
# Parse arguments.
while [[ $# -gt 0 ]]; do
case $1 in
shift # past argument
shift # past argument
shift # past value
if [[ "${no_version_bump}" -eq 0 ]]
echo-info "Updating the Fuchsia SDK checkout..."
git -C $FUCHSIA_EMBEDDER_DIR/third_party/sdk-integration pull origin main
echo-info "Building the embedder to fetch the updated Fuchsia SDK tools..."
$FUCHSIA_EMBEDDER_DIR/tools/bazel clean
$FUCHSIA_EMBEDDER_DIR/tools/bazel build --config=fuchsia_x64 //src/embedder
if [[ "${cleanup}" -eq 0 ]]
echo-info "flutter-embedder's Fuchsia SDK has been updated to version $($FUCHSIA_EMBEDDER_DIR/tools/ffx version)."
echo-warning 'You should restart any running emulators (`$FUCHSIA_EMBEDDER_DIR/tools/ffx emu stop`)'
echo-warning 'and update your product bundles (`$FUCHSIA_EMBEDDER_DIR/tools/ffx product-bundle get workstation_eng.qemu-x64`) as'
echo-warning 'old images may be incompatible with the updated SDK.'
echo-warning 'To do this automatically, run: $FUCHSIA_EMBEDDER_DIR/scripts/ --cleanup'
exit 0
echo-info "Cleaning up old things that are incompatible with the new SDK."
echo-info "If you don't want this, don't run the script with --cleanup."
echo-info "Killing any running emulators..."
$FUCHSIA_EMBEDDER_DIR/tools/ffx emu stop
# TODO( Replace with an ffx product-bundle clean command once
# one exists.
echo-info "Deleting old product bundles..."
rm -rf ~/.local/share/Fuchsia/ffx/pbms
echo-info "Refetching the workstation_eng.qemu-x64 product bundle..."
$FUCHSIA_EMBEDDER_DIR/tools/ffx product-bundle get workstation_eng.qemu-x64
echo-info "flutter-embedder's Fuchsia SDK has been updated to version $($FUCHSIA_EMBEDDER_DIR/tools/ffx version)."
echo-info "You will need to restart your emulator by running:"
echo '$FUCHSIA_EMBEDDER_DIR/tools/ffx emu start workstation_eng.qemu-x64'
echo-info "Or if you're running from a non-graphical environment:"
echo '$FUCHSIA_EMBEDDER_DIR/tools/ffx emu start workstation_eng.qemu-x64 --headless'