Skip to content

Commit 2bc6d8d

Browse files
authored
[native_assets_cli] Cleanup protocol pre 1.7.0 (#2009)
Remove all support for protocol pre-1.7: * Remove all dry run! * Remove the non-hierarchical config Closes: #1485 The minimum SDK constraint on `native_assets_cli` has been bumped to 3.7, and Dart and Flutter 3.8.0 dev contain a builder that emits at least 1.7. So, `native_asset_cli` usages shouldn't start failing. Once this change rolls into dartdev and flutter_tools, users will be see failing hooks with old `native_assets_cli` deps. They should `pub upgrade`. This is expected behavior when depending on an experimental feature.
1 parent 9999ff9 commit 2bc6d8d

40 files changed

+434
-728
lines changed

pkgs/native_assets_builder/lib/src/build_runner/build_runner.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class NativeAssetsBuildRunner {
135135
final inputBuilder =
136136
inputCreator()
137137
..config.setupShared(buildAssetTypes: buildAssetTypes)
138-
..config.setupBuild(dryRun: false, linkingEnabled: linkingEnabled)
138+
..config.setupBuild(linkingEnabled: linkingEnabled)
139139
..setupBuildInput(metadata: metadata);
140140

141141
final (buildDirUri, outDirUri, outDirSharedUri) = await _setupDirectories(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import 'package:native_assets_cli/native_assets_cli_internal.dart';
66

7-
/// The result of executing the link hooks in dry run mode from all packages in
8-
/// the dependency tree of the entry point application.
7+
/// The result of executing the link hooks from all packages in the dependency
8+
/// tree of the entry point application.
99
abstract interface class LinkResult {
1010
/// All assets (produced by the build & link hooks) that have to be bundled
1111
/// with the app.

pkgs/native_assets_builder/test/test_data/native_dynamic_linking_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void main() async {
3939
outputDirectory: outputDirectory,
4040
outputDirectoryShared: outputDirectoryShared,
4141
)
42-
..config.setupBuild(dryRun: false, linkingEnabled: false)
42+
..config.setupBuild(linkingEnabled: false)
4343
..config.setupShared(buildAssetTypes: [CodeAsset.type])
4444
..config.setupCode(
4545
targetArchitecture: Architecture.current,

pkgs/native_assets_builder/test/test_data/transformer_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void main() async {
5050
outputDirectory: outputDirectory,
5151
outputDirectoryShared: outputDirectoryShared,
5252
)
53-
..config.setupBuild(dryRun: false, linkingEnabled: false)
53+
..config.setupBuild(linkingEnabled: false)
5454
..config.setupShared(
5555
buildAssetTypes: [CodeAsset.type, DataAsset.type],
5656
)

pkgs/native_assets_builder/test_data/native_add_version_skew/hook/build.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import 'package:native_assets_cli/native_assets_cli.dart';
77
import 'package:native_toolchain_c/native_toolchain_c.dart';
88

99
void main(List<String> arguments) async {
10-
await build(arguments, (config, output) async {
11-
final packageName = config.packageName;
10+
await build(arguments, (input, output) async {
11+
final packageName = input.packageName;
1212
final cbuilder = CBuilder.library(
1313
name: packageName,
1414
assetName: 'src/native_add_bindings_generated.dart',
1515
sources: ['src/native_add.c'],
1616
);
1717
await cbuilder.run(
18-
config: config,
18+
input: input,
1919
output: output,
2020
logger:
2121
Logger('')

pkgs/native_assets_builder/test_data/native_add_version_skew/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ environment:
99

1010
dependencies:
1111
logging: ^1.1.1
12-
native_assets_cli: ^0.9.0
13-
native_toolchain_c: ^0.6.0
12+
native_assets_cli: ^0.11.0
13+
native_toolchain_c: ^0.8.0
1414

1515
dev_dependencies:
1616
ffigen: ^8.0.2

pkgs/native_assets_builder/test_data/use_all_api/hook/build.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ void main(List<String> args) async {
1919
// c. target config
2020
// c.1. per hook
2121
input.config.linkingEnabled; // build only
22-
input.config.dryRun; // build only, deleted soon
2322
// c.2. per asset
2423
input.config.buildAssetTypes;
2524
input.config.code.linkModePreference;

pkgs/native_assets_cli/example/build/download_asset/tool/build.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ BuildInput createBuildInput(
8383
outputDirectoryShared: outputDirectoryShared,
8484
)
8585
..config.setupShared(buildAssetTypes: [CodeAsset.type])
86-
..config.setupBuild(dryRun: false, linkingEnabled: false)
86+
..config.setupBuild(linkingEnabled: false)
8787
..config.setupCode(
8888
targetArchitecture: Architecture.fromString(architecture),
8989
targetOS: os,

pkgs/native_assets_cli/example/build/local_asset/hook/build.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ Future<void> main(List<String> args) async {
1919
final packageName = input.packageName;
2020
final assetPath = input.outputDirectory.resolve(assetName);
2121
final assetSourcePath = input.packageRoot.resolveUri(packageAssetPath);
22-
// ignore: deprecated_member_use
23-
if (!input.config.dryRun) {
24-
// Insert code that downloads or builds the asset to `assetPath`.
25-
await File.fromUri(assetSourcePath).copy(assetPath.toFilePath());
2622

27-
output.addDependencies([assetSourcePath]);
28-
}
23+
// Insert code that downloads or builds the asset to `assetPath`.
24+
await File.fromUri(assetSourcePath).copy(assetPath.toFilePath());
25+
26+
output.addDependencies([assetSourcePath]);
2927

3028
output.assets.code.add(
3129
// TODO: Change to DataAsset once the Dart/Flutter SDK can consume it.
@@ -35,9 +33,7 @@ Future<void> main(List<String> args) async {
3533
file: assetPath,
3634
linkMode: DynamicLoadingBundled(),
3735
os: input.config.code.targetOS,
38-
architecture:
39-
// ignore: deprecated_member_use
40-
input.config.dryRun ? null : input.config.code.targetArchitecture,
36+
architecture: input.config.code.targetArchitecture,
4137
),
4238
);
4339
});

pkgs/native_assets_cli/lib/src/api/build.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,12 @@ import '../validation.dart';
6767
/// final packageName = input.packageName;
6868
/// final assetPath = input.outputDirectory.resolve(assetName);
6969
/// final assetSourcePath = input.packageRoot.resolveUri(packageAssetPath);
70-
/// if (!input.dryRun) {
71-
/// // Insert code that downloads or builds the asset to `assetPath`.
72-
/// await File.fromUri(assetSourcePath).copy(assetPath.toFilePath());
70+
/// // Insert code that downloads or builds the asset to `assetPath`.
71+
/// await File.fromUri(assetSourcePath).copy(assetPath.toFilePath());
7372
///
74-
/// output.addDependencies([
75-
/// assetSourcePath,
76-
/// ]);
77-
/// }
73+
/// output.addDependencies([
74+
/// assetSourcePath,
75+
/// ]);
7876
///
7977
/// output.assets.code.add(
8078
/// // TODO: Change to DataAsset once the Dart/Flutter SDK can consume it.

pkgs/native_assets_cli/lib/src/code_assets/c_compiler_config.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ final class CCompilerConfig {
7777
///
7878
/// The returned json can be used in [CCompilerConfig.fromJson] to
7979
/// obtain a [CCompilerConfig] again.
80-
///
81-
/// If [deprecatedTopLevel], does not nest developerCommandPrompt.
82-
// TODO: Remove deprecatedTopLevel once protocol 1.8.0 is no longer supported.
83-
Map<String, Object> toJson({bool deprecatedTopLevel = false}) =>
80+
Map<String, Object> toJson() =>
8481
{
8582
_arConfigKey: archiver.toFilePath(),
8683
_ccConfigKey: compiler.toFilePath(),
@@ -91,7 +88,7 @@ final class CCompilerConfig {
9188
if (_windows?.developerCommandPrompt?.arguments != null)
9289
_envScriptArgsConfigKeyDeprecated:
9390
_windows!.developerCommandPrompt!.arguments,
94-
if (_windows != null && !deprecatedTopLevel)
91+
if (_windows != null)
9592
_windowsConfigKey: {
9693
if (_windows.developerCommandPrompt != null)
9794
_developerCommandPromptConfigKey: {

0 commit comments

Comments
 (0)