mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
[dart2wasm] Wire up cfe experimental flags.
Change-Id: Iab9b3a5997e63e61a42bc4fb27825b345ae63ab1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264060 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Jake Macdonald <jakemac@google.com>
This commit is contained in:
parent
30de5494d5
commit
204c03a98e
|
@ -8,6 +8,7 @@ import 'dart:typed_data';
|
|||
import 'package:args/args.dart' as args;
|
||||
import 'package:front_end/src/api_unstable/vm.dart'
|
||||
show printDiagnosticMessage, resolveInputUri;
|
||||
import 'package:front_end/src/api_unstable/vm.dart' as fe;
|
||||
|
||||
import 'package:dart2wasm/compile.dart';
|
||||
import 'package:dart2wasm/compiler_options.dart';
|
||||
|
@ -51,9 +52,17 @@ final List<Option> options = [
|
|||
"watch", (o, values) => o.translatorOptions.watchPoints = values),
|
||||
StringMultiOption(
|
||||
"define", (o, values) => o.environment = processEnvironment(values),
|
||||
abbr: "D")
|
||||
abbr: "D"),
|
||||
StringMultiOption("enable-experiment",
|
||||
(o, values) => o.feExperimentalFlags = processFeExperimentalFlags(values))
|
||||
];
|
||||
|
||||
Map<fe.ExperimentalFlag, bool> processFeExperimentalFlags(
|
||||
List<String> experiments) =>
|
||||
fe.parseExperimentalFlags(fe.parseExperimentalArguments(experiments),
|
||||
onError: (error) => throw ArgumentError(error),
|
||||
onWarning: (warning) => print(warning));
|
||||
|
||||
Map<String, String> processEnvironment(List<String> defines) =>
|
||||
Map<String, String>.fromEntries(defines.map((d) {
|
||||
List<String> keyAndValue = d.split('=');
|
||||
|
|
|
@ -48,6 +48,7 @@ Future<Uint8List?> compileToModule(compiler.CompilerOptions options,
|
|||
..librariesSpecificationUri = options.librariesSpecPath
|
||||
..packagesFileUri = options.packagesPath
|
||||
..environmentDefines = options.environment
|
||||
..explicitExperimentalFlags = options.feExperimentalFlags
|
||||
..verbose = false
|
||||
..onDiagnostic = diagnosticMessageHandler
|
||||
..nnbdMode = NnbdMode.Strong;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:dart2wasm/translator.dart';
|
||||
import 'package:front_end/src/api_unstable/vm.dart' as fe;
|
||||
|
||||
class CompilerOptions {
|
||||
final TranslatorOptions translatorOptions = TranslatorOptions();
|
||||
|
@ -16,6 +17,7 @@ class CompilerOptions {
|
|||
Uri mainUri;
|
||||
String outputFile;
|
||||
Map<String, String> environment = const {};
|
||||
Map<fe.ExperimentalFlag, bool> feExperimentalFlags = const {};
|
||||
|
||||
factory CompilerOptions.defaultOptions() =>
|
||||
CompilerOptions(mainUri: Uri(), outputFile: '');
|
||||
|
|
|
@ -529,6 +529,8 @@ class Dart2WasmCompilerConfiguration extends CompilerConfiguration {
|
|||
TestFile testFile, List<String> vmOptions, List<String> args) {
|
||||
return [
|
||||
...testFile.sharedOptions,
|
||||
..._configuration.sharedOptions,
|
||||
..._experimentsArgument(_configuration, testFile),
|
||||
// The file being compiled is the last argument.
|
||||
args.last
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue