Commit 5faf84c3 authored by Alhaad Gokhale's avatar Alhaad Gokhale

Merge pull request #2528 from alhaad/depsfile_hook

Add `flutter_tools build` hooks to also generate depfile.
parents ad7fd3e4 b8d64ffe
...@@ -23,6 +23,7 @@ class BuildCommand extends FlutterCommand { ...@@ -23,6 +23,7 @@ class BuildCommand extends FlutterCommand {
argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath); argParser.addOption('private-key', defaultsTo: defaultPrivateKeyPath);
argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath); argParser.addOption('output-file', abbr: 'o', defaultsTo: defaultFlxOutputPath);
argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath); argParser.addOption('snapshot', defaultsTo: defaultSnapshotPath);
argParser.addOption('depfile', defaultsTo: defaultDepfilePath);
addTargetOption(); addTargetOption();
} }
...@@ -42,6 +43,7 @@ class BuildCommand extends FlutterCommand { ...@@ -42,6 +43,7 @@ class BuildCommand extends FlutterCommand {
manifestPath: argResults['manifest'], manifestPath: argResults['manifest'],
outputPath: outputPath, outputPath: outputPath,
snapshotPath: argResults['snapshot'], snapshotPath: argResults['snapshot'],
depfilePath: argResults['depfile'],
privateKeyPath: argResults['private-key'], privateKeyPath: argResults['private-key'],
precompiledSnapshot: argResults['precompiled'] precompiledSnapshot: argResults['precompiled']
).then((int result) { ).then((int result) {
......
...@@ -22,6 +22,7 @@ const String defaultAssetBasePath = '.'; ...@@ -22,6 +22,7 @@ const String defaultAssetBasePath = '.';
const String defaultManifestPath = 'flutter.yaml'; const String defaultManifestPath = 'flutter.yaml';
const String defaultFlxOutputPath = 'build/app.flx'; const String defaultFlxOutputPath = 'build/app.flx';
const String defaultSnapshotPath = 'build/snapshot_blob.bin'; const String defaultSnapshotPath = 'build/snapshot_blob.bin';
const String defaultDepfilePath = 'build/snapshot_blob.bin.d';
const String defaultPrivateKeyPath = 'privatekey.der'; const String defaultPrivateKeyPath = 'privatekey.der';
const String _kSnapshotKey = 'snapshot_blob.bin'; const String _kSnapshotKey = 'snapshot_blob.bin';
...@@ -160,6 +161,7 @@ Future<int> build( ...@@ -160,6 +161,7 @@ Future<int> build(
String manifestPath: defaultManifestPath, String manifestPath: defaultManifestPath,
String outputPath: defaultFlxOutputPath, String outputPath: defaultFlxOutputPath,
String snapshotPath: defaultSnapshotPath, String snapshotPath: defaultSnapshotPath,
String depfilePath: defaultDepfilePath,
String privateKeyPath: defaultPrivateKeyPath, String privateKeyPath: defaultPrivateKeyPath,
bool precompiledSnapshot: false bool precompiledSnapshot: false
}) async { }) async {
...@@ -173,7 +175,7 @@ Future<int> build( ...@@ -173,7 +175,7 @@ Future<int> build(
// In a precompiled snapshot, the instruction buffer contains script // In a precompiled snapshot, the instruction buffer contains script
// content equivalents // 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) { if (result != 0) {
printError('Failed to run the Flutter compiler. Exit code: $result'); printError('Failed to run the Flutter compiler. Exit code: $result');
return result; return result;
......
...@@ -18,14 +18,23 @@ class Compiler { ...@@ -18,14 +18,23 @@ class Compiler {
Future<int> compile({ Future<int> compile({
String mainPath, String mainPath,
String snapshotPath String snapshotPath,
String depfilePath,
String buildOutputPath
}) { }) {
return runCommandAndStreamOutput([ final List<String> args = [
_path, _path,
mainPath, mainPath,
'--package-root=${ArtifactStore.packageRoot}', '--package-root=${ArtifactStore.packageRoot}',
'--snapshot=$snapshotPath' '--snapshot=$snapshotPath'
]); ];
if (depfilePath != null) {
args.add('--depfile=$depfilePath');
}
if (buildOutputPath != null) {
args.add('--build-output=$buildOutputPath');
}
return runCommandAndStreamOutput(args);
} }
} }
......
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