[embedder] Workflow improvements.

- Add missing prerequisite step to get started.
- Support multiple examples with build_and_run script.
- Rename flutter_sample_app -> hello_flutter to try to make it more
  clear that it's the default flutter app for a new project.
- Add hello_dart and spinning_cube examples. hello_dart works if you
  run it in the session but doesn't work in headless mode. spinning_cube
  doesn't work at all right now.
- Move engine artifacts into a debug_x64 folder to prepare for release
  artifacts in a follow-up CL, which will be required for AOT support.
- Make the sync_engine_artifacts script fail on any error during
  the first part of the script.
- Remove unused infra scripts. They're not the recommended approach
  for setting up automated tests.

Bug: 46971
Change-Id: I79784b2959c44d17e18bdb6c95119ba540e0d1da
36 files changed
tree: c1563d52efb6504728ef621361b8460dc0bc85d8
  1. scripts/
  2. src/
  3. third_party/
  4. tools/
  5. .bazelrc
  6. .gitignore
  7. .gitmodules
  8. AUTHORS
  9. CONTRIBUTING.md
  10. LICENSE
  11. OWNERS
  12. PATENTS
  13. README.md
  14. 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. Install a Bazel version no older than the one defined in the WORKSPACE.bazel file, by following the instructions at https://bazel.build/install. In some Linux distributions, sudo apt-get install bazel should be enough.

  2. Make sure this repository has the required submodules:

    git submodule update --recursive --init
    
  3. Ensure that there are Fuchsia SSH keys in your host machine. You will need them for running the Fuchsia emulator.

     [[ -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"
    
  4. Set $FUCHSIA_EMBEDDER_DIR to your flutter-embedder.git checkout location, for example ~/flutter-embedder.

Build and package the sample

Now the repository is ready to build the sample.

  1. Fetch an emulator image and start an emulator:

    tools/ffx product-bundle get workstation.qemu-x64
    # If running in a graphical environment:
    tools/ffx emu start workstation.qemu-x64
    # If running in a terminal environment:
    tools/ffx emu start --headless workstation.qemu-x64
    
  2. (optional) Watch the device log in a separate window:

    tools/ffx log
    
  3. Run an example app:

    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. $FUCHSIA_EMBEDDER_DIR should be set to your flutter-embedder.git checkout location, for example ~/flutter-embedder.
  4. $DEPOT_TOOLS should be set to your depot_tools location, for example ~/depot_tools.
  5. 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.

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:

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