Skip to content

Commit 3d50dde

Browse files
committed
[native_assets_cli] Cleanup JSON: assetsForLinking
1 parent 24f71bf commit 3d50dde

18 files changed

+4
-177
lines changed

pkgs/code_assets/doc/schema/shared/shared_definitions.generated.schema.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@
3636
},
3737
{
3838
"properties": {
39-
"assetsForLinking": {
40-
"type": "object",
41-
"additionalProperties": {
42-
"type": "array",
43-
"items": {
44-
"$ref": "shared_definitions.schema.json#/definitions/Asset"
45-
}
46-
}
47-
},
4839
"assets_for_build": {
4940
"type": "array",
5041
"items": {

pkgs/code_assets/test/data/build_output_macos.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,6 @@
5050
"type": "code_assets/code"
5151
}
5252
],
53-
"assetsForLinking": {
54-
"package_with_linker": [
55-
{
56-
"encoding": {
57-
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/iv6i0d/native_add/.dart_tool/native_assets_builder/native_add/c6b312c90c95d2d98ffb6760a738fb36/out/libnative_add.a",
58-
"id": "package:native_add/src/native_add_bindings_generated.dart",
59-
"link_mode": {
60-
"type": "static"
61-
}
62-
},
63-
"type": "code_assets/code"
64-
}
65-
]
66-
},
6753
"assets_for_build": [
6854
{
6955
"encoding": {

pkgs/code_assets/test/schema/schema_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ FieldsFunction _codeFields(AllTestData allTestData) {
122122
for (final (field, expect) in codeAssetFields)
123123
for (final path in [
124124
['assets_for_build'],
125-
['assetsForLinking', 'package_with_linker'],
126125
['assets_for_linking', 'package_with_linker'],
127126
])
128127
([...path, 0, 'encoding', ...field], expect),

pkgs/data_assets/doc/schema/shared/shared_definitions.generated.schema.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@
3636
},
3737
{
3838
"properties": {
39-
"assetsForLinking": {
40-
"type": "object",
41-
"additionalProperties": {
42-
"type": "array",
43-
"items": {
44-
"$ref": "shared_definitions.schema.json#/definitions/Asset"
45-
}
46-
}
47-
},
4839
"assets_for_build": {
4940
"type": "array",
5041
"items": {

pkgs/data_assets/test/data/build_output.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,6 @@
1818
"type": "data_assets/data"
1919
}
2020
],
21-
"assetsForLinking": {
22-
"package_with_linker": [
23-
{
24-
"encoding": {
25-
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_0.json",
26-
"name": "assets/data_0.json",
27-
"package": "simple_link"
28-
},
29-
"type": "data_assets/data"
30-
},
31-
{
32-
"encoding": {
33-
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_1.json",
34-
"name": "assets/data_1.json",
35-
"package": "simple_link"
36-
},
37-
"type": "data_assets/data"
38-
}
39-
]
40-
},
4121
"assets_for_build": [
4222
{
4323
"encoding": {

pkgs/data_assets/test/schema/schema_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ List<(List<Object>, void Function(ValidationResults result))> _dataFields({
5454
for (final field in _dataAssetFields)
5555
for (final path in [
5656
['assets_for_build'],
57-
['assetsForLinking', 'package_with_linker'],
5857
['assets_for_linking', 'package_with_linker'],
5958
])
6059
([...path, 0, 'encoding', field], expectRequiredFieldMissing),

pkgs/hooks/doc/schema/hook/shared_definitions.schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
"BuildInput": {},
66
"BuildOutput": {
77
"$ref": "../shared/shared_definitions.schema.json#/definitions/BuildOutput",
8-
"properties": {
9-
"assets_for_linking": {
10-
"$comment": "Older SDKs will only read 'assetsForLinking', so it must be emitted as well."
11-
}
12-
},
138
"unevaluatedProperties": false
149
},
1510
"HookInput": {},

pkgs/hooks/doc/schema/sdk/shared_definitions.schema.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,7 @@
66
"$ref": "../shared/shared_definitions.schema.json#/definitions/BuildInput",
77
"unevaluatedProperties": false
88
},
9-
"BuildOutput": {
10-
"properties": {
11-
"assetsForLinking": {
12-
"deprecated": true
13-
},
14-
"assets_for_linking": {
15-
"$comment": "Older hooks will still emit 'assetsForLinking', so it must be read."
16-
}
17-
}
18-
},
9+
"BuildOutput": {},
1910
"HookInput": {},
2011
"HookOutput": {},
2112
"LinkInput": {

pkgs/hooks/doc/schema/shared/shared_definitions.schema.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@
9494
"BuildOutput": {
9595
"type": "object",
9696
"properties": {
97-
"assetsForLinking": {
98-
"type": "object",
99-
"additionalProperties": {
100-
"type": "array",
101-
"items": {
102-
"$ref": "#/definitions/Asset"
103-
}
104-
}
105-
},
10697
"assets_for_build": {
10798
"type": "array",
10899
"items": {

pkgs/hooks/test/data/build_output.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,6 @@
1414
"type": "some_other_asset_type"
1515
}
1616
],
17-
"assetsForLinking": {
18-
"package_with_linker": [
19-
{
20-
"encoding": {
21-
"a_key": "some_value"
22-
},
23-
"type": "some_asset_type"
24-
},
25-
{
26-
"encoding": {
27-
"key": "foo",
28-
"value": "bar"
29-
},
30-
"type": "hooks/metadata"
31-
}
32-
]
33-
},
3417
"assets_for_build": [
3518
{
3619
"encoding": {

pkgs/hooks/test/schema/helpers.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ FieldsReturn _hookFields({
316316
(['metadata'], expectOptionalFieldMissing),
317317
for (final path in [
318318
['assets_for_build'],
319-
['assetsForLinking', 'package_with_linker'],
320319
['assets_for_linking', 'package_with_linker'],
321320
]) ...[
322321
([...path], expectOptionalFieldMissing),
@@ -330,7 +329,6 @@ FieldsReturn _hookFields({
330329
if (inputOrOutput == InputOrOutput.output || hook == Hook.link) ['assets'],
331330
if (inputOrOutput == InputOrOutput.output && hook == Hook.build) ...[
332331
['assets_for_build'],
333-
['assetsForLinking', 'package_with_linker'],
334332
['assets_for_linking', 'package_with_linker'],
335333
],
336334
]) ...[

pkgs/hooks/test/schema/schema_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ _metadataAssetFields({
4242
if (inputOrOutput == InputOrOutput.input && hook == Hook.link) ['assets'],
4343
if (inputOrOutput == InputOrOutput.output && hook == Hook.build) ...[
4444
['assets_for_build'],
45-
['assetsForLinking', 'package_with_linker'],
4645
['assets_for_linking', 'package_with_linker'],
4746
],
4847
]) ...[

pkgs/hooks/tool/generate_schemas.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ void generateSharedDefinitions() {
3434
};
3535
const buildOutputAssetOverride = {
3636
'properties': {
37-
'assetsForLinking': {
38-
'type': 'object',
39-
'additionalProperties': {
40-
'type': 'array',
41-
'items': {
42-
r'$ref': 'shared_definitions.schema.json#/definitions/Asset',
43-
},
44-
},
45-
},
4637
'assets_for_linking': {
4738
'type': 'object',
4839
'additionalProperties': {

pkgs/hooks/tool/generate_syntax.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void main(List<String> args) {
3535
'Macos': 'MacOS',
3636
'prefer-dynamic': 'preferDynamicOld',
3737
'prefer-static': 'preferStaticOld',
38-
'assetsForLinking': 'assetsForLinkingOld',
3938
'CodeAssetsCodeAsset': 'NativeCodeAssetNew',
4039
'DataAssetsDataAsset': 'DataAssetNew',
4140
},

pkgs/native_assets_cli/lib/src/config.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,7 @@ class BuildOutput extends HookOutput {
441441
/// specified in the key, which can decide if they are bundled or not.
442442
Map<String, List<EncodedAsset>> get _encodedAssetsForLinking => {
443443
for (final MapEntry(:key, :value)
444-
in (_syntax.assetsForLinking ?? _syntax.assetsForLinkingOld ?? {})
445-
.entries)
444+
in (_syntax.assetsForLinking ?? {}).entries)
446445
key: _parseAssets(value),
447446
};
448447

@@ -619,7 +618,6 @@ extension type EncodedAssetBuildOutputBuilder._(BuildOutputBuilder _output) {
619618
syntax.Asset.fromJson(asset.toJson()),
620619
);
621620
_syntax.assetsForLinking = assetsForLinking;
622-
_syntax.assetsForLinkingOld = assetsForLinking;
623621
}
624622
}
625623

@@ -657,14 +655,12 @@ extension type EncodedAssetBuildOutputBuilder._(BuildOutputBuilder _output) {
657655
_syntax.assetsForBuild = list;
658656
case ToLinkHook():
659657
final linkInPackage = routing.packageName;
660-
final assetsForLinking =
661-
_syntax.assetsForLinking ?? _syntax.assetsForLinkingOld ?? {};
658+
final assetsForLinking = _syntax.assetsForLinking ?? {};
662659
final list = assetsForLinking[linkInPackage] ??= [];
663660
for (final asset in assets) {
664661
list.add(syntax.Asset.fromJson(asset.toJson()));
665662
}
666663
_syntax.assetsForLinking = assetsForLinking;
667-
_syntax.assetsForLinkingOld = assetsForLinking;
668664
}
669665
}
670666

pkgs/native_assets_cli/lib/src/hooks/syntax.g.dart

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,10 @@ class BuildOutput extends HookOutput {
233233
required super.assets,
234234
required List<Asset>? assetsForBuild,
235235
required Map<String, List<Asset>>? assetsForLinking,
236-
required Map<String, List<Asset>>? assetsForLinkingOld,
237236
required super.dependencies,
238237
required JsonObject? metadata,
239238
required super.timestamp,
240239
}) : super() {
241-
this.assetsForLinkingOld = assetsForLinkingOld;
242240
this.assetsForBuild = assetsForBuild;
243241
this.assetsForLinking = assetsForLinking;
244242
this.metadata = metadata;
@@ -248,66 +246,16 @@ class BuildOutput extends HookOutput {
248246
/// Setup all fields for [BuildOutput] that are not in
249247
/// [HookOutput].
250248
void setup({
251-
required Map<String, List<Asset>>? assetsForLinkingOld,
252249
required List<Asset>? assetsForBuild,
253250
required Map<String, List<Asset>>? assetsForLinking,
254251
required JsonObject? metadata,
255252
}) {
256-
this.assetsForLinkingOld = assetsForLinkingOld;
257253
this.assetsForBuild = assetsForBuild;
258254
this.assetsForLinking = assetsForLinking;
259255
this.metadata = metadata;
260256
json.sortOnKey();
261257
}
262258

263-
Map<String, List<Asset>>? get assetsForLinkingOld {
264-
final jsonValue = _reader.optionalMap('assetsForLinking');
265-
if (jsonValue == null) {
266-
return null;
267-
}
268-
final result = <String, List<Asset>>{};
269-
for (final MapEntry(:key, :value) in jsonValue.entries) {
270-
result[key] = [
271-
for (final (index, item) in (value as List<Object?>).indexed)
272-
Asset.fromJson(
273-
item as Map<String, Object?>,
274-
path: [...path, key, index],
275-
),
276-
];
277-
}
278-
return result;
279-
}
280-
281-
set assetsForLinkingOld(Map<String, List<Asset>>? value) {
282-
if (value == null) {
283-
json.remove('assetsForLinking');
284-
} else {
285-
json['assetsForLinking'] = {
286-
for (final MapEntry(:key, :value) in value.entries)
287-
key: [for (final item in value) item.json],
288-
};
289-
}
290-
json.sortOnKey();
291-
}
292-
293-
List<String> _validateAssetsForLinkingOld() {
294-
final mapErrors = _reader.validateOptionalMap('assetsForLinking');
295-
if (mapErrors.isNotEmpty) {
296-
return mapErrors;
297-
}
298-
final jsonValue = _reader.optionalMap('assetsForLinking');
299-
if (jsonValue == null) {
300-
return [];
301-
}
302-
final result = <String>[];
303-
for (final list in assetsForLinkingOld!.values) {
304-
for (final element in list) {
305-
result.addAll(element.validate());
306-
}
307-
}
308-
return result;
309-
}
310-
311259
List<Asset>? get assetsForBuild {
312260
final jsonValue = _reader.optionalList('assets_for_build');
313261
if (jsonValue == null) return null;
@@ -413,7 +361,6 @@ class BuildOutput extends HookOutput {
413361
@override
414362
List<String> validate() => [
415363
...super.validate(),
416-
..._validateAssetsForLinkingOld(),
417364
..._validateAssetsForBuild(),
418365
..._validateAssetsForLinking(),
419366
..._validateMetadata(),

pkgs/native_assets_cli/lib/src/validation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ValidationErrors _validateAssetsForLinking(
138138
if (!input.config.linkingEnabled) {
139139
if (output.assets.encodedAssetsForLinking.isNotEmpty) {
140140
const error =
141-
'BuildOutput.assetsForLinking is not empty while '
141+
'BuildOutput.assets_for_linking is not empty while '
142142
'BuildInput.config.linkingEnabled is false';
143143
errors.add(error);
144144
}

pkgs/native_assets_cli/test/build_output_test.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,6 @@ void main() {
8585
'type': 'my-asset-type',
8686
},
8787
],
88-
'assetsForLinking': {
89-
'package:linker1': [
90-
{
91-
'encoding': {'a-1': 'v-1'},
92-
'type': 'my-asset-type',
93-
},
94-
],
95-
'package:linker2': <Object?>[],
96-
},
9788
'assets_for_linking': {
9889
'package:linker1': [
9990
{

0 commit comments

Comments
 (0)