Skip to content

Commit 40382ef

Browse files
authored
[native_assets_builder] Add AssetRelativePath back in (#941)
1 parent 85be813 commit 40382ef

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

pkgs/native_assets_builder/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.2
2+
3+
- Reintroduce `AssetRelativePath`, it's used in `dart build`.
4+
15
## 0.3.1
26

37
- Add support for `runPackageName` to avoid native assets for packages that

pkgs/native_assets_builder/lib/src/model/asset.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import 'package:native_assets_cli/native_assets_cli_internal.dart';
66

77
import '../utils/yaml.dart';
88

9-
extension on AssetPath {}
9+
/// Asset at absolute path [uri].
10+
class AssetRelativePath implements AssetPath {
11+
final Uri uri;
12+
13+
AssetRelativePath(this.uri);
14+
15+
// Never used in native_assets_cli, but the interface must be implemented.
16+
@override
17+
Map<String, Object> toYaml() => throw UnimplementedError();
18+
}
1019

1120
extension AssetIterable on Iterable<Asset> {
1221
Iterable<Asset> whereLinkMode(LinkMode linkMode) =>
@@ -43,6 +52,8 @@ List<String> _toDartConst(AssetPath path) {
4352
switch (path) {
4453
case AssetAbsolutePath _:
4554
return ['absolute', path.uri.toFilePath()];
55+
case AssetRelativePath _:
56+
return ['relative', path.uri.toFilePath()];
4657
case AssetSystemPath _:
4758
return ['system', path.uri.toFilePath()];
4859
case AssetInProcess _:

pkgs/native_assets_builder/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: native_assets_builder
22
description: >-
33
This package is the backend that invokes top-level `build.dart` scripts.
4-
version: 0.3.1
4+
version: 0.3.2
55
repository: https://github.com/dart-lang/native/tree/main/pkgs/native_assets_builder
66

77
environment:

pkgs/native_assets_builder/test/model/asset_test.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:test/test.dart';
1111

1212
void main() {
1313
final fooUri = Uri.file('path/to/libfoo.so');
14+
final foo2Uri = Uri.file('path/to/libfoo2.so');
1415
final foo3Uri = Uri(path: 'libfoo3.so');
1516
final barUri = Uri(path: 'path/to/libbar.a');
1617
final blaUri = Uri(path: 'path/with spaces/bla.dll');
@@ -21,6 +22,12 @@ void main() {
2122
target: Target.androidX64,
2223
linkMode: LinkMode.dynamic,
2324
),
25+
Asset(
26+
id: 'foo2',
27+
path: AssetRelativePath(foo2Uri),
28+
target: Target.androidX64,
29+
linkMode: LinkMode.dynamic,
30+
),
2431
Asset(
2532
id: 'foo3',
2633
path: AssetSystemPath(foo3Uri),
@@ -62,6 +69,9 @@ native-assets:
6269
foo:
6370
- absolute
6471
- ${fooUri.toFilePath()}
72+
foo2:
73+
- relative
74+
- ${foo2Uri.toFilePath()}
6575
foo3:
6676
- system
6777
- ${foo3Uri.toFilePath()}
@@ -85,6 +95,10 @@ native-assets:
8595

8696
test('List<Asset> whereLinkMode', () async {
8797
final assets2 = assets.whereLinkMode(LinkMode.dynamic);
88-
expect(assets2.length, 5);
98+
expect(assets2.length, 6);
99+
});
100+
101+
test('satisfy coverage', () async {
102+
expect(() => assets[1].toYaml(), throwsUnimplementedError);
89103
});
90104
}

0 commit comments

Comments
 (0)