Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a standalone process to compile DDC dart_sdk.js files #3348

Merged
merged 2 commits into from Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion _test_null_safety/test/disable_sound_null_safety_test.dart
Expand Up @@ -4,7 +4,6 @@

// Disabling sound null safety is only supported on the web right now.
@TestOn('browser')
@Skip('https://github.com/dart-lang/build/issues/3332')
import 'package:test/test.dart';

const weakMode = <int?>[] is List<int>;
Expand Down
1 change: 0 additions & 1 deletion _test_null_safety/test/null_assertions_test.dart
Expand Up @@ -6,7 +6,6 @@
// @dart=2.9

// Null assertions are only supported on the web right now.
@Skip('https://github.com/dart-lang/build/issues/3332')
@TestOn('browser')
import 'package:test/test.dart';

Expand Down
1 change: 0 additions & 1 deletion _test_null_safety/test/opted_out_test.dart
Expand Up @@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
//
// @dart=2.7
@Skip('https://github.com/dart-lang/build/issues/3332')
import 'package:test/test.dart';

import 'common/message.dart';
Expand Down
4 changes: 4 additions & 0 deletions build_web_compilers/CHANGELOG.md
@@ -1,3 +1,7 @@
## 3.2.5

- Use a standalone process to compile the ddc sdk.js file.

## 3.2.4

- Use `dart compile js` instead of running dart2js from its sdk snapshot.
Expand Down
20 changes: 8 additions & 12 deletions build_web_compilers/lib/src/sdk_js_compile_builder.dart
Expand Up @@ -82,8 +82,12 @@ Future<void> _createDevCompilerModule(
var scratchSpace = await buildStep.fetchResource(scratchSpaceResource);
var jsOutputFile = scratchSpace.fileFor(jsOutputId);

var request = WorkRequest()
..arguments.addAll([
ProcessResult result;
try {
// Use standalone process instead of the worker due to
// https://github.com/dart-lang/sdk/issues/49441
result = await Process.run(p.join(sdkDir, 'bin', 'dart'), [
p.join(sdkDir, 'bin', 'snapshots', 'dartdevc.dart.snapshot'),
'--multi-root-scheme=org-dartlang-sdk',
'--modules=amd',
'--module-name=dart_sdk',
Expand All @@ -92,22 +96,14 @@ Future<void> _createDevCompilerModule(
jsOutputFile.path,
p.url.join(dartSdk, sdkKernelPath),
]);

var driverResource = dartdevkDriverResource;
var driver = await buildStep.fetchResource(driverResource);
WorkResponse response;
try {
response = await driver.doWork(request,
trackWork: (response) =>
buildStep.trackStage('Compile', () => response, isExternal: true));
} catch (e) {
throw DartDevcCompilationException(jsOutputId, e.toString());
}

var message = response.output
var message = '${result.stdout}${result.stderr}'
.replaceAll('${scratchSpace.tempDir.path}/', '')
.replaceAll('org-dartlang-sdk:///', '');
if (response.exitCode != EXIT_CODE_OK ||
if (result.exitCode != EXIT_CODE_OK ||
!jsOutputFile.existsSync() ||
message.contains('Error:')) {
throw DartDevcCompilationException(jsOutputId, message);
Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/pubspec.yaml
@@ -1,5 +1,5 @@
name: build_web_compilers
version: 3.2.4
version: 3.2.5
description: Builder implementations wrapping Dart compilers.
repository: https://github.com/dart-lang/build/tree/master/build_web_compilers

Expand Down