From b8d64ffe6857bbf974bc3a6d512c247c18b91e6e Mon Sep 17 00:00:00 2001 From: Alhaad Gokhale Date: Wed, 9 Mar 2016 11:24:47 -0800 Subject: [PATCH] Add `flutter_tools build` hooks to also generate depfile. Fixes #1942. --- .../flutter_tools/lib/src/commands/build.dart | 2 ++ packages/flutter_tools/lib/src/flx.dart | 4 +++- packages/flutter_tools/lib/src/toolchain.dart | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/build.dart b/packages/flutter_tools/lib/src/commands/build.dart index 73f132139e3..769dc703156 100644 --- a/packages/flutter_tools/lib/src/commands/build.dart +++ b/packages/flutter_tools/lib/src/commands/build.dart @@ -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) { diff --git a/packages/flutter_tools/lib/src/flx.dart b/packages/flutter_tools/lib/src/flx.dart index e7aa7dae6cd..7e1a4267188 100644 --- a/packages/flutter_tools/lib/src/flx.dart +++ b/packages/flutter_tools/lib/src/flx.dart @@ -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 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 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; diff --git a/packages/flutter_tools/lib/src/toolchain.dart b/packages/flutter_tools/lib/src/toolchain.dart index 1e5f52318a9..c3bbf758262 100644 --- a/packages/flutter_tools/lib/src/toolchain.dart +++ b/packages/flutter_tools/lib/src/toolchain.dart @@ -18,14 +18,23 @@ class Compiler { Future compile({ String mainPath, - String snapshotPath + String snapshotPath, + String depfilePath, + String buildOutputPath }) { - return runCommandAndStreamOutput([ + final List 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); } }