mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Include kernel_compile.d in Gradle depfiles (#17175)
This updates the Android build to declare the kernel compile depfile as an output and its contents as inputs when running with --preview-dart-2 (the default mode). The 'flutter build aot' command behaves differently depending on whether it's running in Dart 1 or Dart 2 mode: * Dart 1: the entrypoint Dart file (typically main.dart) is passed directly to gen_snapshot, which then emits snapshot.d, whose contents list the transitive closure of Dart dependencies (input files) for the snapshot. snapshot.d is a declared output, its contents (plus gen_snapshot itself) constitute the set of input files to the Gradle build action. * Dart 2: then entrypoint Dart file (typically main.dart) is first compiled with the Dart kernel frontend. This emits kernel_compile.d, whose contents list the transitive closure of Dart dependencies (input files) for the kernel 'dill' output file. This 'dill' file is then passed to gen_snapshot, which emits snapshot.d, whose contents are empty. As of this change, both snapshot.d and kernel_compile.d are declared outputs, and their contents (plus gen_snapshot and the frontend compiler themselves) constitute the set of input files to the Gradle build action. This fixes a bug wherein profile/release AOT outputs were not invalidated due to snapshot.d being empty, and kernel_compile.d being ignored. This was introduced during recent refactoring of the AOT build code, wherein the kernel compile and gen_snapshot actions were changed to emit independent depfiles (previously one stomped -- or failed to -- on the other's output).
This commit is contained in:
parent
7982a3a277
commit
752906498a
@ -371,12 +371,20 @@ abstract class BaseFlutterTask extends DefaultTask {
|
|||||||
@Optional @Input
|
@Optional @Input
|
||||||
String extraGenSnapshotOptions
|
String extraGenSnapshotOptions
|
||||||
|
|
||||||
@OutputFile
|
@OutputFiles
|
||||||
File getDependenciesFile() {
|
FileCollection getDependenciesFiles() {
|
||||||
if (buildMode != 'debug') {
|
if (buildMode != 'debug') {
|
||||||
return project.file("${intermediateDir}/snapshot.d")
|
// For AOT builds, include the gen_snapshot depfile.
|
||||||
|
FileCollection depfiles = project.files("${intermediateDir}/snapshot.d")
|
||||||
|
if (previewDart2) {
|
||||||
|
// For Dart 2, also include the kernel compiler depfile, since
|
||||||
|
// kernel compile is the first stage of AOT build in this mode,
|
||||||
|
// and it includes all the Dart sources.
|
||||||
|
depfiles += project.files("${intermediateDir}/kernel_compile.d")
|
||||||
|
}
|
||||||
|
return depfiles
|
||||||
}
|
}
|
||||||
return project.file("${intermediateDir}/snapshot_blob.bin.d")
|
return project.files("${intermediateDir}/snapshot_blob.bin.d")
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildBundle() {
|
void buildBundle() {
|
||||||
@ -499,31 +507,27 @@ class FlutterTask extends BaseFlutterTask {
|
|||||||
logger.error("Error reading dependency file ${dependenciesFile}: ${e}")
|
logger.error("Error reading dependency file ${dependenciesFile}: ${e}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null
|
return project.files()
|
||||||
}
|
}
|
||||||
|
|
||||||
@InputFiles
|
@InputFiles
|
||||||
FileCollection getSourceFiles() {
|
FileCollection getSourceFiles() {
|
||||||
File dependenciesFile = getDependenciesFile()
|
FileCollection sources = project.files()
|
||||||
FileCollection sources = readDependencies(dependenciesFile)
|
for (File depfile in getDependenciesFiles()) {
|
||||||
if (sources != null) {
|
sources += readDependencies(depfile)
|
||||||
|
}
|
||||||
|
if (!sources.isEmpty()) {
|
||||||
// We have a dependencies file. Add a dependency on gen_snapshot as well, since the
|
// We have a dependencies file. Add a dependency on gen_snapshot as well, since the
|
||||||
// snapshots have to be rebuilt if it changes.
|
// snapshots have to be rebuilt if it changes.
|
||||||
FileCollection snapshotter = readDependencies(project.file("${intermediateDir}/gen_snapshot.d"))
|
sources += readDependencies(project.file("${intermediateDir}/gen_snapshot.d"))
|
||||||
if (snapshotter != null) {
|
|
||||||
sources = sources.plus(snapshotter)
|
|
||||||
}
|
|
||||||
if (previewDart2) {
|
if (previewDart2) {
|
||||||
FileCollection frontendServer = readDependencies(project.file("${intermediateDir}/frontend_server.d"))
|
sources += 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 += project.files("$localEngineSrcPath/$localEngine")
|
||||||
}
|
}
|
||||||
// Finally, add a dependency on pubspec.yaml as well.
|
// Finally, add a dependency on pubspec.yaml as well.
|
||||||
return sources.plus(project.files('pubspec.yaml'))
|
return sources + project.files('pubspec.yaml')
|
||||||
}
|
}
|
||||||
// No dependencies file (or problems parsing it). Fall back to source files.
|
// No dependencies file (or problems parsing it). Fall back to source files.
|
||||||
return project.fileTree(
|
return project.fileTree(
|
||||||
|
Loading…
Reference in New Issue
Block a user