mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Merge pull request #2528 from alhaad/depsfile_hook
Add `flutter_tools build` hooks to also generate depfile.
This commit is contained in:
commit
5faf84c3fa
|
@ -23,6 +23,7 @@ class BuildCommand extends FlutterCommand {
|
|||
argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
|
||||
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
|
||||
argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
|
||||
argParser.addOption('depfile', defaultsTo: defaultDepfilePath);
|
||||
addTargetOption();
|
||||
}
|
||||
|
||||
|
@ -42,6 +43,7 @@ class BuildCommand extends FlutterCommand {
|
|||
manifestPath: argResults['manifest'],
|
||||
outputPath: outputPath,
|
||||
snapshotPath: argResults['snapshot'],
|
||||
depfilePath: argResults['depfile'],
|
||||
privateKeyPath: argResults['private-key'],
|
||||
precompiledSnapshot: argResults['precompiled']
|
||||
).then((int result) {
|
||||
|
|
|
@ -22,6 +22,7 @@ const String defaultAssetBasePath = '.';
|
|||
const String defaultManifestPath = 'flutter.yaml';
|
||||
const String defaultFlxOutputPath = 'build/app.flx';
|
||||
const String defaultSnapshotPath = 'build/snapshot_blob.bin';
|
||||
const String defaultDepfilePath = 'build/snapshot_blob.bin.d';
|
||||
const String defaultPrivateKeyPath = 'privatekey.der';
|
||||
|
||||
const String _kSnapshotKey = 'snapshot_blob.bin';
|
||||
|
@ -160,6 +161,7 @@ Future<int> build(
|
|||
String manifestPath: defaultManifestPath,
|
||||
String outputPath: defaultFlxOutputPath,
|
||||
String snapshotPath: defaultSnapshotPath,
|
||||
String depfilePath: defaultDepfilePath,
|
||||
String privateKeyPath: defaultPrivateKeyPath,
|
||||
bool precompiledSnapshot: false
|
||||
}) async {
|
||||
|
@ -173,7 +175,7 @@ Future<int> build(
|
|||
|
||||
// In a precompiled snapshot, the instruction buffer contains script
|
||||
// content equivalents
|
||||
int result = await toolchain.compiler.compile(mainPath: mainPath, snapshotPath: snapshotPath);
|
||||
int result = await toolchain.compiler.compile(mainPath: mainPath, snapshotPath: snapshotPath, depfilePath: depfilePath, buildOutputPath: outputPath);
|
||||
if (result != 0) {
|
||||
printError('Failed to run the Flutter compiler. Exit code: $result');
|
||||
return result;
|
||||
|
|
|
@ -18,14 +18,23 @@ class Compiler {
|
|||
|
||||
Future<int> compile({
|
||||
String mainPath,
|
||||
String snapshotPath
|
||||
String snapshotPath,
|
||||
String depfilePath,
|
||||
String buildOutputPath
|
||||
}) {
|
||||
return runCommandAndStreamOutput([
|
||||
final List<String> args = [
|
||||
_path,
|
||||
mainPath,
|
||||
'--package-root=${ArtifactStore.packageRoot}',
|
||||
'--snapshot=$snapshotPath'
|
||||
]);
|
||||
];
|
||||
if (depfilePath != null) {
|
||||
args.add('--depfile=$depfilePath');
|
||||
}
|
||||
if (buildOutputPath != null) {
|
||||
args.add('--build-output=$buildOutputPath');
|
||||
}
|
||||
return runCommandAndStreamOutput(args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue