mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Roll engine to 4c79e423dc6f89f98d8ceb263a5ca78e2f2da996 (#23384)
Also includes * Updates to affected tests * Change flutter_tools to pass package URIs to the Dart front end instead of filesystem paths
This commit is contained in:
parent
b7c9c96c6b
commit
a6a1607888
@ -1 +1 @@
|
||||
58cdd53f9083412fa7da893f53c1ca1c93500532
|
||||
4c79e423dc6f89f98d8ceb263a5ca78e2f2da996
|
||||
|
@ -291,6 +291,7 @@ class AOTSnapshotter {
|
||||
@required TargetPlatform platform,
|
||||
@required BuildMode buildMode,
|
||||
@required String mainPath,
|
||||
@required String packagesPath,
|
||||
@required String outputPath,
|
||||
List<String> extraFrontEndOptions = const <String>[],
|
||||
}) async {
|
||||
@ -306,6 +307,7 @@ class AOTSnapshotter {
|
||||
final CompilerOutput compilerOutput = await kernelCompiler.compile(
|
||||
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
|
||||
mainPath: mainPath,
|
||||
packagesPath: packagesPath,
|
||||
outputFilePath: fs.path.join(outputPath, 'app.dill'),
|
||||
depFilePath: depfilePath,
|
||||
extraFrontEndOptions: extraFrontEndOptions,
|
||||
|
@ -84,6 +84,7 @@ class BuildAotCommand extends BuildSubCommand {
|
||||
platform: platform,
|
||||
buildMode: buildMode,
|
||||
mainPath: mainPath,
|
||||
packagesPath: PackageMap.globalPackagesPath,
|
||||
outputPath: outputPath,
|
||||
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
|
||||
);
|
||||
|
@ -10,10 +10,13 @@ import 'package:usage/uuid/uuid.dart';
|
||||
import 'artifacts.dart';
|
||||
import 'base/common.dart';
|
||||
import 'base/context.dart';
|
||||
import 'base/file_system.dart';
|
||||
import 'base/fingerprint.dart';
|
||||
import 'base/io.dart';
|
||||
import 'base/platform.dart';
|
||||
import 'base/process_manager.dart';
|
||||
import 'base/terminal.dart';
|
||||
import 'dart/package_map.dart';
|
||||
import 'globals.dart';
|
||||
|
||||
KernelCompiler get kernelCompiler => context[KernelCompiler];
|
||||
@ -74,6 +77,42 @@ class _StdoutHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// Converts filesystem paths to package URIs.
|
||||
class _PackageUriMapper {
|
||||
_PackageUriMapper(String scriptPath, String packagesPath) {
|
||||
final Map<String, Uri> packageMap = PackageMap(fs.path.absolute(packagesPath)).map;
|
||||
final String scriptUri = Uri.file(scriptPath, windows: platform.isWindows).toString();
|
||||
|
||||
for (String packageName in packageMap.keys) {
|
||||
final String prefix = packageMap[packageName].toString();
|
||||
if (scriptUri.startsWith(prefix)) {
|
||||
_packageName = packageName;
|
||||
_uriPrefix = prefix;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String _packageName;
|
||||
String _uriPrefix;
|
||||
|
||||
Uri map(String scriptPath) {
|
||||
if (_packageName == null)
|
||||
return null;
|
||||
|
||||
final String scriptUri = Uri.file(scriptPath, windows: platform.isWindows).toString();
|
||||
if (scriptUri.startsWith(_uriPrefix)) {
|
||||
return Uri.parse('package:$_packageName/${scriptUri.substring(_uriPrefix.length)}');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static Uri findUri(String scriptPath, String packagesPath) {
|
||||
return _PackageUriMapper(scriptPath, packagesPath).map(scriptPath);
|
||||
}
|
||||
}
|
||||
|
||||
class KernelCompiler {
|
||||
const KernelCompiler();
|
||||
|
||||
@ -168,7 +207,14 @@ class KernelCompiler {
|
||||
|
||||
if (extraFrontEndOptions != null)
|
||||
command.addAll(extraFrontEndOptions);
|
||||
command.add(mainPath);
|
||||
|
||||
Uri mainUri;
|
||||
if (packagesPath != null) {
|
||||
command.addAll(<String>['--packages', packagesPath]);
|
||||
mainUri = _PackageUriMapper.findUri(mainPath, packagesPath);
|
||||
}
|
||||
command.add(mainUri?.toString() ?? mainPath);
|
||||
|
||||
printTrace(command.join(' '));
|
||||
final Process server = await processManager
|
||||
.start(command)
|
||||
@ -302,15 +348,26 @@ class ResidentCompiler {
|
||||
|
||||
// First time recompile is called we actually have to compile the app from
|
||||
// scratch ignoring list of invalidated files.
|
||||
_PackageUriMapper packageUriMapper;
|
||||
if (request.packagesFilePath != null) {
|
||||
packageUriMapper = _PackageUriMapper(request.mainPath, request.packagesFilePath);
|
||||
}
|
||||
|
||||
if (_server == null) {
|
||||
return _compile(_mapFilename(request.mainPath),
|
||||
request.outputPath, _mapFilename(request.packagesFilePath));
|
||||
return _compile(
|
||||
_mapFilename(request.mainPath, packageUriMapper),
|
||||
request.outputPath,
|
||||
_mapFilename(request.packagesFilePath, /* packageUriMapper= */ null)
|
||||
);
|
||||
}
|
||||
|
||||
final String inputKey = Uuid().generateV4();
|
||||
_server.stdin.writeln('recompile ${request.mainPath != null ? _mapFilename(request.mainPath) + " ": ""}$inputKey');
|
||||
final String mainUri = request.mainPath != null
|
||||
? _mapFilename(request.mainPath, packageUriMapper) + ' '
|
||||
: '';
|
||||
_server.stdin.writeln('recompile $mainUri$inputKey');
|
||||
for (String fileUri in request.invalidatedFiles) {
|
||||
_server.stdin.writeln(_mapFileUri(fileUri));
|
||||
_server.stdin.writeln(_mapFileUri(fileUri, packageUriMapper));
|
||||
}
|
||||
_server.stdin.writeln(inputKey);
|
||||
|
||||
@ -334,7 +391,7 @@ class ResidentCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
Future<CompilerOutput> _compile(String scriptFilename, String outputPath,
|
||||
Future<CompilerOutput> _compile(String scriptUri, String outputPath,
|
||||
String packagesFilePath) async {
|
||||
final String frontendServer = artifacts.getArtifactPath(
|
||||
Artifact.frontendServerSnapshotForEngineDartSdk
|
||||
@ -394,7 +451,7 @@ class ResidentCompiler {
|
||||
.transform<String>(const LineSplitter())
|
||||
.listen((String message) { printError(message); });
|
||||
|
||||
_server.stdin.writeln('compile $scriptFilename');
|
||||
_server.stdin.writeln('compile $scriptUri');
|
||||
|
||||
return _stdoutHandler.compilerOutput.future;
|
||||
}
|
||||
@ -457,22 +514,28 @@ class ResidentCompiler {
|
||||
_server?.stdin?.writeln('reset');
|
||||
}
|
||||
|
||||
String _mapFilename(String filename) {
|
||||
if (_fileSystemRoots != null) {
|
||||
for (String root in _fileSystemRoots) {
|
||||
if (filename.startsWith(root)) {
|
||||
return Uri(
|
||||
scheme: _fileSystemScheme, path: filename.substring(root.length))
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
String _mapFilename(String filename, _PackageUriMapper packageUriMapper) {
|
||||
return _doMapFilename(filename, packageUriMapper) ?? filename;
|
||||
}
|
||||
|
||||
String _mapFileUri(String fileUri) {
|
||||
String _mapFileUri(String fileUri, _PackageUriMapper packageUriMapper) {
|
||||
String filename;
|
||||
try {
|
||||
filename = Uri.parse(fileUri).toFilePath();
|
||||
} on UnsupportedError catch (_) {
|
||||
return fileUri;
|
||||
}
|
||||
return _doMapFilename(filename, packageUriMapper) ?? fileUri;
|
||||
}
|
||||
|
||||
String _doMapFilename(String filename, _PackageUriMapper packageUriMapper) {
|
||||
if (packageUriMapper != null) {
|
||||
final Uri packageUri = packageUriMapper.map(filename);
|
||||
if (packageUri != null)
|
||||
return packageUri.toString();
|
||||
}
|
||||
|
||||
if (_fileSystemRoots != null) {
|
||||
final String filename = Uri.parse(fileUri).toFilePath();
|
||||
for (String root in _fileSystemRoots) {
|
||||
if (filename.startsWith(root)) {
|
||||
return Uri(
|
||||
@ -481,7 +544,7 @@ class ResidentCompiler {
|
||||
}
|
||||
}
|
||||
}
|
||||
return fileUri;
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<dynamic> shutdown() {
|
||||
|
@ -33,13 +33,13 @@ void main() {
|
||||
|
||||
Future<VMIsolate> breakInBuildMethod(FlutterTestDriver flutter) async {
|
||||
return _flutter.breakAt(
|
||||
Uri.file(_project.buildMethodBreakpointFile),
|
||||
Uri.parse('package:test/main.dart'),
|
||||
_project.buildMethodBreakpointLine);
|
||||
}
|
||||
|
||||
Future<VMIsolate> breakInTopLevelFunction(FlutterTestDriver flutter) async {
|
||||
return _flutter.breakAt(
|
||||
Uri.file(_project.topLevelFunctionBreakpointFile),
|
||||
Uri.parse('package:test/main.dart'),
|
||||
_project.topLevelFunctionBreakpointLine);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ void main() {
|
||||
test('reload hits breakpoints after reload', () async {
|
||||
await _flutter.run(withDebugger: true);
|
||||
final VMIsolate isolate = await _flutter.breakAt(
|
||||
Uri.file(_project.breakpointFile),
|
||||
Uri.parse('package:test/main.dart'),
|
||||
_project.breakpointLine);
|
||||
expect(isolate.pauseEvent, isInstanceOf<VMPauseBreakpointEvent>());
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user