blob: 3eb8880cc2df6a278a291bee4866a16bf9ae7ed5 [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.
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 value
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 Fuchsia SDK tools..."
bazel build --config=fuchsia_x64 //src/embedder
if [[ "${cleanup}" -eq 0 ]]
echo-info "Your Fuchsia SDK has been updated to version `$FUCHSIA_EMBEDDER_DIR/tools/ffx version`."
echo-warning 'You should restart any running emulators (`ffx emu stop`)'
echo-warning 'and update your product bundles (`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."
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."
ffx product-bundle get workstation_eng.qemu-x64
echo-info "Your 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'