Unverified Commit 9495df4b authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Revert "It's time to #deleteDart1 (#18293)" (#18313)

Several benchmarks started failing during kernel compile:
1. Timeouts:
   * commands_test
   * hot_mode_dev_cycle__benchmark
   * run_machine_concurrent_hot_reload
   * service_extensions_test

2. Kernel compiler crash:
   * hot_mode_dev_cycle_linux__benchmark
   * routing_test

3. Unexpected termination:
   * hot_mode_dev_cycle_win__benchmark

This reverts commit ed63e708.
parent ed63e708
...@@ -68,8 +68,12 @@ Future<Null> _generateDocs() async { ...@@ -68,8 +68,12 @@ Future<Null> _generateDocs() async {
} }
Future<Null> _verifyInternationalizations() async { Future<Null> _verifyInternationalizations() async {
final EvalResult genResult = await _evalCommand(dart, final EvalResult genResult = await _evalCommand(
<String>[ '--preview-dart-2', path.join('dev', 'tools', 'gen_localizations.dart'), ], dart,
<String>[
'--preview-dart-2',
path.join('dev', 'tools', 'gen_localizations.dart'),
],
workingDirectory: flutterRoot, workingDirectory: flutterRoot,
); );
......
...@@ -32,6 +32,14 @@ void main() async { ...@@ -32,6 +32,14 @@ void main() async {
return new TaskResult.failure(errorMessage); return new TaskResult.failure(errorMessage);
} }
section('gradlew assembleDebug no-preview-dart-2');
await project.runGradleTask('assembleDebug', options: <String>['-Ppreview-dart-2=false']);
errorMessage = _validateSnapshotDependency(project,
'${project.rootPath}/build/app/intermediates/flutter/debug/snapshot_blob.bin');
if (errorMessage != null) {
return new TaskResult.failure(errorMessage);
}
section('gradlew assembleProfile'); section('gradlew assembleProfile');
await project.runGradleTask('assembleProfile'); await project.runGradleTask('assembleProfile');
......
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/hot_mode_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
Future<Null> main() async {
await task(createHotModeTest(isPreviewDart2: false));
}
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter_devicelab/tasks/hot_mode_tests.dart';
import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/adb.dart';
Future<Null> main() async {
deviceOperatingSystem = DeviceOperatingSystem.ios;
await task(createHotModeTest(isPreviewDart2: false));
}
...@@ -16,7 +16,7 @@ import '../framework/utils.dart'; ...@@ -16,7 +16,7 @@ import '../framework/utils.dart';
final Directory _editedFlutterGalleryDir = dir(path.join(Directory.systemTemp.path, 'edited_flutter_gallery')); final Directory _editedFlutterGalleryDir = dir(path.join(Directory.systemTemp.path, 'edited_flutter_gallery'));
final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'examples/flutter_gallery')); final Directory flutterGalleryDir = dir(path.join(flutterDirectory.path, 'examples/flutter_gallery'));
TaskFunction createHotModeTest() { TaskFunction createHotModeTest({ bool isPreviewDart2 = true }) {
return () async { return () async {
final Device device = await devices.workingDevice; final Device device = await devices.workingDevice;
await device.unlock(); await device.unlock();
...@@ -25,6 +25,10 @@ TaskFunction createHotModeTest() { ...@@ -25,6 +25,10 @@ TaskFunction createHotModeTest() {
final List<String> options = <String>[ final List<String> options = <String>[
'--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident' '--hot', '-d', device.deviceId, '--benchmark', '--verbose', '--resident'
]; ];
if (isPreviewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options); setLocalEngineOptionIfNecessary(options);
int hotReloadCount = 0; int hotReloadCount = 0;
Map<String, dynamic> twoReloadsData; Map<String, dynamic> twoReloadsData;
...@@ -88,8 +92,8 @@ TaskFunction createHotModeTest() { ...@@ -88,8 +92,8 @@ TaskFunction createHotModeTest() {
} }
benchmarkFile.deleteSync(); benchmarkFile.deleteSync();
// start `flutter run` again to make sure it loads from the previous // start `flutter run` again to make sure it loads from the previous state
// state; frontend loads up from previously generated kernel files. // (in case of --preview-dart-2 frontend loads up from previously generated kernel files).
{ {
final Process process = await startProcess( final Process process = await startProcess(
path.join(flutterDirectory.path, 'bin', 'flutter'), path.join(flutterDirectory.path, 'bin', 'flutter'),
......
...@@ -23,7 +23,7 @@ TaskFunction createMicrobenchmarkTask() { ...@@ -23,7 +23,7 @@ TaskFunction createMicrobenchmarkTask() {
final Device device = await devices.workingDevice; final Device device = await devices.workingDevice;
await device.unlock(); await device.unlock();
Future<Map<String, double>> _runMicrobench(String benchmarkPath) async { Future<Map<String, double>> _runMicrobench(String benchmarkPath, {bool previewDart2 = true}) async {
Future<Map<String, double>> _run() async { Future<Map<String, double>> _run() async {
print('Running $benchmarkPath'); print('Running $benchmarkPath');
final Directory appDir = dir( final Directory appDir = dir(
...@@ -38,6 +38,10 @@ TaskFunction createMicrobenchmarkTask() { ...@@ -38,6 +38,10 @@ TaskFunction createMicrobenchmarkTask() {
'-d', '-d',
device.deviceId, device.deviceId,
]; ];
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options); setLocalEngineOptionIfNecessary(options);
options.add(benchmarkPath); options.add(benchmarkPath);
return await _startFlutter( return await _startFlutter(
...@@ -57,6 +61,26 @@ TaskFunction createMicrobenchmarkTask() { ...@@ -57,6 +61,26 @@ TaskFunction createMicrobenchmarkTask() {
allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart')); allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart'));
allResults.addAll(await _runMicrobench('lib/stocks/animation_bench.dart')); allResults.addAll(await _runMicrobench('lib/stocks/animation_bench.dart'));
// Run micro-benchmarks once again in --no-preview-dart-2 mode.
// Append "_dart1" suffix to the result keys to distinguish them from
// the original results.
void addDart1Results(Map<String, double> benchmarkResults) {
benchmarkResults.forEach((String key, double result) {
allResults[key + '_dart1'] = result;
});
}
addDart1Results(await _runMicrobench(
'lib/stocks/layout_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/stocks/layout_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/stocks/build_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/gestures/velocity_tracker_bench.dart', previewDart2: false));
addDart1Results(await _runMicrobench(
'lib/stocks/animation_bench.dart', previewDart2: false));
return new TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList()); return new TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList());
}; };
} }
......
...@@ -205,13 +205,23 @@ class CompileTest { ...@@ -205,13 +205,23 @@ class CompileTest {
final Map<String, dynamic> metrics = <String, dynamic>{} final Map<String, dynamic> metrics = <String, dynamic>{}
..addAll(await _compileAot()) ..addAll(await _compileAot())
..addAll(await _compileApp()) ..addAll(await _compileApp())
..addAll(await _compileDebug()); ..addAll(await _compileDebug())
..addAll(_suffix(await _compileAot(previewDart2: false), '__dart1'))
..addAll(_suffix(await _compileApp(previewDart2: false), '__dart1'))
..addAll(_suffix(await _compileDebug(previewDart2: false), '__dart1'));
return new TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList()); return new TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList());
}); });
} }
static Future<Map<String, dynamic>> _compileAot() async { static Map<String, dynamic> _suffix(Map<String, dynamic> map, String suffix) {
return new Map<String, dynamic>.fromIterables(
map.keys.map<String>((String key) => '$key$suffix'),
map.values,
);
}
static Future<Map<String, dynamic>> _compileAot({ bool previewDart2 = true }) async {
// Generate blobs instead of assembly. // Generate blobs instead of assembly.
await flutter('clean'); await flutter('clean');
final Stopwatch watch = new Stopwatch()..start(); final Stopwatch watch = new Stopwatch()..start();
...@@ -230,6 +240,10 @@ class CompileTest { ...@@ -230,6 +240,10 @@ class CompileTest {
options.add('android-arm'); options.add('android-arm');
break; break;
} }
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options); setLocalEngineOptionIfNecessary(options);
final String compileLog = await evalFlutter('build', options: options); final String compileLog = await evalFlutter('build', options: options);
watch.stop(); watch.stop();
...@@ -244,11 +258,15 @@ class CompileTest { ...@@ -244,11 +258,15 @@ class CompileTest {
return metrics; return metrics;
} }
static Future<Map<String, dynamic>> _compileApp() async { static Future<Map<String, dynamic>> _compileApp({ bool previewDart2 = true }) async {
await flutter('clean'); await flutter('clean');
final Stopwatch watch = new Stopwatch(); final Stopwatch watch = new Stopwatch();
int releaseSizeInBytes; int releaseSizeInBytes;
final List<String> options = <String>['--release']; final List<String> options = <String>['--release'];
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options); setLocalEngineOptionIfNecessary(options);
switch (deviceOperatingSystem) { switch (deviceOperatingSystem) {
case DeviceOperatingSystem.ios: case DeviceOperatingSystem.ios:
...@@ -281,10 +299,14 @@ class CompileTest { ...@@ -281,10 +299,14 @@ class CompileTest {
}; };
} }
static Future<Map<String, dynamic>> _compileDebug() async { static Future<Map<String, dynamic>> _compileDebug({ bool previewDart2 = true }) async {
await flutter('clean'); await flutter('clean');
final Stopwatch watch = new Stopwatch(); final Stopwatch watch = new Stopwatch();
final List<String> options = <String>['--debug']; final List<String> options = <String>['--debug'];
if (previewDart2)
options.add('--preview-dart-2');
else
options.add('--no-preview-dart-2');
setLocalEngineOptionIfNecessary(options); setLocalEngineOptionIfNecessary(options);
switch (deviceOperatingSystem) { switch (deviceOperatingSystem) {
case DeviceOperatingSystem.ios: case DeviceOperatingSystem.ios:
......
...@@ -154,6 +154,21 @@ tasks: ...@@ -154,6 +154,21 @@ tasks:
stage: devicelab stage: devicelab
required_agent_capabilities: ["mac/android"] required_agent_capabilities: ["mac/android"]
hot_mode_dev_cycle__benchmark_dart1:
description: >
Measures the performance of Dart VM hot patching feature under
--no-preview-dart-2 option, that disables Dart 2.0 frontend.
stage: devicelab
required_agent_capabilities: ["mac/android"]
hot_mode_dev_cycle_ios__benchmark_dart1:
description: >
Measures the performance of Dart VM hot patching feature under
--no-preview-dart-2 option, that disables Dart 2.0 frontend.
stage: devicelab_ios
required_agent_capabilities: ["mac/ios"]
flaky: true
complex_layout_scroll_perf__memory: complex_layout_scroll_perf__memory:
description: > description: >
Measures memory usage of the scroll performance test. Measures memory usage of the scroll performance test.
......
...@@ -102,6 +102,13 @@ BuildApp() { ...@@ -102,6 +102,13 @@ BuildApp() {
local_engine_flag="--local-engine=$LOCAL_ENGINE" local_engine_flag="--local-engine=$LOCAL_ENGINE"
fi fi
local preview_dart_2_flag=""
if [[ -n "$PREVIEW_DART_2" ]]; then
preview_dart_2_flag="--preview-dart-2"
else
preview_dart_2_flag="--no-preview-dart-2"
fi
local track_widget_creation_flag="" local track_widget_creation_flag=""
if [[ -n "$TRACK_WIDGET_CREATION" ]]; then if [[ -n "$TRACK_WIDGET_CREATION" ]]; then
track_widget_creation_flag="--track-widget-creation" track_widget_creation_flag="--track-widget-creation"
...@@ -120,6 +127,7 @@ BuildApp() { ...@@ -120,6 +127,7 @@ BuildApp() {
--${build_mode} \ --${build_mode} \
--ios-arch="${archs}" \ --ios-arch="${archs}" \
${local_engine_flag} \ ${local_engine_flag} \
${preview_dart_2_flag} \
${track_widget_creation_flag} ${track_widget_creation_flag}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
...@@ -159,10 +167,12 @@ BuildApp() { ...@@ -159,10 +167,12 @@ BuildApp() {
${verbose_flag} \ ${verbose_flag} \
build bundle \ build bundle \
--target="${target_path}" \ --target="${target_path}" \
--snapshot="${build_dir}/snapshot_blob.bin" \
--depfile="${build_dir}/snapshot_blob.bin.d" \ --depfile="${build_dir}/snapshot_blob.bin.d" \
--asset-dir="${derived_dir}/flutter_assets" \ --asset-dir="${derived_dir}/flutter_assets" \
${precompilation_flag} \ ${precompilation_flag} \
${local_engine_flag} \ ${local_engine_flag} \
${preview_dart_2_flag} \
${track_widget_creation_flag} ${track_widget_creation_flag}
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
......
...@@ -260,6 +260,10 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -260,6 +260,10 @@ class FlutterPlugin implements Plugin<Project> {
if (project.hasProperty('verbose')) { if (project.hasProperty('verbose')) {
verboseValue = project.property('verbose').toBoolean() verboseValue = project.property('verbose').toBoolean()
} }
Boolean previewDart2Value = true
if (project.hasProperty('preview-dart-2')) {
previewDart2Value = project.property('preview-dart-2').toBoolean()
}
String[] fileSystemRootsValue = null String[] fileSystemRootsValue = null
if (project.hasProperty('filesystem-roots')) { if (project.hasProperty('filesystem-roots')) {
fileSystemRootsValue = project.property('filesystem-roots').split('\\|') fileSystemRootsValue = project.property('filesystem-roots').split('\\|')
...@@ -311,6 +315,7 @@ class FlutterPlugin implements Plugin<Project> { ...@@ -311,6 +315,7 @@ class FlutterPlugin implements Plugin<Project> {
localEngineSrcPath this.localEngineSrcPath localEngineSrcPath this.localEngineSrcPath
targetPath target targetPath target
verbose verboseValue verbose verboseValue
previewDart2 previewDart2Value
fileSystemRoots fileSystemRootsValue fileSystemRoots fileSystemRootsValue
fileSystemScheme fileSystemSchemeValue fileSystemScheme fileSystemSchemeValue
trackWidgetCreation trackWidgetCreationValue trackWidgetCreation trackWidgetCreationValue
...@@ -355,6 +360,8 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -355,6 +360,8 @@ abstract class BaseFlutterTask extends DefaultTask {
@Optional @Input @Optional @Input
Boolean verbose Boolean verbose
@Optional @Input @Optional @Input
Boolean previewDart2
@Optional @Input
String[] fileSystemRoots String[] fileSystemRoots
@Optional @Input @Optional @Input
String fileSystemScheme String fileSystemScheme
...@@ -376,10 +383,12 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -376,10 +383,12 @@ abstract class BaseFlutterTask extends DefaultTask {
if (buildMode != 'debug') { if (buildMode != 'debug') {
// For AOT builds, include the gen_snapshot depfile. // For AOT builds, include the gen_snapshot depfile.
FileCollection depfiles = project.files("${intermediateDir}/snapshot.d") FileCollection depfiles = project.files("${intermediateDir}/snapshot.d")
// Include the kernel compiler depfile, since kernel compile is the if (previewDart2) {
// first stage of AOT build in this mode, and it includes all the // For Dart 2, also include the kernel compiler depfile, since
// Dart sources. // kernel compile is the first stage of AOT build in this mode,
depfiles += project.files("${intermediateDir}/kernel_compile.d") // and it includes all the Dart sources.
depfiles += project.files("${intermediateDir}/kernel_compile.d")
}
return depfiles return depfiles
} }
return project.files("${intermediateDir}/snapshot_blob.bin.d") return project.files("${intermediateDir}/snapshot_blob.bin.d")
...@@ -406,6 +415,11 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -406,6 +415,11 @@ abstract class BaseFlutterTask extends DefaultTask {
args "--target", targetPath args "--target", targetPath
args "--target-platform", "android-arm" args "--target-platform", "android-arm"
args "--output-dir", "${intermediateDir}" args "--output-dir", "${intermediateDir}"
if (previewDart2) {
args "--preview-dart-2"
} else {
args "--no-preview-dart-2"
}
if (trackWidgetCreation) { if (trackWidgetCreation) {
args "--track-widget-creation" args "--track-widget-creation"
} }
...@@ -438,6 +452,11 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -438,6 +452,11 @@ abstract class BaseFlutterTask extends DefaultTask {
if (verbose) { if (verbose) {
args "--verbose" args "--verbose"
} }
if (previewDart2) {
args "--preview-dart-2"
} else {
args "--no-preview-dart-2"
}
if (fileSystemRoots != null) { if (fileSystemRoots != null) {
for (root in fileSystemRoots) { for (root in fileSystemRoots) {
args "--filesystem-root", root args "--filesystem-root", root
...@@ -456,6 +475,9 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -456,6 +475,9 @@ abstract class BaseFlutterTask extends DefaultTask {
args "--precompiled" args "--precompiled"
} else { } else {
args "--depfile", "${intermediateDir}/snapshot_blob.bin.d" args "--depfile", "${intermediateDir}/snapshot_blob.bin.d"
if (!previewDart2) {
args "--snapshot", "${intermediateDir}/snapshot_blob.bin"
}
} }
args "--asset-dir", "${intermediateDir}/flutter_assets" args "--asset-dir", "${intermediateDir}/flutter_assets"
} }
...@@ -511,7 +533,9 @@ class FlutterTask extends BaseFlutterTask { ...@@ -511,7 +533,9 @@ class FlutterTask extends BaseFlutterTask {
// We have a dependencies file. Add a dependency on gen_snapshot as well, since the // We have a dependencies file. Add a dependency on gen_snapshot as well, since the
// snapshots have to be rebuilt if it changes. // snapshots have to be rebuilt if it changes.
sources += readDependencies(project.file("${intermediateDir}/gen_snapshot.d")) sources += readDependencies(project.file("${intermediateDir}/gen_snapshot.d"))
sources += readDependencies(project.file("${intermediateDir}/frontend_server.d")) if (previewDart2) {
sources += readDependencies(project.file("${intermediateDir}/frontend_server.d"))
}
if (localEngineSrcPath != null) { if (localEngineSrcPath != null) {
sources += project.files("$localEngineSrcPath/$localEngine") sources += project.files("$localEngineSrcPath/$localEngine")
} }
......
...@@ -327,16 +327,21 @@ Future<Null> _buildGradleProjectV2(String gradle, BuildInfo buildInfo, String ta ...@@ -327,16 +327,21 @@ Future<Null> _buildGradleProjectV2(String gradle, BuildInfo buildInfo, String ta
if (target != null) { if (target != null) {
command.add('-Ptarget=$target'); command.add('-Ptarget=$target');
} }
if (buildInfo.trackWidgetCreation) if (buildInfo.previewDart2) {
command.add('-Ptrack-widget-creation=true'); command.add('-Ppreview-dart-2=true');
if (buildInfo.extraFrontEndOptions != null) if (buildInfo.trackWidgetCreation)
command.add('-Pextra-front-end-options=${buildInfo.extraFrontEndOptions}'); command.add('-Ptrack-widget-creation=true');
if (buildInfo.extraGenSnapshotOptions != null) if (buildInfo.extraFrontEndOptions != null)
command.add('-Pextra-gen-snapshot-options=${buildInfo.extraGenSnapshotOptions}'); command.add('-Pextra-front-end-options=${buildInfo.extraFrontEndOptions}');
if (buildInfo.fileSystemRoots != null && buildInfo.fileSystemRoots.isNotEmpty) if (buildInfo.extraGenSnapshotOptions != null)
command.add('-Pfilesystem-roots=${buildInfo.fileSystemRoots.join('|')}'); command.add('-Pextra-gen-snapshot-options=${buildInfo.extraGenSnapshotOptions}');
if (buildInfo.fileSystemScheme != null) if (buildInfo.fileSystemRoots != null && buildInfo.fileSystemRoots.isNotEmpty)
command.add('-Pfilesystem-scheme=${buildInfo.fileSystemScheme}'); command.add('-Pfilesystem-roots=${buildInfo.fileSystemRoots.join('|')}');
if (buildInfo.fileSystemScheme != null)
command.add('-Pfilesystem-scheme=${buildInfo.fileSystemScheme}');
} else {
command.add('-Ppreview-dart-2=false');
}
if (buildInfo.buildSharedLibrary && androidSdk.ndk != null) { if (buildInfo.buildSharedLibrary && androidSdk.ndk != null) {
command.add('-Pbuild-shared-library=true'); command.add('-Pbuild-shared-library=true');
} }
......
...@@ -64,6 +64,70 @@ class GenSnapshot { ...@@ -64,6 +64,70 @@ class GenSnapshot {
} }
} }
/// Dart snapshot builder.
///
/// Builds Dart snapshots in one of three modes:
/// * Script snapshot: architecture-independent snapshot of a Dart script
/// and core libraries.
/// * AOT snapshot: architecture-specific ahead-of-time compiled snapshot
/// suitable for loading with `mmap`.
/// * Assembly AOT snapshot: architecture-specific ahead-of-time compile to
/// assembly suitable for compilation as a static or dynamic library.
class ScriptSnapshotter {
/// Builds an architecture-independent snapshot of the specified script.
Future<int> build({
@required String mainPath,
@required String snapshotPath,
@required String depfilePath,
@required String packagesPath
}) async {
final SnapshotType snapshotType = new SnapshotType(null, BuildMode.debug);
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData);
final List<String> args = <String>[
'--snapshot_kind=script',
'--script_snapshot=$snapshotPath',
'--vm_snapshot_data=$vmSnapshotData',
'--isolate_snapshot_data=$isolateSnapshotData',
'--enable-mirrors=false',
mainPath,
];
final Fingerprinter fingerprinter = new Fingerprinter(
fingerprintPath: '$depfilePath.fingerprint',
paths: <String>[
mainPath,
snapshotPath,
vmSnapshotData,
isolateSnapshotData,
],
properties: <String, String>{
'buildMode': snapshotType.mode.toString(),
'targetPlatform': snapshotType.platform?.toString() ?? '',
'entryPoint': mainPath,
},
depfilePaths: <String>[depfilePath],
);
if (await fingerprinter.doesFingerprintMatch()) {
printTrace('Skipping script snapshot build. Fingerprints match.');
return 0;
}
// Build the snapshot.
final int exitCode = await genSnapshot.run(
snapshotType: snapshotType,
packagesPath: packagesPath,
depfilePath: depfilePath,
additionalArgs: args,
);
if (exitCode != 0)
return exitCode;
await fingerprinter.writeFingerprint();
return exitCode;
}
}
class AOTSnapshotter { class AOTSnapshotter {
/// Builds an architecture-specific ahead-of-time compiled snapshot of the specified script. /// Builds an architecture-specific ahead-of-time compiled snapshot of the specified script.
Future<int> build({ Future<int> build({
...@@ -72,6 +136,7 @@ class AOTSnapshotter { ...@@ -72,6 +136,7 @@ class AOTSnapshotter {
@required String mainPath, @required String mainPath,
@required String packagesPath, @required String packagesPath,
@required String outputPath, @required String outputPath,
@required bool previewDart2,
@required bool buildSharedLibrary, @required bool buildSharedLibrary,
IOSArch iosArch, IOSArch iosArch,
List<String> extraGenSnapshotOptions = const <String>[], List<String> extraGenSnapshotOptions = const <String>[],
...@@ -127,10 +192,12 @@ class AOTSnapshotter { ...@@ -127,10 +192,12 @@ class AOTSnapshotter {
'--embedder_entry_points_manifest=$ioEntryPoints', '--embedder_entry_points_manifest=$ioEntryPoints',
'--dependencies=$depfilePath', '--dependencies=$depfilePath',
]; ];
genSnapshotArgs.addAll(<String>[ if (previewDart2) {
'--reify-generic-functions', genSnapshotArgs.addAll(<String>[
'--strong', '--reify-generic-functions',
]); '--strong',
]);
}
if (extraGenSnapshotOptions != null && extraGenSnapshotOptions.isNotEmpty) { if (extraGenSnapshotOptions != null && extraGenSnapshotOptions.isNotEmpty) {
printTrace('Extra gen_snapshot options: $extraGenSnapshotOptions'); printTrace('Extra gen_snapshot options: $extraGenSnapshotOptions');
genSnapshotArgs.addAll(extraGenSnapshotOptions); genSnapshotArgs.addAll(extraGenSnapshotOptions);
...@@ -185,6 +252,7 @@ class AOTSnapshotter { ...@@ -185,6 +252,7 @@ class AOTSnapshotter {
'buildMode': buildMode.toString(), 'buildMode': buildMode.toString(),
'targetPlatform': platform.toString(), 'targetPlatform': platform.toString(),
'entryPoint': mainPath, 'entryPoint': mainPath,
'dart2': previewDart2.toString(),
'sharedLib': buildSharedLibrary.toString(), 'sharedLib': buildSharedLibrary.toString(),
'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '), 'extraGenSnapshotOptions': extraGenSnapshotOptions.join(' '),
}, },
......
...@@ -11,6 +11,7 @@ import 'globals.dart'; ...@@ -11,6 +11,7 @@ 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 = false,
this.trackWidgetCreation = false, this.trackWidgetCreation = false,
this.extraFrontEndOptions, this.extraFrontEndOptions,
this.extraGenSnapshotOptions, this.extraGenSnapshotOptions,
...@@ -32,6 +33,9 @@ class BuildInfo { ...@@ -32,6 +33,9 @@ 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.
final bool previewDart2;
final List<String> fileSystemRoots; final List<String> fileSystemRoots;
final String fileSystemScheme; final String fileSystemScheme;
...@@ -89,6 +93,7 @@ class BuildInfo { ...@@ -89,6 +93,7 @@ class BuildInfo {
BuildInfo withTargetPlatform(TargetPlatform targetPlatform) => BuildInfo withTargetPlatform(TargetPlatform targetPlatform) =>
new BuildInfo(mode, flavor, new BuildInfo(mode, flavor,
previewDart2: previewDart2,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
extraGenSnapshotOptions: extraGenSnapshotOptions, extraGenSnapshotOptions: extraGenSnapshotOptions,
......
...@@ -6,6 +6,7 @@ import 'dart:async'; ...@@ -6,6 +6,7 @@ import 'dart:async';
import 'artifacts.dart'; import 'artifacts.dart';
import 'asset.dart'; import 'asset.dart';
import 'base/build.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'build_info.dart'; import 'build_info.dart';
...@@ -23,6 +24,7 @@ String get defaultApplicationKernelPath => fs.path.join(getBuildDirectory(), 'ap ...@@ -23,6 +24,7 @@ String get defaultApplicationKernelPath => fs.path.join(getBuildDirectory(), 'ap
const String defaultPrivateKeyPath = 'privatekey.der'; const String defaultPrivateKeyPath = 'privatekey.der';
const String _kKernelKey = 'kernel_blob.bin'; const String _kKernelKey = 'kernel_blob.bin';
const String _kSnapshotKey = 'snapshot_blob.bin';
const String _kVMSnapshotData = 'vm_snapshot_data'; const String _kVMSnapshotData = 'vm_snapshot_data';
const String _kIsolateSnapshotData = 'isolate_snapshot_data'; const String _kIsolateSnapshotData = 'isolate_snapshot_data';
const String _kDylibKey = 'libapp.so'; const String _kDylibKey = 'libapp.so';
...@@ -31,11 +33,13 @@ const String _kPlatformKernelKey = 'platform.dill'; ...@@ -31,11 +33,13 @@ const String _kPlatformKernelKey = 'platform.dill';
Future<void> build({ Future<void> build({
String mainPath = defaultMainPath, String mainPath = defaultMainPath,
String manifestPath = defaultManifestPath, String manifestPath = defaultManifestPath,
String snapshotPath,
String applicationKernelFilePath, String applicationKernelFilePath,
String depfilePath, String depfilePath,
String privateKeyPath = defaultPrivateKeyPath, String privateKeyPath = defaultPrivateKeyPath,
String assetDirPath, String assetDirPath,
String packagesPath, String packagesPath,
bool previewDart2 = false,
bool precompiledSnapshot = false, bool precompiledSnapshot = false,
bool reportLicensedPackages = false, bool reportLicensedPackages = false,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
...@@ -43,13 +47,32 @@ Future<void> build({ ...@@ -43,13 +47,32 @@ Future<void> build({
List<String> fileSystemRoots, List<String> fileSystemRoots,
String fileSystemScheme, String fileSystemScheme,
}) async { }) async {
snapshotPath ??= defaultSnapshotPath;
depfilePath ??= defaultDepfilePath; depfilePath ??= defaultDepfilePath;
assetDirPath ??= getAssetBuildDirectory(); assetDirPath ??= getAssetBuildDirectory();
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath); packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
applicationKernelFilePath ??= defaultApplicationKernelPath; applicationKernelFilePath ??= defaultApplicationKernelPath;
File snapshotFile;
if (!precompiledSnapshot && !previewDart2) {
ensureDirectoryExists(snapshotPath);
// In a precompiled snapshot, the instruction buffer contains script
// content equivalents
final int result = await new ScriptSnapshotter().build(
mainPath: mainPath,
snapshotPath: snapshotPath,
depfilePath: depfilePath,
packagesPath: packagesPath,
);
if (result != 0)
throwToolExit('Failed to run the Flutter compiler. Exit code: $result', exitCode: result);
snapshotFile = fs.file(snapshotPath);
}
DevFSContent kernelContent; DevFSContent kernelContent;
if (!precompiledSnapshot) { if (!precompiledSnapshot && previewDart2) {
if ((extraFrontEndOptions != null) && extraFrontEndOptions.isNotEmpty) if ((extraFrontEndOptions != null) && extraFrontEndOptions.isNotEmpty)
printTrace('Extra front-end options: $extraFrontEndOptions'); printTrace('Extra front-end options: $extraFrontEndOptions');
ensureDirectoryExists(applicationKernelFilePath); ensureDirectoryExists(applicationKernelFilePath);
...@@ -86,6 +109,7 @@ Future<void> build({ ...@@ -86,6 +109,7 @@ Future<void> build({
await assemble( await assemble(
assetBundle: assets, assetBundle: assets,
kernelContent: kernelContent, kernelContent: kernelContent,
snapshotFile: snapshotFile,
privateKeyPath: privateKeyPath, privateKeyPath: privateKeyPath,
assetDirPath: assetDirPath, assetDirPath: assetDirPath,
); );
...@@ -119,6 +143,7 @@ Future<AssetBundle> buildAssets({ ...@@ -119,6 +143,7 @@ Future<AssetBundle> buildAssets({
Future<void> assemble({ Future<void> assemble({
AssetBundle assetBundle, AssetBundle assetBundle,
DevFSContent kernelContent, DevFSContent kernelContent,
File snapshotFile,
File dylibFile, File dylibFile,
String privateKeyPath = defaultPrivateKeyPath, String privateKeyPath = defaultPrivateKeyPath,
String assetDirPath, String assetDirPath,
...@@ -127,16 +152,21 @@ Future<void> assemble({ ...@@ -127,16 +152,21 @@ Future<void> assemble({
printTrace('Building bundle'); printTrace('Building bundle');
final Map<String, DevFSContent> assetEntries = new Map<String, DevFSContent>.from(assetBundle.entries); final Map<String, DevFSContent> assetEntries = new Map<String, DevFSContent>.from(assetBundle.entries);
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData);
if (kernelContent != null) { if (kernelContent != null) {
final String platformKernelDill = artifacts.getArtifactPath(Artifact.platformKernelDill); final String platformKernelDill = artifacts.getArtifactPath(Artifact.platformKernelDill);
final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData);
final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData);
assetEntries[_kKernelKey] = kernelContent; assetEntries[_kKernelKey] = kernelContent;
assetEntries[_kPlatformKernelKey] = new DevFSFileContent(fs.file(platformKernelDill)); assetEntries[_kPlatformKernelKey] = new DevFSFileContent(fs.file(platformKernelDill));
assetEntries[_kVMSnapshotData] = new DevFSFileContent(fs.file(vmSnapshotData)); assetEntries[_kVMSnapshotData] = new DevFSFileContent(fs.file(vmSnapshotData));
assetEntries[_kIsolateSnapshotData] = new DevFSFileContent(fs.file(isolateSnapshotData)); assetEntries[_kIsolateSnapshotData] = new DevFSFileContent(fs.file(isolateSnapshotData));
} }
if (snapshotFile != null) {
assetEntries[_kSnapshotKey] = new DevFSFileContent(snapshotFile);
assetEntries[_kVMSnapshotData] = new DevFSFileContent(fs.file(vmSnapshotData));
assetEntries[_kIsolateSnapshotData] = new DevFSFileContent(fs.file(isolateSnapshotData));
}
if (dylibFile != null) if (dylibFile != null)
assetEntries[_kDylibKey] = new DevFSFileContent(dylibFile); assetEntries[_kDylibKey] = new DevFSFileContent(dylibFile);
......
...@@ -26,6 +26,8 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -26,6 +26,8 @@ class AnalyzeCommand extends FlutterCommand {
argParser.addFlag('watch', argParser.addFlag('watch',
help: 'Run analysis continuously, watching the filesystem for changes.', help: 'Run analysis continuously, watching the filesystem for changes.',
negatable: false); negatable: false);
argParser.addFlag('preview-dart-2',
defaultsTo: true, help: 'Preview Dart 2.0 functionality.');
argParser.addOption('write', argParser.addOption('write',
valueHelp: 'file', valueHelp: 'file',
help: 'Also output the results to a file. This is useful with --watch ' help: 'Also output the results to a file. This is useful with --watch '
...@@ -85,6 +87,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -85,6 +87,7 @@ class AnalyzeCommand extends FlutterCommand {
argResults, argResults,
runner.getRepoRoots(), runner.getRepoRoots(),
runner.getRepoPackages(), runner.getRepoPackages(),
previewDart2: argResults['preview-dart-2'],
).analyze(); ).analyze();
} else { } else {
return new AnalyzeOnce( return new AnalyzeOnce(
...@@ -92,6 +95,7 @@ class AnalyzeCommand extends FlutterCommand { ...@@ -92,6 +95,7 @@ class AnalyzeCommand extends FlutterCommand {
runner.getRepoRoots(), runner.getRepoRoots(),
runner.getRepoPackages(), runner.getRepoPackages(),
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
previewDart2: argResults['preview-dart-2'],
).analyze(); ).analyze();
} }
} }
......
...@@ -19,10 +19,13 @@ import '../globals.dart'; ...@@ -19,10 +19,13 @@ import '../globals.dart';
import 'analyze_base.dart'; import 'analyze_base.dart';
class AnalyzeContinuously extends AnalyzeBase { class AnalyzeContinuously extends AnalyzeBase {
AnalyzeContinuously(ArgResults argResults, this.repoRoots, this.repoPackages) : super(argResults); AnalyzeContinuously(ArgResults argResults, this.repoRoots, this.repoPackages, {
this.previewDart2 = false,
}) : super(argResults);
final List<String> repoRoots; final List<String> repoRoots;
final List<Directory> repoPackages; final List<Directory> repoPackages;
final bool previewDart2;
String analysisTarget; String analysisTarget;
bool firstAnalysis = true; bool firstAnalysis = true;
...@@ -57,7 +60,7 @@ class AnalyzeContinuously extends AnalyzeBase { ...@@ -57,7 +60,7 @@ class AnalyzeContinuously extends AnalyzeBase {
final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath; final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath;
final AnalysisServer server = new AnalysisServer(sdkPath, directories); final AnalysisServer server = new AnalysisServer(sdkPath, directories, previewDart2: previewDart2);
server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing)); server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing));
server.onErrors.listen(_handleAnalysisErrors); server.onErrors.listen(_handleAnalysisErrors);
......
...@@ -24,6 +24,7 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -24,6 +24,7 @@ class AnalyzeOnce extends AnalyzeBase {
this.repoRoots, this.repoRoots,
this.repoPackages, { this.repoPackages, {
this.workingDirectory, this.workingDirectory,
this.previewDart2 = false,
}) : super(argResults); }) : super(argResults);
final List<String> repoRoots; final List<String> repoRoots;
...@@ -32,6 +33,8 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -32,6 +33,8 @@ class AnalyzeOnce extends AnalyzeBase {
/// The working directory for testing analysis using dartanalyzer. /// The working directory for testing analysis using dartanalyzer.
final Directory workingDirectory; final Directory workingDirectory;
final bool previewDart2;
@override @override
Future<Null> analyze() async { Future<Null> analyze() async {
final String currentDirectory = final String currentDirectory =
...@@ -88,6 +91,7 @@ class AnalyzeOnce extends AnalyzeBase { ...@@ -88,6 +91,7 @@ class AnalyzeOnce extends AnalyzeBase {
final AnalysisServer server = new AnalysisServer( final AnalysisServer server = new AnalysisServer(
sdkPath, sdkPath,
directories.toList(), directories.toList(),
previewDart2: previewDart2,
); );
StreamSubscription<bool> subscription; StreamSubscription<bool> subscription;
......
...@@ -28,6 +28,11 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -28,6 +28,11 @@ class BuildAotCommand extends BuildSubCommand {
allowed: <String>['android-arm', 'android-arm64', 'ios'] allowed: <String>['android-arm', 'android-arm64', 'ios']
) )
..addFlag('quiet', defaultsTo: false) ..addFlag('quiet', defaultsTo: false)
..addFlag('preview-dart-2',
defaultsTo: true,
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.',
)
..addFlag('build-shared-library', ..addFlag('build-shared-library',
negatable: false, negatable: false,
defaultsTo: false, defaultsTo: false,
...@@ -74,20 +79,23 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -74,20 +79,23 @@ class BuildAotCommand extends BuildSubCommand {
} }
final String outputPath = argResults['output-dir'] ?? getAotBuildDirectory(); final String outputPath = argResults['output-dir'] ?? getAotBuildDirectory();
try { try {
final bool previewDart2 = argResults['preview-dart-2'];
String mainPath = findMainDartFile(targetFile); String mainPath = findMainDartFile(targetFile);
final AOTSnapshotter snapshotter = new AOTSnapshotter(); final AOTSnapshotter snapshotter = new AOTSnapshotter();
// Compile to kernel. // Compile to kernel, if Dart 2.
mainPath = await snapshotter.compileKernel( if (previewDart2) {
platform: platform, mainPath = await snapshotter.compileKernel(
buildMode: buildMode, platform: platform,
mainPath: mainPath, buildMode: buildMode,
outputPath: outputPath, mainPath: mainPath,
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions], outputPath: outputPath,
); extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
if (mainPath == null) { );
printError('Compiler terminated unexpectedly.'); if (mainPath == null) {
return; printError('Compiler terminated unexpectedly.');
return;
}
} }
// Build AOT snapshot. // Build AOT snapshot.
...@@ -108,6 +116,7 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -108,6 +116,7 @@ class BuildAotCommand extends BuildSubCommand {
mainPath: mainPath, mainPath: mainPath,
packagesPath: PackageMap.globalPackagesPath, packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath, outputPath: outputPath,
previewDart2: previewDart2,
buildSharedLibrary: false, buildSharedLibrary: false,
extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions], extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions],
).then((int buildExitCode) { ).then((int buildExitCode) {
...@@ -134,6 +143,7 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -134,6 +143,7 @@ class BuildAotCommand extends BuildSubCommand {
mainPath: mainPath, mainPath: mainPath,
packagesPath: PackageMap.globalPackagesPath, packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath, outputPath: outputPath,
previewDart2: previewDart2,
buildSharedLibrary: argResults['build-shared-library'], buildSharedLibrary: argResults['build-shared-library'],
extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions], extraGenSnapshotOptions: argResults[FlutterOptions.kExtraGenSnapshotOptions],
); );
......
...@@ -17,6 +17,11 @@ class BuildApkCommand extends BuildSubCommand { ...@@ -17,6 +17,11 @@ class BuildApkCommand extends BuildSubCommand {
usesBuildNameOption(); usesBuildNameOption();
argParser argParser
..addFlag('preview-dart-2',
defaultsTo: true,
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.',
)
..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp) ..addFlag('track-widget-creation', negatable: false, hide: !verboseHelp)
..addFlag('build-shared-library', ..addFlag('build-shared-library',
negatable: false, negatable: false,
......
...@@ -19,8 +19,14 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -19,8 +19,14 @@ class BuildBundleCommand extends BuildSubCommand {
..addOption('asset-base', help: 'Ignored. Will be removed.', hide: !verboseHelp) ..addOption('asset-base', help: 'Ignored. Will be removed.', hide: !verboseHelp)
..addOption('manifest', defaultsTo: defaultManifestPath) ..addOption('manifest', defaultsTo: defaultManifestPath)
..addOption('private-key', defaultsTo: defaultPrivateKeyPath) ..addOption('private-key', defaultsTo: defaultPrivateKeyPath)
..addOption('snapshot', defaultsTo: defaultSnapshotPath)
..addOption('depfile', defaultsTo: defaultDepfilePath) ..addOption('depfile', defaultsTo: defaultDepfilePath)
..addOption('kernel-file', defaultsTo: defaultApplicationKernelPath) ..addOption('kernel-file', defaultsTo: defaultApplicationKernelPath)
..addFlag('preview-dart-2',
defaultsTo: true,
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.',
)
..addFlag('track-widget-creation', ..addFlag('track-widget-creation',
hide: !verboseHelp, hide: !verboseHelp,
help: 'Track widget creation locations. Requires Dart 2.0 functionality.', help: 'Track widget creation locations. Requires Dart 2.0 functionality.',
...@@ -66,10 +72,12 @@ class BuildBundleCommand extends BuildSubCommand { ...@@ -66,10 +72,12 @@ class BuildBundleCommand extends BuildSubCommand {
await build( await build(
mainPath: targetFile, mainPath: targetFile,
manifestPath: argResults['manifest'], manifestPath: argResults['manifest'],
snapshotPath: argResults['snapshot'],
applicationKernelFilePath: argResults['kernel-file'], applicationKernelFilePath: argResults['kernel-file'],
depfilePath: argResults['depfile'], depfilePath: argResults['depfile'],
privateKeyPath: argResults['private-key'], privateKeyPath: argResults['private-key'],
assetDirPath: argResults['asset-dir'], assetDirPath: argResults['asset-dir'],
previewDart2: argResults['preview-dart-2'],
precompiledSnapshot: argResults['precompiled'], precompiledSnapshot: argResults['precompiled'],
reportLicensedPackages: argResults['report-licensed-packages'], reportLicensedPackages: argResults['report-licensed-packages'],
trackWidgetCreation: argResults['track-widget-creation'], trackWidgetCreation: argResults['track-widget-creation'],
......
...@@ -38,7 +38,11 @@ class BuildIOSCommand extends BuildSubCommand { ...@@ -38,7 +38,11 @@ class BuildIOSCommand extends BuildSubCommand {
..addFlag('codesign', ..addFlag('codesign',
defaultsTo: true, defaultsTo: true,
help: 'Codesign the application bundle (only available on device builds).', help: 'Codesign the application bundle (only available on device builds).',
); )
..addFlag('preview-dart-2',
defaultsTo: true,
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.');
} }
@override @override
......
...@@ -334,6 +334,7 @@ class AppDomain extends Domain { ...@@ -334,6 +334,7 @@ class AppDomain extends Domain {
final BuildInfo buildInfo = new BuildInfo( final BuildInfo buildInfo = new BuildInfo(
getBuildModeForName(mode) ?? BuildMode.debug, getBuildModeForName(mode) ?? BuildMode.debug,
flavor, flavor,
previewDart2: _getBoolArg(args, 'preview-dart-2'),
); );
DebuggingOptions options; DebuggingOptions options;
if (buildInfo.isRelease) { if (buildInfo.isRelease) {
...@@ -384,6 +385,7 @@ class AppDomain extends Domain { ...@@ -384,6 +385,7 @@ class AppDomain extends Domain {
final FlutterDevice flutterDevice = new FlutterDevice( final FlutterDevice flutterDevice = new FlutterDevice(
device, device,
previewDart2: options.buildInfo.previewDart2,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
); );
......
...@@ -62,7 +62,10 @@ class DriveCommand extends RunCommandBase { ...@@ -62,7 +62,10 @@ class DriveCommand extends RunCommandBase {
'just before the extension, so e.g. if the target is "lib/main.dart", the\n' 'just before the extension, so e.g. if the target is "lib/main.dart", the\n'
'driver will be "test_driver/main_test.dart".', 'driver will be "test_driver/main_test.dart".',
valueHelp: 'path', valueHelp: 'path',
); )
..addFlag('preview-dart-2',
defaultsTo: true,
help: 'Preview Dart 2.0 functionality.');
} }
@override @override
...@@ -120,7 +123,7 @@ class DriveCommand extends RunCommandBase { ...@@ -120,7 +123,7 @@ class DriveCommand extends RunCommandBase {
Cache.releaseLockEarly(); Cache.releaseLockEarly();
try { try {
await testRunner(<String>[testFile], observatoryUri); await testRunner(<String>[testFile], observatoryUri, argResults['preview-dart-2']);
} catch (error, stackTrace) { } catch (error, stackTrace) {
if (error is ToolExit) if (error is ToolExit)
rethrow; rethrow;
...@@ -272,20 +275,24 @@ Future<LaunchResult> _startApp(DriveCommand command) async { ...@@ -272,20 +275,24 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
} }
/// Runs driver tests. /// Runs driver tests.
typedef Future<Null> TestRunner(List<String> testArgs, String observatoryUri); typedef Future<Null> TestRunner(List<String> testArgs, String observatoryUri, bool previewDart2);
TestRunner testRunner = _runTests; TestRunner testRunner = _runTests;
void restoreTestRunner() { void restoreTestRunner() {
testRunner = _runTests; testRunner = _runTests;
} }
Future<Null> _runTests(List<String> testArgs, String observatoryUri) async { Future<Null> _runTests(List<String> testArgs, String observatoryUri, bool previewDart2) async {
printTrace('Running driver tests.'); printTrace('Running driver tests.');
PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath)); PackageMap.globalPackagesPath = fs.path.normalize(fs.path.absolute(PackageMap.globalPackagesPath));
final List<String> args = testArgs.toList() final List<String> args = testArgs.toList()
..add('--packages=${PackageMap.globalPackagesPath}') ..add('--packages=${PackageMap.globalPackagesPath}')
..add('-rexpanded') ..add('-rexpanded');
..add('--preview-dart-2'); if (previewDart2) {
args.add('--preview-dart-2');
} else {
args.add('--no-preview-dart-2');
}
final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart'); final String dartVmPath = fs.path.join(dartSdkPath, 'bin', 'dart');
final int result = await runCommandAndStreamOutput( final int result = await runCommandAndStreamOutput(
......
...@@ -53,6 +53,10 @@ class FuchsiaReloadCommand extends FlutterCommand { ...@@ -53,6 +53,10 @@ class FuchsiaReloadCommand extends FlutterCommand {
argParser.addOption('name-override', argParser.addOption('name-override',
abbr: 'n', abbr: 'n',
help: 'On-device name of the application binary.'); help: 'On-device name of the application binary.');
argParser.addFlag('preview-dart-2',
abbr: '2',
defaultsTo: false,
help: 'Preview Dart 2.0 functionality.');
argParser.addOption('target', argParser.addOption('target',
abbr: 't', abbr: 't',
defaultsTo: bundle.defaultMainPath, defaultsTo: bundle.defaultMainPath,
...@@ -128,8 +132,13 @@ class FuchsiaReloadCommand extends FlutterCommand { ...@@ -128,8 +132,13 @@ class FuchsiaReloadCommand extends FlutterCommand {
final List<Uri> observatoryUris = fullAddresses.map( final List<Uri> observatoryUris = fullAddresses.map(
(String a) => Uri.parse('http://$a') (String a) => Uri.parse('http://$a')
).toList(); ).toList();
final FuchsiaDevice device = new FuchsiaDevice(fullAddresses[0], name: _address); final FuchsiaDevice device = new FuchsiaDevice(
final FlutterDevice flutterDevice = new FlutterDevice(device, trackWidgetCreation: false); fullAddresses[0], name: _address);
final FlutterDevice flutterDevice = new FlutterDevice(
device,
trackWidgetCreation: false,
previewDart2: false,
);
flutterDevice.observatoryUris = observatoryUris; flutterDevice.observatoryUris = observatoryUris;
final HotRunner hotRunner = new HotRunner( final HotRunner hotRunner = new HotRunner(
<FlutterDevice>[flutterDevice], <FlutterDevice>[flutterDevice],
......
...@@ -120,6 +120,11 @@ class RunCommand extends RunCommandBase { ...@@ -120,6 +120,11 @@ class RunCommand extends RunCommandBase {
hide: !verboseHelp, hide: !verboseHelp,
help: 'Specify a pre-built application binary to use when running.', help: 'Specify a pre-built application binary to use when running.',
) )
..addFlag('preview-dart-2',
defaultsTo: true,
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.',
)
..addFlag('track-widget-creation', ..addFlag('track-widget-creation',
hide: !verboseHelp, hide: !verboseHelp,
help: 'Track widget creation locations. Requires Dart 2.0 functionality.', help: 'Track widget creation locations. Requires Dart 2.0 functionality.',
...@@ -342,6 +347,7 @@ class RunCommand extends RunCommandBase { ...@@ -342,6 +347,7 @@ class RunCommand extends RunCommandBase {
final List<FlutterDevice> flutterDevices = devices.map((Device device) { final List<FlutterDevice> flutterDevices = devices.map((Device device) {
return new FlutterDevice( return new FlutterDevice(
device, device,
previewDart2: argResults['preview-dart-2'],
trackWidgetCreation: argResults['track-widget-creation'], trackWidgetCreation: argResults['track-widget-creation'],
dillOutputPath: argResults['output-dill'], dillOutputPath: argResults['output-dill'],
fileSystemRoots: argResults['filesystem-root'], fileSystemRoots: argResults['filesystem-root'],
......
...@@ -68,6 +68,11 @@ class TestCommand extends FlutterCommand { ...@@ -68,6 +68,11 @@ class TestCommand extends FlutterCommand {
help: 'Handle machine structured JSON command input\n' help: 'Handle machine structured JSON command input\n'
'and provide output and progress in machine friendly format.', 'and provide output and progress in machine friendly format.',
) )
..addFlag('preview-dart-2',
defaultsTo: true,
hide: !verboseHelp,
help: 'Preview Dart 2.0 functionality.',
)
..addFlag('track-widget-creation', ..addFlag('track-widget-creation',
negatable: false, negatable: false,
hide: !verboseHelp, hide: !verboseHelp,
...@@ -218,6 +223,7 @@ class TestCommand extends FlutterCommand { ...@@ -218,6 +223,7 @@ class TestCommand extends FlutterCommand {
startPaused: startPaused, startPaused: startPaused,
ipv6: argResults['ipv6'], ipv6: argResults['ipv6'],
machine: machine, machine: machine,
previewDart2: argResults['preview-dart-2'],
trackWidgetCreation: argResults['track-widget-creation'], trackWidgetCreation: argResults['track-widget-creation'],
updateGoldens: argResults['update-goldens'], updateGoldens: argResults['update-goldens'],
); );
......
...@@ -13,10 +13,11 @@ import '../base/process_manager.dart'; ...@@ -13,10 +13,11 @@ import '../base/process_manager.dart';
import '../globals.dart'; import '../globals.dart';
class AnalysisServer { class AnalysisServer {
AnalysisServer(this.sdkPath, this.directories); AnalysisServer(this.sdkPath, this.directories, {this.previewDart2 = false});
final String sdkPath; final String sdkPath;
final List<String> directories; final List<String> directories;
final bool previewDart2;
Process _process; Process _process;
final StreamController<bool> _analyzingController = final StreamController<bool> _analyzingController =
...@@ -34,9 +35,14 @@ class AnalysisServer { ...@@ -34,9 +35,14 @@ class AnalysisServer {
snapshot, snapshot,
'--sdk', '--sdk',
sdkPath, sdkPath,
'--preview-dart-2',
]; ];
if (previewDart2) {
command.add('--preview-dart-2');
} else {
command.add('--no-preview-dart-2');
}
printTrace('dart ${command.skip(1).join(' ')}'); printTrace('dart ${command.skip(1).join(' ')}');
_process = await processManager.start(command); _process = await processManager.start(command);
// This callback hookup can't throw. // This callback hookup can't throw.
......
...@@ -6,7 +6,6 @@ import 'dart:async'; ...@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:convert' show base64, utf8; import 'dart:convert' show base64, utf8;
import 'package:json_rpc_2/json_rpc_2.dart' as rpc; import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:meta/meta.dart';
import 'asset.dart'; import 'asset.dart';
import 'base/context.dart'; import 'base/context.dart';
...@@ -402,14 +401,14 @@ class DevFS { ...@@ -402,14 +401,14 @@ class DevFS {
/// ///
/// Returns the number of bytes synced. /// Returns the number of bytes synced.
Future<int> update({ Future<int> update({
@required String mainPath, String mainPath,
String target, String target,
AssetBundle bundle, AssetBundle bundle,
DateTime firstBuildTime, DateTime firstBuildTime,
bool bundleFirstUpload = false, bool bundleFirstUpload = false,
bool bundleDirty = false, bool bundleDirty = false,
Set<String> fileFilter, Set<String> fileFilter,
@required ResidentCompiler generator, ResidentCompiler generator,
String dillOutputPath, String dillOutputPath,
bool fullRestart = false, bool fullRestart = false,
String projectRootPath, String projectRootPath,
...@@ -425,9 +424,10 @@ class DevFS { ...@@ -425,9 +424,10 @@ class DevFS {
await _scanDirectory(rootDirectory, await _scanDirectory(rootDirectory,
recursive: true, recursive: true,
fileFilter: fileFilter); fileFilter: fileFilter);
final bool previewDart2 = generator != null;
if (fs.isFileSync(_packagesFilePath)) { if (fs.isFileSync(_packagesFilePath)) {
printTrace('Scanning package files'); printTrace('Scanning package files');
await _scanPackages(fileFilter); await _scanPackages(fileFilter, previewDart2);
} }
if (bundle != null) { if (bundle != null) {
printTrace('Scanning asset files'); printTrace('Scanning asset files');
...@@ -468,9 +468,10 @@ class DevFS { ...@@ -468,9 +468,10 @@ class DevFS {
String archivePath; String archivePath;
if (deviceUri.path.startsWith(assetBuildDirPrefix)) if (deviceUri.path.startsWith(assetBuildDirPrefix))
archivePath = deviceUri.path.substring(assetBuildDirPrefix.length); archivePath = deviceUri.path.substring(assetBuildDirPrefix.length);
// When doing full restart in, copy content so that isModified does not // When doing full restart in preview-dart-2 mode, copy content so
// reset last check timestamp because we want to report all modified // that isModified does not reset last check timestamp because we
// files to incremental compiler next time user does hot reload. // want to report all modified files to incremental compiler next time
// user does hot reload.
if (content.isModified || ((bundleDirty || bundleFirstUpload) && archivePath != null)) { if (content.isModified || ((bundleDirty || bundleFirstUpload) && archivePath != null)) {
dirtyEntries[deviceUri] = content; dirtyEntries[deviceUri] = content;
numBytes += content.size; numBytes += content.size;
...@@ -478,24 +479,24 @@ class DevFS { ...@@ -478,24 +479,24 @@ class DevFS {
assetPathsToEvict.add(archivePath); assetPathsToEvict.add(archivePath);
} }
}); });
if (previewDart2) {
// We run generator even if [dirtyEntries] was empty because we want to // We run generator even if [dirtyEntries] was empty because we want
// keep logic of accepting/rejecting generator's output simple: we must // to keep logic of accepting/rejecting generator's output simple:
// accept/reject generator's output after every [update] call. Incremental // we must accept/reject generator's output after every [update] call.
// run with no changes is supposed to be fast (considering that it is // Incremental run with no changes is supposed to be fast (considering
// initiated by user key press). // that it is initiated by user key press).
final List<String> invalidatedFiles = <String>[]; final List<String> invalidatedFiles = <String>[];
final Set<Uri> filesUris = new Set<Uri>(); final Set<Uri> filesUris = new Set<Uri>();
for (Uri uri in dirtyEntries.keys.toList()) { for (Uri uri in dirtyEntries.keys.toList()) {
if (!uri.path.startsWith(assetBuildDirPrefix)) { if (!uri.path.startsWith(assetBuildDirPrefix)) {
final DevFSContent content = dirtyEntries[uri]; final DevFSContent content = dirtyEntries[uri];
if (content is DevFSFileContent) { if (content is DevFSFileContent) {
filesUris.add(uri); filesUris.add(uri);
invalidatedFiles.add(content.file.uri.toString()); invalidatedFiles.add(content.file.uri.toString());
numBytes -= content.size; numBytes -= content.size;
}
} }
} }
// No need to send source files because all compilation is done on the // No need to send source files because all compilation is done on the
// host and result of compilation is single kernel file. // host and result of compilation is single kernel file.
filesUris.forEach(dirtyEntries.remove); filesUris.forEach(dirtyEntries.remove);
...@@ -503,12 +504,10 @@ class DevFS { ...@@ -503,12 +504,10 @@ class DevFS {
if (fullRestart) { if (fullRestart) {
generator.reset(); generator.reset();
} }
final CompilerOutput compilerOutput = await generator.recompile( final CompilerOutput compilerOutput =
mainPath, await generator.recompile(mainPath, invalidatedFiles,
invalidatedFiles, outputPath: dillOutputPath ?? fs.path.join(getBuildDirectory(), 'app.dill'),
outputPath: dillOutputPath ?? fs.path.join(getBuildDirectory(), 'app.dill'), packagesFilePath : _packagesFilePath);
packagesFilePath : _packagesFilePath,
);
final String compiledBinary = compilerOutput?.outputFilename; final String compiledBinary = compilerOutput?.outputFilename;
if (compiledBinary != null && compiledBinary.isNotEmpty) { if (compiledBinary != null && compiledBinary.isNotEmpty) {
final String entryUri = projectRootPath != null ? final String entryUri = projectRootPath != null ?
...@@ -698,7 +697,7 @@ class DevFS { ...@@ -698,7 +697,7 @@ class DevFS {
); );
} }
Future<Null> _scanPackages(Set<String> fileFilter) async { Future<Null> _scanPackages(Set<String> fileFilter, bool previewDart2) async {
StringBuffer sb; StringBuffer sb;
final PackageMap packageMap = new PackageMap(_packagesFilePath); final PackageMap packageMap = new PackageMap(_packagesFilePath);
...@@ -731,6 +730,22 @@ class DevFS { ...@@ -731,6 +730,22 @@ class DevFS {
sb.writeln('$packageName:$directoryUriOnDevice'); sb.writeln('$packageName:$directoryUriOnDevice');
} }
} }
if (previewDart2) {
// When in previewDart2 mode we don't update .packages-file entry
// so actual file will get invalidated in frontend.
// We don't need to synthesize device-correct .packages file because
// it is not going to be used on the device anyway - compilation
// is done on the host.
return;
}
if (sb != null) {
final DevFSContent content = _entries[fs.path.toUri('.packages')];
if (content is DevFSStringContent && content.string == sb.toString()) {
content._exists = true;
return;
}
_entries[fs.path.toUri('.packages')] = new DevFSStringContent(sb.toString());
}
} }
} }
/// Converts a platform-specific file path to a platform-independent Uri path. /// Converts a platform-specific file path to a platform-independent Uri path.
......
...@@ -246,6 +246,7 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -246,6 +246,7 @@ Future<XcodeBuildResult> buildXcodeProject({
projectPath: fs.currentDirectory.path, projectPath: fs.currentDirectory.path,
buildInfo: buildInfo, buildInfo: buildInfo,
targetOverride: targetOverride, targetOverride: targetOverride,
previewDart2: buildInfo.previewDart2,
); );
if (hasPlugins()) { if (hasPlugins()) {
...@@ -427,7 +428,7 @@ Future<XcodeBuildResult> buildXcodeProject({ ...@@ -427,7 +428,7 @@ Future<XcodeBuildResult> buildXcodeProject({
outputDir = expectedOutputDirectory.replaceFirst('/$configuration-', '/'); outputDir = expectedOutputDirectory.replaceFirst('/$configuration-', '/');
if (fs.isDirectorySync(outputDir)) { if (fs.isDirectorySync(outputDir)) {
// Previous output directory might have incompatible artifacts // Previous output directory might have incompatible artifacts
// (for example, kernel binary files produced from previous run). // (for example, kernel binary files produced from previous `--preview-dart-2` run).
fs.directory(outputDir).deleteSync(recursive: true); fs.directory(outputDir).deleteSync(recursive: true);
} }
copyDirectorySync(fs.directory(expectedOutputDirectory), fs.directory(outputDir)); copyDirectorySync(fs.directory(expectedOutputDirectory), fs.directory(outputDir));
......
...@@ -362,6 +362,7 @@ class IOSSimulator extends Device { ...@@ -362,6 +362,7 @@ class IOSSimulator extends Device {
// The build mode for the simulator is always debug. // The build mode for the simulator is always debug.
final BuildInfo debugBuildInfo = new BuildInfo(BuildMode.debug, buildInfo.flavor, final BuildInfo debugBuildInfo = new BuildInfo(BuildMode.debug, buildInfo.flavor,
previewDart2: buildInfo.previewDart2,
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
extraFrontEndOptions: buildInfo.extraFrontEndOptions, extraFrontEndOptions: buildInfo.extraFrontEndOptions,
extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions, extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions,
...@@ -389,10 +390,12 @@ class IOSSimulator extends Device { ...@@ -389,10 +390,12 @@ class IOSSimulator extends Device {
} }
Future<Null> _sideloadUpdatedAssetsForInstalledApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath) { Future<Null> _sideloadUpdatedAssetsForInstalledApplicationBundle(ApplicationPackage app, BuildInfo buildInfo, String mainPath) {
// Run compiler to produce kernel file for the application. // When running in previewDart2 mode, we still need to run compiler to
// produce kernel file for the application.
return bundle.build( return bundle.build(
mainPath: mainPath, mainPath: mainPath,
precompiledSnapshot: false, precompiledSnapshot: !buildInfo.previewDart2,
previewDart2: buildInfo.previewDart2,
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
); );
} }
......
...@@ -42,6 +42,7 @@ Future<void> generateXcodeProperties(String projectPath) async { ...@@ -42,6 +42,7 @@ Future<void> generateXcodeProperties(String projectPath) async {
projectPath: projectPath, projectPath: projectPath,
buildInfo: BuildInfo.debug, buildInfo: BuildInfo.debug,
targetOverride: bundle.defaultMainPath, targetOverride: bundle.defaultMainPath,
previewDart2: false,
); );
} }
} }
...@@ -54,6 +55,7 @@ Future<void> updateGeneratedXcodeProperties({ ...@@ -54,6 +55,7 @@ Future<void> updateGeneratedXcodeProperties({
@required String projectPath, @required String projectPath,
@required BuildInfo buildInfo, @required BuildInfo buildInfo,
String targetOverride, String targetOverride,
@required bool previewDart2,
}) async { }) async {
final StringBuffer localsBuffer = new StringBuffer(); final StringBuffer localsBuffer = new StringBuffer();
...@@ -111,6 +113,10 @@ Future<void> updateGeneratedXcodeProperties({ ...@@ -111,6 +113,10 @@ Future<void> updateGeneratedXcodeProperties({
localsBuffer.writeln('ARCHS=$arch'); localsBuffer.writeln('ARCHS=$arch');
} }
if (previewDart2) {
localsBuffer.writeln('PREVIEW_DART_2=true');
}
if (buildInfo.trackWidgetCreation) { if (buildInfo.trackWidgetCreation) {
localsBuffer.writeln('TRACK_WIDGET_CREATION=true'); localsBuffer.writeln('TRACK_WIDGET_CREATION=true');
} }
......
...@@ -34,7 +34,7 @@ class FlutterDevice { ...@@ -34,7 +34,7 @@ class FlutterDevice {
List<VMService> vmServices; List<VMService> vmServices;
DevFS devFS; DevFS devFS;
ApplicationPackage package; ApplicationPackage package;
final ResidentCompiler generator; ResidentCompiler generator;
String dillOutputPath; String dillOutputPath;
List<String> fileSystemRoots; List<String> fileSystemRoots;
String fileSystemScheme; String fileSystemScheme;
...@@ -42,15 +42,20 @@ class FlutterDevice { ...@@ -42,15 +42,20 @@ class FlutterDevice {
StreamSubscription<String> _loggingSubscription; StreamSubscription<String> _loggingSubscription;
FlutterDevice(this.device, { FlutterDevice(this.device, {
@required bool previewDart2,
@required bool trackWidgetCreation, @required bool trackWidgetCreation,
this.dillOutputPath, this.dillOutputPath,
this.fileSystemRoots, this.fileSystemRoots,
this.fileSystemScheme, this.fileSystemScheme,
}) : generator = new ResidentCompiler( }) {
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), if (previewDart2) {
trackWidgetCreation: trackWidgetCreation, generator = new ResidentCompiler(
fileSystemRoots: fileSystemRoots, artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
fileSystemScheme: fileSystemScheme); trackWidgetCreation: trackWidgetCreation,
fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme
);
}
}
String viewFilter; String viewFilter;
...@@ -407,9 +412,9 @@ class FlutterDevice { ...@@ -407,9 +412,9 @@ class FlutterDevice {
void updateReloadStatus(bool wasReloadSuccessful) { void updateReloadStatus(bool wasReloadSuccessful) {
if (wasReloadSuccessful) if (wasReloadSuccessful)
generator.accept(); generator?.accept();
else else
generator.reject(); generator?.reject();
} }
} }
......
...@@ -412,11 +412,15 @@ class HotRunner extends ResidentRunner { ...@@ -412,11 +412,15 @@ class HotRunner extends ResidentRunner {
} }
// We are now running from source. // We are now running from source.
_runningFromSnapshot = false; _runningFromSnapshot = false;
final String launchPath = debuggingOptions.buildInfo.previewDart2
await _launchFromDevFS('$mainPath.dill'); ? mainPath + '.dill'
: mainPath;
await _launchFromDevFS(launchPath);
restartTimer.stop(); restartTimer.stop();
printTrace('Restart performed in ${getElapsedAsMilliseconds(restartTimer.elapsed)}.'); printTrace('Restart performed in '
'${getElapsedAsMilliseconds(restartTimer.elapsed)}.');
// We are now running from sources.
_runningFromSnapshot = false;
_addBenchmarkData('hotRestartMillisecondsToFrame', _addBenchmarkData('hotRestartMillisecondsToFrame',
restartTimer.elapsed.inMilliseconds); restartTimer.elapsed.inMilliseconds);
flutterUsage.sendEvent('hot', 'restart'); flutterUsage.sendEvent('hot', 'restart');
...@@ -506,6 +510,14 @@ class HotRunner extends ResidentRunner { ...@@ -506,6 +510,14 @@ class HotRunner extends ResidentRunner {
} }
} }
String _uriToRelativePath(Uri uri) {
final String path = uri.toString();
final String base = new Uri.file(projectRootPath).toString();
if (path.startsWith(base))
return path.substring(base.length + 1);
return path;
}
Future<OperationResult> _reloadSources({ bool pause = false }) async { Future<OperationResult> _reloadSources({ bool pause = false }) async {
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) { for (FlutterView view in device.views) {
...@@ -525,6 +537,7 @@ class HotRunner extends ResidentRunner { ...@@ -525,6 +537,7 @@ class HotRunner extends ResidentRunner {
// change from host path to a device path). Subsequent reloads will // change from host path to a device path). Subsequent reloads will
// not be affected, so we resume reporting reload times on the second // not be affected, so we resume reporting reload times on the second
// reload. // reload.
final bool reportUnused = !debuggingOptions.buildInfo.previewDart2;
final bool shouldReportReloadTime = !_runningFromSnapshot; final bool shouldReportReloadTime = !_runningFromSnapshot;
final Stopwatch reloadTimer = new Stopwatch()..start(); final Stopwatch reloadTimer = new Stopwatch()..start();
...@@ -538,7 +551,10 @@ class HotRunner extends ResidentRunner { ...@@ -538,7 +551,10 @@ class HotRunner extends ResidentRunner {
String reloadMessage; String reloadMessage;
final Stopwatch vmReloadTimer = new Stopwatch()..start(); final Stopwatch vmReloadTimer = new Stopwatch()..start();
try { try {
final String entryPath = fs.path.relative('$mainPath.dill', from: projectRootPath); final String entryPath = fs.path.relative(
debuggingOptions.buildInfo.previewDart2 ? mainPath + '.dill' : mainPath,
from: projectRootPath,
);
final Completer<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>(); final Completer<Map<String, dynamic>> retrieveFirstReloadReport = new Completer<Map<String, dynamic>>();
int countExpectedReports = 0; int countExpectedReports = 0;
...@@ -550,7 +566,10 @@ class HotRunner extends ResidentRunner { ...@@ -550,7 +566,10 @@ class HotRunner extends ResidentRunner {
} }
// List has one report per Flutter view. // List has one report per Flutter view.
final List<Future<Map<String, dynamic>>> reports = device.reloadSources(entryPath, pause: pause); final List<Future<Map<String, dynamic>>> reports = device.reloadSources(
entryPath,
pause: pause
);
countExpectedReports += reports.length; countExpectedReports += reports.length;
Future.wait(reports).catchError((dynamic error) { Future.wait(reports).catchError((dynamic error) {
return <Map<String, dynamic>>[error]; return <Map<String, dynamic>>[error];
...@@ -618,8 +637,8 @@ class HotRunner extends ResidentRunner { ...@@ -618,8 +637,8 @@ class HotRunner extends ResidentRunner {
} }
// We are now running from source. // We are now running from source.
_runningFromSnapshot = false; _runningFromSnapshot = false;
// Check if the isolate is paused. // Check if the isolate is paused.
final List<FlutterView> reassembleViews = <FlutterView>[]; final List<FlutterView> reassembleViews = <FlutterView>[];
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) { for (FlutterView view in device.views) {
...@@ -680,9 +699,36 @@ class HotRunner extends ResidentRunner { ...@@ -680,9 +699,36 @@ class HotRunner extends ResidentRunner {
shouldReportReloadTime) shouldReportReloadTime)
flutterUsage.sendTiming('hot', 'reload', reloadTimer.elapsed); flutterUsage.sendTiming('hot', 'reload', reloadTimer.elapsed);
String unusedElementMessage;
if (reportUnused && !reassembleAndScheduleErrors && !reassembleTimedOut) {
final List<Future<List<ProgramElement>>> unusedReports =
<Future<List<ProgramElement>>>[];
for (FlutterDevice device in flutterDevices)
unusedReports.add(device.unusedChangesInLastReload());
final List<ProgramElement> unusedElements = <ProgramElement>[];
for (Future<List<ProgramElement>> unusedReport in unusedReports)
unusedElements.addAll(await unusedReport);
if (unusedElements.isNotEmpty) {
final String restartCommand = hostIsIde ? '' : ' (by pressing "R")';
unusedElementMessage =
'Some program elements were changed during reload but did not run when the view was reassembled;\n'
'you may need to restart the app$restartCommand for the changes to have an effect.';
for (ProgramElement unusedElement in unusedElements) {
final String name = unusedElement.qualifiedName;
final String path = _uriToRelativePath(unusedElement.uri);
final int line = unusedElement.line;
final String description = line == null ? '$name ($path)' : '$name ($path:$line)';
unusedElementMessage += '\n$description';
}
}
}
return new OperationResult( return new OperationResult(
reassembleAndScheduleErrors ? 1 : OperationResult.ok.code, reassembleAndScheduleErrors ? 1 : OperationResult.ok.code,
reloadMessage, reloadMessage,
hintMessage: unusedElementMessage,
hintId: unusedElementMessage != null ? 'restartRecommended' : null,
); );
} }
......
...@@ -182,6 +182,10 @@ abstract class FlutterCommand extends Command<Null> { ...@@ -182,6 +182,10 @@ abstract class FlutterCommand extends Command<Null> {
} }
BuildInfo getBuildInfo() { BuildInfo getBuildInfo() {
final bool previewDart2 = argParser.options.containsKey('preview-dart-2')
? argResults['preview-dart-2']
: true;
TargetPlatform targetPlatform; TargetPlatform targetPlatform;
if (argParser.options.containsKey('target-platform') && if (argParser.options.containsKey('target-platform') &&
argResults['target-platform'] != 'default') { argResults['target-platform'] != 'default') {
...@@ -191,6 +195,10 @@ abstract class FlutterCommand extends Command<Null> { ...@@ -191,6 +195,10 @@ abstract class FlutterCommand extends Command<Null> {
final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation') final bool trackWidgetCreation = argParser.options.containsKey('track-widget-creation')
? argResults['track-widget-creation'] ? argResults['track-widget-creation']
: false; : false;
if (trackWidgetCreation == true && previewDart2 == false) {
throw new UsageException(
'--track-widget-creation is valid only when --preview-dart-2 is specified.', null);
}
int buildNumber; int buildNumber;
try { try {
...@@ -206,6 +214,7 @@ abstract class FlutterCommand extends Command<Null> { ...@@ -206,6 +214,7 @@ abstract class FlutterCommand extends Command<Null> {
argParser.options.containsKey('flavor') argParser.options.containsKey('flavor')
? argResults['flavor'] ? argResults['flavor']
: null, : null,
previewDart2: previewDart2,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
extraFrontEndOptions: argParser.options.containsKey(FlutterOptions.kExtraFrontEndOptions) extraFrontEndOptions: argParser.options.containsKey(FlutterOptions.kExtraFrontEndOptions)
? argResults[FlutterOptions.kExtraFrontEndOptions] ? argResults[FlutterOptions.kExtraFrontEndOptions]
......
...@@ -67,6 +67,7 @@ void installHook({ ...@@ -67,6 +67,7 @@ void installHook({
bool enableObservatory = false, bool enableObservatory = false,
bool machine = false, bool machine = false,
bool startPaused = false, bool startPaused = false,
bool previewDart2 = false,
int port = 0, int port = 0,
String precompiledDillPath, String precompiledDillPath,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
...@@ -85,6 +86,7 @@ void installHook({ ...@@ -85,6 +86,7 @@ void installHook({
startPaused: startPaused, startPaused: startPaused,
explicitObservatoryPort: observatoryPort, explicitObservatoryPort: observatoryPort,
host: _kHosts[serverType], host: _kHosts[serverType],
previewDart2: previewDart2,
port: port, port: port,
precompiledDillPath: precompiledDillPath, precompiledDillPath: precompiledDillPath,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
...@@ -304,6 +306,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -304,6 +306,7 @@ class _FlutterPlatform extends PlatformPlugin {
this.startPaused, this.startPaused,
this.explicitObservatoryPort, this.explicitObservatoryPort,
this.host, this.host,
this.previewDart2,
this.port, this.port,
this.precompiledDillPath, this.precompiledDillPath,
this.trackWidgetCreation, this.trackWidgetCreation,
...@@ -317,6 +320,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -317,6 +320,7 @@ class _FlutterPlatform extends PlatformPlugin {
final bool startPaused; final bool startPaused;
final int explicitObservatoryPort; final int explicitObservatoryPort;
final InternetAddress host; final InternetAddress host;
final bool previewDart2;
final int port; final int port;
final String precompiledDillPath; final String precompiledDillPath;
final bool trackWidgetCreation; final bool trackWidgetCreation;
...@@ -404,15 +408,17 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -404,15 +408,17 @@ class _FlutterPlatform extends PlatformPlugin {
cancelOnError: true, cancelOnError: true,
); );
printTrace('test $ourTestCount: starting shell process'); printTrace('test $ourTestCount: starting shell process${previewDart2? " in preview-dart-2 mode":""}');
// [precompiledDillPath] can be set only if [previewDart2] is [true].
assert(precompiledDillPath == null || previewDart2);
// If a kernel file is given, then use that to launch the test. // If a kernel file is given, then use that to launch the test.
// Otherwise create a "listener" dart that invokes actual test. // Otherwise create a "listener" dart that invokes actual test.
String mainDart = precompiledDillPath != null String mainDart = precompiledDillPath != null
? precompiledDillPath ? precompiledDillPath
: _createListenerDart(finalizers, ourTestCount, testPath, server); : _createListenerDart(finalizers, ourTestCount, testPath, server);
if (precompiledDillPath == null) { if (previewDart2 && precompiledDillPath == null) {
// Lazily instantiate compiler so it is built only if it is actually used. // Lazily instantiate compiler so it is built only if it is actually used.
compiler ??= new _Compiler(trackWidgetCreation); compiler ??= new _Compiler(trackWidgetCreation);
mainDart = await compiler.compile(mainDart); mainDart = await compiler.compile(mainDart);
...@@ -669,6 +675,10 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -669,6 +675,10 @@ class _FlutterPlatform extends PlatformPlugin {
} }
String _getBundlePath(List<_Finalizer> finalizers, int ourTestCount) { String _getBundlePath(List<_Finalizer> finalizers, int ourTestCount) {
if (!previewDart2) {
return null;
}
if (precompiledDillPath != null) { if (precompiledDillPath != null) {
return artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath); return artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:async'; import 'dart:async';
import 'package:args/command_runner.dart';
// ignore: implementation_imports // ignore: implementation_imports
import 'package:test/src/executable.dart' as test; import 'package:test/src/executable.dart' as test;
...@@ -28,10 +29,18 @@ Future<int> runTests( ...@@ -28,10 +29,18 @@ Future<int> runTests(
bool startPaused = false, bool startPaused = false,
bool ipv6 = false, bool ipv6 = false,
bool machine = false, bool machine = false,
bool previewDart2 = false,
bool trackWidgetCreation = false, bool trackWidgetCreation = false,
bool updateGoldens = false, bool updateGoldens = false,
TestWatcher watcher, TestWatcher watcher,
}) async { }) async {
if (trackWidgetCreation && !previewDart2) {
throw new UsageException(
'--track-widget-creation is valid only when --preview-dart-2 is specified.',
null,
);
}
// Compute the command-line arguments for package:test. // Compute the command-line arguments for package:test.
final List<String> testArgs = <String>[]; final List<String> testArgs = <String>[];
if (!terminal.supportsColor) { if (!terminal.supportsColor) {
...@@ -78,6 +87,7 @@ Future<int> runTests( ...@@ -78,6 +87,7 @@ Future<int> runTests(
machine: machine, machine: machine,
startPaused: startPaused, startPaused: startPaused,
serverType: serverType, serverType: serverType,
previewDart2: previewDart2,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
updateGoldens: updateGoldens, updateGoldens: updateGoldens,
); );
......
...@@ -133,11 +133,20 @@ class FlutterTesterDevice extends Device { ...@@ -133,11 +133,20 @@ class FlutterTesterDevice extends Device {
mainPath: mainPath, mainPath: mainPath,
assetDirPath: assetDirPath, assetDirPath: assetDirPath,
applicationKernelFilePath: applicationKernelFilePath, applicationKernelFilePath: applicationKernelFilePath,
precompiledSnapshot: false, precompiledSnapshot: !buildInfo.previewDart2,
previewDart2: buildInfo.previewDart2,
trackWidgetCreation: buildInfo.trackWidgetCreation, trackWidgetCreation: buildInfo.trackWidgetCreation,
); );
if (buildInfo.previewDart2) {
mainPath = applicationKernelFilePath;
}
command.add('--flutter-assets-dir=$assetDirPath'); command.add('--flutter-assets-dir=$assetDirPath');
command.add(applicationKernelFilePath);
// TODO(scheglov): Either remove the check, or make it fail earlier.
if (mainPath != null) {
command.add(mainPath);
}
try { try {
printTrace(command.join(' ')); printTrace(command.join(' '));
......
...@@ -70,10 +70,10 @@ void main() { ...@@ -70,10 +70,10 @@ void main() {
OperatingSystemUtils: () => os OperatingSystemUtils: () => os
}); });
testUsingContext('Returns no errors when source is error-free', () async { testUsingContext('--preview-dart-2', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');"; const String contents = "StringBuffer bar = StringBuffer('baz');";
tempDir.childFile('main.dart').writeAsStringSync(contents); tempDir.childFile('main.dart').writeAsStringSync(contents);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path]); server = new AnalysisServer(dartSdkPath, <String>[tempDir.path], previewDart2: true);
int errorCount = 0; int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
...@@ -88,6 +88,25 @@ void main() { ...@@ -88,6 +88,25 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
OperatingSystemUtils: () => os OperatingSystemUtils: () => os
}); });
testUsingContext('no --preview-dart-2 shows errors', () async {
const String contents = "StringBuffer bar = StringBuffer('baz');";
tempDir.childFile('main.dart').writeAsStringSync(contents);
server = new AnalysisServer(dartSdkPath, <String>[tempDir.path], previewDart2: false);
int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first;
server.onErrors.listen((FileAnalysisErrors errors) {
errorCount += errors.errors.length;
});
await server.start();
await onDone;
expect(errorCount, 1);
}, overrides: <Type, Generator>{
OperatingSystemUtils: () => os
});
} }
void _createSampleProject(Directory directory, { bool brokenCode = false }) { void _createSampleProject(Directory directory, { bool brokenCode = false }) {
......
...@@ -168,7 +168,7 @@ void bar() { ...@@ -168,7 +168,7 @@ void bar() {
} }
}); });
testUsingContext('returns no issues when source is error-free', () async { testUsingContext('--preview-dart-2', () async {
const String contents = ''' const String contents = '''
StringBuffer bar = StringBuffer('baz'); StringBuffer bar = StringBuffer('baz');
'''; ''';
...@@ -179,13 +179,33 @@ StringBuffer bar = StringBuffer('baz'); ...@@ -179,13 +179,33 @@ StringBuffer bar = StringBuffer('baz');
try { try {
await runCommand( await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)), command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
arguments: <String>['analyze'], arguments: <String>['analyze', '--preview-dart-2'],
statusTextContains: <String>['No issues found!'], statusTextContains: <String>['No issues found!'],
); );
} finally { } finally {
tempDir.deleteSync(recursive: true); tempDir.deleteSync(recursive: true);
} }
}); });
testUsingContext('no --preview-dart-2 shows errors', () async {
const String contents = '''
StringBuffer bar = StringBuffer('baz');
''';
final Directory tempDir = fs.systemTempDirectory.createTempSync();
tempDir.childFile('main.dart').writeAsStringSync(contents);
try {
await runCommand(
command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)),
arguments: <String>['analyze', '--no-preview-dart-2'],
statusTextContains: <String>['1 issue found.'],
toolExit: true,
);
} finally {
tempDir.deleteSync(recursive: true);
}
});
}); });
} }
......
...@@ -54,7 +54,7 @@ void main() { ...@@ -54,7 +54,7 @@ void main() {
appStarter = (DriveCommand command) { appStarter = (DriveCommand command) {
throw 'Unexpected call to appStarter'; throw 'Unexpected call to appStarter';
}; };
testRunner = (List<String> testArgs, String observatoryUri) { testRunner = (List<String> testArgs, String observatoryUri, bool previewDart2) {
throw 'Unexpected call to testRunner'; throw 'Unexpected call to testRunner';
}; };
appStopper = (DriveCommand command) { appStopper = (DriveCommand command) {
...@@ -169,7 +169,7 @@ void main() { ...@@ -169,7 +169,7 @@ void main() {
appStarter = expectAsync1((DriveCommand command) async { appStarter = expectAsync1((DriveCommand command) async {
return new LaunchResult.succeeded(); return new LaunchResult.succeeded();
}); });
testRunner = expectAsync2((List<String> testArgs, String observatoryUri) async { testRunner = expectAsync3((List<String> testArgs, String observatoryUri, bool previewDart2) async {
expect(testArgs, <String>[testFile]); expect(testArgs, <String>[testFile]);
return null; return null;
}); });
...@@ -200,7 +200,7 @@ void main() { ...@@ -200,7 +200,7 @@ void main() {
appStarter = expectAsync1((DriveCommand command) async { appStarter = expectAsync1((DriveCommand command) async {
return new LaunchResult.succeeded(); return new LaunchResult.succeeded();
}); });
testRunner = (List<String> testArgs, String observatoryUri) async { testRunner = (List<String> testArgs, String observatoryUri, bool previewDart2) async {
throwToolExit(null, exitCode: 123); throwToolExit(null, exitCode: 123);
}; };
appStopper = expectAsync1((DriveCommand command) async { appStopper = expectAsync1((DriveCommand command) async {
......
This diff is collapsed.
...@@ -284,10 +284,14 @@ Information about project "Runner": ...@@ -284,10 +284,14 @@ Information about project "Runner":
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine'); when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
projectPath: 'path/to/project', projectPath: 'path/to/project',
buildInfo: buildInfo, buildInfo: buildInfo,
previewDart2: true,
); );
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
...@@ -301,12 +305,14 @@ Information about project "Runner": ...@@ -301,12 +305,14 @@ Information about project "Runner":
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine'); when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
trackWidgetCreation: true, trackWidgetCreation: true,
targetPlatform: TargetPlatform.ios, targetPlatform: TargetPlatform.ios,
); );
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
projectPath: 'path/to/project', projectPath: 'path/to/project',
buildInfo: buildInfo, buildInfo: buildInfo,
previewDart2: true,
); );
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
...@@ -319,10 +325,14 @@ Information about project "Runner": ...@@ -319,10 +325,14 @@ Information about project "Runner":
testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async { testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine'); when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
projectPath: 'path/to/project', projectPath: 'path/to/project',
buildInfo: buildInfo, buildInfo: buildInfo,
previewDart2: true,
); );
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
...@@ -335,10 +345,14 @@ Information about project "Runner": ...@@ -335,10 +345,14 @@ Information about project "Runner":
testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async {
when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine'); when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, typed(any))).thenReturn('engine');
when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile')); when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile'));
const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null, targetPlatform: TargetPlatform.ios); const BuildInfo buildInfo = const BuildInfo(BuildMode.debug, null,
previewDart2: true,
targetPlatform: TargetPlatform.ios,
);
await updateGeneratedXcodeProperties( await updateGeneratedXcodeProperties(
projectPath: 'path/to/project', projectPath: 'path/to/project',
buildInfo: buildInfo, buildInfo: buildInfo,
previewDart2: true,
); );
final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig');
...@@ -391,6 +405,7 @@ Information about project "Runner": ...@@ -391,6 +405,7 @@ Information about project "Runner":
projectPath: projectPath, projectPath: projectPath,
buildInfo: buildInfo, buildInfo: buildInfo,
targetOverride: bundle.defaultMainPath, targetOverride: bundle.defaultMainPath,
previewDart2: false,
); );
final String propertiesPath = fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig'); final String propertiesPath = fs.path.join(projectPath, 'ios', 'Flutter', 'Generated.xcconfig');
......
...@@ -44,11 +44,14 @@ class TestRunner extends ResidentRunner { ...@@ -44,11 +44,14 @@ class TestRunner extends ResidentRunner {
void main() { void main() {
TestRunner createTestRunner() { TestRunner createTestRunner() {
// TODO(jacobr): make these tests run with `trackWidgetCreation: true` as // TODO(jacobr): make these tests run with `previewDart2: true` and
// well as the default flags. // `trackWidgetCreation: true` as well as the default flags.
// Currently the TestRunner is not properly configured to be able to run
// with `previewDart2: true` due to missing resources.
return new TestRunner( return new TestRunner(
<FlutterDevice>[new FlutterDevice( <FlutterDevice>[new FlutterDevice(
new MockDevice(), new MockDevice(),
previewDart2: false,
trackWidgetCreation: false, trackWidgetCreation: false,
)], )],
); );
......
...@@ -6,14 +6,11 @@ import 'dart:async'; ...@@ -6,14 +6,11 @@ import 'dart:async';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/tester/flutter_tester.dart'; import 'package:flutter_tools/src/tester/flutter_tester.dart';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
...@@ -100,8 +97,6 @@ void main() { ...@@ -100,8 +97,6 @@ void main() {
String projectPath; String projectPath;
String mainPath; String mainPath;
MockArtifacts mockArtifacts;
MockKernelCompiler mockKernelCompiler;
MockProcessManager mockProcessManager; MockProcessManager mockProcessManager;
MockProcess mockProcess; MockProcess mockProcess;
...@@ -110,8 +105,6 @@ void main() { ...@@ -110,8 +105,6 @@ void main() {
FileSystem: () => fs, FileSystem: () => fs,
Cache: () => new Cache(rootOverride: fs.directory(flutterRoot)), Cache: () => new Cache(rootOverride: fs.directory(flutterRoot)),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
KernelCompiler: () => mockKernelCompiler,
Artifacts: () => mockArtifacts,
}; };
setUp(() { setUp(() {
...@@ -129,13 +122,6 @@ void main() { ...@@ -129,13 +122,6 @@ void main() {
mockProcessManager = new MockProcessManager(); mockProcessManager = new MockProcessManager();
mockProcessManager.processFactory = mockProcessManager.processFactory =
(List<String> commands) => mockProcess; (List<String> commands) => mockProcess;
mockArtifacts = new MockArtifacts();
final String artifactPath = fs.path.join(flutterRoot, 'artifact');
fs.file(artifactPath).createSync(recursive: true);
when(mockArtifacts.getArtifactPath(any)).thenReturn(artifactPath);
mockKernelCompiler = new MockKernelCompiler();
}); });
testUsingContext('not debug', () async { testUsingContext('not debug', () async {
...@@ -167,22 +153,6 @@ Hello! ...@@ -167,22 +153,6 @@ Hello!
.codeUnits .codeUnits
])); ]));
when(mockKernelCompiler.compile(
sdkRoot: any,
incrementalCompilerByteStorePath: any,
mainPath: any,
outputFilePath: any,
depFilePath: any,
trackWidgetCreation: any,
extraFrontEndOptions: any,
fileSystemRoots: any,
fileSystemScheme: any,
packagesPath: any,
)).thenAnswer((_) async {
fs.file('$mainPath.dill').createSync(recursive: true);
return new CompilerOutput('$mainPath.dill', 0);
});
final LaunchResult result = await device.startApp(null, final LaunchResult result = await device.startApp(null,
mainPath: mainPath, mainPath: mainPath,
debuggingOptions: new DebuggingOptions.enabled( debuggingOptions: new DebuggingOptions.enabled(
...@@ -195,6 +165,3 @@ Hello! ...@@ -195,6 +165,3 @@ Hello!
}); });
}); });
} }
class MockArtifacts extends Mock implements Artifacts {}
class MockKernelCompiler extends Mock implements KernelCompiler {}
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