@@ -41,54 +41,43 @@ class SdkAssetGenerator {
41
41
// normally generated by setup tools and their builds,
42
42
// i.e. flutter SDK or build_web_compilers.
43
43
// Generate missing files for tests if needed.
44
- await _generateSdkJavaScript (
45
- canaryFeatures: canaryFeatures,
46
- );
44
+ await _generateSdkJavaScript (canaryFeatures: canaryFeatures);
47
45
48
46
// SDK does not contain any weak assets, generate them.
49
- await _generateSdkJavaScript (
50
- canaryFeatures: canaryFeatures,
51
- );
47
+ await _generateSdkJavaScript (canaryFeatures: canaryFeatures);
52
48
await _generateSdkSummary ();
53
49
}
54
50
}
55
51
56
- String resolveSdkJsPath ({
57
- required bool canaryFeatures,
58
- }) =>
52
+ String resolveSdkJsPath ({required bool canaryFeatures}) =>
59
53
switch (ddcModuleFormat) {
60
54
ModuleFormat .amd => sdkLayout.amdJsPath,
61
55
ModuleFormat .ddc => sdkLayout.ddcJsPath,
62
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
56
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
63
57
};
64
58
65
- String resolveSdkSourcemapPath ({
66
- required bool canaryFeatures,
67
- }) =>
59
+ String resolveSdkSourcemapPath ({required bool canaryFeatures}) =>
68
60
switch (ddcModuleFormat) {
69
61
ModuleFormat .amd => sdkLayout.amdJsMapPath,
70
62
ModuleFormat .ddc => sdkLayout.ddcJsMapPath,
71
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
63
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
72
64
};
73
65
74
- String resolveSdkJsFilename ({
75
- required bool canaryFeatures,
76
- }) =>
66
+ String resolveSdkJsFilename ({required bool canaryFeatures}) =>
77
67
switch (ddcModuleFormat) {
78
68
ModuleFormat .amd => sdkLayout.amdJsFileName,
79
69
ModuleFormat .ddc => sdkLayout.ddcJsFileName,
80
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
70
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
81
71
};
82
72
83
- Future <void > _generateSdkJavaScript ({
84
- required bool canaryFeatures,
85
- }) async {
73
+ Future <void > _generateSdkJavaScript ({required bool canaryFeatures}) async {
86
74
Directory ? outputDir;
87
75
try {
88
76
// Files to copy generated files to.
89
77
final outputJsPath = resolveSdkJsPath (canaryFeatures: canaryFeatures);
90
- final outputJsMapPath =
91
- resolveSdkSourcemapPath (canaryFeatures: canaryFeatures);
78
+ final outputJsMapPath = resolveSdkSourcemapPath (
79
+ canaryFeatures: canaryFeatures,
80
+ );
92
81
final outputFullDillPath = sdkLayout.fullDillPath;
93
82
94
83
final hasJsAsset = _exists (outputJsPath);
@@ -104,7 +93,9 @@ class SdkAssetGenerator {
104
93
105
94
// Files to generate
106
95
final jsPath = p.join (
107
- outputDir.path, resolveSdkJsFilename (canaryFeatures: canaryFeatures));
96
+ outputDir.path,
97
+ resolveSdkJsFilename (canaryFeatures: canaryFeatures),
98
+ );
108
99
final jsMapPath = p.setExtension (jsPath, '.js.map' );
109
100
final fullDillPath = p.setExtension (jsPath, '.dill' );
110
101
@@ -132,24 +123,27 @@ class SdkAssetGenerator {
132
123
133
124
final output = < String > [];
134
125
_logger.fine ('Executing dart ${args .join (' ' )}' );
135
- final process = await Process .start (sdkLayout.dartPath, args,
136
- workingDirectory: sdkLayout.sdkDirectory);
126
+ final process = await Process .start (
127
+ sdkLayout.dartPath,
128
+ args,
129
+ workingDirectory: sdkLayout.sdkDirectory,
130
+ );
137
131
138
132
process.stdout
139
133
.transform <String >(utf8.decoder)
140
134
.transform <String >(const LineSplitter ())
141
135
.listen ((line) {
142
- _logger.fine (line);
143
- output.add (line);
144
- });
136
+ _logger.fine (line);
137
+ output.add (line);
138
+ });
145
139
146
140
process.stderr
147
141
.transform <String >(utf8.decoder)
148
142
.transform <String >(const LineSplitter ())
149
143
.listen ((line) {
150
- _logger.warning (line);
151
- output.add (line);
152
- });
144
+ _logger.warning (line);
145
+ output.add (line);
146
+ });
153
147
154
148
await process.exitCode.then ((int code) {
155
149
if (code != 0 ) {
@@ -169,7 +163,10 @@ class SdkAssetGenerator {
169
163
_logger.info ('Done generating js and full dill SDK files.' );
170
164
} catch (e, s) {
171
165
_logger.severe (
172
- 'Failed to generate SDK js, source map, and full dill' , e, s);
166
+ 'Failed to generate SDK js, source map, and full dill' ,
167
+ e,
168
+ s,
169
+ );
173
170
rethrow ;
174
171
} finally {
175
172
outputDir? .deleteSync (recursive: true );
@@ -213,30 +210,34 @@ class SdkAssetGenerator {
213
210
];
214
211
215
212
_logger.fine ('Executing dart ${args .join (' ' )}' );
216
- final process = await Process .start (sdkLayout.dartPath, args,
217
- workingDirectory: sdkLayout.sdkDirectory);
213
+ final process = await Process .start (
214
+ sdkLayout.dartPath,
215
+ args,
216
+ workingDirectory: sdkLayout.sdkDirectory,
217
+ );
218
218
219
219
final output = < String > [];
220
220
process.stdout
221
221
.transform <String >(utf8.decoder)
222
222
.transform <String >(const LineSplitter ())
223
223
.listen ((line) {
224
- _logger.fine (line);
225
- output.add (line);
226
- });
224
+ _logger.fine (line);
225
+ output.add (line);
226
+ });
227
227
228
228
process.stderr
229
229
.transform <String >(utf8.decoder)
230
230
.transform <String >(const LineSplitter ())
231
231
.listen ((line) {
232
- _logger.warning (line);
233
- output.add (line);
234
- });
232
+ _logger.warning (line);
233
+ output.add (line);
234
+ });
235
235
236
236
await process.exitCode.then ((int code) {
237
237
if (code != 0 ) {
238
- _logger
239
- .warning ('Error generating $summaryPath : ${output .join ('\n ' )}' );
238
+ _logger.warning (
239
+ 'Error generating $summaryPath : ${output .join ('\n ' )}' ,
240
+ );
240
241
throw Exception ('The Dart kernel worker exited unexpectedly' );
241
242
}
242
243
});
0 commit comments