mirror of
https://github.com/flutter/flutter
synced 2024-08-25 02:46:31 +00:00
[flutter_tools] Enable WebAssembly compilation everywhere, remove feature flag (#145562)
This commit is contained in:
parent
55528ba1b7
commit
388f3217e4
|
@ -97,22 +97,18 @@ class BuildWebCommand extends BuildSubCommand {
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Experimental options
|
// WebAssembly compilation options
|
||||||
//
|
//
|
||||||
if (featureFlags.isFlutterWebWasmEnabled) {
|
argParser.addSeparator('WebAssembly compilation options');
|
||||||
argParser.addSeparator('Experimental options');
|
|
||||||
}
|
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
FlutterOptions.kWebWasmFlag,
|
FlutterOptions.kWebWasmFlag,
|
||||||
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
|
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
|
||||||
negatable: false,
|
negatable: false,
|
||||||
hide: !featureFlags.isFlutterWebWasmEnabled,
|
|
||||||
);
|
);
|
||||||
argParser.addFlag(
|
argParser.addFlag(
|
||||||
'strip-wasm',
|
'strip-wasm',
|
||||||
help: 'Whether to strip the resulting wasm file of static symbol names.',
|
help: 'Whether to strip the resulting wasm file of static symbol names.',
|
||||||
defaultsTo: true,
|
defaultsTo: true,
|
||||||
hide: !featureFlags.isFlutterWebWasmEnabled,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,16 +144,13 @@ class BuildWebCommand extends BuildSubCommand {
|
||||||
|
|
||||||
final List<WebCompilerConfig> compilerConfigs;
|
final List<WebCompilerConfig> compilerConfigs;
|
||||||
if (boolArg('wasm')) {
|
if (boolArg('wasm')) {
|
||||||
if (!featureFlags.isFlutterWebWasmEnabled) {
|
|
||||||
throwToolExit('Compiling to WebAssembly (wasm) is only available on the beta and master channels.');
|
|
||||||
}
|
|
||||||
if (stringArg(FlutterOptions.kWebRendererFlag) != argParser.defaultFor(FlutterOptions.kWebRendererFlag)) {
|
if (stringArg(FlutterOptions.kWebRendererFlag) != argParser.defaultFor(FlutterOptions.kWebRendererFlag)) {
|
||||||
throwToolExit('"--${FlutterOptions.kWebRendererFlag}" cannot be combined with "--${FlutterOptions.kWebWasmFlag}"');
|
throwToolExit('"--${FlutterOptions.kWebRendererFlag}" cannot be combined with "--${FlutterOptions.kWebWasmFlag}"');
|
||||||
}
|
}
|
||||||
globals.logger.printBox(
|
globals.logger.printBox(
|
||||||
title: 'Experimental feature',
|
title: 'New feature',
|
||||||
'''
|
'''
|
||||||
WebAssembly compilation is experimental.
|
WebAssembly compilation is new. Understand the details before deploying to production.
|
||||||
$kWasmMoreInfo''',
|
$kWasmMoreInfo''',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import '../build_info.dart';
|
||||||
import '../bundle_builder.dart';
|
import '../bundle_builder.dart';
|
||||||
import '../devfs.dart';
|
import '../devfs.dart';
|
||||||
import '../device.dart';
|
import '../device.dart';
|
||||||
import '../features.dart';
|
|
||||||
import '../globals.dart' as globals;
|
import '../globals.dart' as globals;
|
||||||
import '../native_assets.dart';
|
import '../native_assets.dart';
|
||||||
import '../project.dart';
|
import '../project.dart';
|
||||||
|
@ -240,7 +239,6 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||||
FlutterOptions.kWebWasmFlag,
|
FlutterOptions.kWebWasmFlag,
|
||||||
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
|
help: 'Compile to WebAssembly rather than JavaScript.\n$kWasmMoreInfo',
|
||||||
negatable: false,
|
negatable: false,
|
||||||
hide: !featureFlags.isFlutterWebWasmEnabled,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
addDdsOptions(verboseHelp: verboseHelp);
|
addDdsOptions(verboseHelp: verboseHelp);
|
||||||
|
|
|
@ -42,9 +42,6 @@ abstract class FeatureFlags {
|
||||||
/// Whether custom devices are enabled.
|
/// Whether custom devices are enabled.
|
||||||
bool get areCustomDevicesEnabled => false;
|
bool get areCustomDevicesEnabled => false;
|
||||||
|
|
||||||
/// Whether WebAssembly compilation for Flutter Web is enabled.
|
|
||||||
bool get isFlutterWebWasmEnabled => false;
|
|
||||||
|
|
||||||
/// Whether animations are used in the command line interface.
|
/// Whether animations are used in the command line interface.
|
||||||
bool get isCliAnimationEnabled => true;
|
bool get isCliAnimationEnabled => true;
|
||||||
|
|
||||||
|
@ -70,7 +67,6 @@ const List<Feature> allFeatures = <Feature>[
|
||||||
flutterIOSFeature,
|
flutterIOSFeature,
|
||||||
flutterFuchsiaFeature,
|
flutterFuchsiaFeature,
|
||||||
flutterCustomDevicesFeature,
|
flutterCustomDevicesFeature,
|
||||||
flutterWebWasm,
|
|
||||||
cliAnimation,
|
cliAnimation,
|
||||||
nativeAssets,
|
nativeAssets,
|
||||||
previewDevice,
|
previewDevice,
|
||||||
|
@ -146,20 +142,6 @@ const Feature flutterCustomDevicesFeature = Feature(
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Enabling WebAssembly compilation from `flutter build web`
|
|
||||||
const Feature flutterWebWasm = Feature(
|
|
||||||
name: 'WebAssembly compilation from flutter build web',
|
|
||||||
environmentOverride: 'FLUTTER_WEB_WASM',
|
|
||||||
beta: FeatureChannelSetting(
|
|
||||||
available: true,
|
|
||||||
enabledByDefault: true,
|
|
||||||
),
|
|
||||||
master: FeatureChannelSetting(
|
|
||||||
available: true,
|
|
||||||
enabledByDefault: true,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
const String kCliAnimationsFeatureName = 'cli-animations';
|
const String kCliAnimationsFeatureName = 'cli-animations';
|
||||||
|
|
||||||
/// The [Feature] for CLI animations.
|
/// The [Feature] for CLI animations.
|
||||||
|
|
|
@ -44,9 +44,6 @@ class FlutterFeatureFlags implements FeatureFlags {
|
||||||
@override
|
@override
|
||||||
bool get areCustomDevicesEnabled => isEnabled(flutterCustomDevicesFeature);
|
bool get areCustomDevicesEnabled => isEnabled(flutterCustomDevicesFeature);
|
||||||
|
|
||||||
@override
|
|
||||||
bool get isFlutterWebWasmEnabled => isEnabled(flutterWebWasm);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get isCliAnimationEnabled {
|
bool get isCliAnimationEnabled {
|
||||||
if (_platform.environment['TERM'] == 'dumb') {
|
if (_platform.environment['TERM'] == 'dumb') {
|
||||||
|
|
|
@ -81,12 +81,6 @@ void main() {
|
||||||
expect(featureFlags.isWebEnabled, true);
|
expect(featureFlags.isWebEnabled, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('Flutter web wasm only enable on master', () {
|
|
||||||
expect(flutterWebWasm.getSettingForChannel('master').enabledByDefault, isTrue);
|
|
||||||
expect(flutterWebWasm.getSettingForChannel('beta').enabledByDefault, isTrue);
|
|
||||||
expect(flutterWebWasm.getSettingForChannel('stable').enabledByDefault, isFalse);
|
|
||||||
});
|
|
||||||
|
|
||||||
testWithoutContext('Flutter web help string', () {
|
testWithoutContext('Flutter web help string', () {
|
||||||
expect(flutterWebFeature.generateHelpMessage(),
|
expect(flutterWebFeature.generateHelpMessage(),
|
||||||
'Enable or disable Flutter for web.');
|
'Enable or disable Flutter for web.');
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:file_testing/file_testing.dart';
|
import 'package:file_testing/file_testing.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/features.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_utils.dart';
|
import 'test_utils.dart';
|
||||||
|
@ -42,9 +41,6 @@ void main() {
|
||||||
'--wasm',
|
'--wasm',
|
||||||
],
|
],
|
||||||
workingDirectory: exampleAppDir.path,
|
workingDirectory: exampleAppDir.path,
|
||||||
environment: <String, String>{
|
|
||||||
flutterWebWasm.environmentOverride!: 'true'
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
expect(result, const ProcessResultMatcher());
|
expect(result, const ProcessResultMatcher());
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,6 @@ class TestFeatureFlags implements FeatureFlags {
|
||||||
this.isIOSEnabled = true,
|
this.isIOSEnabled = true,
|
||||||
this.isFuchsiaEnabled = false,
|
this.isFuchsiaEnabled = false,
|
||||||
this.areCustomDevicesEnabled = false,
|
this.areCustomDevicesEnabled = false,
|
||||||
this.isFlutterWebWasmEnabled = false,
|
|
||||||
this.isCliAnimationEnabled = true,
|
this.isCliAnimationEnabled = true,
|
||||||
this.isNativeAssetsEnabled = false,
|
this.isNativeAssetsEnabled = false,
|
||||||
this.isPreviewDeviceEnabled = false,
|
this.isPreviewDeviceEnabled = false,
|
||||||
|
@ -499,9 +498,6 @@ class TestFeatureFlags implements FeatureFlags {
|
||||||
@override
|
@override
|
||||||
final bool areCustomDevicesEnabled;
|
final bool areCustomDevicesEnabled;
|
||||||
|
|
||||||
@override
|
|
||||||
final bool isFlutterWebWasmEnabled;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
final bool isCliAnimationEnabled;
|
final bool isCliAnimationEnabled;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue