Unverified Commit b0864737 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Pass multidex flag when using --machine mode (#101689)

parent 2302daa3
...@@ -157,12 +157,12 @@ class Daemon { ...@@ -157,12 +157,12 @@ class Daemon {
this.logToStdout = false, this.logToStdout = false,
}) { }) {
// Set up domains. // Set up domains.
_registerDomain(daemonDomain = DaemonDomain(this)); registerDomain(daemonDomain = DaemonDomain(this));
_registerDomain(appDomain = AppDomain(this)); registerDomain(appDomain = AppDomain(this));
_registerDomain(deviceDomain = DeviceDomain(this)); registerDomain(deviceDomain = DeviceDomain(this));
_registerDomain(emulatorDomain = EmulatorDomain(this)); registerDomain(emulatorDomain = EmulatorDomain(this));
_registerDomain(devToolsDomain = DevToolsDomain(this)); registerDomain(devToolsDomain = DevToolsDomain(this));
_registerDomain(proxyDomain = ProxyDomain(this)); registerDomain(proxyDomain = ProxyDomain(this));
// Start listening. // Start listening.
_commandSubscription = connection.incomingCommands.listen( _commandSubscription = connection.incomingCommands.listen(
...@@ -192,7 +192,8 @@ class Daemon { ...@@ -192,7 +192,8 @@ class Daemon {
final Completer<int> _onExitCompleter = Completer<int>(); final Completer<int> _onExitCompleter = Completer<int>();
final Map<String, Domain> _domainMap = <String, Domain>{}; final Map<String, Domain> _domainMap = <String, Domain>{};
void _registerDomain(Domain domain) { @visibleForTesting
void registerDomain(Domain domain) {
_domainMap[domain.name] = domain; _domainMap[domain.name] = domain;
} }
...@@ -496,6 +497,7 @@ class AppDomain extends Domain { ...@@ -496,6 +497,7 @@ class AppDomain extends Domain {
String packagesFilePath, String packagesFilePath,
String dillOutputPath, String dillOutputPath,
bool ipv6 = false, bool ipv6 = false,
bool multidexEnabled = false,
String isolateFilter, String isolateFilter,
bool machine = true, bool machine = true,
}) async { }) async {
...@@ -544,6 +546,7 @@ class AppDomain extends Domain { ...@@ -544,6 +546,7 @@ class AppDomain extends Domain {
projectRootPath: projectRootPath, projectRootPath: projectRootPath,
dillOutputPath: dillOutputPath, dillOutputPath: dillOutputPath,
ipv6: ipv6, ipv6: ipv6,
multidexEnabled: multidexEnabled,
hostIsIde: true, hostIsIde: true,
machine: machine, machine: machine,
); );
...@@ -554,6 +557,7 @@ class AppDomain extends Domain { ...@@ -554,6 +557,7 @@ class AppDomain extends Domain {
debuggingOptions: options, debuggingOptions: options,
applicationBinary: applicationBinary, applicationBinary: applicationBinary,
ipv6: ipv6, ipv6: ipv6,
multidexEnabled: multidexEnabled,
machine: machine, machine: machine,
); );
} }
......
...@@ -551,6 +551,21 @@ class RunCommand extends RunCommandBase { ...@@ -551,6 +551,21 @@ class RunCommand extends RunCommandBase {
); );
} }
@visibleForTesting
Daemon createMachineDaemon() {
final Daemon daemon = Daemon(
DaemonConnection(
daemonStreams: DaemonStreams.fromStdio(globals.stdio, logger: globals.logger),
logger: globals.logger,
),
notifyingLogger: (globals.logger is NotifyingLogger)
? globals.logger as NotifyingLogger
: NotifyingLogger(verbose: globals.logger.isVerbose, parent: globals.logger),
logToStdout: true,
);
return daemon;
}
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
// Enable hot mode by default if `--no-hot` was not passed and we are in // Enable hot mode by default if `--no-hot` was not passed and we are in
...@@ -563,16 +578,7 @@ class RunCommand extends RunCommandBase { ...@@ -563,16 +578,7 @@ class RunCommand extends RunCommandBase {
if (devices.length > 1) { if (devices.length > 1) {
throwToolExit('"--machine" does not support "-d all".'); throwToolExit('"--machine" does not support "-d all".');
} }
final Daemon daemon = Daemon( final Daemon daemon = createMachineDaemon();
DaemonConnection(
daemonStreams: DaemonStreams.fromStdio(globals.stdio, logger: globals.logger),
logger: globals.logger,
),
notifyingLogger: (globals.logger is NotifyingLogger)
? globals.logger as NotifyingLogger
: NotifyingLogger(verbose: globals.logger.isVerbose, parent: globals.logger),
logToStdout: true,
);
AppInstance app; AppInstance app;
try { try {
app = await daemon.appDomain.startApp( app = await daemon.appDomain.startApp(
...@@ -586,6 +592,7 @@ class RunCommand extends RunCommandBase { ...@@ -586,6 +592,7 @@ class RunCommand extends RunCommandBase {
packagesFilePath: globalResults['packages'] as String, packagesFilePath: globalResults['packages'] as String,
dillOutputPath: stringArg('output-dill'), dillOutputPath: stringArg('output-dill'),
ipv6: ipv6, ipv6: ipv6,
multidexEnabled: boolArg('multidex'),
); );
} on Exception catch (error) { } on Exception catch (error) {
throwToolExit(error.toString()); throwToolExit(error.toString());
......
...@@ -26,6 +26,7 @@ import 'package:flutter_tools/src/base/platform.dart'; ...@@ -26,6 +26,7 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/user_messages.dart'; import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/daemon.dart';
import 'package:flutter_tools/src/commands/run.dart'; import 'package:flutter_tools/src/commands/run.dart';
import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/devfs.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
...@@ -405,6 +406,67 @@ void main() { ...@@ -405,6 +406,67 @@ void main() {
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage, Usage: () => usage,
}); });
group('--machine', () {
testUsingContext('enables multidex by default', () async {
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
final FakeDevice device = FakeDevice();
mockDeviceManager
..devices = <Device>[device]
..targetDevices = <Device>[device];
await expectLater(
() => createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--machine',
'-d',
device.id,
]),
throwsToolExit(),
);
expect(command.appDomain.multidexEnabled, isTrue);
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
DeviceManager: () => mockDeviceManager,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage,
Stdio: () => FakeStdio(),
Logger: () => AppRunLogger(parent: BufferLogger.test()),
});
testUsingContext('can disable multidex with --no-multidex', () async {
final DaemonCapturingRunCommand command = DaemonCapturingRunCommand();
final FakeDevice device = FakeDevice();
mockDeviceManager
..devices = <Device>[device]
..targetDevices = <Device>[device];
await expectLater(
() => createTestCommandRunner(command).run(<String>[
'run',
'--no-pub',
'--no-multidex',
'--machine',
'-d',
device.id,
]),
throwsToolExit(),
);
expect(command.appDomain.multidexEnabled, isFalse);
}, overrides: <Type, Generator>{
Artifacts: () => artifacts,
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
DeviceManager: () => mockDeviceManager,
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Usage: () => usage,
Stdio: () => FakeStdio(),
Logger: () => AppRunLogger(parent: BufferLogger.test()),
});
});
}); });
group('Fatal Logs', () { group('Fatal Logs', () {
...@@ -687,6 +749,13 @@ class FakeDeviceManager extends Fake implements DeviceManager { ...@@ -687,6 +749,13 @@ class FakeDeviceManager extends Fake implements DeviceManager {
return targetDevices; return targetDevices;
} }
@override
List<DeviceDiscovery> get deviceDiscoverers {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
devices.forEach(discoverer.addDevice);
return <DeviceDiscovery>[discoverer];
}
@override @override
Future<List<Device>> getAllConnectedDevices() async => devices; Future<List<Device>> getAllConnectedDevices() async => devices;
} }
...@@ -739,6 +808,9 @@ class FakeDevice extends Fake implements Device { ...@@ -739,6 +808,9 @@ class FakeDevice extends Fake implements Device {
@override @override
bool supportsHotReload = false; bool supportsHotReload = false;
@override
bool get supportsHotRestart => true;
@override @override
bool get supportsFastStart => false; bool get supportsFastStart => false;
...@@ -858,3 +930,44 @@ class FakeResidentRunner extends Fake implements ResidentRunner { ...@@ -858,3 +930,44 @@ class FakeResidentRunner extends Fake implements ResidentRunner {
return 0; return 0;
} }
} }
class DaemonCapturingRunCommand extends RunCommand {
/*late*/ Daemon daemon;
/*late*/ CapturingAppDomain appDomain;
@override
Daemon createMachineDaemon() {
daemon = super.createMachineDaemon();
appDomain = daemon.appDomain = CapturingAppDomain(daemon);
daemon.registerDomain(appDomain);
return daemon;
}
}
class CapturingAppDomain extends AppDomain {
CapturingAppDomain(Daemon daemon) : super(daemon);
bool /*?*/ multidexEnabled;
@override
Future<AppInstance> startApp(
Device device,
String projectDirectory,
String target,
String route,
DebuggingOptions options,
bool enableHotReload, {
File applicationBinary,
@required bool trackWidgetCreation,
String projectRootPath,
String packagesFilePath,
String dillOutputPath,
bool ipv6 = false,
bool multidexEnabled = false,
String isolateFilter,
bool machine = true,
}) async {
this.multidexEnabled = multidexEnabled;
throwToolExit('');
}
}
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