Skip to content

Add --canary option to build web compilers #3536

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

Merged
merged 3 commits into from
Jun 28, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion build_web_compilers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
## 4.0.4-wip
## 4.0.4

- Add the `canary` option for `build_web_compilers:ddc` and
`build_web_compilers:sdk_js`builders to enable canary features
in DDC. This setting is disabled by default but can be enabled
by setting it to `true` globally:

```yaml
global_options:
build_web_compilers:ddc:
options:
canary: true
build_web_compilers:sdk_js:
options:
canary: true
```

## 4.0.3

Expand Down
15 changes: 12 additions & 3 deletions build_web_compilers/lib/builders.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Builder ddcBuilder(BuilderOptions options) {
useIncrementalCompiler: _readUseIncrementalCompilerOption(options),
generateFullDill: _readGenerateFullDillOption(options),
emitDebugSymbols: _readEmitDebugSymbolsOption(options),
canaryFeatures: _readCanaryOption(options),
sdkKernelPath: sdkDdcKernelPath,
trackUnusedInputs: _readTrackInputsCompilerOption(options),
platform: ddcPlatform,
Expand All @@ -52,9 +53,11 @@ Builder ddcKernelBuilder(BuilderOptions options) {
}

Builder sdkJsCopyRequirejs(_) => SdkJsCopyBuilder();
Builder sdkJsCompile(_) => SdkJsCompileBuilder(
sdkKernelPath: 'lib/_internal/ddc_platform.dill',
outputPath: 'lib/src/dev_compiler/dart_sdk.js');
Builder sdkJsCompile(BuilderOptions options) => SdkJsCompileBuilder(
sdkKernelPath: 'lib/_internal/ddc_platform.dill',
outputPath: 'lib/src/dev_compiler/dart_sdk.js',
canaryFeatures: _readCanaryOption(options),
);

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

bool _readCanaryOption(BuilderOptions options) {
return options.config[_canaryOption] as bool? ?? false;
}

bool _readTrackInputsCompilerOption(BuilderOptions options) {
return options.config[_trackUnusedInputsCompilerOption] as bool? ?? true;
}
Expand All @@ -115,6 +122,7 @@ Map<String, dynamic>? _previousDdcConfig;
const _useIncrementalCompilerOption = 'use-incremental-compiler';
const _generateFullDillOption = 'generate-full-dill';
const _emitDebugSymbolsOption = 'emit-debug-symbols';
const _canaryOption = 'canary';
const _trackUnusedInputsCompilerOption = 'track-unused-inputs';
const _environmentOption = 'environment';

Expand All @@ -123,5 +131,6 @@ const _supportedOptions = [
_useIncrementalCompilerOption,
_generateFullDillOption,
_emitDebugSymbolsOption,
_canaryOption,
_trackUnusedInputsCompilerOption,
];
7 changes: 7 additions & 0 deletions build_web_compilers/lib/src/dev_compiler_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class DevCompilerBuilder implements Builder {
/// watch, expression evaluation, and variable inspection windows.
final bool emitDebugSymbols;

/// Enables canary features in DDC.
final bool canaryFeatures;

final bool trackUnusedInputs;

final DartPlatform platform;
Expand Down Expand Up @@ -75,6 +78,7 @@ class DevCompilerBuilder implements Builder {
{this.useIncrementalCompiler = true,
this.generateFullDill = false,
this.emitDebugSymbols = false,
this.canaryFeatures = false,
this.trackUnusedInputs = false,
required this.platform,
String? sdkKernelPath,
Expand Down Expand Up @@ -124,6 +128,7 @@ class DevCompilerBuilder implements Builder {
useIncrementalCompiler,
generateFullDill,
emitDebugSymbols,
canaryFeatures,
trackUnusedInputs,
platformSdk,
sdkKernelPath,
Expand All @@ -144,6 +149,7 @@ Future<void> _createDevCompilerModule(
bool useIncrementalCompiler,
bool generateFullDill,
bool emitDebugSymbols,
bool canaryFeatures,
bool trackUnusedInputs,
String dartSdk,
String sdkKernelPath,
Expand Down Expand Up @@ -188,6 +194,7 @@ Future<void> _createDevCompilerModule(
'--no-summarize',
if (generateFullDill) '--experimental-output-compiled-kernel',
if (emitDebugSymbols) '--emit-debug-symbols',
if (canaryFeatures) '--canary',
'-o',
jsOutputFile.path,
debugMode ? '--source-map' : '--no-source-map',
Expand Down
Loading