Skip to content

Commit cb53405

Browse files
Don't specify libraries-spec argument if we are passing a platform dill. (#114045)
1 parent 7d037f2 commit cb53405

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

packages/flutter_tools/lib/src/compile.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,9 @@ class DefaultResidentCompiler implements ResidentCompiler {
763763
'--output-dill',
764764
outputPath,
765765
],
766-
if (librariesSpec != null) ...<String>[
766+
// If we have a platform dill, we don't need to pass the libraries spec,
767+
// since the information is embedded in the .dill file.
768+
if (librariesSpec != null && platformDill == null) ...<String>[
767769
'--libraries-spec',
768770
librariesSpec!,
769771
],

packages/flutter_tools/test/general.shard/compile_incremental_test.dart

+39
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import '../src/fakes.dart';
2222
void main() {
2323
late ResidentCompiler generator;
2424
late ResidentCompiler generatorWithScheme;
25+
late ResidentCompiler generatorWithPlatformDillAndLibrariesSpec;
2526
late MemoryIOSink frontendServerStdIn;
2627
late BufferLogger testLogger;
2728
late StdoutHandler generatorStdoutHandler;
@@ -76,6 +77,18 @@ void main() {
7677
fileSystem: MemoryFileSystem.test(),
7778
stdoutHandler: generatorWithSchemeStdoutHandler,
7879
);
80+
generatorWithPlatformDillAndLibrariesSpec = DefaultResidentCompiler(
81+
'sdkroot',
82+
buildMode: BuildMode.debug,
83+
logger: testLogger,
84+
processManager: fakeProcessManager,
85+
artifacts: Artifacts.test(),
86+
platform: FakePlatform(),
87+
fileSystem: MemoryFileSystem.test(),
88+
stdoutHandler: generatorStdoutHandler,
89+
platformDill: '/foo/platform.dill',
90+
librariesSpec: '/bar/libraries.json',
91+
);
7992
});
8093

8194
testWithoutContext('incremental compile single dart compile', () async {
@@ -431,6 +444,32 @@ void main() {
431444
expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
432445
expect(fakeProcessManager, hasNoRemainingExpectations);
433446
});
447+
448+
testWithoutContext('compile does not pass libraries-spec when using a platform dill', () async {
449+
fakeProcessManager.addCommand(FakeCommand(
450+
command: const <String>[
451+
...frontendServerCommand,
452+
'--platform',
453+
'/foo/platform.dill',
454+
'--verbosity=error'
455+
],
456+
stdout: 'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0',
457+
stdin: frontendServerStdIn,
458+
));
459+
460+
final CompilerOutput? output = await generatorWithPlatformDillAndLibrariesSpec.recompile(
461+
Uri.parse('/path/to/main.dart'),
462+
null /* invalidatedFiles */,
463+
outputPath: '/build/',
464+
packageConfig: PackageConfig.empty,
465+
fs: MemoryFileSystem(),
466+
projectRootPath: '',
467+
);
468+
expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
469+
expect(testLogger.errorText, equals('line1\nline2\n'));
470+
expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
471+
expect(fakeProcessManager, hasNoRemainingExpectations);
472+
});
434473
}
435474

436475
Future<void> _recompile(

0 commit comments

Comments
 (0)