From bb4a83b1f043ea35e41bb7bcf0902b57cdf39f7a Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Thu, 24 Jul 2025 15:26:18 -0700 Subject: [PATCH 1/2] Update builds for SDK assets in tests - Remove `--sound-null-safety` flag. It is currently ignored but will be removed in a future version. - Stop building any SDK .dill files. Some of these were needed for unsound builds after the release of Dart 3.0 but currently the full and outline .dill files are packaged and distributed with the SDK. --- test_common/lib/sdk_asset_generator.dart | 145 +++++------------------ test_common/lib/test_sdk_layout.dart | 7 +- 2 files changed, 34 insertions(+), 118 deletions(-) diff --git a/test_common/lib/sdk_asset_generator.dart b/test_common/lib/sdk_asset_generator.dart index 617589495..341556ef2 100644 --- a/test_common/lib/sdk_asset_generator.dart +++ b/test_common/lib/sdk_asset_generator.dart @@ -8,10 +8,7 @@ import 'package:logging/logging.dart'; import 'package:path/path.dart' as p; import 'package:test_common/test_sdk_layout.dart'; -/// Generates sdk.js, sdk.map, sdk full dill, and sdk summary files. -/// -/// Generates following missing assets if needed: -/// - js, source map, full dill. +/// Generates sdk.js, sdk.map, files. class SdkAssetGenerator { bool _sdkAssetsGenerated = false; @@ -37,58 +34,43 @@ class SdkAssetGenerator { if (!_sdkAssetsGenerated) { _sdkAssetsGenerated = true; - // SDK contains sound summary, but SDK js and full dill are - // normally generated by setup tools and their builds, + // SDK full and outline .dill files are shipped with the SDK, + // but the JavaScript and sourcemaps are generated by other tooling // i.e. flutter SDK or build_web_compilers. // Generate missing files for tests if needed. - await _generateSdkJavaScript( - canaryFeatures: canaryFeatures, - ); - - // SDK does not contain any weak assets, generate them. - await _generateSdkJavaScript( - canaryFeatures: canaryFeatures, - ); - await _generateSdkSummary(); + await _generateSdkJavaScript(canaryFeatures: canaryFeatures); } } - String resolveSdkJsPath({ - required bool canaryFeatures, - }) => + String resolveSdkJsPath({required bool canaryFeatures}) => switch (ddcModuleFormat) { ModuleFormat.amd => sdkLayout.amdJsPath, ModuleFormat.ddc => sdkLayout.ddcJsPath, - _ => throw Exception('Unsupported DDC module format $ddcModuleFormat.') + _ => throw Exception('Unsupported DDC module format $ddcModuleFormat.'), }; - String resolveSdkSourcemapPath({ - required bool canaryFeatures, - }) => + String resolveSdkSourcemapPath({required bool canaryFeatures}) => switch (ddcModuleFormat) { ModuleFormat.amd => sdkLayout.amdJsMapPath, ModuleFormat.ddc => sdkLayout.ddcJsMapPath, - _ => throw Exception('Unsupported DDC module format $ddcModuleFormat.') + _ => throw Exception('Unsupported DDC module format $ddcModuleFormat.'), }; - String resolveSdkJsFilename({ - required bool canaryFeatures, - }) => + String resolveSdkJsFilename({required bool canaryFeatures}) => switch (ddcModuleFormat) { ModuleFormat.amd => sdkLayout.amdJsFileName, ModuleFormat.ddc => sdkLayout.ddcJsFileName, - _ => throw Exception('Unsupported DDC module format $ddcModuleFormat.') + _ => throw Exception('Unsupported DDC module format $ddcModuleFormat.'), }; - Future _generateSdkJavaScript({ - required bool canaryFeatures, - }) async { + Future _generateSdkJavaScript({required bool canaryFeatures}) async { Directory? outputDir; try { // Files to copy generated files to. final outputJsPath = resolveSdkJsPath(canaryFeatures: canaryFeatures); - final outputJsMapPath = - resolveSdkSourcemapPath(canaryFeatures: canaryFeatures); + final outputJsMapPath = resolveSdkSourcemapPath( + canaryFeatures: canaryFeatures, + ); final outputFullDillPath = sdkLayout.fullDillPath; final hasJsAsset = _exists(outputJsPath); @@ -104,11 +86,12 @@ class SdkAssetGenerator { // Files to generate final jsPath = p.join( - outputDir.path, resolveSdkJsFilename(canaryFeatures: canaryFeatures)); + outputDir.path, + resolveSdkJsFilename(canaryFeatures: canaryFeatures), + ); final jsMapPath = p.setExtension(jsPath, '.js.map'); - final fullDillPath = p.setExtension(jsPath, '.dill'); - _logger.info('Generating js and full dill SDK files...'); + _logger.info('Generating SDK JavaScript and sourcemap files...'); final sdkDirectoryUri = fileSystem.directory(sdkLayout.sdkDirectory).uri; final args = [ @@ -123,7 +106,6 @@ class SdkAssetGenerator { 'org-dartlang-sdk:///lib/libraries.json', '--modules', ddcModuleFormat.name, - '--sound-null-safety', 'dart:core', '-o', jsPath, @@ -132,8 +114,11 @@ class SdkAssetGenerator { final output = []; _logger.fine('Executing dart ${args.join(' ')}'); - final process = await Process.start(sdkLayout.dartPath, args, - workingDirectory: sdkLayout.sdkDirectory); + final process = await Process.start( + sdkLayout.dartPath, + args, + workingDirectory: sdkLayout.sdkDirectory, + ); process.stdout .transform(utf8.decoder) @@ -164,88 +149,14 @@ class SdkAssetGenerator { } await _moveAndValidate(jsPath, outputJsPath); await _moveAndValidate(jsMapPath, outputJsMapPath); - await _moveAndValidate(fullDillPath, outputFullDillPath); - _logger.info('Done generating js and full dill SDK files.'); + _logger.info('Done generating SDK JavaScript and sourcemap files.'); } catch (e, s) { _logger.severe( - 'Failed to generate SDK js, source map, and full dill', e, s); - rethrow; - } finally { - outputDir?.deleteSync(recursive: true); - } - } - - Future _generateSdkSummary() async { - Directory? outputDir; - try { - // Files to copy generated files to. - final outputSummaryPath = sdkLayout.summaryPath; - final hasAssets = _exists(outputSummaryPath); - - // Files already exist. - if (hasAssets) return; - - // Generate missing files. - outputDir = fileSystem.systemTempDirectory.createTempSync(); - final summaryPath = p.join(outputDir.path, sdkLayout.summaryFileName); - - _logger.info('Generating SDK summary files...'); - - final sdkDirectoryUri = fileSystem.directory(sdkLayout.sdkDirectory).uri; - final args = [ - sdkLayout.kernelWorkerSnapshotPath, - '--target', - 'ddc', - '--multi-root', - '$sdkDirectoryUri', - '--multi-root-scheme', - 'org-dartlang-sdk', - '--libraries-file', - 'org-dartlang-sdk:///lib/libraries.json', - '--source', - 'dart:core', - '--summary-only', - '--sound-null-safety', - '--output', - summaryPath, - if (verbose) '--verbose', - ]; - - _logger.fine('Executing dart ${args.join(' ')}'); - final process = await Process.start(sdkLayout.dartAotRuntimePath, args, - workingDirectory: sdkLayout.sdkDirectory); - - final output = []; - process.stdout - .transform(utf8.decoder) - .transform(const LineSplitter()) - .listen((line) { - _logger.fine(line); - output.add(line); - }); - - process.stderr - .transform(utf8.decoder) - .transform(const LineSplitter()) - .listen((line) { - _logger.warning(line); - output.add(line); - }); - - await process.exitCode.then((int code) { - if (code != 0) { - _logger - .warning('Error generating $summaryPath: ${output.join('\n')}'); - throw Exception('The Dart kernel worker exited unexpectedly'); - } - }); - - await _moveAndValidate(summaryPath, outputSummaryPath); - - _logger.info('Done generating SDK summary files.'); - } catch (e, s) { - _logger.severe('Failed to generate SDK summary', e, s); + 'Failed to generate SDK JavaScript and sourcemap files', + e, + s, + ); rethrow; } finally { outputDir?.deleteSync(recursive: true); diff --git a/test_common/lib/test_sdk_layout.dart b/test_common/lib/test_sdk_layout.dart index 7218a60e2..f9d57596f 100644 --- a/test_common/lib/test_sdk_layout.dart +++ b/test_common/lib/test_sdk_layout.dart @@ -27,7 +27,12 @@ class TestSdkLayout { factory TestSdkLayout.createDefaultFromSdkLayout(SdkLayout sdkLayout) => TestSdkLayout( sdkDirectory: sdkLayout.sdkDirectory, - summaryPath: sdkLayout.summaryPath, + summaryPath: p.join( + sdkLayout.sdkDirectory, + 'lib', + '_internal', + 'ddc_outline.dill', + ), fullDillPath: p.join( sdkLayout.sdkDirectory, 'lib', From a4c6d82531978b64fdb8d8851b5410ba8957a4db Mon Sep 17 00:00:00 2001 From: Nicholas Shahan Date: Thu, 24 Jul 2025 15:44:05 -0700 Subject: [PATCH 2/2] update asset generator test --- test_common/test/sdk_asset_generator_test.dart | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test_common/test/sdk_asset_generator_test.dart b/test_common/test/sdk_asset_generator_test.dart index 21adc1058..02b408065 100644 --- a/test_common/test/sdk_asset_generator_test.dart +++ b/test_common/test/sdk_asset_generator_test.dart @@ -20,11 +20,9 @@ void main() { late Directory tempDir; late String sdkDirectory; - late String sdkSummaryPath; late String compilerWorkerPath; // Missing assets - late String sdkFullDillPath; late String amdSdkJsPath; late String amdSdkJsMapPath; late String ddcSdkJsPath; @@ -37,20 +35,17 @@ void main() { sdkDirectory = tempDir.path; final copySdkLayout = TestSdkLayout.createDefault(sdkDirectory); - sdkSummaryPath = copySdkLayout.summaryPath; compilerWorkerPath = copySdkLayout.dartdevcSnapshotPath; // Copy the SDK directory into a temp directory. await copyDirectory(TestSdkLayout.defaultSdkDirectory, sdkDirectory); // Simulate missing assets. - sdkFullDillPath = copySdkLayout.fullDillPath; amdSdkJsPath = copySdkLayout.amdJsPath; amdSdkJsMapPath = copySdkLayout.amdJsMapPath; ddcSdkJsPath = copySdkLayout.ddcJsPath; ddcSdkJsMapPath = copySdkLayout.ddcJsMapPath; - _deleteIfExists(sdkFullDillPath); _deleteIfExists(amdSdkJsPath); _deleteIfExists(amdSdkJsMapPath); _deleteIfExists(ddcSdkJsPath); @@ -79,8 +74,6 @@ void main() { expect(configuration.sdkDirectory, equals(sdkDirectory)); expect(configuration.compilerWorkerPath, equals(compilerWorkerPath)); - expect(sdkLayout.summaryPath, equals(sdkSummaryPath)); - expect(sdkLayout.fullDillPath, equals(sdkFullDillPath)); expect(sdkLayout.amdJsPath, equals(amdSdkJsPath)); expect(sdkLayout.amdJsMapPath, equals(amdSdkJsMapPath)); @@ -89,8 +82,6 @@ void main() { configuration.validate(); // Validate all assets exist. - expect(sdkLayout.summaryPath, _exists); - expect(sdkLayout.fullDillPath, _exists); expect(sdkLayout.amdJsPath, _exists); expect(sdkLayout.amdJsMapPath, _exists); }); @@ -113,8 +104,6 @@ void main() { expect(configuration.sdkDirectory, equals(sdkDirectory)); expect(configuration.compilerWorkerPath, equals(compilerWorkerPath)); - expect(sdkLayout.summaryPath, equals(sdkSummaryPath)); - expect(sdkLayout.fullDillPath, equals(sdkFullDillPath)); expect(sdkLayout.ddcJsPath, equals(ddcSdkJsPath)); expect(sdkLayout.ddcJsMapPath, equals(ddcSdkJsMapPath)); @@ -123,8 +112,6 @@ void main() { configuration.validate(); // Validate all assets exist. - expect(sdkLayout.summaryPath, _exists); - expect(sdkLayout.fullDillPath, _exists); expect(sdkLayout.ddcJsPath, _exists); expect(sdkLayout.ddcJsMapPath, _exists); });