From b1410c2ce7c075b035ec3c400dd54c734f8c6e18 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Thu, 7 Jul 2022 09:31:18 -0700 Subject: [PATCH] Ensure flutter run build is done in incremental mode. (#107184) * Ensure build is done in incremental mode. This allows for faster bootstrapping of the compiler from previously created dill file. Fixes https://github.com/flutter/flutter/issues/107183 * Avoid initializeFromDill in aot mode * Update tests --- .../lib/src/build_system/targets/common.dart | 2 ++ packages/flutter_tools/lib/src/compile.dart | 1 + .../general.shard/build_system/targets/common_test.dart | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart index c9f2d8d1f8..afa21709af 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/common.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart @@ -226,6 +226,8 @@ class KernelSnapshot extends Target { trackWidgetCreation: trackWidgetCreation && buildMode != BuildMode.release, targetModel: targetModel, outputFilePath: environment.buildDir.childFile('app.dill').path, + initializeFromDill: buildMode.isPrecompiled ? null : + environment.buildDir.childFile('app.dill').path, packagesPath: packagesFile.path, linkPlatformKernelIn: forceLinkPlatform || buildMode.isPrecompiled, mainPath: targetFileAbsolute, diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 807f203394..8733f87396 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -315,6 +315,7 @@ class KernelCompiler { fileSystemScheme, ], if (initializeFromDill != null) ...[ + '--incremental', '--initialize-from-dill', initializeFromDill, ], diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart index 92c2d81631..03c198496a 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/common_test.dart @@ -257,6 +257,9 @@ void main() { '$build/app.dill', '--depfile', '$build/kernel_snapshot.d', + '--incremental', + '--initialize-from-dill', + '$build/app.dill', '--verbosity=error', 'file:///lib/main.dart', ], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/app.dill 0\n'), @@ -295,6 +298,9 @@ void main() { '$build/app.dill', '--depfile', '$build/kernel_snapshot.d', + '--incremental', + '--initialize-from-dill', + '$build/app.dill', '--verbosity=error', 'file:///lib/main.dart', ], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/app.dill 0\n'), @@ -348,6 +354,9 @@ void main() { '$build/app.dill', '--depfile', '$build/kernel_snapshot.d', + '--incremental', + '--initialize-from-dill', + '$build/app.dill', '--verbosity=error', 'file:///lib/main.dart', ], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey /build/653e11a8e6908714056a57cd6b4f602a/app.dill 0\n'),