Skip to content

Commit 316ae9b

Browse files
author
Anna Gringauze
authored
Add --canary option to build web compilers (#3536)
* Add --canary option to build web compilers * Prepare to release build_web_compilers * Update pubspec and build
1 parent ac65c07 commit 316ae9b

9 files changed

+3923
-3673
lines changed

build_web_compilers/CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
## 4.0.4-wip
1+
## 4.0.4
2+
3+
- Add the `canary` option for `build_web_compilers:ddc` and
4+
`build_web_compilers:sdk_js`builders to enable canary features
5+
in DDC. This setting is disabled by default but can be enabled
6+
by setting it to `true` globally:
7+
8+
```yaml
9+
global_options:
10+
build_web_compilers:ddc:
11+
options:
12+
canary: true
13+
build_web_compilers:sdk_js:
14+
options:
15+
canary: true
16+
```
217
318
## 4.0.3
419

build_web_compilers/lib/builders.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Builder ddcBuilder(BuilderOptions options) {
2929
useIncrementalCompiler: _readUseIncrementalCompilerOption(options),
3030
generateFullDill: _readGenerateFullDillOption(options),
3131
emitDebugSymbols: _readEmitDebugSymbolsOption(options),
32+
canaryFeatures: _readCanaryOption(options),
3233
sdkKernelPath: sdkDdcKernelPath,
3334
trackUnusedInputs: _readTrackInputsCompilerOption(options),
3435
platform: ddcPlatform,
@@ -52,9 +53,11 @@ Builder ddcKernelBuilder(BuilderOptions options) {
5253
}
5354

5455
Builder sdkJsCopyRequirejs(_) => SdkJsCopyBuilder();
55-
Builder sdkJsCompile(_) => SdkJsCompileBuilder(
56-
sdkKernelPath: 'lib/_internal/ddc_platform.dill',
57-
outputPath: 'lib/src/dev_compiler/dart_sdk.js');
56+
Builder sdkJsCompile(BuilderOptions options) => SdkJsCompileBuilder(
57+
sdkKernelPath: 'lib/_internal/ddc_platform.dill',
58+
outputPath: 'lib/src/dev_compiler/dart_sdk.js',
59+
canaryFeatures: _readCanaryOption(options),
60+
);
5861

5962
// Dart2js related builders
6063
Builder dart2jsMetaModuleBuilder(BuilderOptions options) =>
@@ -102,6 +105,10 @@ bool _readEmitDebugSymbolsOption(BuilderOptions options) {
102105
return options.config[_emitDebugSymbolsOption] as bool? ?? false;
103106
}
104107

108+
bool _readCanaryOption(BuilderOptions options) {
109+
return options.config[_canaryOption] as bool? ?? false;
110+
}
111+
105112
bool _readTrackInputsCompilerOption(BuilderOptions options) {
106113
return options.config[_trackUnusedInputsCompilerOption] as bool? ?? true;
107114
}
@@ -115,6 +122,7 @@ Map<String, dynamic>? _previousDdcConfig;
115122
const _useIncrementalCompilerOption = 'use-incremental-compiler';
116123
const _generateFullDillOption = 'generate-full-dill';
117124
const _emitDebugSymbolsOption = 'emit-debug-symbols';
125+
const _canaryOption = 'canary';
118126
const _trackUnusedInputsCompilerOption = 'track-unused-inputs';
119127
const _environmentOption = 'environment';
120128

@@ -123,5 +131,6 @@ const _supportedOptions = [
123131
_useIncrementalCompilerOption,
124132
_generateFullDillOption,
125133
_emitDebugSymbolsOption,
134+
_canaryOption,
126135
_trackUnusedInputsCompilerOption,
127136
];

build_web_compilers/lib/src/dev_compiler_builder.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class DevCompilerBuilder implements Builder {
4747
/// watch, expression evaluation, and variable inspection windows.
4848
final bool emitDebugSymbols;
4949

50+
/// Enables canary features in DDC.
51+
final bool canaryFeatures;
52+
5053
final bool trackUnusedInputs;
5154

5255
final DartPlatform platform;
@@ -75,6 +78,7 @@ class DevCompilerBuilder implements Builder {
7578
{this.useIncrementalCompiler = true,
7679
this.generateFullDill = false,
7780
this.emitDebugSymbols = false,
81+
this.canaryFeatures = false,
7882
this.trackUnusedInputs = false,
7983
required this.platform,
8084
String? sdkKernelPath,
@@ -124,6 +128,7 @@ class DevCompilerBuilder implements Builder {
124128
useIncrementalCompiler,
125129
generateFullDill,
126130
emitDebugSymbols,
131+
canaryFeatures,
127132
trackUnusedInputs,
128133
platformSdk,
129134
sdkKernelPath,
@@ -144,6 +149,7 @@ Future<void> _createDevCompilerModule(
144149
bool useIncrementalCompiler,
145150
bool generateFullDill,
146151
bool emitDebugSymbols,
152+
bool canaryFeatures,
147153
bool trackUnusedInputs,
148154
String dartSdk,
149155
String sdkKernelPath,
@@ -188,6 +194,7 @@ Future<void> _createDevCompilerModule(
188194
'--no-summarize',
189195
if (generateFullDill) '--experimental-output-compiled-kernel',
190196
if (emitDebugSymbols) '--emit-debug-symbols',
197+
if (canaryFeatures) '--canary',
191198
'-o',
192199
jsOutputFile.path,
193200
debugMode ? '--source-map' : '--no-source-map',

0 commit comments

Comments
 (0)