-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support compiling to wasm in
build_web_compilers
(#3727)
Add `dart2wasm` as a compiler option for `build_web_compilers`.
- Loading branch information
Showing
26 changed files
with
500 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
targets: | ||
$default: | ||
builders: | ||
build_web_compilers:entrypoint: | ||
options: | ||
compiler: dart2wasm | ||
dart2wasm_args: | ||
- --enable-asserts | ||
- -O0 | ||
release_options: | ||
compiler: dart2wasm | ||
dart2wasm_args: | ||
- --enable-asserts | ||
- -O4 | ||
generate_for: | ||
- web/main.dart | ||
- web/sub/main.dart | ||
- test/configurable_uri_test.dart | ||
- test/configurable_uri_test.dart.browser_test.dart | ||
- test/hello_world_test.dart | ||
- test/hello_world_test.dart.browser_test.dart | ||
- test/hello_world_deferred_test.dart | ||
- test/hello_world_deferred_test.dart.browser_test.dart | ||
- test/hello_world_custom_html_test.dart | ||
- test/hello_world_custom_html_test.dart.browser_test.dart | ||
- test/other_test.dart.browser_test.dart | ||
- test/sub-dir/subdir_test.dart | ||
- test/sub-dir/subdir_test.dart.browser_test.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
String get message => 'Hello World from WebAssembly!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
@TestOn('vm') | ||
@Tags(['integration']) | ||
library; | ||
|
||
import 'dart:async'; | ||
|
||
import 'package:test/test.dart'; | ||
import 'package:test_descriptor/test_descriptor.dart' as d; | ||
|
||
import 'common/utils.dart'; | ||
|
||
// This doesn't actually change anything since we're using precompiled tests, | ||
// but it gets the compiler selector in tests right. | ||
const _testArgs = ['-c', 'dart2wasm']; | ||
|
||
void main() { | ||
group('Can run tests using dart2wasm', () { | ||
test('via build.yaml config flag', () async { | ||
await expectTestsPass( | ||
usePrecompiled: true, | ||
buildArgs: [ | ||
'--config=dart2wasm', | ||
'--output=${d.sandbox}', | ||
], | ||
testArgs: _testArgs, | ||
); | ||
await _expectWasCompiledWithDart2Wasm(); | ||
}, onPlatform: {'windows': const Skip('flaky on windows')}); | ||
|
||
test('via --define flag', () async { | ||
await expectTestsPass( | ||
usePrecompiled: true, | ||
buildArgs: [ | ||
'--define', | ||
'build_web_compilers:entrypoint=compiler=dart2wasm', | ||
'--define', | ||
'build_web_compilers:entrypoint=dart2wasm_args=' | ||
'["--enable-asserts", "-E--enable-experimental-ffi"]', | ||
'--output=${d.sandbox}', | ||
], | ||
testArgs: _testArgs, | ||
); | ||
await _expectWasCompiledWithDart2Wasm(); | ||
}, onPlatform: {'windows': const Skip('flaky on windows')}); | ||
|
||
test('via --release mode', () async { | ||
await expectTestsPass( | ||
usePrecompiled: true, | ||
buildArgs: [ | ||
'--release', | ||
'--config=dart2wasm', | ||
'--output=${d.sandbox}', | ||
], | ||
testArgs: _testArgs, | ||
); | ||
await _expectWasCompiledWithDart2Wasm(); | ||
}, onPlatform: {'windows': const Skip('flaky on windows')}); | ||
}); | ||
} | ||
|
||
Future<void> _expectWasCompiledWithDart2Wasm() async { | ||
await d.dir( | ||
'test', | ||
[ | ||
d.file( | ||
'hello_world_deferred_test.dart.browser_test.wasm', | ||
anything, | ||
), | ||
], | ||
).validate(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.