Fix flutter run --use-application-binary (#6106)
When using --use-application-binary:
- [x] Stop flutter run from checking for a pubspec.yaml in current directory
- [x] Stop flutter run from invoking pub get
- [x] Set 'shouldBuild' based on --use-application-binary
- [x] Stop requiring 'lib/main.dart' to be present before running.
- [x] Stop building an FLX when launching on Android
diff --git a/packages/flutter_tools/lib/src/run.dart b/packages/flutter_tools/lib/src/run.dart
index f9ace41..b4e5d30 100644
--- a/packages/flutter_tools/lib/src/run.dart
+++ b/packages/flutter_tools/lib/src/run.dart
@@ -38,6 +38,8 @@
final bool benchmark;
final String applicationBinary;
+ bool get prebuiltMode => applicationBinary != null;
+
@override
Future<int> run({
Completer<DebugConnectionInfo> connectionInfoCompleter,
@@ -46,6 +48,7 @@
}) {
// Don't let uncaught errors kill the process.
return runZoned(() {
+ assert(shouldBuild == !prebuiltMode);
return _run(
traceStartup: traceStartup,
benchmark: benchmark,
@@ -78,7 +81,8 @@
_package,
_result,
mainPath: _mainPath,
- observatory: vmService
+ observatory: vmService,
+ prebuiltApplication: prebuiltMode
);
status.stop(showElapsedTime: true);
@@ -99,13 +103,15 @@
String route,
bool shouldBuild: true
}) async {
- _mainPath = findMainDartFile(target);
- if (!FileSystemEntity.isFileSync(_mainPath)) {
- String message = 'Tried to run $_mainPath, but that file does not exist.';
- if (target == null)
- message += '\nConsider using the -t option to specify the Dart file to start.';
- printError(message);
- return 1;
+ if (!prebuiltMode) {
+ _mainPath = findMainDartFile(target);
+ if (!FileSystemEntity.isFileSync(_mainPath)) {
+ String message = 'Tried to run $_mainPath, but that file does not exist.';
+ if (target == null)
+ message += '\nConsider using the -t option to specify the Dart file to start.';
+ printError(message);
+ return 1;
+ }
}
_package = getApplicationPackageForPlatform(device.platform, applicationBinary: applicationBinary);
@@ -153,7 +159,12 @@
platformArgs = <String, dynamic>{ 'trace-startup': traceStartup };
await startEchoingDeviceLog();
- printStatus('Running ${getDisplayPath(_mainPath)} on ${device.name}...');
+ if (_mainPath == null) {
+ assert(prebuiltMode);
+ printStatus('Running ${_package.displayName} on ${device.name}');
+ } else {
+ printStatus('Running ${getDisplayPath(_mainPath)} on ${device.name}...');
+ }
_result = await device.startApp(
_package,
@@ -161,7 +172,8 @@
mainPath: _mainPath,
debuggingOptions: debuggingOptions,
platformArgs: platformArgs,
- route: route
+ route: route,
+ prebuiltApplication: prebuiltMode
);
if (!_result.started) {