-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add dartPluginClass support for Android and iOS #87991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dartPluginClass support for Android and iOS #87991
Conversation
| targetPlatform != TargetPlatform.linux_arm64 && | ||
| targetPlatform != TargetPlatform.windows_x64 && | ||
| targetPlatform != TargetPlatform.windows_uwp_x64; | ||
| final TargetPlatform? targetPlatform = platformName == null ? null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what about:
if (platformName == null) {
return false;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what was there before, and has the effect that if a platform isn't passed it silently does nothing. I'd rather we only opt out for platforms we're sure we don't want to do this, since as a failure mode, failing to do registration silently is much worse that generating a registrant that shouldn't do anything.
packages/flutter_tools/test/general.shard/build_system/targets/dart_plugin_registrant_test.dart
Show resolved
Hide resolved
packages/flutter_tools/test/general.shard/dart_plugin_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/test/general.shard/dart_plugin_test.dart
Outdated
Show resolved
Hide resolved
| final bool hasInlineDartImplementation = | ||
| plugin.pluginDartClassPlatforms[platform] != null; | ||
| if (defaultImplementation == null && !hasInlineDartImplementation) { | ||
| if (throwOnPluginPubspecError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi: throwOnPluginPubspecError is false due to backward compatibilities.
flutter/packages/flutter_tools/lib/src/build_system/targets/dart_plugin_registrant.dart
Line 58 in 4c6a9dc
| throwOnPluginPubspecError: false, |
Should it still print the error, but not exit with code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the goal is to eliminate this error in a follow-up PR, I think we can leave it as-is for now.
blasten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good. Just some minor comments
|
@blasten How is this intended to interact with If I delete I'm not sure how to correctly wire this up so that we're calling all of the relevant |
|
That is definitely problematic. We would detect if a test target is currently used, and set
|
|
Maybe, it can be safely inferred from the target file? If not, we would need to pass that information to the build system. |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
With #90288 landed, it looks like the test issues are all resolved. Just waiting on |
This reverts commit 23cea26.
generateDartPluginRegistry was being set to true unconditionally in ResidentRunner, bypassing the primary check in DartPluginRegistrantTarget, and the targetPlatform was not set in that codepath, bypassing the second after the changes in flutter#87991. This caused web hot restarts to be slower due to doing unnecessary work. This ensures that generateDartPluginRegistry is false in the ResidentWebRunner to skip that unnecessary step. Fixes flutter#91262
* Don't generate plugin registry in ResidentWebRunner generateDartPluginRegistry was being set to true unconditionally in ResidentRunner, bypassing the primary check in DartPluginRegistrantTarget, and the targetPlatform was not set in that codepath, bypassing the second after the changes in #87991. This caused web hot restarts to be slower due to doing unnecessary work. This ensures that generateDartPluginRegistry is false in the ResidentWebRunner to skip that unnecessary step. Fixes #91262 * Formatting Co-authored-by: Zachary Anderson <[email protected]> Co-authored-by: Zachary Anderson <[email protected]>
* Don't generate plugin registry in ResidentWebRunner generateDartPluginRegistry was being set to true unconditionally in ResidentRunner, bypassing the primary check in DartPluginRegistrantTarget, and the targetPlatform was not set in that codepath, bypassing the second after the changes in flutter#87991. This caused web hot restarts to be slower due to doing unnecessary work. This ensures that generateDartPluginRegistry is false in the ResidentWebRunner to skip that unnecessary step. Fixes flutter#91262 * Formatting Co-authored-by: Zachary Anderson <[email protected]> Co-authored-by: Zachary Anderson <[email protected]>
These changes allow to override existing native endorsed (federated & inline) plugins with e.g. non-endorsed plugin implementations via direct dependencies as described in the section *Platform implementation selection* in the [design doc](https://docs.google.com/document/d/1LD7QjmzJZLCopUrFAAE98wOUQpjmguyGTN2wd_89Srs). ```yaml # pubspec.yaml name: example dependencies: my_plugin: ^0.0.1 my_plugin_android_alternative: ^0.0.1 ``` Closes #80374, closes #59657 Related: Override Dart plugins (#87991, #79669)
Expands the existing desktop
dartPluginClasssupport, with automatic Dart registration, to Android and iOS.Since we do not have existing
dartPluginClassimplementations on mobile, this addresses from the outset the issue described in #87862, so that inline implementations mobile implementations will work as well. This does not attempt to change that behavior for desktop, since that has breaking implications, so will be handled separately.Fixes #52267
Pre-launch Checklist
///).