[embedder] Add commit hooks and bootstrap script.

The Git commit hooks check for changes to
the Fuchsia SDK as you pull updates to the
embedder repo to warn you when your ffx
version has changed in case you need to update
running emulators etc.

The hooks also look out for updates to the hooks themselves
to let you know when there are new updates
to the hooks to install.

The bootstrap script removes a couple of steps of setup and warns you
when KVM is not enabled, which is vital for
working in the embedder repo.

Change-Id: I41312994074ff465cbc4764e068f101c1d4beb3f
8 files changed
tree: 4f095dc59e9e2a485ea86c488f672113f85fac6e
  1. hooks/
  2. scripts/
  3. src/
  4. third_party/
  5. tools/
  6. .bazelrc
  7. .clang-format
  8. .editorconfig
  9. .gitignore
  10. .gitmodules
  11. AUTHORS
  12. CONTRIBUTING.md
  13. LICENSE
  14. OWNERS
  15. PATENTS
  16. README.md
  17. WORKSPACE.bazel
README.md

flutter-embedder.git

The Flutter Embedder for Fuchsia is a new in-progress runtime for Flutter apps on Fuchsia. This runtime is built on top of Flutter's embedder platform.

This repository is a work in progress and should be considered experimental.

Requirements

  1. Set $FUCHSIA_EMBEDDER_DIR to your flutter-embedder.git checkout location, for example ~/flutter-embedder.

    export FUCHSIA_EMBEDDER_DIR=$HOME/flutter-embedder
    
  2. Bootstrap the repository's dependencies:

    $FUCHSIA_EMBEDDER_DIR/scripts/bootstrap.sh
    

    This script initializes tools (including bazel and ffx), installs some Git hooks and downloads the workstation_eng.qemu-x64 product bundle, which you can use to run the examples below.

Run an example app

  1. Start the emulator.

    If running in a graphical environment:

    $FUCHSIA_EMBEDDER_DIR/tools/ffx emu start workstation_eng.qemu-x64
    

    If running in a terminal environment:

    $FUCHSIA_EMBEDDER_DIR/tools/ffx emu start --headless workstation_eng.qemu-x64
    
    
  2. (optional) Watch the device log in a separate window:

    $FUCHSIA_EMBEDDER_DIR/tools/ffx log
    
  3. Run an example app:

    $FUCHSIA_EMBEDDER_DIR/scripts/build_and_run_example.sh hello_flutter
    

TODO(akbiggs): The app occasionally gets stuck on a loading screen instead of rendering. Re-running the app usually fixes it. We need to fix this.

Syncing engine artifacts

Occasionally you will need to update the Flutter Engine artifacts (embedder.h and libengine_flutter.so) that are used by the embedder to run Flutter apps. A script is provided for this workflow.

Requirements

  1. You will need to get the Flutter Engine source code. Note that this is not just cloning https://github.com/flutter/engine.
  2. Set $ENGINE_DIR to the src folder of your Flutter Engine checkout location, for example ~/engine/src.
  3. $DEPOT_TOOLS should be set to your depot_tools location, for example ~/depot_tools.
  4. You will need to git stash or git commit any local changes to the Flutter Engine or the script will fail.

Running the script

You can run the script with a flutter/engine Git commit to sync the Engine artifacts to that revision.

$FUCHSIA_EMBEDDER_DIR/scripts/sync_engine_artifacts_to_revision.sh <ENGINE_COMMIT_SHA>

A common workflow is to sync your Engine commit to the Flutter tool in this repository, for example when updating the Flutter tool to a new version. To do this:

$FUCHSIA_EMBEDDER_DIR/scripts/sync_engine_artifacts_to_revision.sh $(cat $FUCHSIA_EMBEDDER_DIR/third_party/dart-pkg/internal/flutter/flutter/bin/internal/engine.version)