Skip to content

Commit 0caab92

Browse files
authored
[native_assets_cli] Rename supportedAssetTypes to buildAssetTypes (#1786)
This PR changes the `supportedAssetTypes` to `buildAssetTypes`. Hooks should not fail early if an asset type is not supported. This enables the following situations: 1. If some part of the Dart code requires an asset, but is not invoked transitively, the Dart code can still run in JIT, instead of failing on the build hook. 2. If an asset is not available, Dart code could fallback on a Dart implementation. 3. Hot reload hook invocations can omit the asset types that are not supported for hot reload (#1207 (comment)). The PR changes both the Dart API and the JSON protocol. The JSON protocol passes and parses the old key for the time being to allow for a graceful transition until this rolls into a next Dart stable release and we can bump the lower SDK bound. Side note: * The refactorings somehow started disallowing version skew where an older SDK is used with a newer `package:native_assets_cli`, but we do allow this, we can fill in the blanks (see `pkgs/native_assets_cli/lib/src/model/build_config_CHANGELOG.md`). So this PR adds a lowest-parsable-version.
1 parent 7e9897b commit 0caab92

File tree

58 files changed

+243
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+243
-226
lines changed

pkgs/native_assets_builder/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## 0.9.1-wip
22

3+
- **Breaking change**: Rename `supportedAssetTypes` to `buildAssetTypes`. Hooks
4+
should no longer fail. Instead, the code should fail at runtime if an asset is
5+
missing. This enables (1) code to run if an asset is missing but that code is
6+
not invoked at runtime, and (2) doing fallback implementations in Dart if an
7+
asset is missing.
8+
39
## 0.9.0
410

511
- Also lock `BuildConfig` and `LinkConfig` `outputDirectoryShared` when invoking

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class NativeAssetsBuildRunner {
9898
required Uri workingDirectory,
9999
PackageLayout? packageLayout,
100100
String? runPackageName,
101-
required List<String> supportedAssetTypes,
101+
required List<String> buildAssetTypes,
102102
required bool linkingEnabled,
103103
}) async {
104104
packageLayout ??= await PackageLayout.fromRootPackageRoot(workingDirectory);
@@ -124,7 +124,7 @@ class NativeAssetsBuildRunner {
124124
final configBuilder = configCreator()
125125
..setupHookConfig(
126126
targetOS: targetOS,
127-
supportedAssetTypes: supportedAssetTypes,
127+
buildAssetTypes: buildAssetTypes,
128128
buildMode: buildMode,
129129
packageName: package.name,
130130
packageRoot: packageLayout.packageRoot(package.name),
@@ -206,7 +206,7 @@ class NativeAssetsBuildRunner {
206206
PackageLayout? packageLayout,
207207
Uri? resourceIdentifiers,
208208
String? runPackageName,
209-
required List<String> supportedAssetTypes,
209+
required List<String> buildAssetTypes,
210210
required BuildResult buildResult,
211211
}) async {
212212
packageLayout ??= await PackageLayout.fromRootPackageRoot(workingDirectory);
@@ -224,7 +224,7 @@ class NativeAssetsBuildRunner {
224224
final configBuilder = configCreator()
225225
..setupHookConfig(
226226
targetOS: targetOS,
227-
supportedAssetTypes: supportedAssetTypes,
227+
buildAssetTypes: buildAssetTypes,
228228
buildMode: buildMode,
229229
packageName: package.name,
230230
packageRoot: packageLayout.packageRoot(package.name),
@@ -328,7 +328,7 @@ class NativeAssetsBuildRunner {
328328
required bool linkingEnabled,
329329
PackageLayout? packageLayout,
330330
String? runPackageName,
331-
required List<String> supportedAssetTypes,
331+
required List<String> buildAssetTypes,
332332
}) =>
333333
_runDryRun(
334334
targetOS: targetOS,
@@ -338,7 +338,7 @@ class NativeAssetsBuildRunner {
338338
workingDirectory: workingDirectory,
339339
packageLayout: packageLayout,
340340
runPackageName: runPackageName,
341-
supportedAssetTypes: supportedAssetTypes,
341+
buildAssetTypes: buildAssetTypes,
342342
linkingEnabled: linkingEnabled,
343343
);
344344

@@ -350,7 +350,7 @@ class NativeAssetsBuildRunner {
350350
PackageLayout? packageLayout,
351351
String? runPackageName,
352352
required bool linkingEnabled,
353-
required List<String> supportedAssetTypes,
353+
required List<String> buildAssetTypes,
354354
}) async {
355355
const hook = Hook.build;
356356

@@ -369,7 +369,7 @@ class NativeAssetsBuildRunner {
369369
final configBuilder = configCreator();
370370
configBuilder.setupHookConfig(
371371
targetOS: targetOS,
372-
supportedAssetTypes: supportedAssetTypes,
372+
buildAssetTypes: buildAssetTypes,
373373
buildMode: null, // not set in dry-run mode
374374
packageName: package.name,
375375
packageRoot: packageLayout.packageRoot(package.name),

pkgs/native_assets_builder/test/build_runner/build_dependencies_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void main() async {
3131
logger,
3232
dartExecutable,
3333
capturedLogs: logMessages,
34-
supportedAssetTypes: [CodeAsset.type],
34+
buildAssetTypes: [CodeAsset.type],
3535
configValidator: validateCodeAssetBuildConfig,
3636
buildValidator: validateCodeAssetBuildOutput,
3737
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_asset_id_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void main() async {
2727
packageUri,
2828
createCapturingLogger(logMessages, level: Level.SEVERE),
2929
dartExecutable,
30-
supportedAssetTypes: [CodeAsset.type],
30+
buildAssetTypes: [CodeAsset.type],
3131
configValidator: validateCodeAssetBuildConfig,
3232
buildValidator: validateCodeAssetBuildOutput,
3333
applicationAssetValidator: validateCodeAssetInApplication,
@@ -63,7 +63,7 @@ void main() async {
6363
packageUri,
6464
logger,
6565
dartExecutable,
66-
supportedAssetTypes: [CodeAsset.type],
66+
buildAssetTypes: [CodeAsset.type],
6767
configValidator: validateCodeAssetBuildConfig,
6868
buildValidator: validateCodeAssetBuildOutput,
6969
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_build_dry_run_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ void main() async {
2828
logger,
2929
dartExecutable,
3030
linkingEnabled: false,
31-
supportedAssetTypes: [CodeAsset.type],
31+
buildAssetTypes: [CodeAsset.type],
3232
buildValidator: validateCodeAssetBuildOutput,
3333
))!;
3434
final buildResult = (await build(
3535
packageUri,
3636
logger,
3737
dartExecutable,
38-
supportedAssetTypes: [CodeAsset.type],
38+
buildAssetTypes: [CodeAsset.type],
3939
configValidator: validateCodeAssetBuildConfig,
4040
buildValidator: validateCodeAssetBuildOutput,
4141
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_build_output_format_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void main() async {
3333
packageUri,
3434
createCapturingLogger(logMessages, level: Level.SEVERE),
3535
dartExecutable,
36-
supportedAssetTypes: [],
36+
buildAssetTypes: [],
3737
configValidator: (config) async => [],
3838
buildValidator: (config, output) async => [],
3939
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_caching_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void main() async {
3030
logger,
3131
dartExecutable,
3232
capturedLogs: logMessages,
33-
supportedAssetTypes: [CodeAsset.type],
33+
buildAssetTypes: [CodeAsset.type],
3434
configValidator: validateCodeAssetBuildConfig,
3535
buildValidator: validateCodeAssetBuildOutput,
3636
applicationAssetValidator: validateCodeAssetInApplication,
@@ -57,7 +57,7 @@ void main() async {
5757
logger,
5858
dartExecutable,
5959
capturedLogs: logMessages,
60-
supportedAssetTypes: [CodeAsset.type],
60+
buildAssetTypes: [CodeAsset.type],
6161
configValidator: validateCodeAssetBuildConfig,
6262
buildValidator: validateCodeAssetBuildOutput,
6363
applicationAssetValidator: validateCodeAssetInApplication,
@@ -107,7 +107,7 @@ void main() async {
107107
packageUri,
108108
logger,
109109
dartExecutable,
110-
supportedAssetTypes: [CodeAsset.type],
110+
buildAssetTypes: [CodeAsset.type],
111111
configValidator: validateCodeAssetBuildConfig,
112112
buildValidator: validateCodeAssetBuildOutput,
113113
applicationAssetValidator: validateCodeAssetInApplication,
@@ -128,7 +128,7 @@ void main() async {
128128
packageUri,
129129
logger,
130130
dartExecutable,
131-
supportedAssetTypes: [CodeAsset.type],
131+
buildAssetTypes: [CodeAsset.type],
132132
configValidator: validateCodeAssetBuildConfig,
133133
buildValidator: validateCodeAssetBuildOutput,
134134
applicationAssetValidator: validateCodeAssetInApplication,
@@ -171,7 +171,7 @@ void main() async {
171171
packageUri,
172172
logger,
173173
dartExecutable,
174-
supportedAssetTypes: [CodeAsset.type],
174+
buildAssetTypes: [CodeAsset.type],
175175
configValidator: validateCodeAssetBuildConfig,
176176
buildValidator: validateCodeAssetBuildOutput,
177177
applicationAssetValidator: validateCodeAssetInApplication,
@@ -199,7 +199,7 @@ void main() async {
199199
packageUri,
200200
logger,
201201
dartExecutable,
202-
supportedAssetTypes: [CodeAsset.type],
202+
buildAssetTypes: [CodeAsset.type],
203203
configValidator: validateCodeAssetBuildConfig,
204204
buildValidator: validateCodeAssetBuildOutput,
205205
applicationAssetValidator: validateCodeAssetInApplication,
@@ -239,7 +239,7 @@ void main() async {
239239
packageUri,
240240
logger,
241241
dartExecutable,
242-
supportedAssetTypes: [CodeAsset.type],
242+
buildAssetTypes: [CodeAsset.type],
243243
configValidator: validateCodeAssetBuildConfig,
244244
buildValidator: validateCodeAssetBuildOutput,
245245
applicationAssetValidator: validateCodeAssetInApplication,
@@ -271,7 +271,7 @@ void main() async {
271271
packageUri,
272272
logger,
273273
dartExecutable,
274-
supportedAssetTypes: [CodeAsset.type],
274+
buildAssetTypes: [CodeAsset.type],
275275
configValidator: validateCodeAssetBuildConfig,
276276
buildValidator: validateCodeAssetBuildOutput,
277277
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_cycle_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void main() async {
2727
createCapturingLogger(logMessages, level: Level.SEVERE),
2828
dartExecutable,
2929
linkingEnabled: false,
30-
supportedAssetTypes: [],
30+
buildAssetTypes: [],
3131
buildValidator: (config, output) async => [],
3232
);
3333
final fullLog = logMessages.join('\n');
@@ -47,7 +47,7 @@ void main() async {
4747
packageUri,
4848
createCapturingLogger(logMessages, level: Level.SEVERE),
4949
dartExecutable,
50-
supportedAssetTypes: [],
50+
buildAssetTypes: [],
5151
configValidator: (config) async => [],
5252
buildValidator: (config, output) async => [],
5353
applicationAssetValidator: (_) async => [],

pkgs/native_assets_builder/test/build_runner/build_runner_failure_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void main() async {
2828
packageUri,
2929
logger,
3030
dartExecutable,
31-
supportedAssetTypes: [CodeAsset.type],
31+
buildAssetTypes: [CodeAsset.type],
3232
configValidator: validateCodeAssetBuildConfig,
3333
buildValidator: validateCodeAssetBuildOutput,
3434
applicationAssetValidator: validateCodeAssetInApplication,
@@ -56,7 +56,7 @@ void main() async {
5656
packageUri,
5757
createCapturingLogger(logMessages, level: Level.SEVERE),
5858
dartExecutable,
59-
supportedAssetTypes: [CodeAsset.type],
59+
buildAssetTypes: [CodeAsset.type],
6060
configValidator: validateCodeAssetBuildConfig,
6161
buildValidator: validateCodeAssetBuildOutput,
6262
applicationAssetValidator: validateCodeAssetInApplication,
@@ -84,7 +84,7 @@ void main() async {
8484
packageUri,
8585
logger,
8686
dartExecutable,
87-
supportedAssetTypes: [CodeAsset.type],
87+
buildAssetTypes: [CodeAsset.type],
8888
configValidator: validateCodeAssetBuildConfig,
8989
buildValidator: validateCodeAssetBuildOutput,
9090
applicationAssetValidator: validateCodeAssetInApplication,
@@ -120,7 +120,7 @@ void main() async {
120120
logger,
121121
capturedLogs: logMessages,
122122
dartExecutable,
123-
supportedAssetTypes: [CodeAsset.type],
123+
buildAssetTypes: [CodeAsset.type],
124124
configValidator: validateCodeAssetBuildConfig,
125125
buildValidator: validateCodeAssetBuildOutput,
126126
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_non_root_package_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void main() async {
3030
dartExecutable,
3131
capturedLogs: logMessages,
3232
runPackageName: 'some_dev_dep',
33-
supportedAssetTypes: [CodeAsset.type],
33+
buildAssetTypes: [CodeAsset.type],
3434
configValidator: validateDataAssetBuildConfig,
3535
buildValidator: validateCodeAssetBuildOutput,
3636
applicationAssetValidator: validateCodeAssetInApplication,
@@ -47,7 +47,7 @@ void main() async {
4747
dartExecutable,
4848
capturedLogs: logMessages,
4949
runPackageName: 'native_add',
50-
supportedAssetTypes: [CodeAsset.type],
50+
buildAssetTypes: [CodeAsset.type],
5151
configValidator: validateDataAssetBuildConfig,
5252
buildValidator: validateCodeAssetBuildOutput,
5353
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/build_runner_reusability_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ void main() async {
3838
targetOS: Target.current.os,
3939
workingDirectory: packageUri,
4040
linkingEnabled: false,
41-
supportedAssetTypes: [],
41+
buildAssetTypes: [],
4242
buildValidator: (config, output) async => [],
4343
);
4444
await buildRunner.buildDryRun(
4545
configCreator: configCreator,
4646
targetOS: Target.current.os,
4747
workingDirectory: packageUri,
4848
linkingEnabled: false,
49-
supportedAssetTypes: [],
49+
buildAssetTypes: [],
5050
buildValidator: (config, output) async => [],
5151
);
5252
await buildRunner.build(
@@ -55,7 +55,7 @@ void main() async {
5555
buildMode: BuildMode.release,
5656
workingDirectory: packageUri,
5757
linkingEnabled: false,
58-
supportedAssetTypes: [],
58+
buildAssetTypes: [],
5959
configValidator: (config) async => [],
6060
buildValidator: (config, output) async => [],
6161
applicationAssetValidator: (_) async => [],
@@ -66,7 +66,7 @@ void main() async {
6666
targetOS: OS.current,
6767
workingDirectory: packageUri,
6868
linkingEnabled: false,
69-
supportedAssetTypes: [],
69+
buildAssetTypes: [],
7070
configValidator: (config) async => [],
7171
buildValidator: (config, output) async => [],
7272
applicationAssetValidator: (_) async => [],

pkgs/native_assets_builder/test/build_runner/build_runner_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void main() async {
3333
dartExecutable,
3434
capturedLogs: logMessages,
3535
configValidator: validateCodeAssetBuildConfig,
36-
supportedAssetTypes: [CodeAsset.type],
36+
buildAssetTypes: [CodeAsset.type],
3737
buildValidator: validateCodeAssetBuildOutput,
3838
applicationAssetValidator: validateCodeAssetInApplication,
3939
))!;
@@ -59,7 +59,7 @@ void main() async {
5959
dartExecutable,
6060
capturedLogs: logMessages,
6161
packageLayout: packageLayout,
62-
supportedAssetTypes: [CodeAsset.type],
62+
buildAssetTypes: [CodeAsset.type],
6363
configValidator: validateCodeAssetBuildConfig,
6464
buildValidator: validateCodeAssetBuildOutput,
6565
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/concurrency_shared_test_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void main(List<String> args) async {
2525
targetOS: target.os,
2626
workingDirectory: packageUri,
2727
linkingEnabled: false,
28-
supportedAssetTypes: [DataAsset.type],
28+
buildAssetTypes: [DataAsset.type],
2929
configValidator: validateDataAssetBuildConfig,
3030
buildValidator: (config, output) async =>
3131
await validateDataAssetBuildOutput(config, output),

pkgs/native_assets_builder/test/build_runner/concurrency_test_helper.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void main(List<String> args) async {
3636
targetOS: OS.current,
3737
workingDirectory: packageUri,
3838
linkingEnabled: false,
39-
supportedAssetTypes: [CodeAsset.type, DataAsset.type],
39+
buildAssetTypes: [CodeAsset.type, DataAsset.type],
4040
configValidator: (config) async => [
4141
...await validateDataAssetBuildConfig(config),
4242
...await validateCodeAssetBuildConfig(config),

pkgs/native_assets_builder/test/build_runner/conflicting_dylib_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void main() async {
2727
packageUri,
2828
createCapturingLogger(logMessages, level: Level.SEVERE),
2929
dartExecutable,
30-
supportedAssetTypes: [CodeAsset.type],
30+
buildAssetTypes: [CodeAsset.type],
3131
configValidator: validateCodeAssetBuildConfig,
3232
buildValidator: validateCodeAssetBuildOutput,
3333
applicationAssetValidator: validateCodeAssetInApplication,
@@ -58,7 +58,7 @@ void main() async {
5858
logger,
5959
linkingEnabled: true,
6060
dartExecutable,
61-
supportedAssetTypes: [CodeAsset.type],
61+
buildAssetTypes: [CodeAsset.type],
6262
configValidator: validateCodeAssetBuildConfig,
6363
buildValidator: validateCodeAssetBuildOutput,
6464
applicationAssetValidator: validateCodeAssetInApplication,
@@ -69,7 +69,7 @@ void main() async {
6969
logger,
7070
dartExecutable,
7171
buildResult: buildResult,
72-
supportedAssetTypes: [CodeAsset.type],
72+
buildAssetTypes: [CodeAsset.type],
7373
configValidator: validateCodeAssetLinkConfig,
7474
linkValidator: validateCodeAssetLinkOutput,
7575
applicationAssetValidator: validateCodeAssetInApplication,

pkgs/native_assets_builder/test/build_runner/fail_on_os_sdk_version_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void main() async {
7373
packageUri,
7474
createCapturingLogger(logMessages, level: Level.SEVERE),
7575
dartExecutable,
76-
supportedAssetTypes: [CodeAsset.type, DataAsset.type],
76+
buildAssetTypes: [CodeAsset.type, DataAsset.type],
7777
buildConfigValidator: (config) async => [
7878
...await validateDataAssetBuildConfig(config),
7979
...await validateCodeAssetBuildConfig(config),

0 commit comments

Comments
 (0)