-
Notifications
You must be signed in to change notification settings - Fork 3k
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 Linux support to Pigeon #5100
Conversation
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.
Nice! Thanks for tackling this :)
b891227
to
8378c7d
Compare
Is this blocked on anything now that custom codec support has landed, or just waiting for you to have time to get back to it? |
Just blocked on getting back to it after the GTK4 work. |
13aeabc
to
b7cdd5f
Compare
b7cdd5f
to
4fb2014
Compare
@stuartmorgan I think this PR is now close enough to be ready to land. I think I've included what was previously discussed, but this is probably worth doing a full review as it might have changed since last time. There's one feature I know that isn't there, which is nullable values, might be worth doing in a follow up PR. |
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.
Overall this looks good (with the usual caveats about my poor gobject-fu). I mostly just skimmed the generator code; @tarrinneal should review that for structure.
The main thing we'll need in order to land this is wiring up Linux in platform_tests/test_plugin/
and the test suites in tool
so that we're running integration tests and have confidence that everything is working end to end. Let me know if you'd like me to do that part.
I'll also try this out on url_launcher_linux
and see how it works for me in practice, since we often find things that we missed in review once we actually use the generators.
packages/pigeon/example/README.md
Outdated
return; | ||
} | ||
|
||
g_printerr("Got result from Flutter method: %s\n", return_value); |
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.
This is inconsistent with the other examples, but also seems more useful. @tarrinneal what do you think about changing the other examples to show a simple example like this of handling success and failure, instead of just being straight passthroughs that don't do anything with the result?
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.
Seems like a very reasonable idea
@@ -11,6 +11,9 @@ import 'package:pigeon/pigeon.dart'; | |||
cppOptions: CppOptions(namespace: 'pigeon_example'), | |||
cppHeaderOut: 'windows/runner/messages.g.h', | |||
cppSourceOut: 'windows/runner/messages.g.cpp', | |||
linuxHeaderOut: 'linux/messages.g.h', | |||
linuxSourceOut: 'linux/messages.g.cc', | |||
linuxOptions: LinuxOptions(), |
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.
Seems like module may be doing that work. It is prepended to all class names.
I haven't had time to do a full review (hopefully today), but given that you've eliminated all of the integration test (I'll also try using this on our native Linux plugins ASAP. Those aren't especially complex plugins so they probably won't find anything that the tests didn't, but it'll be another data point.) |
@stuartmorgan another review please! Hopefully all issues are resolved. |
Sorry, I'd been trying to find some time to update my url_launcher_linux rework prototype again, since using the generator often lets me find issues I would miss in review (like the lifetime thing from the last round). Now I'm running into issues with unit tests. It looks like the response objects generated by pigeon are totally opaque, which means we can't write unit tests directly against the handlers that we use to populate the vtable. Doing that is the pattern we use in most of our plugin tests in other languages, because it means we can do integration-y tests of just the native part, without leaving out any code that's not Pigeon-generated. Can we put some accessors for the value and error of the response in the generated header? |
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.
Other than needing the query methods for host API responses, this looks great! I've both reviewed it and successfully used it for url_launcher_linux
locally, and don't have any other feedback at this point.
Thank you so much for tackling this! It's awesome that we're going to have complete 1P platform coverage for Pigeon now.
|
||
indent.newln(); | ||
indent.writeln('/**'); | ||
indent.writeln(' * ${responseMethodPrefix}_is_error:'); |
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.
It looks like we just need to have these five methods for Host API response classes too.
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.
The Changelog was merged improperly, but everything is fine besides that. I can do the doc comment stuff later (since it only effects code maintenance). Thanks again, a ton, for putting in all this time and effort to this project! (and I hope I can reach out for help on occasion when I'm working on this in the future :)
packages/pigeon/CHANGELOG.md
Outdated
## 20.1.0 | ||
|
||
* [java] Adds `equals` and `hashCode` support for data classes. | ||
* [swift] Fully-qualifies types in Equatable extension test. | ||
* Adds GObject (Linux) support. |
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.
The 20.1.0 and Adds GObject lines should be their own entry, not merged with the previous
indent.writeln('/**'); | ||
indent.writeln(' * ${methodPrefix}_new:'); | ||
for (final NamedType field in classDefinition.fields) { | ||
final String fieldName = _getFieldName(field.name); | ||
indent.writeln(' * $fieldName: field in this object.'); | ||
if (_isNumericListType(field.type)) { | ||
indent.writeln(' * ${fieldName}_length: length of @$fieldName.'); | ||
} | ||
} | ||
indent.writeln(' *'); | ||
indent.writeln(' * Creates a new #${classDefinition.name} object.'); | ||
indent.writeln(' *'); | ||
indent.writeln(' * Returns: a new #$className'); | ||
indent.writeln(' */'); | ||
indent.writeln( | ||
"$className* ${methodPrefix}_new(${constructorArgs.join(', ')});"); | ||
|
||
for (final NamedType field in classDefinition.fields) { | ||
final String fieldName = _getFieldName(field.name); | ||
final String returnType = _getType(module, field.type); | ||
|
||
indent.newln(); | ||
indent.writeln('/**'); | ||
indent.writeln(' * ${methodPrefix}_get_$fieldName'); | ||
indent.writeln(' * @object: a #$className.'); | ||
if (_isNumericListType(field.type)) { | ||
indent | ||
.writeln(' * @length: location to write the length of this value.'); | ||
} | ||
indent.writeln(' *'); | ||
if (field.documentationComments.isNotEmpty) { | ||
addDocumentationComments( |
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.
Can these documentation comments be added using the addDocumentationComments
method? If there's a reason not to, it's ok as is.
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.
This comment applies to any manually added documentation comments.
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.
I can also do it later myself if you don't want to deal with it :)
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.
I pushed a change to adopt addDocumentationComment
everywhere; do you want to give it a quick review? (I validated that the output is identical to before, so just the code structure).
Per offline discussion, we're going to go ahead and land without that since adding them later won't affect any existing code, and we have a short-term work-around. I filed flutter/flutter#152166 to track adding it. I'll do the final tiny cleanup on this PR, and then land it! 🎉 |
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.
another check mark for this
flutter/packages@1c319ac...19daf6f 2024-07-25 [email protected] Modernize the rest of the `index.html` files to support WASM compilation (flutter/packages#7192) 2024-07-25 [email protected] Add Linux support to Pigeon (flutter/packages#5100) 2024-07-24 [email protected] [gis_web] Allow package:web 1.0.0 (flutter/packages#7203) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@1c319ac...19daf6f 2024-07-25 [email protected] Modernize the rest of the `index.html` files to support WASM compilation (flutter/packages#7192) 2024-07-25 [email protected] Add Linux support to Pigeon (flutter/packages#5100) 2024-07-24 [email protected] [gis_web] Allow package:web 1.0.0 (flutter/packages#7203) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@1c319ac...19daf6f 2024-07-25 [email protected] Modernize the rest of the `index.html` files to support WASM compilation (flutter/packages#7192) 2024-07-25 [email protected] Add Linux support to Pigeon (flutter/packages#5100) 2024-07-24 [email protected] [gis_web] Allow package:web 1.0.0 (flutter/packages#7203) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Add Linux support for Pigeon. This has minimal work porting the generator and some manually written generated code so we can review this before implementing the generator support.
flutter/flutter#73740