Revert "Read dart_plugin_registrant path from FlutterProject to support non-standard path." (#107850)
This commit is contained in:
parent
b156c0c440
commit
81045d4a44
@ -328,7 +328,7 @@ class KernelCompiler {
|
||||
dartPluginRegistrant.path,
|
||||
'--source',
|
||||
'package:flutter/src/dart_plugin_registrant.dart',
|
||||
'-Dflutter.dart_plugin_registrant=${toMultiRootPath(dartPluginRegistrant.uri, _fileSystemScheme, _fileSystemRoots, _fileSystem.path.separator == r'\')}',
|
||||
'-Dflutter.dart_plugin_registrant=${dartPluginRegistrant.uri}',
|
||||
],
|
||||
// See: https://github.com/flutter/flutter/issues/103994
|
||||
'--verbosity=error',
|
||||
@ -375,7 +375,7 @@ class _RecompileRequest extends _CompilationRequest {
|
||||
this.outputPath,
|
||||
this.packageConfig,
|
||||
this.suppressErrors,
|
||||
{this.additionalSourceUri}
|
||||
{this.additionalSource}
|
||||
);
|
||||
|
||||
Uri mainUri;
|
||||
@ -383,7 +383,7 @@ class _RecompileRequest extends _CompilationRequest {
|
||||
String outputPath;
|
||||
PackageConfig packageConfig;
|
||||
bool suppressErrors;
|
||||
final Uri? additionalSourceUri;
|
||||
final String? additionalSource;
|
||||
|
||||
@override
|
||||
Future<CompilerOutput?> _run(DefaultResidentCompiler compiler) async =>
|
||||
@ -499,7 +499,6 @@ abstract class ResidentCompiler {
|
||||
String? projectRootPath,
|
||||
bool suppressErrors = false,
|
||||
bool checkDartPluginRegistry = false,
|
||||
File? dartPluginRegistrant,
|
||||
});
|
||||
|
||||
Future<CompilerOutput?> compileExpression(
|
||||
@ -643,7 +642,6 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
||||
required PackageConfig packageConfig,
|
||||
bool suppressErrors = false,
|
||||
bool checkDartPluginRegistry = false,
|
||||
File? dartPluginRegistrant,
|
||||
String? projectRootPath,
|
||||
FileSystem? fs,
|
||||
}) async {
|
||||
@ -651,10 +649,20 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
||||
if (!_controller.hasListener) {
|
||||
_controller.stream.listen(_handleCompilationRequest);
|
||||
}
|
||||
Uri? additionalSourceUri;
|
||||
String? additionalSource;
|
||||
// `dart_plugin_registrant.dart` contains the Dart plugin registry.
|
||||
if (checkDartPluginRegistry && dartPluginRegistrant != null && dartPluginRegistrant.existsSync()) {
|
||||
additionalSourceUri = dartPluginRegistrant.uri;
|
||||
if (checkDartPluginRegistry && projectRootPath != null && fs != null) {
|
||||
final File dartPluginRegistrantDart = fs.file(
|
||||
fs.path.join(
|
||||
projectRootPath,
|
||||
'.dart_tool',
|
||||
'flutter_build',
|
||||
'dart_plugin_registrant.dart',
|
||||
),
|
||||
);
|
||||
if (dartPluginRegistrantDart != null && dartPluginRegistrantDart.existsSync()) {
|
||||
additionalSource = dartPluginRegistrantDart.path;
|
||||
}
|
||||
}
|
||||
final Completer<CompilerOutput?> completer = Completer<CompilerOutput?>();
|
||||
_controller.add(_RecompileRequest(
|
||||
@ -664,7 +672,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
||||
outputPath,
|
||||
packageConfig,
|
||||
suppressErrors,
|
||||
additionalSourceUri: additionalSourceUri,
|
||||
additionalSource: additionalSource,
|
||||
));
|
||||
return completer.future;
|
||||
}
|
||||
@ -677,15 +685,9 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
||||
final String mainUri = request.packageConfig.toPackageUri(request.mainUri)?.toString() ??
|
||||
toMultiRootPath(request.mainUri, fileSystemScheme, fileSystemRoots, _platform.isWindows);
|
||||
|
||||
String? additionalSourceUri;
|
||||
if (request.additionalSourceUri != null) {
|
||||
additionalSourceUri = request.packageConfig.toPackageUri(request.additionalSourceUri!)?.toString() ??
|
||||
toMultiRootPath(request.additionalSourceUri!, fileSystemScheme, fileSystemRoots, _platform.isWindows);
|
||||
}
|
||||
|
||||
final Process? server = _server;
|
||||
if (server == null) {
|
||||
return _compile(mainUri, request.outputPath, additionalSourceUri: additionalSourceUri);
|
||||
return _compile(mainUri, request.outputPath, additionalSource: request.additionalSource);
|
||||
}
|
||||
final String inputKey = Uuid().generateV4();
|
||||
|
||||
@ -731,7 +733,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
||||
Future<CompilerOutput?> _compile(
|
||||
String scriptUri,
|
||||
String? outputPath,
|
||||
{String? additionalSourceUri}
|
||||
{String? additionalSource}
|
||||
) async {
|
||||
final String frontendServer = _artifacts.getArtifactPath(
|
||||
Artifact.frontendServerSnapshotForEngineDartSdk
|
||||
@ -784,12 +786,12 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
||||
initializeFromDill!,
|
||||
],
|
||||
if (assumeInitializeFromDillUpToDate) '--assume-initialize-from-dill-up-to-date',
|
||||
if (additionalSourceUri != null) ...<String>[
|
||||
if (additionalSource != null) ...<String>[
|
||||
'--source',
|
||||
additionalSourceUri,
|
||||
additionalSource,
|
||||
'--source',
|
||||
'package:flutter/src/dart_plugin_registrant.dart',
|
||||
'-Dflutter.dart_plugin_registrant=$additionalSourceUri',
|
||||
'-Dflutter.dart_plugin_registrant=${Uri.file(additionalSource)}',
|
||||
],
|
||||
if (platformDill != null) ...<String>[
|
||||
'--platform',
|
||||
|
@ -581,7 +581,6 @@ class DevFS {
|
||||
bool bundleFirstUpload = false,
|
||||
bool fullRestart = false,
|
||||
String? projectRootPath,
|
||||
File? dartPluginRegistrant,
|
||||
}) async {
|
||||
assert(trackWidgetCreation != null);
|
||||
assert(generator != null);
|
||||
@ -611,7 +610,6 @@ class DevFS {
|
||||
projectRootPath: projectRootPath,
|
||||
packageConfig: packageConfig,
|
||||
checkDartPluginRegistry: true, // The entry point is assumed not to have changed.
|
||||
dartPluginRegistrant: dartPluginRegistrant,
|
||||
).then((CompilerOutput? result) {
|
||||
compileTimer.stop();
|
||||
return result;
|
||||
|
@ -799,7 +799,6 @@ class WebDevFS implements DevFS {
|
||||
bool bundleFirstUpload = false,
|
||||
bool fullRestart = false,
|
||||
String? projectRootPath,
|
||||
File? dartPluginRegistrant,
|
||||
}) async {
|
||||
assert(trackWidgetCreation != null);
|
||||
assert(generator != null);
|
||||
@ -867,7 +866,6 @@ class WebDevFS implements DevFS {
|
||||
packageConfig: packageConfig,
|
||||
projectRootPath: projectRootPath,
|
||||
fs: globals.fs,
|
||||
dartPluginRegistrant: dartPluginRegistrant,
|
||||
);
|
||||
if (compilerOutput == null || compilerOutput.errorCount > 0) {
|
||||
return UpdateFSReport();
|
||||
|
@ -563,7 +563,6 @@ class FlutterDevice {
|
||||
invalidatedFiles: invalidatedFiles,
|
||||
packageConfig: packageConfig,
|
||||
devFSWriter: devFSWriter,
|
||||
dartPluginRegistrant: FlutterProject.current().dartPluginRegistrant,
|
||||
);
|
||||
} on DevFSException {
|
||||
devFSStatus.cancel();
|
||||
|
@ -373,7 +373,6 @@ class HotRunner extends ResidentRunner {
|
||||
// should only be displayed once.
|
||||
suppressErrors: applicationBinary == null,
|
||||
checkDartPluginRegistry: true,
|
||||
dartPluginRegistrant: FlutterProject.current().dartPluginRegistrant,
|
||||
outputPath: dillOutputPath,
|
||||
packageConfig: debuggingOptions.buildInfo.packageConfig,
|
||||
projectRootPath: FlutterProject.current().directory.absolute.path,
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/async_guard.dart';
|
||||
@ -395,43 +394,6 @@ void main() {
|
||||
'line2\nline3\n'
|
||||
));
|
||||
});
|
||||
|
||||
testWithoutContext('incremental compile with dartPluginRegistrant', () async {
|
||||
fakeProcessManager.addCommand(FakeCommand(
|
||||
command: const <String>[
|
||||
...frontendServerCommand,
|
||||
'--filesystem-root',
|
||||
'/foo/bar/fizz',
|
||||
'--filesystem-scheme',
|
||||
'scheme',
|
||||
'--source',
|
||||
'some/dir/plugin_registrant.dart',
|
||||
'--source',
|
||||
'package:flutter/src/dart_plugin_registrant.dart',
|
||||
'-Dflutter.dart_plugin_registrant=some/dir/plugin_registrant.dart',
|
||||
'--verbosity=error',
|
||||
],
|
||||
stdout: 'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0',
|
||||
stdin: frontendServerStdIn,
|
||||
));
|
||||
|
||||
final MemoryFileSystem fs = MemoryFileSystem();
|
||||
final File dartPluginRegistrant = fs.file('some/dir/plugin_registrant.dart')..createSync(recursive: true);
|
||||
final CompilerOutput? output = await generatorWithScheme.recompile(
|
||||
Uri.parse('file:///foo/bar/fizz/main.dart'),
|
||||
null /* invalidatedFiles */,
|
||||
outputPath: '/build/',
|
||||
packageConfig: PackageConfig.empty,
|
||||
fs: fs,
|
||||
projectRootPath: '',
|
||||
checkDartPluginRegistry: true,
|
||||
dartPluginRegistrant: dartPluginRegistrant,
|
||||
);
|
||||
expect(frontendServerStdIn.getAndClear(), 'compile scheme:///main.dart\n');
|
||||
expect(testLogger.errorText, equals('line1\nline2\n'));
|
||||
expect(output?.outputFilename, equals('/path/to/main.dart.dill'));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _recompile(
|
||||
|
@ -581,7 +581,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
||||
Future<CompilerOutput> Function(Uri mainUri, List<Uri>? invalidatedFiles)? onRecompile;
|
||||
|
||||
@override
|
||||
Future<CompilerOutput> recompile(Uri mainUri, List<Uri>? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false, File? dartPluginRegistrant}) {
|
||||
Future<CompilerOutput> recompile(Uri mainUri, List<Uri>? invalidatedFiles, {String? outputPath, PackageConfig? packageConfig, String? projectRootPath, FileSystem? fs, bool suppressErrors = false, bool checkDartPluginRegistry = false}) {
|
||||
return onRecompile?.call(mainUri, invalidatedFiles)
|
||||
?? Future<CompilerOutput>.value(const CompilerOutput('', 1, <Uri>[]));
|
||||
}
|
||||
|
@ -2464,7 +2464,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
||||
@required FileSystem fs,
|
||||
bool suppressErrors = false,
|
||||
bool checkDartPluginRegistry = false,
|
||||
File dartPluginRegistrant,
|
||||
}) async {
|
||||
didSuppressErrors = suppressErrors;
|
||||
return nextOutput ?? const CompilerOutput('foo.dill', 0, <Uri>[]);
|
||||
@ -2624,7 +2623,6 @@ class FakeDevFS extends Fake implements DevFS {
|
||||
bool bundleFirstUpload = false,
|
||||
bool fullRestart = false,
|
||||
String projectRootPath,
|
||||
File dartPluginRegistrant,
|
||||
}) async {
|
||||
return nextUpdateReport;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -200,7 +200,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
||||
FileSystem? fs,
|
||||
bool suppressErrors = false,
|
||||
bool checkDartPluginRegistry = false,
|
||||
File? dartPluginRegistrant,
|
||||
}) async {
|
||||
if (compilerOutput != null) {
|
||||
fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true);
|
||||
|
@ -1120,7 +1120,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
||||
FileSystem fs,
|
||||
bool suppressErrors = false,
|
||||
bool checkDartPluginRegistry = false,
|
||||
File dartPluginRegistrant,
|
||||
}) async {
|
||||
return output;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user