Skip to content

Commit cf34082

Browse files
committed
[native_assets_cli] Syntax for assets_for_build and hooks/metadata
1 parent 18e2518 commit cf34082

19 files changed

+561
-74
lines changed

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

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
},
1111
{
1212
"$ref": "../../../../hooks/doc/schema/shared/shared_definitions.schema.json#/definitions/BuildInput"
13+
},
14+
{
15+
"properties": {
16+
"assets": {
17+
"type": "object",
18+
"additionalProperties": {
19+
"type": "array",
20+
"items": {
21+
"$ref": "shared_definitions.schema.json#/definitions/Asset"
22+
}
23+
}
24+
}
25+
}
1326
}
1427
]
1528
},
@@ -32,6 +45,12 @@
3245
}
3346
}
3447
},
48+
"assets_for_build": {
49+
"type": "array",
50+
"items": {
51+
"$ref": "shared_definitions.schema.json#/definitions/Asset"
52+
}
53+
},
3554
"assets_for_linking": {
3655
"type": "object",
3756
"additionalProperties": {

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
"type": "string",
3939
"anyOf": [
4040
{
41-
"const": "native_code"
41+
"const": "code_assets/code"
4242
},
4343
{
44-
"const": "code_assets/code"
44+
"const": "native_code"
4545
},
4646
{
4747
"type": "string"
@@ -54,7 +54,7 @@
5454
"if": {
5555
"properties": {
5656
"type": {
57-
"const": "native_code"
57+
"const": "code_assets/code"
5858
}
5959
}
6060
},
@@ -63,20 +63,14 @@
6363
"encoding": {
6464
"$ref": "#/definitions/NativeCodeAssetEncoding"
6565
}
66-
},
67-
"allOf": [
68-
{
69-
"$comment": "Also include the fields parent object for backwards compatibility.",
70-
"$ref": "#/definitions/NativeCodeAssetEncoding"
71-
}
72-
]
66+
}
7367
}
7468
},
7569
{
7670
"if": {
7771
"properties": {
7872
"type": {
79-
"const": "code_assets/code"
73+
"const": "native_code"
8074
}
8175
}
8276
},
@@ -85,7 +79,13 @@
8579
"encoding": {
8680
"$ref": "#/definitions/NativeCodeAssetEncoding"
8781
}
88-
}
82+
},
83+
"allOf": [
84+
{
85+
"$comment": "Also include the fields parent object for backwards compatibility.",
86+
"$ref": "#/definitions/NativeCodeAssetEncoding"
87+
}
88+
]
8989
}
9090
}
9191
]

