@@ -8,10 +8,7 @@ import 'package:logging/logging.dart';
88import 'package:path/path.dart' as p;
99import 'package:test_common/test_sdk_layout.dart' ;
1010
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.
1512
1613class SdkAssetGenerator {
1714 bool _sdkAssetsGenerated = false ;
@@ -37,58 +34,43 @@ class SdkAssetGenerator {
3734 if (! _sdkAssetsGenerated) {
3835 _sdkAssetsGenerated = true ;
3936
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
4239 // i.e. flutter SDK or build_web_compilers.
4340 // 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);
5342 }
5443 }
5544
56- String resolveSdkJsPath ({
57- required bool canaryFeatures,
58- }) =>
45+ String resolveSdkJsPath ({required bool canaryFeatures}) =>
5946 switch (ddcModuleFormat) {
6047 ModuleFormat .amd => sdkLayout.amdJsPath,
6148 ModuleFormat .ddc => sdkLayout.ddcJsPath,
62- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
49+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
6350 };
6451
65- String resolveSdkSourcemapPath ({
66- required bool canaryFeatures,
67- }) =>
52+ String resolveSdkSourcemapPath ({required bool canaryFeatures}) =>
6853 switch (ddcModuleFormat) {
6954 ModuleFormat .amd => sdkLayout.amdJsMapPath,
7055 ModuleFormat .ddc => sdkLayout.ddcJsMapPath,
71- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
56+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
7257 };
7358
74- String resolveSdkJsFilename ({
75- required bool canaryFeatures,
76- }) =>
59+ String resolveSdkJsFilename ({required bool canaryFeatures}) =>
7760 switch (ddcModuleFormat) {
7861 ModuleFormat .amd => sdkLayout.amdJsFileName,
7962 ModuleFormat .ddc => sdkLayout.ddcJsFileName,
80- _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' )
63+ _ => throw Exception ('Unsupported DDC module format $ddcModuleFormat .' ),
8164 };
8265
83- Future <void > _generateSdkJavaScript ({
84- required bool canaryFeatures,
85- }) async {
66+ Future <void > _generateSdkJavaScript ({required bool canaryFeatures}) async {
8667 Directory ? outputDir;
8768 try {
8869 // Files to copy generated files to.
8970 final outputJsPath = resolveSdkJsPath (canaryFeatures: canaryFeatures);
90- final outputJsMapPath =
91- resolveSdkSourcemapPath (canaryFeatures: canaryFeatures);
71+ final outputJsMapPath = resolveSdkSourcemapPath (
72+ canaryFeatures: canaryFeatures,
73+ );
9274 final outputFullDillPath = sdkLayout.fullDillPath;
9375
9476 final hasJsAsset = _exists (outputJsPath);
@@ -104,11 +86,12 @@ class SdkAssetGenerator {
10486
10587 // Files to generate
10688 final jsPath = p.join (
107- outputDir.path, resolveSdkJsFilename (canaryFeatures: canaryFeatures));
89+ outputDir.path,
90+ resolveSdkJsFilename (canaryFeatures: canaryFeatures),
91+ );
10892 final jsMapPath = p.setExtension (jsPath, '.js.map' );
109- final fullDillPath = p.setExtension (jsPath, '.dill' );
11093
111- _logger.info ('Generating js and full dill SDK files...' );
94+ _logger.info ('Generating SDK JavaScript and sourcemap files...' );
11295
11396 final sdkDirectoryUri = fileSystem.directory (sdkLayout.sdkDirectory).uri;
11497 final args = < String > [
@@ -123,7 +106,6 @@ class SdkAssetGenerator {
123106 'org-dartlang-sdk:///lib/libraries.json' ,
124107 '--modules' ,
125108 ddcModuleFormat.name,
126- '--sound-null-safety' ,
127109 'dart:core' ,
128110 '-o' ,
129111 jsPath,
@@ -132,8 +114,11 @@ class SdkAssetGenerator {
132114
133115 final output = < String > [];
134116 _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+ );
137122
138123 process.stdout
139124 .transform <String >(utf8.decoder)
@@ -164,88 +149,14 @@ class SdkAssetGenerator {
164149 }
165150 await _moveAndValidate (jsPath, outputJsPath);
166151 await _moveAndValidate (jsMapPath, outputJsMapPath);
167- await _moveAndValidate (fullDillPath, outputFullDillPath);
168152
169- _logger.info ('Done generating js and full dill SDK files.' );
153+ _logger.info ('Done generating SDK JavaScript and sourcemap files.' );
170154 } catch (e, s) {
171155 _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+ );
249160 rethrow ;
250161 } finally {
251162 outputDir? .deleteSync (recursive: true );
0 commit comments