Unverified Commit a6a16078 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

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
parent b7c9c96c
58cdd53f9083412fa7da893f53c1ca1c93500532 4c79e423dc6f89f98d8ceb263a5ca78e2f2da996
...@@ -291,6 +291,7 @@ class AOTSnapshotter { ...@@ -291,6 +291,7 @@ class AOTSnapshotter {
@required TargetPlatform platform, @required TargetPlatform platform,
@required BuildMode buildMode, @required BuildMode buildMode,
@required String mainPath, @required String mainPath,
@required String packagesPath,
@required String outputPath, @required String outputPath,
List<String> extraFrontEndOptions = const <String>[], List<String> extraFrontEndOptions = const <String>[],
}) async { }) async {
...@@ -306,6 +307,7 @@ class AOTSnapshotter { ...@@ -306,6 +307,7 @@ class AOTSnapshotter {
final CompilerOutput compilerOutput = await kernelCompiler.compile( final CompilerOutput compilerOutput = await kernelCompiler.compile(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
mainPath: mainPath, mainPath: mainPath,
packagesPath: packagesPath,
outputFilePath: fs.path.join(outputPath, 'app.dill'), outputFilePath: fs.path.join(outputPath, 'app.dill'),
depFilePath: depfilePath, depFilePath: depfilePath,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
......
...@@ -84,6 +84,7 @@ class BuildAotCommand extends BuildSubCommand { ...@@ -84,6 +84,7 @@ class BuildAotCommand extends BuildSubCommand {
platform: platform, platform: platform,
buildMode: buildMode, buildMode: buildMode,
mainPath: mainPath, mainPath: mainPath,
packagesPath: PackageMap.globalPackagesPath,
outputPath: outputPath, outputPath: outputPath,
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions], extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
); );
......
...@@ -10,10 +10,13 @@ import 'package:usage/uuid/uuid.dart'; ...@@ -10,10 +10,13 @@ import 'package:usage/uuid/uuid.dart';
import 'artifacts.dart'; import 'artifacts.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart';
import 'base/fingerprint.dart'; import 'base/fingerprint.dart';
import 'base/io.dart'; import 'base/io.dart';
import 'base/platform.dart';
import 'base/process_manager.dart'; import 'base/process_manager.dart';
import 'base/terminal.dart'; import 'base/terminal.dart';
import 'dart/package_map.dart';
import 'globals.dart'; import 'globals.dart';
KernelCompiler get kernelCompiler => context[KernelCompiler]; KernelCompiler get kernelCompiler => context[KernelCompiler];
...@@ -74,6 +77,42 @@ class _StdoutHandler { ...@@ -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 { class KernelCompiler {
const KernelCompiler(); const KernelCompiler();
...@@ -168,7 +207,14 @@ class KernelCompiler { ...@@ -168,7 +207,14 @@ class KernelCompiler {
if (extraFrontEndOptions != null) if (extraFrontEndOptions != null)
command.addAll(extraFrontEndOptions); 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(' ')); printTrace(command.join(' '));
final Process server = await processManager final Process server = await processManager
.start(command) .start(command)
...@@ -302,15 +348,26 @@ class ResidentCompiler { ...@@ -302,15 +348,26 @@ class ResidentCompiler {
// First time recompile is called we actually have to compile the app from // First time recompile is called we actually have to compile the app from
// scratch ignoring list of invalidated files. // scratch ignoring list of invalidated files.
_PackageUriMapper packageUriMapper;
if (request.packagesFilePath != null) {
packageUriMapper = _PackageUriMapper(request.mainPath, request.packagesFilePath);
}
if (_server == null) { if (_server == null) {
return _compile(_mapFilename(request.mainPath), return _compile(
request.outputPath, _mapFilename(request.packagesFilePath)); _mapFilename(request.mainPath, packageUriMapper),
request.outputPath,
_mapFilename(request.packagesFilePath, /* packageUriMapper= */ null)
);
} }
final String inputKey = Uuid().generateV4(); 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) { for (String fileUri in request.invalidatedFiles) {
_server.stdin.writeln(_mapFileUri(fileUri)); _server.stdin.writeln(_mapFileUri(fileUri, packageUriMapper));
} }
_server.stdin.writeln(inputKey); _server.stdin.writeln(inputKey);
...@@ -334,7 +391,7 @@ class ResidentCompiler { ...@@ -334,7 +391,7 @@ class ResidentCompiler {
} }
} }
Future<CompilerOutput> _compile(String scriptFilename, String outputPath, Future<CompilerOutput> _compile(String scriptUri, String outputPath,
String packagesFilePath) async { String packagesFilePath) async {
final String frontendServer = artifacts.getArtifactPath( final String frontendServer = artifacts.getArtifactPath(
Artifact.frontendServerSnapshotForEngineDartSdk Artifact.frontendServerSnapshotForEngineDartSdk
...@@ -394,7 +451,7 @@ class ResidentCompiler { ...@@ -394,7 +451,7 @@ class ResidentCompiler {
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
.listen((String message) { printError(message); }); .listen((String message) { printError(message); });
_server.stdin.writeln('compile $scriptFilename'); _server.stdin.writeln('compile $scriptUri');
return _stdoutHandler.compilerOutput.future; return _stdoutHandler.compilerOutput.future;
} }
...@@ -457,22 +514,28 @@ class ResidentCompiler { ...@@ -457,22 +514,28 @@ class ResidentCompiler {
_server?.stdin?.writeln('reset'); _server?.stdin?.writeln('reset');
} }
String _mapFilename(String filename) { String _mapFilename(String filename, _PackageUriMapper packageUriMapper) {
if (_fileSystemRoots != null) { return _doMapFilename(filename, packageUriMapper) ?? filename;
for (String root in _fileSystemRoots) { }
if (filename.startsWith(root)) {
return Uri( String _mapFileUri(String fileUri, _PackageUriMapper packageUriMapper) {
scheme: _fileSystemScheme, path: filename.substring(root.length)) String filename;
.toString(); try {
} filename = Uri.parse(fileUri).toFilePath();
} } on UnsupportedError catch (_) {
return fileUri;
} }
return filename; return _doMapFilename(filename, packageUriMapper) ?? fileUri;
} }
String _mapFileUri(String 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) { if (_fileSystemRoots != null) {
final String filename = Uri.parse(fileUri).toFilePath();
for (String root in _fileSystemRoots) { for (String root in _fileSystemRoots) {
if (filename.startsWith(root)) { if (filename.startsWith(root)) {
return Uri( return Uri(
...@@ -481,7 +544,7 @@ class ResidentCompiler { ...@@ -481,7 +544,7 @@ class ResidentCompiler {
} }
} }
} }
return fileUri; return null;
} }
Future<dynamic> shutdown() { Future<dynamic> shutdown() {
......
...@@ -33,13 +33,13 @@ void main() { ...@@ -33,13 +33,13 @@ void main() {
Future<VMIsolate> breakInBuildMethod(FlutterTestDriver flutter) async { Future<VMIsolate> breakInBuildMethod(FlutterTestDriver flutter) async {
return _flutter.breakAt( return _flutter.breakAt(
Uri.file(_project.buildMethodBreakpointFile), Uri.parse('package:test/main.dart'),
_project.buildMethodBreakpointLine); _project.buildMethodBreakpointLine);
} }
Future<VMIsolate> breakInTopLevelFunction(FlutterTestDriver flutter) async { Future<VMIsolate> breakInTopLevelFunction(FlutterTestDriver flutter) async {
return _flutter.breakAt( return _flutter.breakAt(
Uri.file(_project.topLevelFunctionBreakpointFile), Uri.parse('package:test/main.dart'),
_project.topLevelFunctionBreakpointLine); _project.topLevelFunctionBreakpointLine);
} }
......
...@@ -41,7 +41,7 @@ void main() { ...@@ -41,7 +41,7 @@ void main() {
test('reload hits breakpoints after reload', () async { test('reload hits breakpoints after reload', () async {
await _flutter.run(withDebugger: true); await _flutter.run(withDebugger: true);
final VMIsolate isolate = await _flutter.breakAt( final VMIsolate isolate = await _flutter.breakAt(
Uri.file(_project.breakpointFile), Uri.parse('package:test/main.dart'),
_project.breakpointLine); _project.breakpointLine);
expect(isolate.pauseEvent, isInstanceOf<VMPauseBreakpointEvent>()); expect(isolate.pauseEvent, isInstanceOf<VMPauseBreakpointEvent>());
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment