Unverified Commit dbed10bb authored by Lau Ching Jun's avatar Lau Ching Jun Committed by GitHub

Pass 'assume-initialize-from-dill-up-to-date' flag to the frontend server (#99791)

parent f0524d54
...@@ -42,6 +42,7 @@ class BuildInfo { ...@@ -42,6 +42,7 @@ class BuildInfo {
this.androidGradleDaemon = true, this.androidGradleDaemon = true,
this.packageConfig = PackageConfig.empty, this.packageConfig = PackageConfig.empty,
this.initializeFromDill, this.initializeFromDill,
this.assumeInitializeFromDillUpToDate = false,
}) : extraFrontEndOptions = extraFrontEndOptions ?? const <String>[], }) : extraFrontEndOptions = extraFrontEndOptions ?? const <String>[],
extraGenSnapshotOptions = extraGenSnapshotOptions ?? const <String>[], extraGenSnapshotOptions = extraGenSnapshotOptions ?? const <String>[],
fileSystemRoots = fileSystemRoots ?? const <String>[], fileSystemRoots = fileSystemRoots ?? const <String>[],
...@@ -159,6 +160,10 @@ class BuildInfo { ...@@ -159,6 +160,10 @@ class BuildInfo {
/// If this is null, it will be initialized from the default cached location. /// If this is null, it will be initialized from the default cached location.
final String? initializeFromDill; final String? initializeFromDill;
/// If set, assumes that the file passed in [initializeFromDill] is up to date
/// and skips the check and potential invalidation of files.
final bool assumeInitializeFromDillUpToDate;
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false); static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault); static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault); static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
......
...@@ -451,6 +451,7 @@ abstract class ResidentCompiler { ...@@ -451,6 +451,7 @@ abstract class ResidentCompiler {
List<String> fileSystemRoots, List<String> fileSystemRoots,
String? fileSystemScheme, String? fileSystemScheme,
String initializeFromDill, String initializeFromDill,
bool assumeInitializeFromDillUpToDate,
TargetModel targetModel, TargetModel targetModel,
bool unsafePackageSerialization, bool unsafePackageSerialization,
List<String> extraFrontEndOptions, List<String> extraFrontEndOptions,
...@@ -559,6 +560,7 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -559,6 +560,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
List<String> fileSystemRoots = const <String>[], List<String> fileSystemRoots = const <String>[],
this.fileSystemScheme, this.fileSystemScheme,
this.initializeFromDill, this.initializeFromDill,
this.assumeInitializeFromDillUpToDate = false,
this.targetModel = TargetModel.flutter, this.targetModel = TargetModel.flutter,
this.unsafePackageSerialization = false, this.unsafePackageSerialization = false,
this.extraFrontEndOptions, this.extraFrontEndOptions,
...@@ -591,6 +593,7 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -591,6 +593,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
final List<String> fileSystemRoots; final List<String> fileSystemRoots;
final String? fileSystemScheme; final String? fileSystemScheme;
final String? initializeFromDill; final String? initializeFromDill;
final bool assumeInitializeFromDillUpToDate;
final bool unsafePackageSerialization; final bool unsafePackageSerialization;
final List<String>? extraFrontEndOptions; final List<String>? extraFrontEndOptions;
final List<String> dartDefines; final List<String> dartDefines;
...@@ -768,6 +771,7 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -768,6 +771,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
'--initialize-from-dill', '--initialize-from-dill',
initializeFromDill!, initializeFromDill!,
], ],
if (assumeInitializeFromDillUpToDate) '--assume-initialize-from-dill-up-to-date',
if (additionalSource != null) ...<String>[ if (additionalSource != null) ...<String>[
'--source', '--source',
additionalSource, additionalSource,
......
...@@ -126,6 +126,7 @@ class FlutterDevice { ...@@ -126,6 +126,7 @@ class FlutterDevice {
dartDefines: buildInfo.dartDefines, dartDefines: buildInfo.dartDefines,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
), ),
assumeInitializeFromDillUpToDate: buildInfo.assumeInitializeFromDillUpToDate,
targetModel: TargetModel.dartdevc, targetModel: TargetModel.dartdevc,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
platformDill: globals.fs.file(globals.artifacts platformDill: globals.fs.file(globals.artifacts
...@@ -168,6 +169,7 @@ class FlutterDevice { ...@@ -168,6 +169,7 @@ class FlutterDevice {
dartDefines: buildInfo.dartDefines, dartDefines: buildInfo.dartDefines,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
), ),
assumeInitializeFromDillUpToDate: buildInfo.assumeInitializeFromDillUpToDate,
packagesPath: buildInfo.packagesPath, packagesPath: buildInfo.packagesPath,
artifacts: globals.artifacts, artifacts: globals.artifacts,
processManager: globals.processManager, processManager: globals.processManager,
......
...@@ -115,6 +115,7 @@ class FlutterOptions { ...@@ -115,6 +115,7 @@ class FlutterOptions {
static const String kDeferredComponents = 'deferred-components'; static const String kDeferredComponents = 'deferred-components';
static const String kAndroidProjectArgs = 'android-project-arg'; static const String kAndroidProjectArgs = 'android-project-arg';
static const String kInitializeFromDill = 'initialize-from-dill'; static const String kInitializeFromDill = 'initialize-from-dill';
static const String kAssumeInitializeFromDillUpToDate = 'assume-initialize-from-dill-up-to-date';
static const String kFatalWarnings = 'fatal-warnings'; static const String kFatalWarnings = 'fatal-warnings';
} }
...@@ -829,6 +830,11 @@ abstract class FlutterCommand extends Command<void> { ...@@ -829,6 +830,11 @@ abstract class FlutterCommand extends Command<void> {
'the default cached location.', 'the default cached location.',
hide: hide, hide: hide,
); );
argParser.addFlag(FlutterOptions.kAssumeInitializeFromDillUpToDate,
help: 'If set, assumes that the file passed in initialize-from-dill is up '
'to date and skip the check and potential invalidation of files.',
hide: hide,
);
} }
void addMultidexOption({ bool hide = false }) { void addMultidexOption({ bool hide = false }) {
...@@ -1113,6 +1119,8 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1113,6 +1119,8 @@ abstract class FlutterCommand extends Command<void> {
initializeFromDill: argParser.options.containsKey(FlutterOptions.kInitializeFromDill) initializeFromDill: argParser.options.containsKey(FlutterOptions.kInitializeFromDill)
? stringArg(FlutterOptions.kInitializeFromDill) ? stringArg(FlutterOptions.kInitializeFromDill)
: null, : null,
assumeInitializeFromDillUpToDate: argParser.options.containsKey(FlutterOptions.kAssumeInitializeFromDillUpToDate)
&& boolArg(FlutterOptions.kAssumeInitializeFromDillUpToDate),
); );
} }
......
...@@ -1882,6 +1882,30 @@ flutter: ...@@ -1882,6 +1882,30 @@ flutter:
)).generator as DefaultResidentCompiler; )).generator as DefaultResidentCompiler;
expect(residentCompiler.initializeFromDill, '/foo/bar.dill'); expect(residentCompiler.initializeFromDill, '/foo/bar.dill');
expect(residentCompiler.assumeInitializeFromDillUpToDate, false);
}, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('FlutterDevice passes assumeInitializeFromDillUpToDate parameter if specified', () async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
final FakeDevice device = FakeDevice();
final DefaultResidentCompiler residentCompiler = (await FlutterDevice.create(
device,
buildInfo: const BuildInfo(
BuildMode.debug,
'',
treeShakeIcons: false,
extraFrontEndOptions: <String>[],
assumeInitializeFromDillUpToDate: true,
),
target: null, platform: null,
)).generator as DefaultResidentCompiler;
expect(residentCompiler.assumeInitializeFromDillUpToDate, true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Artifacts: () => Artifacts.test(), Artifacts: () => Artifacts.test(),
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
......
...@@ -588,6 +588,28 @@ void main() { ...@@ -588,6 +588,28 @@ void main() {
ProcessManager: () => processManager, ProcessManager: () => processManager,
}); });
testUsingContext('includes assumeInitializeFromDillUpToDate in BuildInfo', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand()..usesInitializeFromDillOption(hide: false);
final CommandRunner<void> runner = createTestCommandRunner(flutterCommand);
await runner.run(<String>['dummy', '--assume-initialize-from-dill-up-to-date']);
final BuildInfo buildInfo = await flutterCommand.getBuildInfo(forcedBuildMode: BuildMode.debug);
expect(buildInfo.assumeInitializeFromDillUpToDate, isTrue);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
});
testUsingContext('unsets assumeInitializeFromDillUpToDate in BuildInfo when disabled', () async {
final DummyFlutterCommand flutterCommand = DummyFlutterCommand()..usesInitializeFromDillOption(hide: false);
final CommandRunner<void> runner = createTestCommandRunner(flutterCommand);
await runner.run(<String>['dummy', '--no-assume-initialize-from-dill-up-to-date']);
final BuildInfo buildInfo = await flutterCommand.getBuildInfo(forcedBuildMode: BuildMode.debug);
expect(buildInfo.assumeInitializeFromDillUpToDate, isFalse);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => processManager,
});
testUsingContext('dds options', () async { testUsingContext('dds options', () async {
final FakeDdsCommand ddsCommand = FakeDdsCommand(); final FakeDdsCommand ddsCommand = FakeDdsCommand();
final CommandRunner<void> runner = createTestCommandRunner(ddsCommand); final CommandRunner<void> runner = createTestCommandRunner(ddsCommand);
......
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