[flutter_tools] add flag for sound-null-safety, unify with experiments (#58533)
Also combines experiments into extraGenSnapshot/ExtraFrontEndOptions. Allows providing --no-sound-null-safety to allow out of order migration and running.
This commit is contained in:
@@ -246,8 +246,7 @@ class AndroidAot extends AotElfBase {
|
||||
if (!output.existsSync()) {
|
||||
output.createSync(recursive: true);
|
||||
}
|
||||
final List<String> extraGenSnapshotOptions = environment.defines[kExtraGenSnapshotOptions]?.split(',')
|
||||
?? const <String>[];
|
||||
final List<String> extraGenSnapshotOptions = decodeDartDefines(environment.defines, kExtraGenSnapshotOptions);
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final bool dartObfuscation = environment.defines[kDartObfuscation] == 'true';
|
||||
final int snapshotExitCode = await snapshotter.build(
|
||||
|
||||
@@ -205,10 +205,7 @@ class KernelSnapshot extends Target {
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
|
||||
|
||||
// This configuration is all optional.
|
||||
final String rawFrontEndOption = environment.defines[kExtraFrontEndOptions];
|
||||
final List<String> extraFrontEndOptions = (rawFrontEndOption?.isNotEmpty ?? false)
|
||||
? rawFrontEndOption?.split(',')
|
||||
: null;
|
||||
final List<String> extraFrontEndOptions = decodeDartDefines(environment.defines, kExtraFrontEndOptions);
|
||||
final List<String> fileSystemRoots = environment.defines[kFileSystemRoots]?.split(',');
|
||||
final String fileSystemScheme = environment.defines[kFileSystemScheme];
|
||||
|
||||
@@ -254,7 +251,7 @@ class KernelSnapshot extends Target {
|
||||
extraFrontEndOptions: extraFrontEndOptions,
|
||||
fileSystemRoots: fileSystemRoots,
|
||||
fileSystemScheme: fileSystemScheme,
|
||||
dartDefines: decodeDartDefines(environment.defines),
|
||||
dartDefines: decodeDartDefines(environment.defines, kDartDefines),
|
||||
packageConfig: packageConfig,
|
||||
);
|
||||
if (output == null || output.errorCount != 0) {
|
||||
@@ -287,8 +284,7 @@ abstract class AotElfBase extends Target {
|
||||
if (environment.defines[kTargetPlatform] == null) {
|
||||
throw MissingDefineException(kTargetPlatform, 'aot_elf');
|
||||
}
|
||||
final List<String> extraGenSnapshotOptions = environment.defines[kExtraGenSnapshotOptions]?.split(',')
|
||||
?? const <String>[];
|
||||
final List<String> extraGenSnapshotOptions = decodeDartDefines(environment.defines, kExtraGenSnapshotOptions);
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
|
||||
final String splitDebugInfo = environment.defines[kSplitDebugInfo];
|
||||
|
||||
@@ -46,7 +46,7 @@ abstract class AotAssemblyBase extends Target {
|
||||
if (environment.defines[kTargetPlatform] == null) {
|
||||
throw MissingDefineException(kTargetPlatform, 'aot_assembly');
|
||||
}
|
||||
final List<String> extraGenSnapshotOptions = parseExtraGenSnapshotOptions(environment);
|
||||
final List<String> extraGenSnapshotOptions = decodeDartDefines(environment.defines, kExtraGenSnapshotOptions);
|
||||
final bool bitcode = environment.defines[kBitcodeFlag] == 'true';
|
||||
final BuildMode buildMode = getBuildModeForName(environment.defines[kBuildMode]);
|
||||
final TargetPlatform targetPlatform = getTargetPlatformForName(environment.defines[kTargetPlatform]);
|
||||
@@ -447,13 +447,3 @@ Future<RunResult> createStubAppFramework(File outputFile, SdkType sdk, { bool in
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// iOS and macOS build scripts may pass extraGenSnapshotOptions as an empty
|
||||
/// string.
|
||||
List<String> parseExtraGenSnapshotOptions(Environment environment) {
|
||||
final String value = environment.defines[kExtraGenSnapshotOptions];
|
||||
if (value == null || value.trim().isEmpty) {
|
||||
return <String>[];
|
||||
}
|
||||
return value.split(',');
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import '../exceptions.dart';
|
||||
import 'assets.dart';
|
||||
import 'dart.dart';
|
||||
import 'icon_tree_shaker.dart';
|
||||
import 'ios.dart';
|
||||
|
||||
/// Copy the macOS framework to the correct copy dir by invoking 'cp -R'.
|
||||
///
|
||||
@@ -198,7 +197,7 @@ class CompileMacOSFramework extends Target {
|
||||
}
|
||||
final String splitDebugInfo = environment.defines[kSplitDebugInfo];
|
||||
final bool dartObfuscation = environment.defines[kDartObfuscation] == 'true';
|
||||
final List<String> extraGenSnapshotOptions = parseExtraGenSnapshotOptions(environment);
|
||||
final List<String> extraGenSnapshotOptions = decodeDartDefines(environment.defines, kExtraGenSnapshotOptions);
|
||||
final AOTSnapshotter snapshotter = AOTSnapshotter(
|
||||
reportTimings: false,
|
||||
fileSystem: globals.fs,
|
||||
|
||||
@@ -28,11 +28,6 @@ const String kHasWebPlugins = 'HasWebPlugins';
|
||||
/// Valid values are O1 (lowest, profile default) to O4 (highest, release default).
|
||||
const String kDart2jsOptimization = 'Dart2jsOptimization';
|
||||
|
||||
/// Allow specifying experiments for dart2js.
|
||||
///
|
||||
/// Multiple values should be encoded as a comma-separated list.
|
||||
const String kEnableExperiment = 'EnableExperiment';
|
||||
|
||||
/// Whether to disable dynamic generation code to satisfy csp policies.
|
||||
const String kCspMode = 'cspMode';
|
||||
|
||||
@@ -164,8 +159,8 @@ class Dart2JSTarget extends Target {
|
||||
final String packageFile = globalPackagesPath;
|
||||
final File outputKernel = environment.buildDir.childFile('app.dill');
|
||||
final File outputFile = environment.buildDir.childFile('main.dart.js');
|
||||
final List<String> dartDefines = decodeDartDefines(environment.defines);
|
||||
final String enabledExperiments = environment.defines[kEnableExperiment];
|
||||
final List<String> dartDefines = decodeDartDefines(environment.defines, kDartDefines);
|
||||
final List<String> extraFrontEndOptions = decodeDartDefines(environment.defines, kExtraFrontEndOptions);
|
||||
|
||||
// Run the dart2js compilation in two stages, so that icon tree shaking can
|
||||
// parse the kernel file for web builds.
|
||||
@@ -173,8 +168,7 @@ class Dart2JSTarget extends Target {
|
||||
globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
globals.artifacts.getArtifactPath(Artifact.dart2jsSnapshot),
|
||||
'--libraries-spec=$specPath',
|
||||
if (enabledExperiments != null)
|
||||
'--enable-experiment=$enabledExperiments',
|
||||
...?extraFrontEndOptions,
|
||||
'-o',
|
||||
outputKernel.path,
|
||||
'--packages=$packageFile',
|
||||
@@ -194,8 +188,7 @@ class Dart2JSTarget extends Target {
|
||||
globals.artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
globals.artifacts.getArtifactPath(Artifact.dart2jsSnapshot),
|
||||
'--libraries-spec=$specPath',
|
||||
if (enabledExperiments != null)
|
||||
'--enable-experiment=$enabledExperiments',
|
||||
...?extraFrontEndOptions,
|
||||
if (dart2jsOptimization != null)
|
||||
'-$dart2jsOptimization'
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user