Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/code_assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.19.9

- Document that asset file paths must be absolute.

## 0.19.8

- Polished README.md, Dartdocs, and examples.
Expand Down
5 changes: 3 additions & 2 deletions pkgs/code_assets/lib/src/code_assets/code_asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ final class CodeAsset {
/// Either dynamic loading or static linking.
final LinkMode linkMode;

/// The file to be bundled with the Dart or Flutter application.
/// The native library to be bundled with the Dart or Flutter application.
///
/// If the [linkMode] is [DynamicLoadingBundled], the file must be provided
/// and exist.
/// and exist. The path must be an absolute path. Prefer constructing the path
/// via [HookInput.outputDirectoryShared] or [HookInput.outputDirectory].
///
/// If the [linkMode] is [DynamicLoadingSystem], the file must be provided,
/// and not exist.
Expand Down
8 changes: 8 additions & 0 deletions pkgs/code_assets/lib/src/code_assets/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,18 @@ final class BuildOutputCodeAssetBuilder {
BuildOutputCodeAssetBuilder._(this._output);

/// Adds the given [asset] to the hook output with [routing].
///
/// The [CodeAsset.file], if provided, must be an absolute path. Prefer
/// constructing the path via [HookInput.outputDirectoryShared] or
/// [HookInput.outputDirectory].
void add(CodeAsset asset, {AssetRouting routing = const ToAppBundle()}) =>
_output.addEncodedAsset(asset.encode(), routing: routing);

/// Adds the given [assets] to the hook output with [routing].
///
/// The [CodeAsset.file]s, if provided, must be absolute paths. Prefer
/// constructing the paths via [HookInput.outputDirectoryShared] or
/// [HookInput.outputDirectory].
void addAll(
Iterable<CodeAsset> assets, {
AssetRouting routing = const ToAppBundle(),
Expand Down
5 changes: 4 additions & 1 deletion pkgs/code_assets/lib/src/code_assets/validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ ValidationErrors _validateFile(
}) {
final errors = <String>[];
if (mustBeAbsolute && !uri.isAbsolute) {
errors.add('$name (${uri.toFilePath()}) must be an absolute path.');
errors.add(
'$name (${uri.toFilePath()}) must be an absolute path. '
'Prefer constructing it via `input.outputDirectoryShared`.',
);
}
if (mustExist && !File.fromUri(uri).existsSync()) {
errors.add('$name (${uri.toFilePath()}) does not exist as a file.');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/code_assets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
This library contains the hook protocol specification for bundling native code
with Dart packages.

version: 0.19.8
version: 0.19.9

repository: https://github.com/dart-lang/native/tree/main/pkgs/code_assets

Expand Down
4 changes: 4 additions & 0 deletions pkgs/data_assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.19.4

- Document that asset file paths must be absolute.

## 0.19.3

- Added a library comment detailing how to use the package.
Expand Down
10 changes: 10 additions & 0 deletions pkgs/data_assets/lib/src/data_assets/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,20 @@ final class BuildOutputDataAssetsBuilder {
BuildOutputDataAssetsBuilder._(this._output);

/// Adds the given [asset] to the hook output with [routing].
///
/// The [DataAsset.file] must be an absolute path. Prefer constructing the
/// path via [HookInput.outputDirectoryShared] or [HookInput.outputDirectory]
/// for files emitted during a hook, and via [HookInput.packageRoot] for files
/// which are part of the package.
void add(DataAsset asset, {AssetRouting routing = const ToAppBundle()}) =>
_output.addEncodedAsset(asset.encode(), routing: routing);

/// Adds the given [assets] to the hook output with [routing].
///
/// The [DataAsset.file]s must be absolute paths. Prefer constructing the
/// path via [HookInput.outputDirectoryShared] or [HookInput.outputDirectory]
/// for files emitted during a hook, and via [HookInput.packageRoot] for files
/// which are part of the package.
void addAll(
Iterable<DataAsset> assets, {
AssetRouting routing = const ToAppBundle(),
Expand Down
7 changes: 4 additions & 3 deletions pkgs/data_assets/lib/src/data_assets/data_asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import 'syntax.g.dart';
final class DataAsset {
/// The file to be bundled with the Dart or Flutter application.
///
/// The file can also be omitted for asset types which refer to an asset
/// already present on the target system or an asset already present in Dart
/// or Flutter.
/// The path must be an absolute path. Prefer constructing the path via
/// [HookInput.outputDirectoryShared] or [HookInput.outputDirectory] for files
/// emitted during a hook, and via [HookInput.packageRoot] for files which are
/// part of the package.
final Uri file;

/// The name of this asset, which must be unique for the package.
Expand Down
6 changes: 5 additions & 1 deletion pkgs/data_assets/lib/src/data_assets/validation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ ValidationErrors _validateFile(
}) {
final errors = <String>[];
if (mustBeAbsolute && !uri.isAbsolute) {
errors.add('$name (${uri.toFilePath()}) must be an absolute path.');
errors.add(
'$name (${uri.toFilePath()}) must be an absolute path. '
'Prefer constructing it via `input.outputDirectoryShared` or '
'`input.packageRoot`.',
);
}
if (mustExist && !File.fromUri(uri).existsSync()) {
errors.add('$name (${uri.toFilePath()}) does not exist as a file.');
Expand Down
2 changes: 1 addition & 1 deletion pkgs/data_assets/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
This library contains the hook protocol specification for bundling data assets
with Dart packages.

version: 0.19.3
version: 0.19.4

repository: https://github.com/dart-lang/native/tree/main/pkgs/data_assets

Expand Down