Skip to content
Prev Previous commit
Next Next commit
Address a bunch of comments
  • Loading branch information
dcharkes committed Jan 31, 2024
commit 7fb1fce1cba9119c70810c7394eb510c1e550420
30 changes: 15 additions & 15 deletions pkgs/native_assets_builder/doc/protocol/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ An asset must have a link mode. Currently, the only supported link mode is dynam

An asset must specify a path type for dynamic linking.

* `absolute` paths are absolute paths in the output dir (see below).
* `system` paths are expected to resolve on the target machine PATH. In this case the asset is not a file but only metadata.
* `process` "paths" have no path, symbols are resolved in the current process. In this case the asset is not a file but only metadata.
* `executable` "paths" have no path, symbols are resolved in the current executable. In this case the asset is not a file but only metadata.
* An `absolute` path is an absolute path in the output dir (see below).
* A `system` path is expected to resolve on the target machine PATH. In this case the asset is not a file but only metadata.
* A `process` "path" has no path, symbols are resolved in the current process. In this case the asset is not a file but only metadata.
* An `executable` "path" has no path, symbols are resolved in the current executable. In this case the asset is not a file but only metadata.

#### AssetId
An asset must have an `assetId`. Dart code that uses an asset, references the asset using the `assetId`.
Expand All @@ -37,30 +37,30 @@ A target specifies the operating system and architecture of the targeted platfor

### `build.dart`
To bundle native assets with a package, that package must define a `build.dart`
script which accepts a `--config` option as follows:
script which accepts a `--config <path>` command line option as follows:

```console
$ dart build.dart --config <build_config.yaml>
```

The `--config` option specifies location of the `build_config.yaml` file.
The `--config` option specifies the location of the `build_config.yaml` file as an absolute path.

The `build.dart` file MUST:
* Read the `build_config.yaml` file,
* Build assets using configuration from `build_config.yaml`.
* If `dry_run: true` in `build_config.yaml`, then this may be skipped.
* Write assets into `out_dir` from `build_config.yaml`.
* If `dry_run: true` in `build_config.yaml`, then this may be skipped.
* Filename are unrelated to `assetId`.
* Build assets using the configuration from `build_config.yaml`.
* If the boolean parameter `dry_run` is set to true in the build configuration, then this may be skipped.
* Write asset files into output dir that was provided by `build_config.yaml`.
* If the boolean parameter `dry_run` is set to true in the build configuration, then this may be skipped.
* The file name inside `out_dir` doesn't really matter, because in Dart code you'll always access things by `assetId`. So in some sense the file name is irrelevant.
* Arbitrary file names are fine, `build_output.yaml` will map `assetId` to files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file names of the assets don't really matter. It could be file1.foo, file2.foo, file3.foo. Because the only way assets are accessed from Dart code is through their assetId.

However, we do want to have to files written to disk rather than having a buffer of bytes for files, because quite often the files are produces by an external Process call or for data assets already in your package.

* MUST avoid file name `build_output.yaml`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a name for an asset?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you write your asset to out_dir/build_output.yaml it's going to fail to write build_output.yaml

Maybe in v2 we should consider writing the assets somewhere else than the build output.

* Write `build_output.yaml` into `out_dir` (from `build_config.yaml`).
* This maps `assetId` to assets previous written in `out_dir`.
* This maps the `assetId`s to assets previously written into `out_dir`.
* There may be multiple assets for a given `assetId` depending on
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to add something about the uniqueness of an assetId - this was unclear in an earlier review comment as well.

characteristics like `target`, `link_mode`, etc.
* If `dry_run: true` in `build_config.yaml`, the list of assets that would be
generated must this be enumerated. Mapping `assetId`s to non-existing files
is expected.
* If the boolean parameter `dry_run` is set to true in the build configuration,
the list of assets must be output, but the asset files must not be written.
The asset file urls are expected to refer to non-existing files.


### `build_config.yaml`
Expand Down