@@ -8,10 +8,7 @@ import 'package:logging/logging.dart';
8
8
import 'package:path/path.dart' as p;
9
9
import 'package:test_common/test_sdk_layout.dart' ;
10
10
11
- /// Generates sdk.js, sdk.map, sdk full dill, and sdk summary files.
12
- ///
13
- /// Generates following missing assets if needed:
14
- /// - js, source map, full dill.
11
+ /// Generates sdk.js, sdk.map, files.
15
12
16
13
class SdkAssetGenerator {
17
14
bool _sdkAssetsGenerated = false ;
@@ -37,58 +34,43 @@ class SdkAssetGenerator {
37
34
if (! _sdkAssetsGenerated) {
38
35
_sdkAssetsGenerated = true ;
39
36
40
- // SDK contains sound summary, but SDK js and full dill are
41
- // normally generated by setup tools and their builds,
37
+ // SDK full and outline .dill files are shipped with the SDK,
38
+ // but the JavaScript and sourcemaps are generated by other tooling
42
39
// i.e. flutter SDK or build_web_compilers.
43
40
// Generate missing files for tests if needed.
44
- await _generateSdkJavaScript (
45
- canaryFeatures: canaryFeatures,
46
- );
47
-
48
- // SDK does not contain any weak assets, generate them.
49
- await _generateSdkJavaScript (
50
- canaryFeatures: canaryFeatures,
51
- );
52
- await _generateSdkSummary ();
41
+ await _generateSdkJavaScript (canaryFeatures: canaryFeatures);
53
42
}
54
43
}
55
44
56
- String resolveSdkJsPath ({
57
- required bool canaryFeatures,
58
- }) =>
45
+ String resolveSdkJsPath ({required bool canaryFeatures}) =>
59
46
switch (ddcModuleFormat) {
60
47
ModuleFormat .amd => sdkLayout.amdJsPath,
61
48
ModuleFormat .ddc => sdkLayout.ddcJsPath,
62
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
49
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
63
50
};
64
51
65
- String resolveSdkSourcemapPath ({
66
- required bool canaryFeatures,
67
- }) =>
52
+ String resolveSdkSourcemapPath ({required bool canaryFeatures}) =>
68
53
switch (ddcModuleFormat) {
69
54
ModuleFormat .amd => sdkLayout.amdJsMapPath,
70
55
ModuleFormat .ddc => sdkLayout.ddcJsMapPath,
71
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
56
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
72
57
};
73
58
74
- String resolveSdkJsFilename ({
75
- required bool canaryFeatures,
76
- }) =>
59
+ String resolveSdkJsFilename ({required bool canaryFeatures}) =>
77
60
switch (ddcModuleFormat) {
78
61
ModuleFormat .amd => sdkLayout.amdJsFileName,
79
62
ModuleFormat .ddc => sdkLayout.ddcJsFileName,
80
- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
63
+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
81
64
};
82
65
83
- Future <void > _generateSdkJavaScript ({
84
- required bool canaryFeatures,
85
- }) async {
66
+ Future <void > _generateSdkJavaScript ({required bool canaryFeatures}) async {
86
67
Directory ? outputDir;
87
68
try {
88
69
// Files to copy generated files to.
89
70
final outputJsPath = resolveSdkJsPath (canaryFeatures: canaryFeatures);
90
- final outputJsMapPath =
91
- resolveSdkSourcemapPath (canaryFeatures: canaryFeatures);
71
+ final outputJsMapPath = resolveSdkSourcemapPath (
72
+ canaryFeatures: canaryFeatures,
73
+ );
92
74
final outputFullDillPath = sdkLayout.fullDillPath;
93
75
94
76
final hasJsAsset = _exists (outputJsPath);
@@ -104,11 +86,12 @@ class SdkAssetGenerator {
104
86
105
87
// Files to generate
106
88
final jsPath = p.join (
107
- outputDir.path, resolveSdkJsFilename (canaryFeatures: canaryFeatures));
89
+ outputDir.path,
90
+ resolveSdkJsFilename (canaryFeatures: canaryFeatures),
91
+ );
108
92
final jsMapPath = p.setExtension (jsPath, '.js.map' );
109
- final fullDillPath = p.setExtension (jsPath, '.dill' );
110
93
111
- _logger.info ('Generating js and full dill SDK files...' );
94
+ _logger.info ('Generating SDK JavaScript and sourcemap files...' );
112
95
113
96
final sdkDirectoryUri = fileSystem.directory (sdkLayout.sdkDirectory).uri;
114
97
final args = < String > [
@@ -123,7 +106,6 @@ class SdkAssetGenerator {
123
106
'org-dartlang-sdk:///lib/libraries.json' ,
124
107
'--modules' ,
125
108
ddcModuleFormat.name,
126
- '--sound-null-safety' ,
127
109
'dart:core' ,
128
110
'-o' ,
129
111
jsPath,
@@ -132,8 +114,11 @@ class SdkAssetGenerator {
132
114
133
115
final output = < String > [];
134
116
_logger.fine ('Executing dart ${args .join (' ' )}' );
135
- final process = await Process .start (sdkLayout.dartPath, args,
136
- workingDirectory: sdkLayout.sdkDirectory);
117
+ final process = await Process .start (
118
+ sdkLayout.dartPath,
119
+ args,
120
+ workingDirectory: sdkLayout.sdkDirectory,
121
+ );
137
122
138
123
process.stdout
139
124
.transform <String >(utf8.decoder)
@@ -164,88 +149,14 @@ class SdkAssetGenerator {
164
149
}
165
150
await _moveAndValidate (jsPath, outputJsPath);
166
151
await _moveAndValidate (jsMapPath, outputJsMapPath);
167
- await _moveAndValidate (fullDillPath, outputFullDillPath);
168
152
169
- _logger.info ('Done generating js and full dill SDK files.' );
153
+ _logger.info ('Done generating SDK JavaScript and sourcemap files.' );
170
154
} catch (e, s) {
171
155
_logger.severe (
172
- 'Failed to generate SDK js, source map, and full dill' , e, s);
173
- rethrow ;
174
- } finally {
175
- outputDir? .deleteSync (recursive: true );
176
- }
177
- }
178
-
179
- Future <void > _generateSdkSummary () async {
180
- Directory ? outputDir;
181
- try {
182
- // Files to copy generated files to.
183
- final outputSummaryPath = sdkLayout.summaryPath;
184
- final hasAssets = _exists (outputSummaryPath);
185
-
186
- // Files already exist.
187
- if (hasAssets) return ;
188
-
189
- // Generate missing files.
190
- outputDir = fileSystem.systemTempDirectory.createTempSync ();
191
- final summaryPath = p.join (outputDir.path, sdkLayout.summaryFileName);
192
-
193
- _logger.info ('Generating SDK summary files...' );
194
-
195
- final sdkDirectoryUri = fileSystem.directory (sdkLayout.sdkDirectory).uri;
196
- final args = < String > [
197
- sdkLayout.kernelWorkerSnapshotPath,
198
- '--target' ,
199
- 'ddc' ,
200
- '--multi-root' ,
201
- '$sdkDirectoryUri ' ,
202
- '--multi-root-scheme' ,
203
- 'org-dartlang-sdk' ,
204
- '--libraries-file' ,
205
- 'org-dartlang-sdk:///lib/libraries.json' ,
206
- '--source' ,
207
- 'dart:core' ,
208
- '--summary-only' ,
209
- '--sound-null-safety' ,
210
- '--output' ,
211
- summaryPath,
212
- if (verbose) '--verbose' ,
213
- ];
214
-
215
- _logger.fine ('Executing dart ${args .join (' ' )}' );
216
- final process = await Process .start (sdkLayout.dartAotRuntimePath, args,
217
- workingDirectory: sdkLayout.sdkDirectory);
218
-
219
- final output = < String > [];
220
- process.stdout
221
- .transform <String >(utf8.decoder)
222
- .transform <String >(const LineSplitter ())
223
- .listen ((line) {
224
- _logger.fine (line);
225
- output.add (line);
226
- });
227
-
228
- process.stderr
229
- .transform <String >(utf8.decoder)
230
- .transform <String >(const LineSplitter ())
231
- .listen ((line) {
232
- _logger.warning (line);
233
- output.add (line);
234
- });
235
-
236
- await process.exitCode.then ((int code) {
237
- if (code != 0 ) {
238
- _logger
239
- .warning ('Error generating $summaryPath : ${output .join ('\n ' )}' );
240
- throw Exception ('The Dart kernel worker exited unexpectedly' );
241
- }
242
- });
243
-
244
- await _moveAndValidate (summaryPath, outputSummaryPath);
245
-
246
- _logger.info ('Done generating SDK summary files.' );
247
- } catch (e, s) {
248
- _logger.severe ('Failed to generate SDK summary' , e, s);
156
+ 'Failed to generate SDK JavaScript and sourcemap files' ,
157
+ e,
158
+ s,
159
+ );
249
160
rethrow ;
250
161
} finally {
251
162
outputDir? .deleteSync (recursive: true );
0 commit comments