diff --git a/pkgs/native_assets_builder/CHANGELOG.md b/pkgs/native_assets_builder/CHANGELOG.md index 50a1b629f..f70d95e62 100644 --- a/pkgs/native_assets_builder/CHANGELOG.md +++ b/pkgs/native_assets_builder/CHANGELOG.md @@ -14,6 +14,13 @@ - **Breaking change**: Remove asset-type specific logic from `package:native_assets_builder`. Bundling tools have to now supply `supportedAssetTypes` and corresponding validation routines. +- **Breaking change**: The `NativeAssetsBuildRunner.link()` command will now + produce a `LinkResult` containing all assets for the application (not just + those that happened to have a linker). This removes the need for a bundling + tool to combine parts of `BuildResult` and `LinkResult` and possibly checking + consistency of the sum of those parts. Effectively this means: Any asset that + doesn't have an explicit linker will get a NOP linker that emits as outputs + it's inputs. ## 0.8.3 diff --git a/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart b/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart index c17774f3b..12afbcb11 100644 --- a/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart +++ b/pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart @@ -234,6 +234,9 @@ class NativeAssetsBuildRunner { } var hookResult = HookResult(); + if (hook == Hook.link) { + hookResult.encodedAssets.addAll(buildResult!.encodedAssets); + } final metadata = {}; for (final package in buildPlan) { final DependencyMetadata? dependencyMetadata; diff --git a/pkgs/native_assets_builder/lib/src/model/link_result.dart b/pkgs/native_assets_builder/lib/src/model/link_result.dart index a717f9618..7b72ef951 100644 --- a/pkgs/native_assets_builder/lib/src/model/link_result.dart +++ b/pkgs/native_assets_builder/lib/src/model/link_result.dart @@ -9,7 +9,8 @@ import '../build_runner/build_runner.dart'; /// The result of executing the link hooks in dry run mode from all packages in /// the dependency tree of the entry point application. abstract interface class LinkResult { - /// The native assets produced by the hooks, which should be bundled. + /// All assets (produced by the build & link hooks) that have to be bundled + /// with the app. List get encodedAssets; /// The files used by the hooks. diff --git a/pkgs/native_assets_builder/test/build_runner/conflicting_dylib_test.dart b/pkgs/native_assets_builder/test/build_runner/conflicting_dylib_test.dart index ddd48256a..78d4ddca8 100644 --- a/pkgs/native_assets_builder/test/build_runner/conflicting_dylib_test.dart +++ b/pkgs/native_assets_builder/test/build_runner/conflicting_dylib_test.dart @@ -72,14 +72,8 @@ void main() async { linkValidator: validateCodeAssetLinkOutput, applicationAssetValidator: validateCodeAssetsInApplication, ); - expect(linkResult.success, isTrue); - - final allAssets = [ - ...buildResult.encodedAssets, - ...linkResult.encodedAssets - ].where((e) => e.type == CodeAsset.type).toList(); - final validateResult = await validateCodeAssetsInApplication(allAssets); - expect(validateResult, isNotEmpty); + // Application validation error due to conflicting dylib name. + expect(linkResult.success, isFalse); }); }); } diff --git a/pkgs/native_assets_builder/test/build_runner/link_test.dart b/pkgs/native_assets_builder/test/build_runner/link_test.dart index 2a7d5d76f..cd261d578 100644 --- a/pkgs/native_assets_builder/test/build_runner/link_test.dart +++ b/pkgs/native_assets_builder/test/build_runner/link_test.dart @@ -121,8 +121,8 @@ void main() async { ); expect(linkResult.success, true); - expect( - _getNames(linkResult.encodedAssets), unorderedEquals(linkedAssets)); + expect(_getNames(linkResult.encodedAssets), + unorderedEquals([...builtHelperAssets, ...linkedAssets])); }); }, );