Skip to content

Commit b7b8e00

Browse files
authored
[native_assets_cli] [doc] Add READMEs for examples (#1878)
Add READMEs for the current set of supported use cases. I added a cross-link to the transformer test case so it doubles as example. Closes: #1375
1 parent 9c07864 commit b7b8e00

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
An example of a library that transforms some source files and bundles them as
2+
data assets.
3+
4+
## Usage
5+
6+
Data assets are not yet consumable in Dart and Flutter.
7+
This package is for illustration purposes only.
8+
9+
## Code organization
10+
11+
A typical layout of a package with data assets:
12+
13+
* `data/` contains source files.
14+
* `hook/build.dart` loops over all these files and transforms them. It reports
15+
the transformed files as data assets. The file transformations are cached
16+
within the hook to prevent retransforming the files if the sources didn't
17+
change.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
1-
The examples in this folder illustrate how native code is built and bundled
2-
in Dart and Flutter apps.
3-
4-
* [native_add_app/](native_add_app/) has a dependency with C code.
5-
This app should declare nothing special. Dart and Flutter should check
6-
all dependencies for native code.
7-
* [native_add_library/](native_add_library/) contains a library with C code.
8-
When Dart code in this library or dependent on this library is invoked, the
9-
C code must be built and bundled so that it can be used by the Dart code.
1+
The examples in this folder illustrate how assets are built and bundled in Dart
2+
and Flutter apps.
3+
4+
Currently two main asset types are supported in `package:native_assets_cli`:
5+
* Native libraries
6+
* Data assets
7+
8+
Note that Data assets are not yet consumable in Dart and Flutter.
9+
10+
Examples:
11+
12+
* Bundling C/C++/Objective-C source code in a package. This native code is built on the developers' machine when such package is a dependency.
13+
* [native_add_library/](native_add_library/) contains a library with C code.
14+
When Dart code in this library or dependent on this library is invoked, the
15+
C code must be built and bundled so that it can be used by the Dart code.
16+
* [native_add_app/](native_add_app/) has a dependency with C code.
17+
This app should declare nothing special. Dart and Flutter should check
18+
all dependencies for native code.
19+
* Bundling prebuilt native libaries.
20+
* [download_asset/](download_asset/) is very similar to
21+
[native_add_library/](native_add_library/), but instead of building the
22+
native code on the machine of developers pulling in the package, the native
23+
libraries are prebuilt in GitHub actions and downloaded in the build hook.
24+
* Bundling multiple dynamic libraries depending on each other.
25+
* [native_dynamic_linking/](native_dynamic_linking/) contains source code for
26+
3 native libraries that depend on each other and load each other with the
27+
native dynamic loader at runtime.
28+
* Building dynamic libraries against `dart_api_dl.h`.
29+
* [use_dart_api/](use_dart_api/) contains a library with C code that invokes
30+
`dart_api_dl.h` to interact with the Dart runtime.
31+
* Bundling all files in a directory as data assets.
32+
* [local_asset/](local_asset/) contains a package that bundles all files in
33+
the `assets/` directory as data assets.
34+
* Transforming files and bundling them as data assets.
35+
* [transformer/](../../../native_assets_builder/test_data/transformer/README.md)
36+
contains a package that transforms files and bundles the result as data
37+
assets. The hook uses caching internally to prevent retransforming files if
38+
not needed.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
This example shows two use cases:
1+
An example of a library bundling all files in a directory as data assets.
22

3-
* Data assets that are part of the package source code.
4-
* Code assets which are downloaded from the cloud.
5-
(It doesn't show how to download, but shows how to implement the protocol correctly.)
3+
## Usage
4+
5+
Data assets are not yet consumable in Dart and Flutter.
6+
This package is for illustration purposes only.
7+
8+
## Code organization
9+
10+
A typical layout of a package with data assets:
11+
12+
* `assets/` contains data assets.
13+
* `hook/build.dart` reports all these files as data assets.

0 commit comments

Comments
 (0)