Skip to content

Commit 5d5efbf

Browse files
authored
fix experiment support in ddc (#3178)
Previously we only passed experiments to Kernel, which was enough for null-safety to work but not for constructor-tearoffs. I also marked the old `experiments` option as deprecated so you will get a warning if using it.
1 parent 85900b1 commit 5d5efbf

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

build_web_compilers/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
## 3.2.1-dev
1+
## 3.2.1
22

3+
- Fix enable-experiment flag support for dartdevc to also pass experiment flags
4+
to dartdevc as well as kernel.
5+
- Add deprecation warning for the old `experiments` config.
36
- Update `pub run` references to `dart run`.
47
- Fix `doctor` command warnings for this package.
58

build_web_compilers/lib/builders.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Builder ddcBuilderUnsound(BuilderOptions options) =>
2727
ddcBuilder(options, soundNullSafety: false);
2828

2929
Builder ddcBuilder(BuilderOptions options, {bool soundNullSafety = false}) {
30-
validateOptions(options.config, _supportedOptions, 'build_web_compilers:ddc');
30+
validateOptions(options.config, _supportedOptions, 'build_web_compilers:ddc',
31+
deprecatedOptions: _deprecatedOptions);
3132
_ensureSameDdcOptions(options);
3233

3334
return DevCompilerBuilder(
@@ -50,7 +51,8 @@ Builder ddcKernelBuilderSound(BuilderOptions options) =>
5051

5152
Builder ddcKernelBuilder(BuilderOptions options,
5253
{bool soundNullSafety = false}) {
53-
validateOptions(options.config, _supportedOptions, 'build_web_compilers:ddc');
54+
validateOptions(options.config, _supportedOptions, 'build_web_compilers:ddc',
55+
deprecatedOptions: _deprecatedOptions);
5456
_ensureSameDdcOptions(options);
5557

5658
return KernelBuilder(
@@ -135,9 +137,11 @@ const _emitDebugSymbolsOption = 'emit-debug-symbols';
135137
const _trackUnusedInputsCompilerOption = 'track-unused-inputs';
136138
const _environmentOption = 'environment';
137139
const _experimentOption = 'experiments';
140+
const _deprecatedOptions = [
141+
_experimentOption,
142+
];
138143
const _supportedOptions = [
139144
_environmentOption,
140-
_experimentOption,
141145
_useIncrementalCompilerOption,
142146
_generateFullDillOption,
143147
_emitDebugSymbolsOption,

build_web_compilers/lib/src/dev_compiler_builder.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:io';
88

99
import 'package:bazel_worker/bazel_worker.dart';
1010
import 'package:build/build.dart';
11+
import 'package:build/experiments.dart';
1112
import 'package:build_modules/build_modules.dart';
1213
import 'package:path/path.dart' as p;
1314
import 'package:scratch_space/scratch_space.dart';
@@ -76,9 +77,6 @@ class DevCompilerBuilder implements Builder {
7677
/// Environment defines to pass to ddc (as -D variables).
7778
final Map<String, String> environment;
7879

79-
/// Experiments to pass to ddc (as --enable-experiment=<experiment> args).
80-
final Iterable<String> experiments;
81-
8280
/// Whether or not strong null safety should be enabled.
8381
final bool soundNullSafety;
8482

@@ -92,7 +90,6 @@ class DevCompilerBuilder implements Builder {
9290
String? librariesPath,
9391
String? platformSdk,
9492
this.environment = const {},
95-
this.experiments = const [],
9693
this.soundNullSafety = false})
9794
: platformSdk = platformSdk ?? sdkDir,
9895
librariesPath = librariesPath ??
@@ -144,7 +141,6 @@ class DevCompilerBuilder implements Builder {
144141
sdkKernelPath,
145142
librariesPath,
146143
environment,
147-
experiments,
148144
soundNullSafety);
149145
} on DartDevcCompilationException catch (e) {
150146
await handleError(e);
@@ -166,7 +162,6 @@ Future<void> _createDevCompilerModule(
166162
String sdkKernelPath,
167163
String librariesPath,
168164
Map<String, String> environment,
169-
Iterable<String> experiments,
170165
bool soundNullSafety,
171166
{bool debugMode = true}) async {
172167
var transitiveDeps = await buildStep.trackStage('CollectTransitiveDeps',
@@ -228,7 +223,8 @@ Future<void> _createDevCompilerModule(
228223
'--used-inputs-file=${usedInputsFile.uri.toFilePath()}',
229224
for (var source in module.sources) _sourceArg(source),
230225
for (var define in environment.entries) '-D${define.key}=${define.value}',
231-
for (var experiment in experiments) '--enable-experiment=$experiment',
226+
for (var experiment in enabledExperiments)
227+
'--enable-experiment=$experiment',
232228
'--${soundNullSafety ? '' : 'no-'}sound-null-safety',
233229
])
234230
..inputs.add(Input()

build_web_compilers/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_web_compilers
2-
version: 3.2.1-dev
2+
version: 3.2.1
33
description: Builder implementations wrapping Dart compilers.
44
repository: https://github.com/dart-lang/build/tree/master/build_web_compilers
55

0 commit comments

Comments
 (0)