Fix dep tracking (#147709)
Fix dependency tracking in the build. * https://github.com/flutter/flutter/issues/147643 ## Testing It's not clear to me where to test the caching behavior of specific targets. * test/general.shard/build_system/targets/common_test.dart * This doesn't test the caching behavior of any targets * test/general.shard/build_system/build_system_test.dart * test/general.shard/cache_test.dart * Both of these don't test specific `Target`s, these have `TestTarget`s. * test/integration.shard/isolated/native_assets_test.dart * This could work, but it's an integration test that already takes long to run.
This commit is contained in:
parent
d04edd1d7f
commit
6967ae551e
@ -143,12 +143,15 @@ class KernelSnapshotProgram extends Target {
|
||||
|
||||
@override
|
||||
List<Source> get outputs => const <Source>[
|
||||
Source.pattern('{BUILD_DIR}/${KernelSnapshotProgram.dillName}'),
|
||||
// TODO(mosuem): Should output resources.json. https://github.com/flutter/flutter/issues/146263
|
||||
];
|
||||
|
||||
static const String depfile = 'kernel_snapshot_program.d';
|
||||
|
||||
@override
|
||||
List<String> get depfiles => <String>[
|
||||
'kernel_snapshot.d',
|
||||
List<String> get depfiles => const <String>[
|
||||
depfile,
|
||||
];
|
||||
|
||||
@override
|
||||
@ -258,7 +261,7 @@ class KernelSnapshotProgram extends Target {
|
||||
packagesPath: packagesFile.path,
|
||||
linkPlatformKernelIn: forceLinkPlatform || buildMode.isPrecompiled,
|
||||
mainPath: targetFileAbsolute,
|
||||
depFilePath: environment.buildDir.childFile('kernel_snapshot.d').path,
|
||||
depFilePath: environment.buildDir.childFile(depfile).path,
|
||||
frontendServerStarterPath: frontendServerStarterPath,
|
||||
extraFrontEndOptions: extraFrontEndOptions,
|
||||
fileSystemRoots: fileSystemRoots,
|
||||
@ -293,7 +296,9 @@ class KernelSnapshotNativeAssets extends Target {
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get outputs => const <Source>[];
|
||||
List<Source> get outputs => const <Source>[
|
||||
Source.pattern('{BUILD_DIR}/${KernelSnapshotNativeAssets.dillName}'),
|
||||
];
|
||||
|
||||
@override
|
||||
List<String> get depfiles => const <String>[];
|
||||
@ -392,7 +397,10 @@ class KernelSnapshot extends Target {
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get inputs => <Source>[];
|
||||
List<Source> get inputs => const <Source>[
|
||||
Source.pattern('{BUILD_DIR}/${KernelSnapshotProgram.dillName}'),
|
||||
Source.pattern('{BUILD_DIR}/${KernelSnapshotNativeAssets.dillName}'),
|
||||
];
|
||||
|
||||
@override
|
||||
List<Source> get outputs => <Source>[];
|
||||
|
@ -121,7 +121,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--verbosity=error',
|
||||
'file:///lib/main.dart',
|
||||
], exitCode: 1),
|
||||
@ -161,7 +161,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--verbosity=error',
|
||||
'file:///lib/main.dart',
|
||||
], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/program.dill 0\n'),
|
||||
@ -202,7 +202,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--verbosity=error',
|
||||
'file:///lib/main.dart',
|
||||
], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/program.dill 0\n'),
|
||||
@ -244,7 +244,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--verbosity=error',
|
||||
'file:///lib/main.dart',
|
||||
], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/program.dill 0\n'),
|
||||
@ -286,7 +286,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--verbosity=error',
|
||||
'foo',
|
||||
'bar',
|
||||
@ -327,7 +327,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--incremental',
|
||||
'--initialize-from-dill',
|
||||
'$build/program.dill',
|
||||
@ -368,7 +368,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--incremental',
|
||||
'--initialize-from-dill',
|
||||
'$build/program.dill',
|
||||
@ -424,7 +424,7 @@ native-assets:
|
||||
'--output-dill',
|
||||
'$build/program.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'$build/kernel_snapshot_program.d',
|
||||
'--incremental',
|
||||
'--initialize-from-dill',
|
||||
'$build/program.dill',
|
||||
@ -488,6 +488,27 @@ native-assets:
|
||||
}
|
||||
}
|
||||
|
||||
for (final bool empty in <bool>[true, false]) {
|
||||
final String testName = empty ? 'empty' : 'non empty';
|
||||
testWithoutContext('KernelSnapshot native assets $testName', () async {
|
||||
const List<int> programDillBytes = <int>[1, 2, 3, 4];
|
||||
androidEnvironment.buildDir.childFile('program.dill')
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(programDillBytes);
|
||||
final List<int> nativeAssetsDillBytes = empty ? <int>[] : <int>[5, 6, 7, 8];
|
||||
androidEnvironment.buildDir.childFile('native_assets.dill')
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(nativeAssetsDillBytes);
|
||||
|
||||
await const KernelSnapshot().build(androidEnvironment);
|
||||
|
||||
expect(
|
||||
androidEnvironment.buildDir.childFile('app.dill').readAsBytesSync(),
|
||||
equals(<int>[...programDillBytes, ...nativeAssetsDillBytes]),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
testUsingContext('AotElfProfile Produces correct output directory', () async {
|
||||
final String build = androidEnvironment.buildDir.path;
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
|
Loading…
x
Reference in New Issue
Block a user