pkgs/code_assets/test/data/build_input_macos.json

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
{
22
"$schema": "../../doc/schema/sdk/build_input.generated.schema.json",
3+
"assets": {
4+
"some_package": [
5+
{
6+
"architecture": "arm64",
7+
"encoding": {
8+
"architecture": "arm64",
9+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/iv6i0d/native_add/.dart_tool/native_assets_builder/native_add/c6b312c90c95d2d98ffb6760a738fb36/out/libnative_add.a",
10+
"id": "package:native_add/src/native_add_bindings_generated.dart",
11+
"link_mode": {
12+
"type": "static"
13+
},
14+
"os": "macos"
15+
},
16+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/iv6i0d/native_add/.dart_tool/native_assets_builder/native_add/c6b312c90c95d2d98ffb6760a738fb36/out/libnative_add.a",
17+
"id": "package:native_add/src/native_add_bindings_generated.dart",
18+
"link_mode": {
19+
"type": "static"
20+
},
21+
"os": "macos",
22+
"type": "native_code"
23+
}
24+
]
25+
},
326
"config": {
427
"build_asset_types": [
528
"native_code"

pkgs/code_assets/test/data/build_output_macos.json

+21
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@
116116
}
117117
]
118118
},
119+
"assets_for_build": [
120+
{
121+
"architecture": "arm64",
122+
"encoding": {
123+
"architecture": "arm64",
124+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/iv6i0d/native_add/.dart_tool/native_assets_builder/native_add/c6b312c90c95d2d98ffb6760a738fb36/out/libnative_add.a",
125+
"id": "package:native_add/src/native_add_bindings_generated.dart",
126+
"link_mode": {
127+
"type": "static"
128+
},
129+
"os": "macos"
130+
},
131+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/iv6i0d/native_add/.dart_tool/native_assets_builder/native_add/c6b312c90c95d2d98ffb6760a738fb36/out/libnative_add.a",
132+
"id": "package:native_add/src/native_add_bindings_generated.dart",
133+
"link_mode": {
134+
"type": "static"
135+
},
136+
"os": "macos",
137+
"type": "native_code"
138+
}
139+
],
119140
"assets_for_linking": {
120141
"package_with_linker": [
121142
{

pkgs/code_assets/test/schema/schema_test.dart

+5-13
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,12 @@ FieldsFunction _codeFields(AllTestData allTestData) {
127127
if (hook == Hook.build) ...[
128128
for (final (field, expect) in codeAssetFields)
129129
for (final encoding in _encoding)
130-
for (final assetsForLinking in [
131-
'assetsForLinking',
132-
'assets_for_linking',
130+
for (final path in [
131+
['assets_for_build'],
132+
['assetsForLinking', 'package_with_linker'],
133+
['assets_for_linking', 'package_with_linker'],
133134
])
134-
(
135-
[
136-
assetsForLinking,
137-
'package_with_linker',
138-
0,
139-
...encoding,
140-
...field,
141-
],
142-
expect,
143-
),
135+
([...path, 0, ...encoding, ...field], expect),
144136
],
145137
(['assets', staticIndex, 'file'], expectRequiredFieldMissing),
146138
(

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

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
},
1111
{
1212
"$ref": "../../../../hooks/doc/schema/shared/shared_definitions.schema.json#/definitions/BuildInput"
13+
},
14+
{
15+
"properties": {
16+
"assets": {
17+
"type": "object",
18+
"additionalProperties": {
19+
"type": "array",
20+
"items": {
21+
"$ref": "shared_definitions.schema.json#/definitions/Asset"
22+
}
23+
}
24+
}
25+
}
1326
}
1427
]
1528
},
@@ -32,6 +45,12 @@
3245
}
3346
}
3447
},
48+
"assets_for_build": {
49+
"type": "array",
50+
"items": {
51+
"$ref": "shared_definitions.schema.json#/definitions/Asset"
52+
}
53+
},
3554
"assets_for_linking": {
3655
"type": "object",
3756
"additionalProperties": {

pkgs/data_assets/test/data/build_input.json

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
{
22
"$schema": "../../doc/schema/sdk/build_input.generated.schema.json",
3+
"assets": {
4+
"some_package": [
5+
{
6+
"encoding": {
7+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_0.json",
8+
"name": "assets/data_0.json",
9+
"package": "simple_link"
10+
},
11+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_0.json",
12+
"name": "assets/data_0.json",
13+
"package": "simple_link",
14+
"type": "data"
15+
},
16+
{
17+
"encoding": {
18+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_1.json",
19+
"name": "assets/data_1.json",
20+
"package": "simple_link"
21+
},
22+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_1.json",
23+
"name": "assets/data_1.json",
24+
"package": "simple_link",
25+
"type": "data"
26+
}
27+
]
28+
},
329
"config": {
430
"build_asset_types": [
531
"data"

pkgs/data_assets/test/data/build_output.json

+24
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@
5050
}
5151
]
5252
},
53+
"assets_for_build": [
54+
{
55+
"encoding": {
56+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_0.json",
57+
"name": "assets/data_0.json",
58+
"package": "simple_link"
59+
},
60+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_0.json",
61+
"name": "assets/data_0.json",
62+
"package": "simple_link",
63+
"type": "data"
64+
},
65+
{
66+
"encoding": {
67+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_1.json",
68+
"name": "assets/data_1.json",
69+
"package": "simple_link"
70+
},
71+
"file": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/0s5bKi/simple_link/assets/data_1.json",
72+
"name": "assets/data_1.json",
73+
"package": "simple_link",
74+
"type": "data"
75+
}
76+
],
5377
"assets_for_linking": {
5478
"package_with_linker": [
5579
{

pkgs/data_assets/test/schema/schema_test.dart

+5-7
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@ List<(List<Object>, void Function(ValidationResults result))> _dataFields({
5858
if (hook == Hook.build) ...[
5959
for (final field in _dataAssetFields)
6060
for (final encoding in _encoding)
61-
for (final assetsForLinking in [
62-
'assetsForLinking',
63-
'assets_for_linking',
61+
for (final path in [
62+
['assets_for_build'],
63+
['assetsForLinking', 'package_with_linker'],
64+
['assets_for_linking', 'package_with_linker'],
6465
])
65-
(
66-
[assetsForLinking, 'package_with_linker', 0, ...encoding, field],
67-
expectRequiredFieldMissing,
68-
),
66+
([...path, 0, ...encoding, field], expectRequiredFieldMissing),
6967
],
7068
],
7169
];

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

+57-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66
"type": "object",
77
"properties": {
88
"type": {
9-
"type": "string"
9+
"type": "string",
10+
"anyOf": [
11+
{
12+
"const": "hooks/metadata"
13+
},
14+
{
15+
"type": "string"
16+
}
17+
]
1018
},
1119
"encoding": {
1220
"type": "object",
@@ -15,6 +23,27 @@
1523
},
1624
"required": [
1725
"type"
26+
],
27+
"allOf": [
28+
{
29+
"if": {
30+
"properties": {
31+
"type": {
32+
"const": "hooks/metadata"
33+
}
34+
}
35+
},
36+
"then": {
37+
"properties": {
38+
"encoding": {
39+
"$ref": "#/definitions/MetadataAssetEncoding"
40+
}
41+
},
42+
"required": [
43+
"encoding"
44+
]
45+
}
46+
}
1847
]
1948
},
2049
"BuildConfig": {
@@ -36,6 +65,15 @@
3665
},
3766
"BuildInput": {
3867
"properties": {
68+
"assets": {
69+
"type": "object",
70+
"additionalProperties": {
71+
"type": "array",
72+
"items": {
73+
"$ref": "#/definitions/Asset"
74+
}
75+
}
76+
},
3977
"config": {
4078
"$ref": "#/definitions/BuildConfig"
4179
},
@@ -65,6 +103,12 @@
65103
}
66104
}
67105
},
106+
"assets_for_build": {
107+
"type": "array",
108+
"items": {
109+
"$ref": "#/definitions/Asset"
110+
}
111+
},
68112
"assets_for_linking": {
69113
"type": "object",
70114
"additionalProperties": {
@@ -196,6 +240,18 @@
196240
}
197241
]
198242
},
243+
"MetadataAssetEncoding": {
244+
"type": "object",
245+
"properties": {
246+
"key": {
247+
"type": "string"
248+
},
249+
"value": {}
250+
},
251+
"required": [
252+
"key"
253+
]
254+
},
199255
"absolutePath": {
200256
"type": "string",
201257
"pattern": "^(\\/|[A-Za-z]:)"

0 commit comments

Comments
 (0)