Unverified Commit 094179e8 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

Enable Dart plugin registrant on Desktop only (#81586)

parent 59b406c7
......@@ -8,6 +8,7 @@ import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart';
import '../../base/file_system.dart';
import '../../build_info.dart';
import '../../dart/package_map.dart';
import '../../flutter_plugins.dart';
import '../../project.dart';
......@@ -63,7 +64,21 @@ class DartPluginRegistrantTarget extends Target {
@override
bool canSkip(Environment environment) {
return !environment.generateDartPluginRegistry;
if (!environment.generateDartPluginRegistry) {
return true;
}
final String platformName = environment.defines[kTargetPlatform];
if (platformName == null) {
return true;
}
final TargetPlatform targetPlatform = getTargetPlatformForName(platformName);
// TODO(egarciad): Support Android and iOS.
// https://github.com/flutter/flutter/issues/52267
return targetPlatform != TargetPlatform.darwin &&
targetPlatform != TargetPlatform.linux_x64 &&
targetPlatform != TargetPlatform.linux_arm64 &&
targetPlatform != TargetPlatform.windows_x64 &&
targetPlatform != TargetPlatform.windows_uwp_x64;
}
@override
......
......@@ -104,9 +104,12 @@ void main() {
fileSystem: fileSystem,
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
generateDartPluginRegistry: false);
generateDartPluginRegistry: false,
defines: <String, String>{
kTargetPlatform: 'darwin-x64',
});
expect(const DartPluginRegistrantTarget().canSkip(environment), true);
expect(const DartPluginRegistrantTarget().canSkip(environment), isTrue);
final Environment environment2 = Environment.test(
fileSystem.currentDirectory,
......@@ -114,9 +117,46 @@ void main() {
fileSystem: fileSystem,
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
generateDartPluginRegistry: true);
generateDartPluginRegistry: true,
defines: <String, String>{
kTargetPlatform: 'darwin-x64',
});
expect(const DartPluginRegistrantTarget().canSkip(environment2), isFalse);
});
expect(const DartPluginRegistrantTarget().canSkip(environment2), false);
testWithoutContext('skipped based on platform', () async {
const Map<String, bool> canSkip = <String, bool>{
'darwin-x64': false,
'linux-x64': false,
'linux-arm64': false,
'windows-x64': false,
'windows-uwp-x64': false,
'web-javascript': true,
'ios': true,
'android': true,
'fuchsia-arm64': true,
'fuchsia-x64': true,
};
for (final String targetPlatform in canSkip.keys) {
expect(
const DartPluginRegistrantTarget().canSkip(
Environment.test(
fileSystem.currentDirectory,
artifacts: null,
fileSystem: fileSystem,
logger: BufferLogger.test(),
processManager: FakeProcessManager.any(),
generateDartPluginRegistry: true,
defines: <String, String>{
kTargetPlatform: targetPlatform,
},
),
),
canSkip[targetPlatform],
);
}
});
testUsingContext("doesn't generate generated_main.dart if there aren't Dart plugins", () async {
......
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