Eric Seidel 4ab78869b8 feat: Add start_updater_thread to update off the main thread (#11)
* feat: Add start_updater_thread to update off the main thread

This makes it so that clients can easily not block when wanting to
queue an update.

I have a separate patch which updates the Engine to use this new
API.

I also needed to split the concept of the "next_boot" patch
from the "current_boot" patch, previously refered to as
"current" or "active" patch.  This required adding a
report_launch_start api to let the updater library know
when to set current_boot patch from next_boot.

I also removed the rust updater/cli in this as well as the
vmpath argument to init.

I also exposed the report_launch_success api, but its not yet
used by the Engine.

I renamed report_failed_launch to report_launch_failure to match
report_launch_start which I introduced.

* Update naming per comments from Felix.

Also added a helper for char* allocation (not sure if it's better).

* Update library/src/updater.rs

---------

Co-authored-by: Felix Angelov <felix@shorebird.dev>
2023-04-25 09:06:40 -07:00
2023-03-06 15:06:31 -08:00

Updater library

This is the Rust side of the Shorebird code push system. This is built in Rust with a C API for easy calling from other languages, most notably for linking into libflutter.so.

Parts

  • dart_cli: Test ffi wrapping of updater library.
  • library: The rust library that does the actual update work.
  • dart_bindings: The Dart bindings for the updater library.

All of the interesting code is in the library directory. There is also a README.md in that directory explaining the design.

Developing

It's best to edit this repository from within an engine checkout. See BUILDING_ENGINE.md for instructions on how to set up an engine checkout.

The workflow I use involves 2 to 3 VSC windows:

  1. Opening the engine src.

In that terminal I:

cd third_party/updater
  1. To build the updater as part of the engine:
cargo ndk --target aarch64-linux-android build --release && \
    ninja -C ../../out/android_release_arm64 && say "done"

The cargo part should not be needed, but I haven't yet done the work to integrate the Rust code into the gn files for the Flutter engine yet.

I add say "done" to the end as linking can take several minutes for release Android builds.

  1. In a second window, I open code third_party/updater. I do this because otherwise the rust_analyzer can't seem to find the rust code. We could fix this by adding the directory to the VSC workspace, but I'm not sure where we would put the workspace file in the first place. src is actually shorebirdtech/buildroot and is controlled via gclient by shorebirdtech/engine/DEPS.

  2. In a third window I open my test app. e.g.:

flutter create test_app
cd test_app
shorebird init
shorebird release
code .
  1. To run the test app with my local engine I use:
shorebird run --local-engine-src-path $HOME/Documents/GitHub/engine/src \
    --local-engine android_release_arm64

You may also need to build out/host_release once as flutter build looks for some Dart .dill files in host_release.

Coverage

We'd like to get to 100% coverage but aren't there yet.

https://github.com/taiki-e/cargo-llvm-cov is the best tool I've found for generating coverage reports.

Install: https://github.com/taiki-e/cargo-llvm-cov#installation

cargo llvm-cov will then generate the report.

S
Description
No description provided
Readme 1.6 MiB
Languages
Rust 46.3%
Dart 45.3%
C++ 3.2%
CMake 2.7%
C 1.6%
Other 0.9%