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,
|
dartPluginRegistrant.path,
|
||||||
'--source',
|
'--source',
|
||||||
'package:flutter/src/dart_plugin_registrant.dart',
|
'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
|
// See: https://github.com/flutter/flutter/issues/103994
|
||||||
'--verbosity=error',
|
'--verbosity=error',
|
||||||
@ -375,7 +375,7 @@ class _RecompileRequest extends _CompilationRequest {
|
|||||||
this.outputPath,
|
this.outputPath,
|
||||||
this.packageConfig,
|
this.packageConfig,
|
||||||
this.suppressErrors,
|
this.suppressErrors,
|
||||||
{this.additionalSourceUri}
|
{this.additionalSource}
|
||||||
);
|
);
|
||||||
|
|
||||||
Uri mainUri;
|
Uri mainUri;
|
||||||
@ -383,7 +383,7 @@ class _RecompileRequest extends _CompilationRequest {
|
|||||||
String outputPath;
|
String outputPath;
|
||||||
PackageConfig packageConfig;
|
PackageConfig packageConfig;
|
||||||
bool suppressErrors;
|
bool suppressErrors;
|
||||||
final Uri? additionalSourceUri;
|
final String? additionalSource;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<CompilerOutput?> _run(DefaultResidentCompiler compiler) async =>
|
Future<CompilerOutput?> _run(DefaultResidentCompiler compiler) async =>
|
||||||
@ -499,7 +499,6 @@ abstract class ResidentCompiler {
|
|||||||
String? projectRootPath,
|
String? projectRootPath,
|
||||||
bool suppressErrors = false,
|
bool suppressErrors = false,
|
||||||
bool checkDartPluginRegistry = false,
|
bool checkDartPluginRegistry = false,
|
||||||
File? dartPluginRegistrant,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<CompilerOutput?> compileExpression(
|
Future<CompilerOutput?> compileExpression(
|
||||||
@ -643,7 +642,6 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
required PackageConfig packageConfig,
|
required PackageConfig packageConfig,
|
||||||
bool suppressErrors = false,
|
bool suppressErrors = false,
|
||||||
bool checkDartPluginRegistry = false,
|
bool checkDartPluginRegistry = false,
|
||||||
File? dartPluginRegistrant,
|
|
||||||
String? projectRootPath,
|
String? projectRootPath,
|
||||||
FileSystem? fs,
|
FileSystem? fs,
|
||||||
}) async {
|
}) async {
|
||||||
@ -651,10 +649,20 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
if (!_controller.hasListener) {
|
if (!_controller.hasListener) {
|
||||||
_controller.stream.listen(_handleCompilationRequest);
|
_controller.stream.listen(_handleCompilationRequest);
|
||||||
}
|
}
|
||||||
Uri? additionalSourceUri;
|
String? additionalSource;
|
||||||
// `dart_plugin_registrant.dart` contains the Dart plugin registry.
|
// `dart_plugin_registrant.dart` contains the Dart plugin registry.
|
||||||
if (checkDartPluginRegistry && dartPluginRegistrant != null && dartPluginRegistrant.existsSync()) {
|
if (checkDartPluginRegistry && projectRootPath != null && fs != null) {
|
||||||
additionalSourceUri = dartPluginRegistrant.uri;
|
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?>();
|
final Completer<CompilerOutput?> completer = Completer<CompilerOutput?>();
|
||||||
_controller.add(_RecompileRequest(
|
_controller.add(_RecompileRequest(
|
||||||
@ -664,7 +672,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
outputPath,
|
outputPath,
|
||||||
packageConfig,
|
packageConfig,
|
||||||
suppressErrors,
|
suppressErrors,
|
||||||
additionalSourceUri: additionalSourceUri,
|
additionalSource: additionalSource,
|
||||||
));
|
));
|
||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
@ -677,15 +685,9 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
final String mainUri = request.packageConfig.toPackageUri(request.mainUri)?.toString() ??
|
final String mainUri = request.packageConfig.toPackageUri(request.mainUri)?.toString() ??
|
||||||
toMultiRootPath(request.mainUri, fileSystemScheme, fileSystemRoots, _platform.isWindows);
|
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;
|
final Process? server = _server;
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
return _compile(mainUri, request.outputPath, additionalSourceUri: additionalSourceUri);
|
return _compile(mainUri, request.outputPath, additionalSource: request.additionalSource);
|
||||||
}
|
}
|
||||||
final String inputKey = Uuid().generateV4();
|
final String inputKey = Uuid().generateV4();
|
||||||
|
|
||||||
@ -731,7 +733,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
Future<CompilerOutput?> _compile(
|
Future<CompilerOutput?> _compile(
|
||||||
String scriptUri,
|
String scriptUri,
|
||||||
String? outputPath,
|
String? outputPath,
|
||||||
{String? additionalSourceUri}
|
{String? additionalSource}
|
||||||
) async {
|
) async {
|
||||||
final String frontendServer = _artifacts.getArtifactPath(
|
final String frontendServer = _artifacts.getArtifactPath(
|
||||||
Artifact.frontendServerSnapshotForEngineDartSdk
|
Artifact.frontendServerSnapshotForEngineDartSdk
|
||||||
@ -784,12 +786,12 @@ class DefaultResidentCompiler implements ResidentCompiler {
|
|||||||
initializeFromDill!,
|
initializeFromDill!,
|
||||||
],
|
],
|
||||||
if (assumeInitializeFromDillUpToDate) '--assume-initialize-from-dill-up-to-date',
|
if (assumeInitializeFromDillUpToDate) '--assume-initialize-from-dill-up-to-date',
|
||||||
if (additionalSourceUri != null) ...<String>[
|
if (additionalSource != null) ...<String>[
|
||||||
'--source',
|
'--source',
|
||||||
additionalSourceUri,
|
additionalSource,
|
||||||
'--source',
|
'--source',
|
||||||
'package:flutter/src/dart_plugin_registrant.dart',
|
'package:flutter/src/dart_plugin_registrant.dart',
|
||||||
'-Dflutter.dart_plugin_registrant=$additionalSourceUri',
|
'-Dflutter.dart_plugin_registrant=${Uri.file(additionalSource)}',
|
||||||
],
|
],
|
||||||
if (platformDill != null) ...<String>[
|
if (platformDill != null) ...<String>[
|
||||||
'--platform',
|
'--platform',
|
||||||
|
@ -581,7 +581,6 @@ class DevFS {
|
|||||||
bool bundleFirstUpload = false,
|
bool bundleFirstUpload = false,
|
||||||
bool fullRestart = false,
|
bool fullRestart = false,
|
||||||
String? projectRootPath,
|
String? projectRootPath,
|
||||||
File? dartPluginRegistrant,
|
|
||||||
}) async {
|
}) async {
|
||||||
assert(trackWidgetCreation != null);
|
assert(trackWidgetCreation != null);
|
||||||
assert(generator != null);
|
assert(generator != null);
|
||||||
@ -611,7 +610,6 @@ class DevFS {
|
|||||||
projectRootPath: projectRootPath,
|
projectRootPath: projectRootPath,
|
||||||
packageConfig: packageConfig,
|
packageConfig: packageConfig,
|
||||||
checkDartPluginRegistry: true, // The entry point is assumed not to have changed.
|
checkDartPluginRegistry: true, // The entry point is assumed not to have changed.
|
||||||
dartPluginRegistrant: dartPluginRegistrant,
|
|
||||||
).then((CompilerOutput? result) {
|
).then((CompilerOutput? result) {
|
||||||
compileTimer.stop();
|
compileTimer.stop();
|
||||||
return result;
|
return result;
|
||||||
|
@ -799,7 +799,6 @@ class WebDevFS implements DevFS {
|
|||||||
bool bundleFirstUpload = false,
|
bool bundleFirstUpload = false,
|
||||||
bool fullRestart = false,
|
bool fullRestart = false,
|
||||||
String? projectRootPath,
|
String? projectRootPath,
|
||||||
File? dartPluginRegistrant,
|
|
||||||
}) async {
|
}) async {
|
||||||
assert(trackWidgetCreation != null);
|
assert(trackWidgetCreation != null);
|
||||||
assert(generator != null);
|
assert(generator != null);
|
||||||
@ -867,7 +866,6 @@ class WebDevFS implements DevFS {
|
|||||||
packageConfig: packageConfig,
|
packageConfig: packageConfig,
|
||||||
projectRootPath: projectRootPath,
|
projectRootPath: projectRootPath,
|
||||||
fs: globals.fs,
|
fs: globals.fs,
|
||||||
dartPluginRegistrant: dartPluginRegistrant,
|
|
||||||
);
|
);
|
||||||
if (compilerOutput == null || compilerOutput.errorCount > 0) {
|
if (compilerOutput == null || compilerOutput.errorCount > 0) {
|
||||||
return UpdateFSReport();
|
return UpdateFSReport();
|
||||||
|
@ -563,7 +563,6 @@ class FlutterDevice {
|
|||||||
invalidatedFiles: invalidatedFiles,
|
invalidatedFiles: invalidatedFiles,
|
||||||
packageConfig: packageConfig,
|
packageConfig: packageConfig,
|
||||||
devFSWriter: devFSWriter,
|
devFSWriter: devFSWriter,
|
||||||
dartPluginRegistrant: FlutterProject.current().dartPluginRegistrant,
|
|
||||||
);
|
);
|
||||||
} on DevFSException {
|
} on DevFSException {
|
||||||
devFSStatus.cancel();
|
devFSStatus.cancel();
|
||||||
|
@ -373,7 +373,6 @@ class HotRunner extends ResidentRunner {
|
|||||||
// should only be displayed once.
|
// should only be displayed once.
|
||||||
suppressErrors: applicationBinary == null,
|
suppressErrors: applicationBinary == null,
|
||||||
checkDartPluginRegistry: true,
|
checkDartPluginRegistry: true,
|
||||||
dartPluginRegistrant: FlutterProject.current().dartPluginRegistrant,
|
|
||||||
outputPath: dillOutputPath,
|
outputPath: dillOutputPath,
|
||||||
packageConfig: debuggingOptions.buildInfo.packageConfig,
|
packageConfig: debuggingOptions.buildInfo.packageConfig,
|
||||||
projectRootPath: FlutterProject.current().directory.absolute.path,
|
projectRootPath: FlutterProject.current().directory.absolute.path,
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/artifacts.dart';
|
import 'package:flutter_tools/src/artifacts.dart';
|
||||||
import 'package:flutter_tools/src/base/async_guard.dart';
|
import 'package:flutter_tools/src/base/async_guard.dart';
|
||||||
@ -395,43 +394,6 @@ void main() {
|
|||||||
'line2\nline3\n'
|
'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(
|
Future<void> _recompile(
|
||||||
|
@ -581,7 +581,7 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
|||||||
Future<CompilerOutput> Function(Uri mainUri, List<Uri>? invalidatedFiles)? onRecompile;
|
Future<CompilerOutput> Function(Uri mainUri, List<Uri>? invalidatedFiles)? onRecompile;
|
||||||
|
|
||||||
@override
|
@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)
|
return onRecompile?.call(mainUri, invalidatedFiles)
|
||||||
?? Future<CompilerOutput>.value(const CompilerOutput('', 1, <Uri>[]));
|
?? Future<CompilerOutput>.value(const CompilerOutput('', 1, <Uri>[]));
|
||||||
}
|
}
|
||||||
|
@ -2464,7 +2464,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
|||||||
@required FileSystem fs,
|
@required FileSystem fs,
|
||||||
bool suppressErrors = false,
|
bool suppressErrors = false,
|
||||||
bool checkDartPluginRegistry = false,
|
bool checkDartPluginRegistry = false,
|
||||||
File dartPluginRegistrant,
|
|
||||||
}) async {
|
}) async {
|
||||||
didSuppressErrors = suppressErrors;
|
didSuppressErrors = suppressErrors;
|
||||||
return nextOutput ?? const CompilerOutput('foo.dill', 0, <Uri>[]);
|
return nextOutput ?? const CompilerOutput('foo.dill', 0, <Uri>[]);
|
||||||
@ -2624,7 +2623,6 @@ class FakeDevFS extends Fake implements DevFS {
|
|||||||
bool bundleFirstUpload = false,
|
bool bundleFirstUpload = false,
|
||||||
bool fullRestart = false,
|
bool fullRestart = false,
|
||||||
String projectRootPath,
|
String projectRootPath,
|
||||||
File dartPluginRegistrant,
|
|
||||||
}) async {
|
}) async {
|
||||||
return nextUpdateReport;
|
return nextUpdateReport;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -200,7 +200,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
|||||||
FileSystem? fs,
|
FileSystem? fs,
|
||||||
bool suppressErrors = false,
|
bool suppressErrors = false,
|
||||||
bool checkDartPluginRegistry = false,
|
bool checkDartPluginRegistry = false,
|
||||||
File? dartPluginRegistrant,
|
|
||||||
}) async {
|
}) async {
|
||||||
if (compilerOutput != null) {
|
if (compilerOutput != null) {
|
||||||
fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true);
|
fileSystem!.file(compilerOutput!.outputFilename).createSync(recursive: true);
|
||||||
|
@ -1120,7 +1120,6 @@ class FakeResidentCompiler extends Fake implements ResidentCompiler {
|
|||||||
FileSystem fs,
|
FileSystem fs,
|
||||||
bool suppressErrors = false,
|
bool suppressErrors = false,
|
||||||
bool checkDartPluginRegistry = false,
|
bool checkDartPluginRegistry = false,
|
||||||
File dartPluginRegistrant,
|
|
||||||
}) async {
|
}) async {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user