Unverified Commit 905f9acf authored by Yegor's avatar Yegor Committed by GitHub

[tools] consolidate "preview Dart 2" option in BuildInfo (#15083)

* [tools] consolidate "preview Dart 2" option in BuildInfo

* format BuildInfo constructor
parent 973742fe
...@@ -10,15 +10,17 @@ import 'globals.dart'; ...@@ -10,15 +10,17 @@ import 'globals.dart';
/// Information about a build to be performed or used. /// Information about a build to be performed or used.
class BuildInfo { class BuildInfo {
const BuildInfo(this.mode, this.flavor, const BuildInfo(this.mode, this.flavor, {
{this.previewDart2, this.previewDart2: false,
this.trackWidgetCreation, this.trackWidgetCreation,
this.extraFrontEndOptions, this.extraFrontEndOptions,
this.extraGenSnapshotOptions, this.extraGenSnapshotOptions,
this.preferSharedLibrary, this.preferSharedLibrary,
this.targetPlatform}); this.targetPlatform,
});
final BuildMode mode; final BuildMode mode;
/// Represents a custom Android product flavor or an Xcode scheme, null for /// Represents a custom Android product flavor or an Xcode scheme, null for
/// using the default. /// using the default.
/// ///
...@@ -27,7 +29,7 @@ class BuildInfo { ...@@ -27,7 +29,7 @@ class BuildInfo {
/// Mode-Flavor (e.g. Release-Paid). /// Mode-Flavor (e.g. Release-Paid).
final String flavor; final String flavor;
// Whether build should be done using Dart2 Frontend parser. /// Whether build should be done using Dart2 Frontend parser.
final bool previewDart2; final bool previewDart2;
/// Whether the build should track widget creation locations. /// Whether the build should track widget creation locations.
...@@ -39,7 +41,7 @@ class BuildInfo { ...@@ -39,7 +41,7 @@ class BuildInfo {
/// Extra command-line options for gen_snapshot. /// Extra command-line options for gen_snapshot.
final String extraGenSnapshotOptions; final String extraGenSnapshotOptions;
// Whether to prefer AOT compiling to a *so file. /// Whether to prefer AOT compiling to a *so file.
final bool preferSharedLibrary; final bool preferSharedLibrary;
/// Target platform for the build (e.g. android_arm versus android_arm64). /// Target platform for the build (e.g. android_arm versus android_arm64).
......
...@@ -316,7 +316,11 @@ class AppDomain extends Domain { ...@@ -316,7 +316,11 @@ class AppDomain extends Domain {
if (!fs.isDirectorySync(projectDirectory)) if (!fs.isDirectorySync(projectDirectory))
throw "'$projectDirectory' does not exist"; throw "'$projectDirectory' does not exist";
final BuildInfo buildInfo = new BuildInfo(getBuildModeForName(mode) ?? BuildMode.debug, flavor); final BuildInfo buildInfo = new BuildInfo(
getBuildModeForName(mode) ?? BuildMode.debug,
flavor,
previewDart2: _getBoolArg(args, 'preview-dart-2'),
);
DebuggingOptions options; DebuggingOptions options;
if (buildInfo.isRelease) { if (buildInfo.isRelease) {
options = new DebuggingOptions.disabled(buildInfo); options = new DebuggingOptions.disabled(buildInfo);
...@@ -335,7 +339,6 @@ class AppDomain extends Domain { ...@@ -335,7 +339,6 @@ class AppDomain extends Domain {
route, route,
options, options,
enableHotReload, enableHotReload,
previewDart2: _getBoolArg(args, 'preview-dart-2'),
trackWidgetCreation: _getBoolArg(args, 'track-widget-creation'), trackWidgetCreation: _getBoolArg(args, 'track-widget-creation'),
); );
...@@ -351,7 +354,6 @@ class AppDomain extends Domain { ...@@ -351,7 +354,6 @@ class AppDomain extends Domain {
Device device, String projectDirectory, String target, String route, Device device, String projectDirectory, String target, String route,
DebuggingOptions options, bool enableHotReload, { DebuggingOptions options, bool enableHotReload, {
String applicationBinary, String applicationBinary,
@required bool previewDart2,
@required bool trackWidgetCreation, @required bool trackWidgetCreation,
String projectRootPath, String projectRootPath,
String packagesFilePath, String packagesFilePath,
...@@ -367,7 +369,7 @@ class AppDomain extends Domain { ...@@ -367,7 +369,7 @@ class AppDomain extends Domain {
final FlutterDevice flutterDevice = new FlutterDevice( final FlutterDevice flutterDevice = new FlutterDevice(
device, device,
previewDart2: previewDart2, previewDart2: options.buildInfo.previewDart2,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
); );
...@@ -380,7 +382,6 @@ class AppDomain extends Domain { ...@@ -380,7 +382,6 @@ class AppDomain extends Domain {
debuggingOptions: options, debuggingOptions: options,
usesTerminalUI: false, usesTerminalUI: false,
applicationBinary: applicationBinary, applicationBinary: applicationBinary,
previewDart2: previewDart2,
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
packagesFilePath: packagesFilePath, packagesFilePath: packagesFilePath,
ipv6: ipv6, ipv6: ipv6,
...@@ -393,7 +394,6 @@ class AppDomain extends Domain { ...@@ -393,7 +394,6 @@ class AppDomain extends Domain {
debuggingOptions: options, debuggingOptions: options,
usesTerminalUI: false, usesTerminalUI: false,
applicationBinary: applicationBinary, applicationBinary: applicationBinary,
previewDart2: previewDart2,
ipv6: ipv6, ipv6: ipv6,
); );
} }
......
...@@ -259,7 +259,6 @@ class RunCommand extends RunCommandBase { ...@@ -259,7 +259,6 @@ class RunCommand extends RunCommandBase {
devices.first, fs.currentDirectory.path, targetFile, route, devices.first, fs.currentDirectory.path, targetFile, route,
_createDebuggingOptions(), hotMode, _createDebuggingOptions(), hotMode,
applicationBinary: argResults['use-application-binary'], applicationBinary: argResults['use-application-binary'],
previewDart2: argResults['preview-dart-2'],
trackWidgetCreation: argResults['track-widget-creation'], trackWidgetCreation: argResults['track-widget-creation'],
projectRootPath: argResults['project-root'], projectRootPath: argResults['project-root'],
packagesFilePath: globalResults['packages'], packagesFilePath: globalResults['packages'],
...@@ -313,7 +312,6 @@ class RunCommand extends RunCommandBase { ...@@ -313,7 +312,6 @@ class RunCommand extends RunCommandBase {
debuggingOptions: _createDebuggingOptions(), debuggingOptions: _createDebuggingOptions(),
benchmarkMode: argResults['benchmark'], benchmarkMode: argResults['benchmark'],
applicationBinary: argResults['use-application-binary'], applicationBinary: argResults['use-application-binary'],
previewDart2: argResults['preview-dart-2'],
projectRootPath: argResults['project-root'], projectRootPath: argResults['project-root'],
packagesFilePath: globalResults['packages'], packagesFilePath: globalResults['packages'],
stayResident: stayResident, stayResident: stayResident,
...@@ -326,7 +324,6 @@ class RunCommand extends RunCommandBase { ...@@ -326,7 +324,6 @@ class RunCommand extends RunCommandBase {
debuggingOptions: _createDebuggingOptions(), debuggingOptions: _createDebuggingOptions(),
traceStartup: traceStartup, traceStartup: traceStartup,
applicationBinary: argResults['use-application-binary'], applicationBinary: argResults['use-application-binary'],
previewDart2: argResults['preview-dart-2'],
stayResident: stayResident, stayResident: stayResident,
ipv6: ipv6, ipv6: ipv6,
); );
......
...@@ -20,7 +20,6 @@ class ColdRunner extends ResidentRunner { ...@@ -20,7 +20,6 @@ class ColdRunner extends ResidentRunner {
bool usesTerminalUI: true, bool usesTerminalUI: true,
this.traceStartup: false, this.traceStartup: false,
this.applicationBinary, this.applicationBinary,
this.previewDart2 : false,
bool stayResident: true, bool stayResident: true,
bool ipv6: false, bool ipv6: false,
}) : super(devices, }) : super(devices,
...@@ -32,7 +31,6 @@ class ColdRunner extends ResidentRunner { ...@@ -32,7 +31,6 @@ class ColdRunner extends ResidentRunner {
final bool traceStartup; final bool traceStartup;
final String applicationBinary; final String applicationBinary;
final bool previewDart2;
@override @override
Future<int> run({ Future<int> run({
......
...@@ -39,7 +39,6 @@ class HotRunner extends ResidentRunner { ...@@ -39,7 +39,6 @@ class HotRunner extends ResidentRunner {
bool usesTerminalUI: true, bool usesTerminalUI: true,
this.benchmarkMode: false, this.benchmarkMode: false,
this.applicationBinary, this.applicationBinary,
this.previewDart2: false,
this.hostIsIde: false, this.hostIsIde: false,
String projectRootPath, String projectRootPath,
String packagesFilePath, String packagesFilePath,
...@@ -54,15 +53,14 @@ class HotRunner extends ResidentRunner { ...@@ -54,15 +53,14 @@ class HotRunner extends ResidentRunner {
stayResident: stayResident, stayResident: stayResident,
ipv6: ipv6); ipv6: ipv6);
final bool benchmarkMode;
final String applicationBinary; final String applicationBinary;
final bool hostIsIde; final bool hostIsIde;
Set<String> _dartDependencies; Set<String> _dartDependencies;
final bool benchmarkMode;
final Map<String, List<int>> benchmarkData = <String, List<int>>{}; final Map<String, List<int>> benchmarkData = <String, List<int>>{};
// The initial launch is from a snapshot. // The initial launch is from a snapshot.
bool _runningFromSnapshot = true; bool _runningFromSnapshot = true;
bool previewDart2 = false;
DateTime firstBuildTime; DateTime firstBuildTime;
void _addBenchmarkData(String name, int value) { void _addBenchmarkData(String name, int value) {
...@@ -391,7 +389,7 @@ class HotRunner extends ResidentRunner { ...@@ -391,7 +389,7 @@ class HotRunner extends ResidentRunner {
} }
// We are now running from source. // We are now running from source.
_runningFromSnapshot = false; _runningFromSnapshot = false;
await _launchFromDevFS(previewDart2 ? mainPath + '.dill' : mainPath); await _launchFromDevFS(debuggingOptions.buildInfo.previewDart2 ? mainPath + '.dill' : mainPath);
restartTimer.stop(); restartTimer.stop();
printTrace('Restart performed in ' printTrace('Restart performed in '
'${getElapsedAsMilliseconds(restartTimer.elapsed)}.'); '${getElapsedAsMilliseconds(restartTimer.elapsed)}.');
...@@ -510,8 +508,8 @@ class HotRunner extends ResidentRunner { ...@@ -510,8 +508,8 @@ class HotRunner extends ResidentRunner {
final Stopwatch vmReloadTimer = new Stopwatch()..start(); final Stopwatch vmReloadTimer = new Stopwatch()..start();
try { try {
final String entryPath = fs.path.relative( final String entryPath = fs.path.relative(
previewDart2 ? mainPath + '.dill' : mainPath, debuggingOptions.buildInfo.previewDart2 ? mainPath + '.dill' : mainPath,
from: projectRootPath from: projectRootPath,
); );
final Completer<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>(); final Completer<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment