Commit 1d018387 authored by Devon Carew's avatar Devon Carew Committed by GitHub

make the apk building part of flutter run optional (#5301)

parent 4f9e329f
...@@ -56,6 +56,9 @@ class RunCommand extends RunCommandBase { ...@@ -56,6 +56,9 @@ class RunCommand extends RunCommandBase {
help: 'Start in a paused mode and wait for a debugger to connect.'); help: 'Start in a paused mode and wait for a debugger to connect.');
argParser.addOption('debug-port', argParser.addOption('debug-port',
help: 'Listen to the given port for a debug connection (defaults to $kDefaultObservatoryPort).'); help: 'Listen to the given port for a debug connection (defaults to $kDefaultObservatoryPort).');
argParser.addFlag('build',
defaultsTo: true,
help: 'If necessary, build the app before running.');
usesPubOption(); usesPubOption();
// Option to enable hot reloading. // Option to enable hot reloading.
...@@ -171,7 +174,7 @@ class RunCommand extends RunCommandBase { ...@@ -171,7 +174,7 @@ class RunCommand extends RunCommandBase {
); );
} }
return runner.run(route: route); return runner.run(route: route, shouldBuild: argResults['build']);
} }
} }
......
...@@ -76,12 +76,17 @@ class HotRunner extends ResidentRunner { ...@@ -76,12 +76,17 @@ class HotRunner extends ResidentRunner {
} }
@override @override
Future<int> run({ Completer<int> observatoryPortCompleter, String route }) { Future<int> run({
Completer<int> observatoryPortCompleter,
String route,
bool shouldBuild: true
}) {
// Don't let uncaught errors kill the process. // Don't let uncaught errors kill the process.
return runZoned(() { return runZoned(() {
return _run( return _run(
observatoryPortCompleter: observatoryPortCompleter, observatoryPortCompleter: observatoryPortCompleter,
route: route route: route,
shouldBuild: shouldBuild
); );
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace stackTrace) {
printError('Exception from flutter run: $error', stackTrace); printError('Exception from flutter run: $error', stackTrace);
...@@ -90,7 +95,8 @@ class HotRunner extends ResidentRunner { ...@@ -90,7 +95,8 @@ class HotRunner extends ResidentRunner {
Future<int> _run({ Future<int> _run({
Completer<int> observatoryPortCompleter, Completer<int> observatoryPortCompleter,
String route String route,
bool shouldBuild: true
}) async { }) async {
_mainPath = findMainDartFile(target); _mainPath = findMainDartFile(target);
if (!FileSystemEntity.isFileSync(_mainPath)) { if (!FileSystemEntity.isFileSync(_mainPath)) {
...@@ -113,7 +119,7 @@ class HotRunner extends ResidentRunner { ...@@ -113,7 +119,7 @@ class HotRunner extends ResidentRunner {
} }
// TODO(devoncarew): We shouldn't have to do type checks here. // TODO(devoncarew): We shouldn't have to do type checks here.
if (device is AndroidDevice) { if (shouldBuild && device is AndroidDevice) {
printTrace('Running build command.'); printTrace('Running build command.');
int result = await buildApk( int result = await buildApk(
......
...@@ -31,7 +31,11 @@ abstract class ResidentRunner { ...@@ -31,7 +31,11 @@ abstract class ResidentRunner {
StreamSubscription<String> _loggingSubscription; StreamSubscription<String> _loggingSubscription;
/// Start the app and keep the process running during its lifetime. /// Start the app and keep the process running during its lifetime.
Future<int> run({ Completer<int> observatoryPortCompleter, String route }); Future<int> run({
Completer<int> observatoryPortCompleter,
String route,
bool shouldBuild: true
});
Future<bool> restart(); Future<bool> restart();
......
...@@ -36,14 +36,19 @@ class RunAndStayResident extends ResidentRunner { ...@@ -36,14 +36,19 @@ class RunAndStayResident extends ResidentRunner {
bool benchmark; bool benchmark;
@override @override
Future<int> run({ Completer<int> observatoryPortCompleter, String route }) { Future<int> run({
Completer<int> observatoryPortCompleter,
String route,
bool shouldBuild: true
}) {
// Don't let uncaught errors kill the process. // Don't let uncaught errors kill the process.
return runZoned(() { return runZoned(() {
return _run( return _run(
traceStartup: traceStartup, traceStartup: traceStartup,
benchmark: benchmark, benchmark: benchmark,
observatoryPortCompleter: observatoryPortCompleter, observatoryPortCompleter: observatoryPortCompleter,
route: route route: route,
shouldBuild: shouldBuild
); );
}, onError: (dynamic error, StackTrace stackTrace) { }, onError: (dynamic error, StackTrace stackTrace) {
printError('Exception from flutter run: $error', stackTrace); printError('Exception from flutter run: $error', stackTrace);
...@@ -88,7 +93,8 @@ class RunAndStayResident extends ResidentRunner { ...@@ -88,7 +93,8 @@ class RunAndStayResident extends ResidentRunner {
bool traceStartup: false, bool traceStartup: false,
bool benchmark: false, bool benchmark: false,
Completer<int> observatoryPortCompleter, Completer<int> observatoryPortCompleter,
String route String route,
bool shouldBuild: true
}) async { }) async {
_mainPath = findMainDartFile(target); _mainPath = findMainDartFile(target);
if (!FileSystemEntity.isFileSync(_mainPath)) { if (!FileSystemEntity.isFileSync(_mainPath)) {
...@@ -113,7 +119,7 @@ class RunAndStayResident extends ResidentRunner { ...@@ -113,7 +119,7 @@ class RunAndStayResident extends ResidentRunner {
Stopwatch startTime = new Stopwatch()..start(); Stopwatch startTime = new Stopwatch()..start();
// TODO(devoncarew): We shouldn't have to do type checks here. // TODO(devoncarew): We shouldn't have to do type checks here.
if (device is AndroidDevice) { if (shouldBuild && device is AndroidDevice) {
printTrace('Running build command.'); printTrace('Running build command.');
int result = await buildApk( int result = await buildApk(
......
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