blob: b29d5b591d457649c751b78857fa49f2b06b298b [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.
# Sets up this repository and all its dependencies.
# Usage:
set -e # Fail on any error.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/lib/ || exit $?
# fails quietly if run outside the Bazel workspace.
echo-info "Initializing submodules..."
git submodule update --recursive --init
echo-info "Configuring git to update submodules when pulling changes in this repo..."
echo-info "(This is necessary to keep and third_party/dart-pkg/flutter aligned"
echo-info "to avoid crashes from Dart SDK incompatibilities)"
git config submodule.recurse true
echo-info "Bootstrapping Bazel..."
$FUCHSIA_EMBEDDER_DIR/tools/bazel clean
echo-info 'Building the embedder to fetch external dependencies (clang)...'
$FUCHSIA_EMBEDDER_DIR/tools/bazel build --config=fuchsia_x64 //src/embedder
echo-info "Initializing Fuchsia SSH keys (if not already created)..."
[[ -f "${HOME}/.ssh/fuchsia_ed25519" ]] || ssh-keygen -P "" -t ed25519 -f "${HOME}/.ssh/fuchsia_ed25519" -C "${USER}@$(hostname -f) Shared SSH Key for Fuchsia"
[[ -f "${HOME}/.ssh/fuchsia_authorized_keys" ]] || ssh-keygen -y -f "${HOME}/.ssh/fuchsia_ed25519" > "${HOME}/.ssh/fuchsia_authorized_keys"
echo-info "Installing Git hooks..."
# Installing the product-bundle fails when the user has product bundles
# from a previous version of ffx installed, so we clean up old product bundles
# here.
# TODO(akbiggs): Is there something less invasive we can do here?
echo-warning "Deleting other product bundles to ensure the new product bundle installs... Sorry..."
rm -rf ~/.local/share/Fuchsia/ffx/pbms
echo-info "Installing the workstation_eng.qemu-x64 product bundle..."
$FUCHSIA_EMBEDDER_DIR/tools/ffx product-bundle get workstation_eng.qemu-x64
if [[ -r /dev/kvm ]] && grep '^flags' /proc/cpuinfo | grep -qE 'vmx|svm'
# I'm bad at shell and couldn't figure out how to invert this condition properly.
echo-warning 'VM acceleration (KVM) is not enabled on your machine. Consider enabling it by following'
echo-warning 'Without KVM enabled, emulator performance will be terrible.'
echo-warning 'If you have already enabled KVM, you may need to reboot your machine.'
echo "Done. You're now ready to run a Flutter on Fuchsia example app:"
echo ""