From cb534057e73d422831c78346bcd204c80708bb57 Mon Sep 17 00:00:00 2001 From: Jackson Gardner Date: Wed, 26 Oct 2022 09:05:08 -0700 Subject: [PATCH] Don't specify libraries-spec argument if we are passing a platform dill. (#114045) --- packages/flutter_tools/lib/src/compile.dart | 4 +- .../compile_incremental_test.dart | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 5483ee1e83..e072e6b7a4 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -763,7 +763,9 @@ class DefaultResidentCompiler implements ResidentCompiler { '--output-dill', outputPath, ], - if (librariesSpec != null) ...[ + // If we have a platform dill, we don't need to pass the libraries spec, + // since the information is embedded in the .dill file. + if (librariesSpec != null && platformDill == null) ...[ '--libraries-spec', librariesSpec!, ], diff --git a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart index 8e20fe9eff..e4968fd2e4 100644 --- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart @@ -22,6 +22,7 @@ import '../src/fakes.dart'; void main() { late ResidentCompiler generator; late ResidentCompiler generatorWithScheme; + late ResidentCompiler generatorWithPlatformDillAndLibrariesSpec; late MemoryIOSink frontendServerStdIn; late BufferLogger testLogger; late StdoutHandler generatorStdoutHandler; @@ -76,6 +77,18 @@ void main() { fileSystem: MemoryFileSystem.test(), stdoutHandler: generatorWithSchemeStdoutHandler, ); + generatorWithPlatformDillAndLibrariesSpec = DefaultResidentCompiler( + 'sdkroot', + buildMode: BuildMode.debug, + logger: testLogger, + processManager: fakeProcessManager, + artifacts: Artifacts.test(), + platform: FakePlatform(), + fileSystem: MemoryFileSystem.test(), + stdoutHandler: generatorStdoutHandler, + platformDill: '/foo/platform.dill', + librariesSpec: '/bar/libraries.json', + ); }); testWithoutContext('incremental compile single dart compile', () async { @@ -431,6 +444,32 @@ void main() { expect(output?.outputFilename, equals('/path/to/main.dart.dill')); expect(fakeProcessManager, hasNoRemainingExpectations); }); + + testWithoutContext('compile does not pass libraries-spec when using a platform dill', () async { + fakeProcessManager.addCommand(FakeCommand( + command: const [ + ...frontendServerCommand, + '--platform', + '/foo/platform.dill', + '--verbosity=error' + ], + stdout: 'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0', + stdin: frontendServerStdIn, + )); + + final CompilerOutput? output = await generatorWithPlatformDillAndLibrariesSpec.recompile( + Uri.parse('/path/to/main.dart'), + null /* invalidatedFiles */, + outputPath: '/build/', + packageConfig: PackageConfig.empty, + fs: MemoryFileSystem(), + projectRootPath: '', + ); + expect(frontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n'); + expect(testLogger.errorText, equals('line1\nline2\n')); + expect(output?.outputFilename, equals('/path/to/main.dart.dill')); + expect(fakeProcessManager, hasNoRemainingExpectations); + }); } Future _recompile(