-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Initial import of GLFW Linux shell from FDE #8159
Initial import of GLFW Linux shell from FDE #8159
Conversation
Changes include: - File structure - Header guards - Include paths - Namespaces - Integration with the engine's GN build Doesn't yet build due to use of jsoncpp.
RapidJSON is already in use in the engine, so rather than introduce a second JSON library, converts all JSON handling to rapidjson. More error-handling is needed in the text code, but since there's a pending restructuring of that code full error handling is left for a follow-up.
I expect that landing this will be blocked on adding a script to |
Exciting. |
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.
Publishing comments about BUILD system and source code organization while I do a pass over the source.
shell/platform/cpp/BUILD.gn
Outdated
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("$flutter_root/common/config.gni") |
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 convention followed is //flutter/shell/platform/<name_of_platform>
. Since cpp
is not a platform, this location does not make sense. Please move this to platform/linux
. If this is going to be a thing on Windows too, platform/glfw
with its own subdirectory for linux and Windows specific files (if any).
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.
Moved the code into a combination of flutter/glfw
and flutter/common/cpp
per discussion.
shell/platform/cpp/BUILD.gn
Outdated
source_set("common_cpp_library_headers") { | ||
public = _public_headers | ||
|
||
defines = _common_defines |
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.
Please use gn configs for this purpose (see gn help config
).
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.
Done.
shell/platform/cpp/BUILD.gn
Outdated
} | ||
|
||
source_set("common_cpp") { | ||
public = [ |
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.
Ditto about the use of configs. Use a public
and private
config and targets can selectively import. For the SDK export, you can use a variable that both that copy target and the configs reference.
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.
Per offline discussion, I'm not clear on what to change here, and the decisions was to revisit this in a follow-up.
common/config.gni
Outdated
@@ -16,6 +16,9 @@ declare_args() { | |||
|
|||
# The runtime mode ("debug", "profile", "release", "dynamic_profile", or "dynamic_release") | |||
flutter_runtime_mode = "debug" | |||
|
|||
# Whether or not to use the GLFW desktop shell implementation. | |||
use_glfw_desktop = is_linux || is_win |
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 variable is not common to all targets. Please move this into a new config.gni file in platform/foo
with its own declare_args block.
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 ended up removing this in the re-org; the reason it was here already (even though turning it off wouldn't work yet) was to help enforce a separation between code that would be used for any C++ implementation and code that's GLFW-specific. With the reorg the file structure does that even more strongly, so the variable isn't needed.
] | ||
} | ||
|
||
copy("_publish_includes") { |
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.
Not sure why the target names have the _
prefix. If you meant to restrict visibility, use visibility = [ ":*" ]
(see gn help visibility
) and get rid of the prefix. That will prevent incorrect use by GN.
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.
Yep, I misread the GN docs and thought the _ applied to targets as well as variables. Fixed.
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 take with minor nits about convention and such.
BasicMessageChannel(BinaryMessenger* messenger, | ||
const std::string& name, | ||
const MessageCodec<T>* codec) | ||
: messenger_(messenger), name_(name), codec_(codec) {} |
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 engine uses the = default
convention.
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 assume you meant this for the next line, since this constructor takes arguments and thus isn't a default constructor.
Done for all default constructors/destructors that weren't already using default
.
~BasicMessageChannel() {} | ||
|
||
// Prevent copying. | ||
BasicMessageChannel(BasicMessageChannel const&) = delete; |
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 suggest adding a macro.h file with these decorations for reuse. Seems like boilerplate that is repeated elsewhere.
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 DISALLOW_COPY-style macro you are describing is no longer allowed by Google style; explicit deletion is the preferred approach. See
https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types
and
https://google.github.io/styleguide/cppguide.html#Preprocessor_Macros
#include <vector> | ||
|
||
#ifdef FLUTTER_DESKTOP_LIBRARY | ||
#include "flutter/shell/platform/cpp/public/flutter_glfw.h" |
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.
Please modify the header search paths in the GN rule to not have to do this.
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.
Done.
JsonMethodCodec() = default; | ||
|
||
// MethodCodec: | ||
std::unique_ptr<MethodCall<JsonValueType>> DecodeMethodCallInternal( |
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.
By convention, every overridden method name has a comment right above it listing the superclass that specifies the virtual method. See files like this as an example. Also a single empty newline after each method definition.
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.
Done everywhere.
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifdef FLUTTER_DESKTOP_LIBRARY |
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.
Please modify the header search paths to make this consistent.
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.
Done.
@@ -0,0 +1,9 @@ | |||
This code is intended to be built into plugins and applications to provide |
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 didn't see a unittest target for this. If there are not currently available, please create a stub target so folks know where to begin.
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.
So far FDE didn't have any tests :( Added test targets for the client wrappers, some infrastructure for writing non-trivial tests, and a couple of starter tests. It'll need a bunch of test coverage as follow-up.
|
||
ReplyManager::ReplyManager(BinaryReply reply_handler) | ||
: reply_handler_(std::move(reply_handler)) { | ||
if (!reply_handler_) { |
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 this just be an assertion?
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.
Done.
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.
All comments from the last round should be addressed; PTAL
~BasicMessageChannel() {} | ||
|
||
// Prevent copying. | ||
BasicMessageChannel(BasicMessageChannel const&) = delete; |
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 DISALLOW_COPY-style macro you are describing is no longer allowed by Google style; explicit deletion is the preferred approach. See
https://google.github.io/styleguide/cppguide.html#Copyable_Movable_Types
and
https://google.github.io/styleguide/cppguide.html#Preprocessor_Macros
shell/platform/cpp/BUILD.gn
Outdated
source_set("common_cpp_library_headers") { | ||
public = _public_headers | ||
|
||
defines = _common_defines |
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.
Done.
] | ||
} | ||
|
||
copy("_publish_includes") { |
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.
Yep, I misread the GN docs and thought the _ applied to targets as well as variables. Fixed.
|
||
ReplyManager::ReplyManager(BinaryReply reply_handler) | ||
: reply_handler_(std::move(reply_handler)) { | ||
if (!reply_handler_) { |
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.
Done.
BasicMessageChannel(BinaryMessenger* messenger, | ||
const std::string& name, | ||
const MessageCodec<T>* codec) | ||
: messenger_(messenger), name_(name), codec_(codec) {} |
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 assume you meant this for the next line, since this constructor takes arguments and thus isn't a default constructor.
Done for all default constructors/destructors that weren't already using default
.
shell/platform/cpp/BUILD.gn
Outdated
} | ||
|
||
source_set("common_cpp") { | ||
public = [ |
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.
Per offline discussion, I'm not clear on what to change here, and the decisions was to revisit this in a follow-up.
shell/platform/cpp/BUILD.gn
Outdated
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("$flutter_root/common/config.gni") |
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.
Moved the code into a combination of flutter/glfw
and flutter/common/cpp
per discussion.
#include <vector> | ||
|
||
#ifdef FLUTTER_DESKTOP_LIBRARY | ||
#include "flutter/shell/platform/cpp/public/flutter_glfw.h" |
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.
Done.
@@ -0,0 +1,9 @@ | |||
This code is intended to be built into plugins and applications to provide |
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.
So far FDE didn't have any tests :( Added test targets for the client wrappers, some infrastructure for writing non-trivial tests, and a couple of starter tests. It'll need a bunch of test coverage as follow-up.
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.
Admittedly, this PR is a bit too large for me to review thoroughly (and I am sure it is unwieldy for you to have it one another branch while under review). I think the structure is fine and I have done my best to go over everything. Let's land this ASAP and tinker on it once it is in the tree. LGTM. Thanks!
flutter/engine@d8c89e2...188adf7 git log d8c89e2..188adf7 --no-merges --oneline 188adf7 Removed Activity reference from AccessibilityBridge by using a View for insets instead of the Activity (#18115) (flutter/engine#8231) d452dd5 Initial import of GLFW Linux shell from FDE (flutter/engine#8159) 5120045 Remove jsoncpp from desktop Linux shell setup (flutter/engine#8230) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff (liyuqian@google.com), and stop the roller if necessary.
Changes include: - File structure - Header guards - Include paths - Namespaces - Integration with the engine's GN build - Conversion from jsoncpp to rapidjson - Style and clang-format adjustment to match engine repository
This reverts commit f0ef655.
This reverts commit f0ef655.
The initial commit in this PR is the flutter-desktop-embedding Linux implementation essentially as-is, but integrated into the engine build. The main things that need review there are:
cpp
as a straw man for the location of this code, which will be shared between Linux and Windows when I do the Windows migration shortly)The second commit switches from jsoncpp to RapidJSON, which could also use review. @franciscojma86 please take a look at that part too.
The last two commits are mechanical changes to stop using
Embedder
in prefixes (and in code and comments in general, to avoid confusion), and to reformat the files with Flutter's format.