Skip to content

Commit

Permalink
[flutter_plugin_tools] Remove UWP (flutter#5432)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan committed Apr 28, 2022
1 parent 4cecb9b commit 6770bf9
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 320 deletions.
1 change: 1 addition & 0 deletions script/tool/CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
- `license-check` now ignores submodules.
- Allows `make-deps-path-based` to skip packages it has alredy rewritten, so
that running multiple times won't fail after the first time.
- Removes UWP support, since Flutter has dropped support for UWP.

## 0.8.2+1

Expand Down
48 changes: 5 additions & 43 deletions script/tool/lib/src/build_examples_command.dart
Expand Up @@ -37,8 +37,7 @@ const String _flutterBuildTypeIOS = 'ios';
const String _flutterBuildTypeLinux = 'linux';
const String _flutterBuildTypeMacOS = 'macos';
const String _flutterBuildTypeWeb = 'web';
const String _flutterBuildTypeWin32 = 'windows';
const String _flutterBuildTypeWinUwp = 'winuwp';
const String _flutterBuildTypeWindows = 'windows';

/// A command to build the example applications for packages.
class BuildExamplesCommand extends PackageLoopingCommand {
Expand All @@ -52,7 +51,6 @@ class BuildExamplesCommand extends PackageLoopingCommand {
argParser.addFlag(platformMacOS);
argParser.addFlag(platformWeb);
argParser.addFlag(platformWindows);
argParser.addFlag(platformWinUwp);
argParser.addFlag(platformIOS);
argParser.addFlag(_platformFlagApk);
argParser.addOption(
Expand Down Expand Up @@ -93,16 +91,9 @@ class BuildExamplesCommand extends PackageLoopingCommand {
flutterBuildType: _flutterBuildTypeWeb,
),
platformWindows: const _PlatformDetails(
'Win32',
'Windows',
pluginPlatform: platformWindows,
pluginPlatformVariant: platformVariantWin32,
flutterBuildType: _flutterBuildTypeWin32,
),
platformWinUwp: const _PlatformDetails(
'UWP',
pluginPlatform: platformWindows,
pluginPlatformVariant: platformVariantWinUwp,
flutterBuildType: _flutterBuildTypeWinUwp,
flutterBuildType: _flutterBuildTypeWindows,
),
};

Expand Down Expand Up @@ -146,9 +137,8 @@ class BuildExamplesCommand extends PackageLoopingCommand {
// no package-level platform information for non-plugin packages.
final Set<_PlatformDetails> buildPlatforms = isPlugin
? requestedPlatforms
.where((_PlatformDetails platform) => pluginSupportsPlatform(
platform.pluginPlatform, package,
variant: platform.pluginPlatformVariant))
.where((_PlatformDetails platform) =>
pluginSupportsPlatform(platform.pluginPlatform, package))
.toSet()
: requestedPlatforms.toSet();

Expand Down Expand Up @@ -280,22 +270,6 @@ class BuildExamplesCommand extends PackageLoopingCommand {
}) async {
final String enableExperiment = getStringArg(kEnableExperiment);

// The UWP template is not yet stable, so the UWP directory
// needs to be created on the fly with 'flutter create .'
Directory? temporaryPlatformDirectory;
if (flutterBuildType == _flutterBuildTypeWinUwp) {
final Directory uwpDirectory = example.directory.childDirectory('winuwp');
if (!uwpDirectory.existsSync()) {
print('Creating temporary winuwp folder');
final int exitCode = await processRunner.runAndStream(flutterCommand,
<String>['create', '--platforms=$platformWinUwp', '.'],
workingDir: example.directory);
if (exitCode == 0) {
temporaryPlatformDirectory = uwpDirectory;
}
}
}

final int exitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
Expand All @@ -308,13 +282,6 @@ class BuildExamplesCommand extends PackageLoopingCommand {
],
workingDir: example.directory,
);

if (temporaryPlatformDirectory != null &&
temporaryPlatformDirectory.existsSync()) {
print('Cleaning up ${temporaryPlatformDirectory.path}');
temporaryPlatformDirectory.deleteSync(recursive: true);
}

return exitCode == 0;
}
}
Expand All @@ -324,7 +291,6 @@ class _PlatformDetails {
const _PlatformDetails(
this.label, {
required this.pluginPlatform,
this.pluginPlatformVariant,
required this.flutterBuildType,
this.extraBuildFlags = const <String>[],
});
Expand All @@ -335,10 +301,6 @@ class _PlatformDetails {
/// The key in a pubspec's platform: entry.
final String pluginPlatform;

/// The supportedVariants key under a plugin's [pluginPlatform] entry, if
/// applicable.
final String? pluginPlatformVariant;

/// The `flutter build` build type.
final String flutterBuildType;

Expand Down
19 changes: 0 additions & 19 deletions script/tool/lib/src/common/core.dart
Expand Up @@ -26,27 +26,8 @@ const String platformMacOS = 'macos';
const String platformWeb = 'web';

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

/// Key for WinUWP platform.
///
/// Note that UWP is a platform for the purposes of flutter commands like
/// `build` and `run`, but a variant of the `windows` platform for the purposes
/// of plugin pubspecs).
const String platformWinUwp = 'winuwp';

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

/// Key for UWP variant of the Windows platform.
///
/// See the note on [platformWinUwp].
const String platformVariantWinUwp = 'uwp';

/// Key for enable experiment.
const String kEnableExperiment = 'enable-experiment';

Expand Down
21 changes: 0 additions & 21 deletions script/tool/lib/src/common/plugin_utils.dart
Expand Up @@ -37,7 +37,6 @@ bool pluginSupportsPlatform(
String platform,
RepositoryPackage plugin, {
PlatformSupport? requiredMode,
String? variant,
}) {
assert(platform == platformIOS ||
platform == platformAndroid ||
Expand All @@ -61,26 +60,6 @@ bool pluginSupportsPlatform(
}
}

// If a variant is specified, check for that variant.
if (variant != null) {
const String variantsKey = 'supportedVariants';
if (platformEntry.containsKey(variantsKey)) {
if (!(platformEntry['supportedVariants']! as YamlList)
.contains(variant)) {
return false;
}
} else {
// Platforms with variants have a default variant when unspecified for
// backward compatibility. Must match the flutter tool logic.
const Map<String, String> defaultVariants = <String, String>{
platformWindows: platformVariantWin32,
};
if (variant != defaultVariants[platform]) {
return false;
}
}
}

return true;
}

Expand Down
24 changes: 2 additions & 22 deletions script/tool/lib/src/drive_examples_command.dart
Expand Up @@ -36,10 +36,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
argParser.addFlag(platformWeb,
help: 'Runs the web implementation of the examples');
argParser.addFlag(platformWindows,
help: 'Runs the Windows (Win32) implementation of the examples');
argParser.addFlag(platformWinUwp,
help:
'Runs the UWP implementation of the examples [currently a no-op]');
help: 'Runs the Windows implementation of the examples');
argParser.addOption(
kEnableExperiment,
defaultsTo: '',
Expand Down Expand Up @@ -70,7 +67,6 @@ class DriveExamplesCommand extends PackageLoopingCommand {
platformMacOS,
platformWeb,
platformWindows,
platformWinUwp,
];
final int platformCount = platformSwitches
.where((String platform) => getBoolArg(platform))
Expand All @@ -85,10 +81,6 @@ class DriveExamplesCommand extends PackageLoopingCommand {
throw ToolExit(_exitNoPlatformFlags);
}

if (getBoolArg(platformWinUwp)) {
logWarning('Driving UWP applications is not yet supported');
}

String? androidDevice;
if (getBoolArg(platformAndroid)) {
final List<String> devices = await _getDevicesForPlatform('android');
Expand Down Expand Up @@ -126,9 +118,6 @@ class DriveExamplesCommand extends PackageLoopingCommand {
],
if (getBoolArg(platformWindows))
platformWindows: <String>['-d', 'windows'],
// TODO(stuartmorgan): Check these flags once drive supports UWP:
// https://github.com/flutter/flutter/issues/82821
if (getBoolArg(platformWinUwp)) platformWinUwp: <String>['-d', 'winuwp'],
};
}

Expand All @@ -146,16 +135,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
for (final MapEntry<String, List<String>> entry
in _targetDeviceFlags.entries) {
final String platform = entry.key;
String? variant;
if (platform == platformWindows) {
variant = platformVariantWin32;
} else if (platform == platformWinUwp) {
variant = platformVariantWinUwp;
// TODO(stuartmorgan): Remove this once drive supports UWP.
// https://github.com/flutter/flutter/issues/82821
return PackageResult.skip('Drive does not yet support UWP');
}
if (pluginSupportsPlatform(platform, package, variant: variant)) {
if (pluginSupportsPlatform(platform, package)) {
deviceFlags.addAll(entry.value);
} else {
print('Skipping unsupported platform ${entry.key}...');
Expand Down
90 changes: 4 additions & 86 deletions script/tool/test/build_examples_command_test.dart
Expand Up @@ -313,7 +313,7 @@ void main() {
});

test(
'building for win32 when plugin is not set up for Windows results in no-op',
'building for Windows when plugin is not set up for Windows results in no-op',
() async {
mockPlatform.isWindows = true;
createFakePlugin('plugin', packagesDir);
Expand All @@ -325,7 +325,7 @@ void main() {
output,
containsAllInOrder(<Matcher>[
contains('Running for plugin'),
contains('Win32 is not supported by this plugin'),
contains('Windows is not supported by this plugin'),
]),
);

Expand All @@ -334,7 +334,7 @@ void main() {
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

test('building for win32', () async {
test('building for Windows', () async {
mockPlatform.isWindows = true;
final Directory pluginDirectory = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
Expand All @@ -350,7 +350,7 @@ void main() {
expect(
output,
containsAllInOrder(<String>[
'\nBUILDING plugin/example for Win32 (windows)',
'\nBUILDING plugin/example for Windows',
]),
);

Expand All @@ -364,88 +364,6 @@ void main() {
]));
});

test('building for UWP when plugin does not support UWP is a no-op',
() async {
createFakePlugin('plugin', packagesDir);

final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--winuwp']);

expect(
output,
containsAllInOrder(<Matcher>[
contains('Running for plugin'),
contains('UWP is not supported by this plugin'),
]),
);

// Output should be empty since running build-examples --macos with no macos
// implementation is a no-op.
expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

test('building for UWP', () async {
final Directory pluginDirectory =
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
'example/test',
], platformSupport: <String, PlatformDetails>{
platformWindows: const PlatformDetails(PlatformSupport.federated,
variants: <String>[platformVariantWinUwp]),
});

final Directory pluginExampleDirectory =
pluginDirectory.childDirectory('example');

final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--winuwp']);

expect(
output,
containsAllInOrder(<Matcher>[
contains('BUILDING plugin/example for UWP (winuwp)'),
]),
);

expect(
processRunner.recordedCalls,
containsAll(<ProcessCall>[
ProcessCall(getFlutterCommand(mockPlatform),
const <String>['build', 'winuwp'], pluginExampleDirectory.path),
]));
});

test('building for UWP creates a folder if necessary', () async {
final Directory pluginDirectory =
createFakePlugin('plugin', packagesDir, extraFiles: <String>[
'example/test',
], platformSupport: <String, PlatformDetails>{
platformWindows: const PlatformDetails(PlatformSupport.federated,
variants: <String>[platformVariantWinUwp]),
});

final Directory pluginExampleDirectory =
pluginDirectory.childDirectory('example');

final List<String> output = await runCapturingPrint(
runner, <String>['build-examples', '--winuwp']);

expect(
output,
contains('Creating temporary winuwp folder'),
);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
getFlutterCommand(mockPlatform),
const <String>['create', '--platforms=winuwp', '.'],
pluginExampleDirectory.path),
ProcessCall(getFlutterCommand(mockPlatform),
const <String>['build', 'winuwp'], pluginExampleDirectory.path),
]));
});

test(
'building for Android when plugin is not set up for Android results in no-op',
() async {
Expand Down

0 comments on commit 6770bf9

Please sign in to comment.