Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
/pluginsPublic archive

[flutter_plugin_tool] Add support for building UWP plugins#4047

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
507f06d
Add UWP support to build-example
stuartmorgan-gMay 17, 2021
aca220d
Fix create order
stuartmorgan-gMay 17, 2021
5a93a36
Add the ability to check for the new supportedVariants
stuartmorgan-gJun 11, 2021
903c642
Gate the build support on platform variant
stuartmorgan-gJun 11, 2021
27ec174
Clean up createFakePlugin API
stuartmorgan-gJun 11, 2021
c414de1
More API cleanup
stuartmorgan-gJun 11, 2021
e50ac6c
More cleanup from API changes
stuartmorgan-gJun 11, 2021
dfc85ef
CHANGELOG
stuartmorgan-gJun 11, 2021
7422daa
Merge branch 'master' into uwp-build-example
stuartmorgan-gJun 12, 2021
2bc437d
Merge branch 'master' into uwp-build-example
stuartmorgan-gJun 17, 2021
e9966ca
Merge branch 'master' into uwp-build-example
stuartmorgan-gJun 21, 2021
04d5917
Merge branch 'master' into uwp-build-example
stuartmorgan-gJun 22, 2021
139004b
Merge branch 'master' into uwp-build-example
stuartmorgan-gJul 15, 2021
06c5c85
Fix analyze warnings from merge mistake
stuartmorgan-gJul 15, 2021
4ce6158
Merge branch 'master' into uwp-build-example
stuartmorgan-gJul 26, 2021
0fd7eb3
Add no-op UWP support to drive
stuartmorgan-gAug 2, 2021
ca8b344
Merge branch 'master' into uwp-build-example
stuartmorgan-gAug 18, 2021
49caa9b
Post-merge build fixes
stuartmorgan-gAug 18, 2021
258781b
Merge branch 'master' into uwp-build-example
stuartmorgan-gAug 26, 2021
d715988
Review feedback
stuartmorgan-gAug 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsscript/tool/CHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
- Added a new `android-lint` command to lint Android plugin native code.
- Pubspec validation now checks for `implements` in implementation packages.
- Pubspec valitation now checks the full relative path of `repository` entries.
- `build-examples` now supports UWP plugins via a `--winuwp` flag.

## 0.5.0

Expand Down
64 changes: 55 additions & 9 deletionsscript/tool/lib/src/build_examples_command.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,16 @@ import 'common/repository_package.dart';
/// Key for APK.
const String _platformFlagApk = 'apk';

const int _exitNoPlatformFlags = 2;
const int _exitNoPlatformFlags = 3;

// Flutter build types. These are the values passed to `flutter build <foo>`.
const String _flutterBuildTypeAndroid = 'apk';
const String _flutterBuildTypeIos = 'ios';
const String _flutterBuildTypeLinux = 'linux';
const String _flutterBuildTypeMacOS = 'macos';
const String _flutterBuildTypeWeb = 'web';
const String _flutterBuildTypeWin32 = 'windows';
const String _flutterBuildTypeWinUwp = 'winuwp';

