forked from firka/flutter
[flutter_tools] initialize frontend server with build (#49405)
This commit is contained in:
@@ -469,7 +469,6 @@ abstract class ResidentCompiler {
|
||||
// See: https://github.com/flutter/flutter/issues/50494
|
||||
void addFileSystemRoot(String root);
|
||||
|
||||
|
||||
/// If invoked for the first time, it compiles Dart script identified by
|
||||
/// [mainPath], [invalidatedFiles] list is ignored.
|
||||
/// On successive runs [invalidatedFiles] indicates which files need to be
|
||||
|
||||
@@ -488,6 +488,9 @@ class DevFS {
|
||||
if (fullRestart) {
|
||||
generator.reset();
|
||||
}
|
||||
// On a full restart, or on an initial compile for the attach based workflow,
|
||||
// this will produce a full dill. Subsequent invocations will produce incremental
|
||||
// dill files that depend on the invalidated files.
|
||||
globals.printTrace('Compiling dart to kernel with ${invalidatedFiles.length} updated files');
|
||||
final CompilerOutput compilerOutput = await generator.recompile(
|
||||
mainPath,
|
||||
|
||||
@@ -629,16 +629,6 @@ abstract class ResidentRunner {
|
||||
if (!artifactDirectory.existsSync()) {
|
||||
artifactDirectory.createSync(recursive: true);
|
||||
}
|
||||
// TODO(jonahwilliams): this is a temporary work around to regain some of
|
||||
// the initialize from dill performance. Longer term, we should have a
|
||||
// better way to determine where the appropriate dill file is, as this
|
||||
// doesn't work for Android or macOS builds.}
|
||||
if (dillOutputPath == null) {
|
||||
final File existingDill = globals.fs.file(globals.fs.path.join('build', 'app.dill'));
|
||||
if (existingDill.existsSync()) {
|
||||
existingDill.copySync(globals.fs.path.join(artifactDirectory.path, 'app.dill'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@protected
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'base/file_system.dart';
|
||||
import 'base/logger.dart';
|
||||
import 'base/utils.dart';
|
||||
import 'build_info.dart';
|
||||
import 'bundle.dart';
|
||||
import 'compile.dart';
|
||||
import 'convert.dart';
|
||||
import 'devfs.dart';
|
||||
@@ -329,14 +330,36 @@ class HotRunner extends ResidentRunner {
|
||||
|
||||
firstBuildTime = DateTime.now();
|
||||
|
||||
final List<Future<bool>> startupTasks = <Future<bool>>[];
|
||||
for (final FlutterDevice device in flutterDevices) {
|
||||
final int result = await device.runHot(
|
||||
// Here we initialize the frontend_server concurrently with the platform
|
||||
// build, reducing overall initialization time. This is safe because the first
|
||||
// invocation of the frontend server produces a full dill file that the
|
||||
// subsequent invocation in devfs will not overwrite.
|
||||
if (device.generator != null) {
|
||||
startupTasks.add(
|
||||
device.generator.recompile(
|
||||
mainPath,
|
||||
<Uri>[],
|
||||
outputPath: dillOutputPath ??
|
||||
getDefaultApplicationKernelPath(trackWidgetCreation: device.trackWidgetCreation),
|
||||
packagesFilePath : packagesFilePath,
|
||||
).then((CompilerOutput output) => output?.errorCount == 0)
|
||||
);
|
||||
}
|
||||
startupTasks.add(device.runHot(
|
||||
hotRunner: this,
|
||||
route: route,
|
||||
);
|
||||
if (result != 0) {
|
||||
return result;
|
||||
).then((int result) => result == 0));
|
||||
}
|
||||
try {
|
||||
final List<bool> results = await Future.wait(startupTasks);
|
||||
if (!results.every((bool passed) => passed)) {
|
||||
return 1;
|
||||
}
|
||||
} on Exception catch (err) {
|
||||
globals.printError(err.toString());
|
||||
return 1;
|
||||
}
|
||||
|
||||
return attach(
|
||||
|
||||
Reference in New Issue
Block a user