diff --git a/pkgs/native_assets_builder/CHANGELOG.md b/pkgs/native_assets_builder/CHANGELOG.md index ed1a89875..8e40e14a8 100644 --- a/pkgs/native_assets_builder/CHANGELOG.md +++ b/pkgs/native_assets_builder/CHANGELOG.md @@ -9,6 +9,7 @@ Dart CI test runner to the `package:native_assets_builder` for testing the dart-lang/native repository to make it clear those are not intended to be used by end-users. +- Remove link-dry-run concept as it's unused by Flutter Tools & Dart SDK ## 0.8.3 diff --git a/pkgs/native_assets_builder/lib/native_assets_builder.dart b/pkgs/native_assets_builder/lib/native_assets_builder.dart index 7eb67361d..ec69de6cd 100644 --- a/pkgs/native_assets_builder/lib/native_assets_builder.dart +++ b/pkgs/native_assets_builder/lib/native_assets_builder.dart @@ -6,6 +6,5 @@ export 'package:native_assets_builder/src/build_runner/build_runner.dart'; export 'package:native_assets_builder/src/model/build_dry_run_result.dart'; export 'package:native_assets_builder/src/model/build_result.dart'; export 'package:native_assets_builder/src/model/kernel_assets.dart'; -export 'package:native_assets_builder/src/model/link_dry_run_result.dart'; export 'package:native_assets_builder/src/model/link_result.dart'; export 'package:native_assets_builder/src/package_layout/package_layout.dart'; 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 5c0a2a0cb..30df250f3 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 @@ -14,7 +14,6 @@ import '../locking/locking.dart'; import '../model/build_dry_run_result.dart'; import '../model/build_result.dart'; import '../model/hook_result.dart'; -import '../model/link_dry_run_result.dart'; import '../model/link_result.dart'; import '../package_layout/package_layout.dart'; import '../utils/file.dart'; @@ -379,66 +378,12 @@ class NativeAssetsBuildRunner { PackageLayout? packageLayout, String? runPackageName, Iterable? supportedAssetTypes, - }) => - _runDryRun( - hook: Hook.build, - linkModePreference: linkModePreference, - targetOS: targetOS, - workingDirectory: workingDirectory, - includeParentEnvironment: includeParentEnvironment, - packageLayout: packageLayout, - runPackageName: runPackageName, - supportedAssetTypes: supportedAssetTypes, - linkingEnabled: linkingEnabled, - ); - - /// [workingDirectory] is expected to contain `.dart_tool`. - /// - /// This method is invoked by launchers such as dartdev (for `dart run`) and - /// flutter_tools (for `flutter run` and `flutter build`). - /// - /// If provided, only native assets of all transitive dependencies of - /// [runPackageName] are built. - Future linkDryRun({ - required LinkModePreferenceImpl linkModePreference, - required OSImpl targetOS, - required Uri workingDirectory, - required bool includeParentEnvironment, - PackageLayout? packageLayout, - String? runPackageName, - Iterable? supportedAssetTypes, - required BuildDryRunResult buildDryRunResult, - }) => - _runDryRun( - hook: Hook.link, - linkModePreference: linkModePreference, - targetOS: targetOS, - workingDirectory: workingDirectory, - includeParentEnvironment: includeParentEnvironment, - packageLayout: packageLayout, - runPackageName: runPackageName, - supportedAssetTypes: supportedAssetTypes, - buildDryRunResult: buildDryRunResult, - linkingEnabled: null, - ); - - Future _runDryRun({ - required LinkModePreferenceImpl linkModePreference, - required OSImpl targetOS, - required Uri workingDirectory, - required bool includeParentEnvironment, - PackageLayout? packageLayout, - String? runPackageName, - Iterable? supportedAssetTypes, - required Hook hook, - BuildDryRunResult? buildDryRunResult, - required bool? linkingEnabled, }) async { + const hook = Hook.build; packageLayout ??= await PackageLayout.fromRootPackageRoot(workingDirectory); final (buildPlan, _, planSuccess) = await _makePlan( hook: hook, packageLayout: packageLayout, - buildDryRunResult: buildDryRunResult, runPackageName: runPackageName, ); if (!planSuccess) { @@ -455,8 +400,6 @@ class NativeAssetsBuildRunner { linkMode: linkModePreference, buildParentDir: packageLayout.dartToolNativeAssetsBuilder, supportedAssetTypes: supportedAssetTypes, - hook: hook, - buildDryRunResult: buildDryRunResult, linkingEnabled: linkingEnabled, ); final packageConfigUri = packageLayout.packageConfigUri; @@ -820,11 +763,10 @@ ${compileResult.stdout} required OSImpl targetOS, required LinkModePreferenceImpl linkMode, required Uri buildParentDir, - required Hook hook, - BuildDryRunResult? buildDryRunResult, Iterable? supportedAssetTypes, required bool? linkingEnabled, }) async { + const hook = Hook.build; final buildDirName = HookConfigImpl.checksumDryRun( packageName: package.name, packageRoot: package.root, @@ -850,30 +792,16 @@ ${compileResult.stdout} await outDirShared.create(recursive: true); } - switch (hook) { - case Hook.build: - return BuildConfigImpl.dryRun( - outputDirectory: outDirUri, - outputDirectoryShared: outputDirectoryShared, - packageName: packageName, - packageRoot: packageRoot, - targetOS: targetOS, - linkModePreference: linkMode, - supportedAssetTypes: supportedAssetTypes, - linkingEnabled: linkingEnabled, - ); - case Hook.link: - return LinkConfigImpl.dryRun( - outputDirectory: outDirUri, - outputDirectoryShared: outputDirectoryShared, - packageName: packageName, - packageRoot: packageRoot, - targetOS: targetOS, - assets: buildDryRunResult!.assetsForLinking[packageName] ?? [], - supportedAssetTypes: supportedAssetTypes, - linkModePreference: linkMode, - ); - } + return BuildConfigImpl.dryRun( + outputDirectory: outDirUri, + outputDirectoryShared: outputDirectoryShared, + packageName: packageName, + packageRoot: packageRoot, + targetOS: targetOS, + linkModePreference: linkMode, + supportedAssetTypes: supportedAssetTypes, + linkingEnabled: linkingEnabled, + ); } DependencyMetadata? _metadataForPackage({ @@ -926,7 +854,6 @@ ${compileResult.stdout} required Hook hook, // TODO(dacoharkes): How to share these two? Make them extend each other? BuildResult? buildResult, - BuildDryRunResult? buildDryRunResult, }) async { final packagesWithHook = await packageLayout.packagesWithAssets(hook); final List buildPlan; @@ -956,8 +883,7 @@ ${compileResult.stdout} // Link hooks are skipped if no assets for linking are provided. buildPlan = []; final skipped = []; - final assetsForLinking = buildResult?.assetsForLinking ?? - buildDryRunResult?.assetsForLinking; + final assetsForLinking = buildResult?.assetsForLinking; for (final package in packagesWithHook) { if (assetsForLinking![package.name]?.isNotEmpty ?? false) { buildPlan.add(package); diff --git a/pkgs/native_assets_builder/lib/src/model/hook_result.dart b/pkgs/native_assets_builder/lib/src/model/hook_result.dart index f0c23c9eb..cc7656c0c 100644 --- a/pkgs/native_assets_builder/lib/src/model/hook_result.dart +++ b/pkgs/native_assets_builder/lib/src/model/hook_result.dart @@ -9,8 +9,7 @@ import '../../native_assets_builder.dart'; /// The result from a [NativeAssetsBuildRunner.build] or /// [NativeAssetsBuildRunner.link]. -final class HookResult - implements BuildResult, BuildDryRunResult, LinkResult, LinkDryRunResult { +final class HookResult implements BuildResult, BuildDryRunResult, LinkResult { /// The native assets produced by the hooks, which should be bundled. @override final List assets; diff --git a/pkgs/native_assets_builder/lib/src/model/link_dry_run_result.dart b/pkgs/native_assets_builder/lib/src/model/link_dry_run_result.dart deleted file mode 100644 index 65342ef86..000000000 --- a/pkgs/native_assets_builder/lib/src/model/link_dry_run_result.dart +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:native_assets_cli/native_assets_cli_internal.dart'; - -import '../../native_assets_builder.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 LinkDryRunResult { - /// The native assets produced by the hooks, which should be bundled. - List get assets; - - /// Whether all hooks completed without errors. - /// - /// All error messages are streamed to [NativeAssetsBuildRunner.logger]. - bool get success; -} diff --git a/pkgs/native_assets_builder/test/build_runner/helpers.dart b/pkgs/native_assets_builder/test/build_runner/helpers.dart index c5aa75d04..399fa9812 100644 --- a/pkgs/native_assets_builder/test/build_runner/helpers.dart +++ b/pkgs/native_assets_builder/test/build_runner/helpers.dart @@ -246,34 +246,6 @@ Future buildDryRun( return result; }); -Future linkDryRun( - Uri packageUri, - Logger logger, - Uri dartExecutable, { - LinkModePreferenceImpl linkModePreference = LinkModePreferenceImpl.dynamic, - CCompilerConfigImpl? cCompilerConfig, - bool includeParentEnvironment = true, - List? capturedLogs, - PackageLayout? packageLayout, - required BuildDryRunResult buildDryRunResult, - Iterable? supportedAssetTypes, -}) async => - runWithLog(capturedLogs, () async { - final result = await NativeAssetsBuildRunner( - logger: logger, - dartExecutable: dartExecutable, - ).linkDryRun( - linkModePreference: linkModePreference, - targetOS: Target.current.os, - workingDirectory: packageUri, - includeParentEnvironment: includeParentEnvironment, - packageLayout: packageLayout, - buildDryRunResult: buildDryRunResult, - supportedAssetTypes: supportedAssetTypes, - ); - return result; - }); - Future expectAssetsExist(List assets) async { for (final asset in assets) { expect(File.fromUri(asset.file!), exists); diff --git a/pkgs/native_assets_builder/test/build_runner/link_dry_run_test.dart b/pkgs/native_assets_builder/test/build_runner/link_dry_run_test.dart deleted file mode 100644 index c18011cf7..000000000 --- a/pkgs/native_assets_builder/test/build_runner/link_dry_run_test.dart +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'package:native_assets_cli/native_assets_cli.dart' as cli; -import 'package:native_assets_cli/src/api/asset.dart'; -import 'package:test/test.dart'; - -import '../helpers.dart'; -import 'helpers.dart'; - -const Timeout longTimeout = Timeout(Duration(minutes: 5)); - -void main() async { - const supportedAssetTypes = [DataAsset.type]; - - test( - 'simple_link linking', - timeout: longTimeout, - () async { - await inTempDir((tempUri) async { - await copyTestProjects(targetUri: tempUri); - final packageUri = tempUri.resolve('simple_link/'); - - // First, run `pub get`, we need pub to resolve our dependencies. - await runPubGet( - workingDirectory: packageUri, - logger: logger, - ); - - final buildResult = await buildDryRun( - packageUri, - logger, - dartExecutable, - linkingEnabled: true, - supportedAssetTypes: supportedAssetTypes, - ); - expect(buildResult.assets.length, 0); - - final linkResult = await linkDryRun( - packageUri, - logger, - dartExecutable, - buildDryRunResult: buildResult, - supportedAssetTypes: supportedAssetTypes, - ); - expect(linkResult.assets.length, 2); - }); - }, - ); - - test( - 'complex_link linking', - timeout: longTimeout, - () async { - await inTempDir((tempUri) async { - // From package:complex_link_helper. - const builtHelperAssets = [ - 'assets/data_helper_0.json', - 'assets/data_helper_1.json', - ]; - const helperAssetsForLinking = [ - 'assets/data_helper_2.json', - 'assets/data_helper_3.json', - ]; - // From package:complex_link. - const mainAssetsForLinking = [ - 'assets/data_0.json', - 'assets/data_1.json', - ]; - final assetsForLinking = [ - ...helperAssetsForLinking, - ...mainAssetsForLinking, - ]; - final linkedAssets = assetsForLinking.skip(1); - - await copyTestProjects(targetUri: tempUri); - final packageUri = tempUri.resolve('complex_link/'); - - // First, run `pub get`, we need pub to resolve our dependencies. - await runPubGet(workingDirectory: packageUri, logger: logger); - - final buildResult = await buildDryRun( - packageUri, - logger, - dartExecutable, - linkingEnabled: true, - supportedAssetTypes: supportedAssetTypes, - ); - expect(buildResult.success, true); - expect( - _getNames(buildResult.assets), unorderedEquals(builtHelperAssets)); - expect( - _getNames(buildResult.assetsForLinking['complex_link']!), - unorderedEquals(assetsForLinking), - ); - - final linkResult = await linkDryRun( - packageUri, - logger, - dartExecutable, - buildDryRunResult: buildResult, - supportedAssetTypes: supportedAssetTypes, - ); - expect(linkResult.success, true); - - expect(_getNames(linkResult.assets), unorderedEquals(linkedAssets)); - }); - }, - ); -} - -Iterable _getNames(List assets) => - assets.whereType().map((asset) => asset.name);