Skip to content

☂️ [vm/ffi] Build hooks & Code assets #50565

Open
@dcharkes

Description

@dcharkes

Build hooks and code assets support in Dart standalone is available in preview on the main channel. (In Dart 3.2 and later it was available behind an experimental flag: dart --enable-experiment=native-assets run [path/to/script.dart].)

Current ongoing work can be tracked in: Native Assets

This is a high level "feature" issue that we can refer to from various places.

The current way of bundling native code with Dart packages is far from ideal, we will introduce "Native Assets" to Dart.

Problem

As of right now, one can do one (or more) of the following:

  1. ship sources in a Dart standalone package and let users run a build by calling dart run <your-package>/setup.dart see webcrypto, or
  2. make your bin/setup.dart download the native library, or
  3. ship sources a flutter plugins with flutter create --template=plugin_ffi --platform=..., or
  4. ship a script that downloads the native library during flutter build see realm_flutter.

This leads to pain for both package developers (options 1-4) and package users (option 1-2). Moreover, there is currently no way to make a package with native code that works both for flutter and Dart standalone.

High level solution

We introduce the concept of "Native Assets" to the Dart eco system.

A native asset is a native library (compiled from native source code).

Three components of the "Native Assets" solution in Dart:

  1. A standardized way to build or download native assets. This will be done by a CLI.
  2. A transparent way to find native symbols in these native assets in Dart.
  3. Integration with all the dart and flutter tooling to link the above two together.

Try now

Native assets support in Dart standalone is available in Dart 3.2 behind an experimental flag : dart --enable-experiment=native-assets run [path/to/script.dart].

Native assets support in Flutter is in development. Progress can be tracked in flutter/flutter#129757.

An example on how to use native assets can be found here.

Checklist

Metadata

Metadata

Assignees

Labels

area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffivm-native

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions