Unverified Commit 673c5485 authored by Alexander Aprelev's avatar Alexander Aprelev Committed by GitHub

Generate and use dep-file for --preview-dart-2 (#15077)

* Use depfile in --preview-dart-2 mode.

* Generate and use frontend_server.d to guard against reusing outdated dill files when frontend_server changes.
parent bcdbed96
...@@ -438,9 +438,9 @@ abstract class BaseFlutterTask extends DefaultTask { ...@@ -438,9 +438,9 @@ abstract class BaseFlutterTask extends DefaultTask {
if (buildMode != "debug") { if (buildMode != "debug") {
args "--precompiled" args "--precompiled"
} else { } else {
args "--depfile", "${intermediateDir}/snapshot_blob.bin.d"
if (!previewDart2) { if (!previewDart2) {
args "--snapshot", "${intermediateDir}/snapshot_blob.bin" args "--snapshot", "${intermediateDir}/snapshot_blob.bin"
args "--depfile", "${intermediateDir}/snapshot_blob.bin.d"
} }
} }
args "--working-dir", "${intermediateDir}/flutter_assets" args "--working-dir", "${intermediateDir}/flutter_assets"
...@@ -508,6 +508,12 @@ class FlutterTask extends BaseFlutterTask { ...@@ -508,6 +508,12 @@ class FlutterTask extends BaseFlutterTask {
if (snapshotter != null) { if (snapshotter != null) {
sources = sources.plus(snapshotter) sources = sources.plus(snapshotter)
} }
if (previewDart2) {
FileCollection frontendServer = readDependencies(project.file("${intermediateDir}/frontend_server.d"))
if (frontendServer != null) {
sources = sources.plus(frontendServer)
}
}
if (localEngineSrcPath != null) { if (localEngineSrcPath != null) {
sources = sources.plus(project.files("$localEngineSrcPath/$localEngine")) sources = sources.plus(project.files("$localEngineSrcPath/$localEngine"))
} }
......
...@@ -367,6 +367,7 @@ Future<String> _buildAotSnapshot( ...@@ -367,6 +367,7 @@ Future<String> _buildAotSnapshot(
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
mainPath: mainPath, mainPath: mainPath,
outputFilePath: kApplicationKernelPath, outputFilePath: kApplicationKernelPath,
depFilePath: dependencies,
extraFrontEndOptions: extraFrontEndOptions, extraFrontEndOptions: extraFrontEndOptions,
linkPlatformKernelIn : true, linkPlatformKernelIn : true,
aot : true, aot : true,
...@@ -376,6 +377,10 @@ Future<String> _buildAotSnapshot( ...@@ -376,6 +377,10 @@ Future<String> _buildAotSnapshot(
printError('Compiler terminated unexpectedly.'); printError('Compiler terminated unexpectedly.');
return null; return null;
} }
// Write path to frontend_server, since things need to be re-generated when
// that changes.
await outputDir.childFile('frontend_server.d')
.writeAsString('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n');
genSnapshotCmd.addAll(<String>[ genSnapshotCmd.addAll(<String>[
'--reify-generic-functions', '--reify-generic-functions',
......
...@@ -59,6 +59,7 @@ Future<String> compile( ...@@ -59,6 +59,7 @@ Future<String> compile(
{String sdkRoot, {String sdkRoot,
String mainPath, String mainPath,
String outputFilePath, String outputFilePath,
String depFilePath,
bool linkPlatformKernelIn: false, bool linkPlatformKernelIn: false,
bool aot: false, bool aot: false,
bool trackWidgetCreation: false, bool trackWidgetCreation: false,
...@@ -96,6 +97,9 @@ Future<String> compile( ...@@ -96,6 +97,9 @@ Future<String> compile(
if (outputFilePath != null) { if (outputFilePath != null) {
command.addAll(<String>['--output-dill', outputFilePath]); command.addAll(<String>['--output-dill', outputFilePath]);
} }
if (depFilePath != null) {
command.addAll(<String>['--depfile', depFilePath]);
}
if (extraFrontEndOptions != null) if (extraFrontEndOptions != null)
command.addAll(extraFrontEndOptions); command.addAll(extraFrontEndOptions);
......
...@@ -80,11 +80,15 @@ Future<Null> build({ ...@@ -80,11 +80,15 @@ Future<Null> build({
incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()), incrementalCompilerByteStorePath: fs.path.absolute(getIncrementalCompilerByteStoreDirectory()),
mainPath: fs.file(mainPath).absolute.path, mainPath: fs.file(mainPath).absolute.path,
outputFilePath: applicationKernelFilePath, outputFilePath: applicationKernelFilePath,
depFilePath: depfilePath,
trackWidgetCreation: trackWidgetCreation, trackWidgetCreation: trackWidgetCreation,
); );
if (kernelBinaryFilename == null) { if (kernelBinaryFilename == null) {
throwToolExit('Compiler terminated unexpectedly on $mainPath'); throwToolExit('Compiler terminated unexpectedly on $mainPath');
} }
await fs.directory(getBuildDirectory()).childFile('frontend_server.d')
.writeAsString('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n');
kernelContent = new DevFSFileContent(fs.file(kernelBinaryFilename)); kernelContent = new DevFSFileContent(fs.file(kernelBinaryFilename));
} }
......
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