diff --git a/pkgs/native_assets_builder/CHANGELOG.md b/pkgs/native_assets_builder/CHANGELOG.md index 2477fd0d4..da64bdf9f 100644 --- a/pkgs/native_assets_builder/CHANGELOG.md +++ b/pkgs/native_assets_builder/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.2 + +- Reintroduce `AssetRelativePath`, it's used in `dart build`. + ## 0.3.1 - Add support for `runPackageName` to avoid native assets for packages that diff --git a/pkgs/native_assets_builder/lib/src/model/asset.dart b/pkgs/native_assets_builder/lib/src/model/asset.dart index 3ef919a44..f98cf7de2 100644 --- a/pkgs/native_assets_builder/lib/src/model/asset.dart +++ b/pkgs/native_assets_builder/lib/src/model/asset.dart @@ -6,7 +6,16 @@ import 'package:native_assets_cli/native_assets_cli_internal.dart'; import '../utils/yaml.dart'; -extension on AssetPath {} +/// Asset at absolute path [uri]. +class AssetRelativePath implements AssetPath { + final Uri uri; + + AssetRelativePath(this.uri); + + // Never used in native_assets_cli, but the interface must be implemented. + @override + Map toYaml() => throw UnimplementedError(); +} extension AssetIterable on Iterable { Iterable whereLinkMode(LinkMode linkMode) => @@ -43,6 +52,8 @@ List _toDartConst(AssetPath path) { switch (path) { case AssetAbsolutePath _: return ['absolute', path.uri.toFilePath()]; + case AssetRelativePath _: + return ['relative', path.uri.toFilePath()]; case AssetSystemPath _: return ['system', path.uri.toFilePath()]; case AssetInProcess _: diff --git a/pkgs/native_assets_builder/pubspec.yaml b/pkgs/native_assets_builder/pubspec.yaml index e785f976d..feadc61ed 100644 --- a/pkgs/native_assets_builder/pubspec.yaml +++ b/pkgs/native_assets_builder/pubspec.yaml @@ -1,7 +1,7 @@ name: native_assets_builder description: >- This package is the backend that invokes top-level `build.dart` scripts. -version: 0.3.1 +version: 0.3.2 repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder environment: diff --git a/pkgs/native_assets_builder/test/model/asset_test.dart b/pkgs/native_assets_builder/test/model/asset_test.dart index 62916cca2..0272a790a 100644 --- a/pkgs/native_assets_builder/test/model/asset_test.dart +++ b/pkgs/native_assets_builder/test/model/asset_test.dart @@ -11,6 +11,7 @@ import 'package:test/test.dart'; void main() { final fooUri = Uri.file('path/to/libfoo.so'); + final foo2Uri = Uri.file('path/to/libfoo2.so'); final foo3Uri = Uri(path: 'libfoo3.so'); final barUri = Uri(path: 'path/to/libbar.a'); final blaUri = Uri(path: 'path/with spaces/bla.dll'); @@ -21,6 +22,12 @@ void main() { target: Target.androidX64, linkMode: LinkMode.dynamic, ), + Asset( + id: 'foo2', + path: AssetRelativePath(foo2Uri), + target: Target.androidX64, + linkMode: LinkMode.dynamic, + ), Asset( id: 'foo3', path: AssetSystemPath(foo3Uri), @@ -62,6 +69,9 @@ native-assets: foo: - absolute - ${fooUri.toFilePath()} + foo2: + - relative + - ${foo2Uri.toFilePath()} foo3: - system - ${foo3Uri.toFilePath()} @@ -85,6 +95,10 @@ native-assets: test('List whereLinkMode', () async { final assets2 = assets.whereLinkMode(LinkMode.dynamic); - expect(assets2.length, 5); + expect(assets2.length, 6); + }); + + test('satisfy coverage', () async { + expect(() => assets[1].toYaml(), throwsUnimplementedError); }); }