/// A command to build the example applications for packages.
class BuildExamplesCommand extends PackageLoopingCommand {
Expand All@@ -30,6 +39,7 @@ class BuildExamplesCommand extends PackageLoopingCommand {
argParser.addFlag(kPlatformMacos);
argParser.addFlag(kPlatformWeb);
argParser.addFlag(kPlatformWindows);
argParser.addFlag(kPlatformWinUwp);
argParser.addFlag(kPlatformIos);
argParser.addFlag(_platformFlagApk);
argParser.addOption(
Expand All@@ -46,33 +56,40 @@ class BuildExamplesCommand extends PackageLoopingCommand {
_platformFlagApk: const _PlatformDetails(
'Android',
pluginPlatform: kPlatformAndroid,
flutterBuildType:'apk',
flutterBuildType:_flutterBuildTypeAndroid,
),
kPlatformIos: const _PlatformDetails(
'iOS',
pluginPlatform: kPlatformIos,
flutterBuildType:'ios',
flutterBuildType:_flutterBuildTypeIos,
extraBuildFlags: <String>['--no-codesign'],
),
kPlatformLinux: const _PlatformDetails(
'Linux',
pluginPlatform: kPlatformLinux,
flutterBuildType:'linux',
flutterBuildType:_flutterBuildTypeLinux,
),
kPlatformMacos: const _PlatformDetails(
'macOS',
pluginPlatform: kPlatformMacos,
flutterBuildType:'macos',
flutterBuildType:_flutterBuildTypeMacOS,
),
kPlatformWeb: const _PlatformDetails(
'web',
pluginPlatform: kPlatformWeb,
flutterBuildType:'web',
flutterBuildType:_flutterBuildTypeWeb,
),
kPlatformWindows: const _PlatformDetails(
'Windows',
'Win32',
pluginPlatform: kPlatformWindows,
pluginPlatformVariant: platformVariantWin32,
flutterBuildType: _flutterBuildTypeWin32,
),
kPlatformWinUwp: const _PlatformDetails(
'UWP',
pluginPlatform: kPlatformWindows,
flutterBuildType: 'windows',
pluginPlatformVariant: platformVariantWinUwp,
flutterBuildType: _flutterBuildTypeWinUwp,
),
};

Expand DownExpand Up@@ -107,7 +124,8 @@ class BuildExamplesCommand extends PackageLoopingCommand {
final Set<_PlatformDetails> buildPlatforms = <_PlatformDetails>{};
final Set<_PlatformDetails> unsupportedPlatforms = <_PlatformDetails>{};
for (final _PlatformDetails platform in requestedPlatforms) {
if (pluginSupportsPlatform(platform.pluginPlatform, package)) {
if (pluginSupportsPlatform(platform.pluginPlatform, package,
variant: platform.pluginPlatformVariant)) {
buildPlatforms.add(platform);
} else {
unsupportedPlatforms.add(platform);
Expand DownExpand Up@@ -156,6 +174,22 @@ 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=$kPlatformWinUwp', '.'],
workingDir: example.directory);
if (exitCode == 0) {
temporaryPlatformDirectory = uwpDirectory;
}
}
}

final int exitCode = await processRunner.runAndStream(
flutterCommand,
<String>[
Expand All@@ -167,6 +201,13 @@ 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@@ -176,6 +217,7 @@ class _PlatformDetails {
const _PlatformDetails(
this.label, {
required this.pluginPlatform,
this.pluginPlatformVariant,
required this.flutterBuildType,
this.extraBuildFlags = const <String>[],
});
Expand All@@ -186,6 +228,10 @@ 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
37 changes: 28 additions & 9 deletionsscript/tool/lib/src/common/core.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,24 +10,43 @@ import 'package:yaml/yaml.dart';
/// print destination.
typedef Print = void Function(Object? object);

/// Key forwindows platform.
const StringkPlatformWindows = 'windows';
/// Key forAPK (Android) platform.
const StringkPlatformAndroid = 'android';

/// Key formacos platform.
const StringkPlatformMacos = 'macos';
/// Key forIPA (iOS) platform.
const StringkPlatformIos = 'ios';

/// Key for linux platform.
const String kPlatformLinux = 'linux';

/// Key for IPA (iOS) platform.
const String kPlatformIos = 'ios';

/// Key for APK (Android) platform.
const String kPlatformAndroid = 'android';
/// Key for macos platform.
const String kPlatformMacos = 'macos';

/// Key for Web platform.
const String kPlatformWeb = '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 kPlatformWindows = '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 kPlatformWinUwp = '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 [kPlatformWinUwp].
const String platformVariantWinUwp = 'uwp';

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

Expand Down
39 changes: 34 additions & 5 deletionsscript/tool/lib/src/common/plugin_utils.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,8 +28,12 @@ enum PlatformSupport {
///
/// If [requiredMode] is provided, the plugin must have the given type of
/// implementation in order to return true.
bool pluginSupportsPlatform(String platform, RepositoryPackage package,
{PlatformSupport? requiredMode}) {
bool pluginSupportsPlatform(
String platform,
RepositoryPackage package, {
PlatformSupport? requiredMode,
String? variant,
}) {
assert(platform == kPlatformIos ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should this be updated to includekPlatformWinUwp or is that always passed askPlatformWindows with the uwp variant?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The latter; from the standpoint of a plugin, UWP isn't a platform.

(But see my other comment; I think I could avoid this kind of confusion with a generic platform class.)

cbracken reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Agreed; the backward compatibility makes this a bit of a pain. As you say, modelling this with classes might result in better readability than with logic in various bits of the tool. Agree that approach is worth exploring.

platform == kPlatformAndroid ||
platform == kPlatformWeb ||
Expand DownExpand Up@@ -65,9 +69,34 @@ bool pluginSupportsPlatform(String platform, RepositoryPackage package,
}
// If the platform entry is present, then it supports the platform. Check
// for required mode if specified.
final bool federated = platformEntry.containsKey('default_package');
return requiredMode == null ||
federated == (requiredMode == PlatformSupport.federated);
if (requiredMode != null) {
final bool federated = platformEntry.containsKey('default_package');
if (federated != (requiredMode == PlatformSupport.federated)) {
return false;
}
}

// 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>{
kPlatformWindows: platformVariantWin32,
};
if (variant != defaultVariants[platform]) {
return false;
}
}
}

return true;
} on FileSystemException {
return false;
} on YamlException {
Expand Down
26 changes: 24 additions & 2 deletionsscript/tool/lib/src/drive_examples_command.dart
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
argParser.addFlag(kPlatformWeb,
help: 'Runs the web implementation of the examples');
argParser.addFlag(kPlatformWindows,
help: 'Runs the Windows implementation of the examples');
help: 'Runs the Windows (Win32) implementation of the examples');
argParser.addFlag(kPlatformWinUwp,
help:
'Runs the UWP implementation of the examples [currently a no-op]');
argParser.addOption(
kEnableExperiment,
defaultsTo: '',
Expand DownExpand Up@@ -67,6 +70,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
kPlatformMacos,
kPlatformWeb,
kPlatformWindows,
kPlatformWinUwp,
];
final int platformCount = platformSwitches
.where((String platform) => getBoolArg(platform))
Expand All@@ -81,6 +85,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
throw ToolExit(_exitNoPlatformFlags);
}

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

String? androidDevice;
if (getBoolArg(kPlatformAndroid)) {
final List<String> devices = await _getDevicesForPlatform('android');
Expand DownExpand Up@@ -116,6 +124,10 @@ class DriveExamplesCommand extends PackageLoopingCommand {
],
if (getBoolArg(kPlatformWindows))
kPlatformWindows: <String>['-d', 'windows'],
// TODO(stuartmorgan): Check these flags once drive supports UWP:
// https://github.com/flutter/flutter/issues/82821
if (getBoolArg(kPlatformWinUwp))
kPlatformWinUwp: <String>['-d', 'winuwp'],
};
}

Expand All@@ -132,7 +144,17 @@ class DriveExamplesCommand extends PackageLoopingCommand {
final List<String> deviceFlags = <String>[];
for (final MapEntry<String, List<String>> entry
in _targetDeviceFlags.entries) {
if (pluginSupportsPlatform(entry.key, package)) {
final String platform = entry.key;
String? variant;
if (platform == kPlatformWindows) {
variant = platformVariantWin32;
} else if (platform == kPlatformWinUwp) {
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)) {
deviceFlags.addAll(entry.value);
} else {
print('Skipping unsupported platform ${entry.key}...');
Expand Down
Loading

[8]ページ先頭

©2009-2026 Movatter.jp