Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit d110538

Browse files
[flutter_plugin_tool] Fix iOS/macOS naming (#4861)
1 parent ce0870e commit d110538

16 files changed

+316
-317
lines changed

script/tool/lib/src/build_examples_command.dart

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const int _exitInvalidPluginToolsConfig = 4;
3333

3434
// Flutter build types. These are the values passed to `flutter build <foo>`.
3535
const String _flutterBuildTypeAndroid = 'apk';
36-
const String _flutterBuildTypeIos = 'ios';
36+
const String _flutterBuildTypeIOS = 'ios';
3737
const String _flutterBuildTypeLinux = 'linux';
3838
const String _flutterBuildTypeMacOS = 'macos';
3939
const String _flutterBuildTypeWeb = 'web';
@@ -48,12 +48,12 @@ class BuildExamplesCommand extends PackageLoopingCommand {
4848
ProcessRunner processRunner = const ProcessRunner(),
4949
Platform platform = const LocalPlatform(),
5050
}) : super(packagesDir, processRunner: processRunner, platform: platform) {
51-
argParser.addFlag(kPlatformLinux);
52-
argParser.addFlag(kPlatformMacos);
53-
argParser.addFlag(kPlatformWeb);
54-
argParser.addFlag(kPlatformWindows);
55-
argParser.addFlag(kPlatformWinUwp);
56-
argParser.addFlag(kPlatformIos);
51+
argParser.addFlag(platformLinux);
52+
argParser.addFlag(platformMacOS);
53+
argParser.addFlag(platformWeb);
54+
argParser.addFlag(platformWindows);
55+
argParser.addFlag(platformWinUwp);
56+
argParser.addFlag(platformIOS);
5757
argParser.addFlag(_platformFlagApk);
5858
argParser.addOption(
5959
kEnableExperiment,
@@ -68,39 +68,39 @@ class BuildExamplesCommand extends PackageLoopingCommand {
6868
<String, _PlatformDetails>{
6969
_platformFlagApk: const _PlatformDetails(
7070
'Android',
71-
pluginPlatform: kPlatformAndroid,
71+
pluginPlatform: platformAndroid,
7272
flutterBuildType: _flutterBuildTypeAndroid,
7373
),
74-
kPlatformIos: const _PlatformDetails(
74+
platformIOS: const _PlatformDetails(
7575
'iOS',
76-
pluginPlatform: kPlatformIos,
77-
flutterBuildType: _flutterBuildTypeIos,
76+
pluginPlatform: platformIOS,
77+
flutterBuildType: _flutterBuildTypeIOS,
7878
extraBuildFlags: <String>['--no-codesign'],
7979
),
80-
kPlatformLinux: const _PlatformDetails(
80+
platformLinux: const _PlatformDetails(
8181
'Linux',
82-
pluginPlatform: kPlatformLinux,
82+
pluginPlatform: platformLinux,
8383
flutterBuildType: _flutterBuildTypeLinux,
8484
),
85-
kPlatformMacos: const _PlatformDetails(
85+
platformMacOS: const _PlatformDetails(
8686
'macOS',
87-
pluginPlatform: kPlatformMacos,
87+
pluginPlatform: platformMacOS,
8888
flutterBuildType: _flutterBuildTypeMacOS,
8989
),
90-
kPlatformWeb: const _PlatformDetails(
90+
platformWeb: const _PlatformDetails(
9191
'web',
92-
pluginPlatform: kPlatformWeb,
92+
pluginPlatform: platformWeb,
9393
flutterBuildType: _flutterBuildTypeWeb,
9494
),
95-
kPlatformWindows: const _PlatformDetails(
95+
platformWindows: const _PlatformDetails(
9696
'Win32',
97-
pluginPlatform: kPlatformWindows,
97+
pluginPlatform: platformWindows,
9898
pluginPlatformVariant: platformVariantWin32,
9999
flutterBuildType: _flutterBuildTypeWin32,
100100
),
101-
kPlatformWinUwp: const _PlatformDetails(
101+
platformWinUwp: const _PlatformDetails(
102102
'UWP',
103-
pluginPlatform: kPlatformWindows,
103+
pluginPlatform: platformWindows,
104104
pluginPlatformVariant: platformVariantWinUwp,
105105
flutterBuildType: _flutterBuildTypeWinUwp,
106106
),
@@ -288,7 +288,7 @@ class BuildExamplesCommand extends PackageLoopingCommand {
288288
if (!uwpDirectory.existsSync()) {
289289
print('Creating temporary winuwp folder');
290290
final int exitCode = await processRunner.runAndStream(flutterCommand,
291-
<String>['create', '--platforms=$kPlatformWinUwp', '.'],
291+
<String>['create', '--platforms=$platformWinUwp', '.'],
292292
workingDir: example.directory);
293293
if (exitCode == 0) {
294294
temporaryPlatformDirectory = uwpDirectory;

script/tool/lib/src/common/core.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,40 @@ import 'package:yaml/yaml.dart';
1111
typedef Print = void Function(Object? object);
1212

1313
/// Key for APK (Android) platform.
14-
const String kPlatformAndroid = 'android';
14+
const String platformAndroid = 'android';
1515

1616
/// Key for IPA (iOS) platform.
17-
const String kPlatformIos = 'ios';
17+
const String platformIOS = 'ios';
1818

1919
/// Key for linux platform.
20-
const String kPlatformLinux = 'linux';
20+
const String platformLinux = 'linux';
2121

2222
/// Key for macos platform.
23-
const String kPlatformMacos = 'macos';
23+
const String platformMacOS = 'macos';
2424

2525
/// Key for Web platform.
26-
const String kPlatformWeb = 'web';
26+
const String platformWeb = 'web';
2727

2828
/// Key for windows platform.
2929
///
3030
/// Note that this corresponds to the Win32 variant for flutter commands like
3131
/// `build` and `run`, but is a general platform containing all Windows
3232
/// variants for purposes of the `platform` section of a plugin pubspec).
33-
const String kPlatformWindows = 'windows';
33+
const String platformWindows = 'windows';
3434

3535
/// Key for WinUWP platform.
3636
///
3737
/// Note that UWP is a platform for the purposes of flutter commands like
3838
/// `build` and `run`, but a variant of the `windows` platform for the purposes
3939
/// of plugin pubspecs).
40-
const String kPlatformWinUwp = 'winuwp';
40+
const String platformWinUwp = 'winuwp';
4141

4242
/// Key for Win32 variant of the Windows platform.
4343
const String platformVariantWin32 = 'win32';
4444

4545
/// Key for UWP variant of the Windows platform.
4646
///
47-
/// See the note on [kPlatformWinUwp].
47+
/// See the note on [platformWinUwp].
4848
const String platformVariantWinUwp = 'uwp';
4949

5050
/// Key for enable experiment.

script/tool/lib/src/common/plugin_utils.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ bool pluginSupportsPlatform(
3939
PlatformSupport? requiredMode,
4040
String? variant,
4141
}) {
42-
assert(platform == kPlatformIos ||
43-
platform == kPlatformAndroid ||
44-
platform == kPlatformWeb ||
45-
platform == kPlatformMacos ||
46-
platform == kPlatformWindows ||
47-
platform == kPlatformLinux);
42+
assert(platform == platformIOS ||
43+
platform == platformAndroid ||
44+
platform == platformWeb ||
45+
platform == platformMacOS ||
46+
platform == platformWindows ||
47+
platform == platformLinux);
4848

4949
final YamlMap? platformEntry =
5050
_readPlatformPubspecSectionForPlugin(platform, plugin);
@@ -73,7 +73,7 @@ bool pluginSupportsPlatform(
7373
// Platforms with variants have a default variant when unspecified for
7474
// backward compatibility. Must match the flutter tool logic.
7575
const Map<String, String> defaultVariants = <String, String>{
76-
kPlatformWindows: platformVariantWin32,
76+
platformWindows: platformVariantWin32,
7777
};
7878
if (variant != defaultVariants[platform]) {
7979
return false;
@@ -87,7 +87,7 @@ bool pluginSupportsPlatform(
8787
/// Returns true if [plugin] includes native code for [platform], as opposed to
8888
/// being implemented entirely in Dart.
8989
bool pluginHasNativeCodeForPlatform(String platform, RepositoryPackage plugin) {
90-
if (platform == kPlatformWeb) {
90+
if (platform == platformWeb) {
9191
// Web plugins are always Dart-only.
9292
return false;
9393
}

script/tool/lib/src/drive_examples_command.dart

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ class DriveExamplesCommand extends PackageLoopingCommand {
2525
ProcessRunner processRunner = const ProcessRunner(),
2626
Platform platform = const LocalPlatform(),
2727
}) : super(packagesDir, processRunner: processRunner, platform: platform) {
28-
argParser.addFlag(kPlatformAndroid,
28+
argParser.addFlag(platformAndroid,
2929
help: 'Runs the Android implementation of the examples');
30-
argParser.addFlag(kPlatformIos,
30+
argParser.addFlag(platformIOS,
3131
help: 'Runs the iOS implementation of the examples');
32-
argParser.addFlag(kPlatformLinux,
32+
argParser.addFlag(platformLinux,
3333
help: 'Runs the Linux implementation of the examples');
34-
argParser.addFlag(kPlatformMacos,
34+
argParser.addFlag(platformMacOS,
3535
help: 'Runs the macOS implementation of the examples');
36-
argParser.addFlag(kPlatformWeb,
36+
argParser.addFlag(platformWeb,
3737
help: 'Runs the web implementation of the examples');
38-
argParser.addFlag(kPlatformWindows,
38+
argParser.addFlag(platformWindows,
3939
help: 'Runs the Windows (Win32) implementation of the examples');
40-
argParser.addFlag(kPlatformWinUwp,
40+
argParser.addFlag(platformWinUwp,
4141
help:
4242
'Runs the UWP implementation of the examples [currently a no-op]');
4343
argParser.addOption(
@@ -64,13 +64,13 @@ class DriveExamplesCommand extends PackageLoopingCommand {
6464
@override
6565
Future<void> initializeRun() async {
6666
final List<String> platformSwitches = <String>[
67-
kPlatformAndroid,
68-
kPlatformIos,
69-
kPlatformLinux,
70-
kPlatformMacos,
71-
kPlatformWeb,
72-
kPlatformWindows,
73-
kPlatformWinUwp,
67+
platformAndroid,
68+
platformIOS,
69+
platformLinux,
70+
platformMacOS,
71+
platformWeb,
72+
platformWindows,
73+
platformWinUwp,
7474
];
7575
final int platformCount = platformSwitches
7676
.where((String platform) => getBoolArg(platform))
@@ -85,12 +85,12 @@ class DriveExamplesCommand extends PackageLoopingCommand {
8585
throw ToolExit(_exitNoPlatformFlags);
8686
}
8787

88-
if (getBoolArg(kPlatformWinUwp)) {
88+
if (getBoolArg(platformWinUwp)) {
8989
logWarning('Driving UWP applications is not yet supported');
9090
}
9191

9292
String? androidDevice;
93-
if (getBoolArg(kPlatformAndroid)) {
93+
if (getBoolArg(platformAndroid)) {
9494
final List<String> devices = await _getDevicesForPlatform('android');
9595
if (devices.isEmpty) {
9696
printError('No Android devices available');
@@ -99,37 +99,36 @@ class DriveExamplesCommand extends PackageLoopingCommand {
9999
androidDevice = devices.first;
100100
}
101101

102-
String? iosDevice;
103-
if (getBoolArg(kPlatformIos)) {
102+
String? iOSDevice;
103+
if (getBoolArg(platformIOS)) {
104104
final List<String> devices = await _getDevicesForPlatform('ios');
105105
if (devices.isEmpty) {
106106
printError('No iOS devices available');
107107
throw ToolExit(_exitNoAvailableDevice);
108108
}
109-
iosDevice = devices.first;
109+
iOSDevice = devices.first;
110110
}
111111

112112
_targetDeviceFlags = <String, List<String>>{
113-
if (getBoolArg(kPlatformAndroid))
114-
kPlatformAndroid: <String>['-d', androidDevice!],
115-
if (getBoolArg(kPlatformIos)) kPlatformIos: <String>['-d', iosDevice!],
116-
if (getBoolArg(kPlatformLinux)) kPlatformLinux: <String>['-d', 'linux'],
117-
if (getBoolArg(kPlatformMacos)) kPlatformMacos: <String>['-d', 'macos'],
118-
if (getBoolArg(kPlatformWeb))
119-
kPlatformWeb: <String>[
113+
if (getBoolArg(platformAndroid))
114+
platformAndroid: <String>['-d', androidDevice!],
115+
if (getBoolArg(platformIOS)) platformIOS: <String>['-d', iOSDevice!],
116+
if (getBoolArg(platformLinux)) platformLinux: <String>['-d', 'linux'],
117+
if (getBoolArg(platformMacOS)) platformMacOS: <String>['-d', 'macos'],
118+
if (getBoolArg(platformWeb))
119+
platformWeb: <String>[
120120
'-d',
121121
'web-server',
122122
'--web-port=7357',
123123
'--browser-name=chrome',
124124
if (platform.environment.containsKey('CHROME_EXECUTABLE'))
125125
'--chrome-binary=${platform.environment['CHROME_EXECUTABLE']}',
126126
],
127-
if (getBoolArg(kPlatformWindows))
128-
kPlatformWindows: <String>['-d', 'windows'],
127+
if (getBoolArg(platformWindows))
128+
platformWindows: <String>['-d', 'windows'],
129129
// TODO(stuartmorgan): Check these flags once drive supports UWP:
130130
// https://github.com/flutter/flutter/issues/82821
131-
if (getBoolArg(kPlatformWinUwp))
132-
kPlatformWinUwp: <String>['-d', 'winuwp'],
131+
if (getBoolArg(platformWinUwp)) platformWinUwp: <String>['-d', 'winuwp'],
133132
};
134133
}
135134

@@ -148,9 +147,9 @@ class DriveExamplesCommand extends PackageLoopingCommand {
148147
in _targetDeviceFlags.entries) {
149148
final String platform = entry.key;
150149
String? variant;
151-
if (platform == kPlatformWindows) {
150+
if (platform == platformWindows) {
152151
variant = platformVariantWin32;
153-
} else if (platform == kPlatformWinUwp) {
152+
} else if (platform == platformWinUwp) {
154153
variant = platformVariantWinUwp;
155154
// TODO(stuartmorgan): Remove this once drive supports UWP.
156155
// https://github.com/flutter/flutter/issues/82821

script/tool/lib/src/lint_android_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class LintAndroidCommand extends PackageLoopingCommand {
3232

3333
@override
3434
Future<PackageResult> runForPackage(RepositoryPackage package) async {
35-
if (!pluginSupportsPlatform(kPlatformAndroid, package,
35+
if (!pluginSupportsPlatform(platformAndroid, package,
3636
requiredMode: PlatformSupport.inline)) {
3737
return PackageResult.skip(
3838
'Plugin does not have an Android implemenatation.');

0 commit comments

Comments
 (0)