From d7a3001ea076df835d2f7d32bbfb52bd85df779e Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 5 Feb 2019 11:54:26 -0500 Subject: [PATCH 1/5] WIP: Switch the C++ embedder code to a client wrapper Rather than have a C++ interface in the shared library, make the C++ code a client wrapper layer that plugins and embedders consume. Ideally in the future more code will move out of this layer and behind a C interface in the library, so that the wrapper is as thin as possible, but this addresses the immediate issue of the shared library not having a viable interface. --- build/BUILDCONFIG.gn | 7 ++ example/linux_fde/Makefile | 7 ++ library/BUILD.gn | 44 ++------ library/common/client_wrapper/BUILD.gn | 103 ++++++++++++++++++ library/common/client_wrapper/README | 9 ++ .../basic_message_channel.h | 9 +- .../binary_messenger.h | 10 +- .../engine_method_result.h | 5 +- .../glfw/flutter_window_controller.h | 22 ++-- .../json_message_codec.h | 7 +- .../json_method_codec.h | 9 +- .../flutter_desktop_embedding/message_codec.h | 10 +- .../flutter_desktop_embedding/method_call.h | 10 +- .../method_channel.h | 9 +- .../flutter_desktop_embedding/method_codec.h | 9 +- .../flutter_desktop_embedding/method_result.h | 10 +- .../plugin_registrar.h | 11 +- .../src}/engine_method_result.cc | 2 +- .../src}/glfw/flutter_window_controller.cc | 12 +- .../src}/json_message_codec.cc | 2 +- .../src}/json_method_codec.cc | 4 +- .../src}/plugin_handler.cc | 6 +- .../src}/plugin_handler.h | 13 ++- library/common/glfw/embedder.cc | 4 +- library/common/glfw/key_event_handler.cc | 2 +- library/common/glfw/key_event_handler.h | 4 +- library/common/glfw/text_input_plugin.cc | 2 +- library/common/glfw/text_input_plugin.h | 4 +- .../internal/incoming_message_dispatcher.h | 2 +- .../fde_export.h | 6 +- .../glfw/embedder.h | 8 +- plugins/color_panel/BUILD.gn | 1 + plugins/file_chooser/BUILD.gn | 1 + plugins/menubar/BUILD.gn | 1 + 34 files changed, 238 insertions(+), 127 deletions(-) create mode 100644 library/common/client_wrapper/BUILD.gn create mode 100644 library/common/client_wrapper/README rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/basic_message_channel.h (92%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/binary_messenger.h (87%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/engine_method_result.h (96%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/glfw/flutter_window_controller.h (85%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/json_message_codec.h (84%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/json_method_codec.h (84%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/message_codec.h (87%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/method_call.h (83%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/method_channel.h (92%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/method_codec.h (91%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/method_result.h (88%) rename library/{ => common/client_wrapper}/include/flutter_desktop_embedding/plugin_registrar.h (86%) rename library/common/{ => client_wrapper/src}/engine_method_result.cc (95%) rename library/common/{ => client_wrapper/src}/glfw/flutter_window_controller.cc (90%) rename library/common/{ => client_wrapper/src}/json_message_codec.cc (96%) rename library/common/{ => client_wrapper/src}/json_method_codec.cc (95%) rename library/common/{internal => client_wrapper/src}/plugin_handler.cc (94%) rename library/common/{internal => client_wrapper/src}/plugin_handler.h (85%) rename library/include/{flutter_desktop_embedding => flutter_desktop_embedding_core}/fde_export.h (82%) rename library/include/{flutter_desktop_embedding => flutter_desktop_embedding_core}/glfw/embedder.h (95%) diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn index a87e2dff4..2583ff86c 100644 --- a/build/BUILDCONFIG.gn +++ b/build/BUILDCONFIG.gn @@ -40,3 +40,10 @@ if (host_os == "linux") { is_mac = false is_win = true } + +declare_args() { + # Whether to use the GLFW embedding implementation. Currently overriding this + # would not work since each platform only has one working implementation, + # but in the future GLFW may be one of multiple supported implementations. + use_glfw = is_linux || is_win +} diff --git a/example/linux_fde/Makefile b/example/linux_fde/Makefile index 70ebcac21..3d158dc05 100644 --- a/example/linux_fde/Makefile +++ b/example/linux_fde/Makefile @@ -78,6 +78,13 @@ BIN_OUT=$(OUT_DIR)/flutter_embedder_example ICU_DATA_OUT=$(OUT_DATA_DIR)/$(ICU_DATA_NAME) ALL_LIBS_OUT=$(foreach lib,$(ALL_LIBS),$(OUT_LIB_DIR)/$(notdir $(lib))) +# Add the code for the wrapper library, which is intended to be statically +# built into the client. +WRAPPER_ROOT = $(GN_OUT_DIR)/fde_cpp_wrapper +SOURCES += $(shell find $(WRAPPER_ROOT) -type f -name '*.cc') +INCLUDE_DIRS += $(WRAPPER_ROOT)/include + + # Build settings CXX=g++ -std=c++14 CXXFLAGS.release=-DNDEBUG diff --git a/library/BUILD.gn b/library/BUILD.gn index 4b1efa9d9..378918aa7 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -16,23 +16,14 @@ import("//build/flutter.gni") import("//build/packaging.gni") import("//library/engine.gni") -declare_args() { - # Whether to use the GLFW embedding implementation. Currently overriding this - # would not work since each platform only has one working implementation, - # but in the future GLFW may be one of multiple supported implementations. - use_glfw = is_linux || is_win -} - published_shared_library("flutter_embedder") { # GLFW embedding implementation. if (use_glfw) { public = [ - "include/flutter_desktop_embedding/glfw/embedder.h", - "include/flutter_desktop_embedding/glfw/flutter_window_controller.h", + "include/flutter_desktop_embedding_core/glfw/embedder.h", ] sources = [ "common/glfw/embedder.cc", - "common/glfw/flutter_window_controller.cc", "common/glfw/key_event_handler.cc", "common/glfw/key_event_handler.h", "common/glfw/keyboard_hook_handler.h", @@ -41,42 +32,31 @@ published_shared_library("flutter_embedder") { ] } + deps = [ + ":flutter_engine", + ] + # Embedding-agnostic shared C++. if (is_linux || is_win) { sources += [ - "common/engine_method_result.cc", "common/internal/incoming_message_dispatcher.cc", "common/internal/incoming_message_dispatcher.h", - "common/internal/plugin_handler.cc", - "common/internal/plugin_handler.h", "common/internal/text_input_model.cc", "common/internal/text_input_model.h", - "common/json_message_codec.cc", - "common/json_method_codec.cc", ] public += [ - "include/flutter_desktop_embedding/basic_message_channel.h", - "include/flutter_desktop_embedding/binary_messenger.h", - "include/flutter_desktop_embedding/engine_method_result.h", - "include/flutter_desktop_embedding/fde_export.h", - "include/flutter_desktop_embedding/json_message_codec.h", - "include/flutter_desktop_embedding/json_method_codec.h", - "include/flutter_desktop_embedding/message_codec.h", - "include/flutter_desktop_embedding/method_call.h", - "include/flutter_desktop_embedding/method_channel.h", - "include/flutter_desktop_embedding/method_codec.h", - "include/flutter_desktop_embedding/method_result.h", - "include/flutter_desktop_embedding/plugin_registrar.h", + "include/flutter_desktop_embedding_core/fde_export.h", ] + + deps += ["//library/common/client_wrapper:client_wrapper", "//library/common/client_wrapper:publish_wrapper"] } - deps = [ - ":flutter_engine", + defines = [ + "FLUTTER_DESKTOP_EMBEDDING_IMPL", + "USE_FDE_TREE_PATHS", ] - defines = [ "FLUTTER_DESKTOP_EMBEDDING_IMPL" ] - - public_header_subdir = "flutter_desktop_embedding" + public_header_subdir = "flutter_desktop_embedding_core" public_configs = [ ":relative_public_headers" ] diff --git a/library/common/client_wrapper/BUILD.gn b/library/common/client_wrapper/BUILD.gn new file mode 100644 index 000000000..a52005087 --- /dev/null +++ b/library/common/client_wrapper/BUILD.gn @@ -0,0 +1,103 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +_wrapper_includes = [ + "include/flutter_desktop_embedding/basic_message_channel.h", + "include/flutter_desktop_embedding/binary_messenger.h", + "include/flutter_desktop_embedding/engine_method_result.h", + "include/flutter_desktop_embedding/json_message_codec.h", + "include/flutter_desktop_embedding/json_method_codec.h", + "include/flutter_desktop_embedding/message_codec.h", + "include/flutter_desktop_embedding/method_call.h", + "include/flutter_desktop_embedding/method_channel.h", + "include/flutter_desktop_embedding/method_codec.h", + "include/flutter_desktop_embedding/method_result.h", + "include/flutter_desktop_embedding/plugin_registrar.h", +] +_wrapper_sources = [ + "src/engine_method_result.cc", + "src/json_message_codec.cc", + "src/json_method_codec.cc", + "src/plugin_handler.cc", + "src/plugin_handler.h", +] + +if (use_glfw) { + _wrapper_includes += + [ "include/flutter_desktop_embedding/glfw/flutter_window_controller.h" ] + _wrapper_sources += [ "src/glfw/flutter_window_controller.cc" ] +} + +_wrapper_publish_dir = "$root_out_dir/fde_cpp_wrapper" + +# A static library version of the client wrapper, for use both within the +# framework implementation itself, as well as with the plugin builds. +source_set("client_wrapper") { + sources = _wrapper_sources + public = _wrapper_includes + + if (is_linux) { + configs = [ + "//build/linux/config:jsoncpp", + + # Use shared library settings since this target will be folded into + # shared libraries. + "//build:shared_library_defaults", + ] + } + if (is_win) { + deps = [ + "//third_party/jsoncpp:jsoncpp", + ] + } + + public_configs = [ ":_relative_headers" ] + + # Since these sources are for client use, they are written assuming they will + # consume the embedder as a framework. + include_dirs = [ "//library/include/" ] + + # Explicitly disable flattened headers, since this is being built in-tree. + # TODO: Simplify down to one define once Windows is using GN. + defines = [ "USE_FLATTENED_INCLUDES=0", "USE_FDE_TREE_PATHS" ] +} + +# Since this code is intended to be used by clients in a source bundle, the +# include paths use library-relative header paths rather than project-relative. +config("_relative_headers") { + include_dirs = [ "include" ] +} + +copy("_publish_includes") { + sources = _wrapper_includes + output_dir = "$_wrapper_publish_dir/include/flutter_desktop_embedding" + outputs = [ + "$output_dir/{{source_file_part}}", + ] +} + +copy("_publish_sources") { + sources = _wrapper_sources + [ "README" ] + output_dir = "$_wrapper_publish_dir" + outputs = [ + "$output_dir/{{source_file_part}}", + ] +} + +group("publish_wrapper") { + deps = [ + ":_publish_includes", + ":_publish_sources", + ] +} diff --git a/library/common/client_wrapper/README b/library/common/client_wrapper/README new file mode 100644 index 000000000..cca08aa26 --- /dev/null +++ b/library/common/client_wrapper/README @@ -0,0 +1,9 @@ +This code is intended to be built into plugins and embedders to provide +higher-level, C++ abstractions for interacting with the embedding library. + +Over time, the goal is to move more of this code into the library in a way that +provides a usable ABI (e.g., does not use standard libary in the interfaces). + +Note that this wrapper is still in early stages. Expect significant churn in +both the APIs and the structure of the wrapper (e.g., the exact set of files +that need to be built). diff --git a/library/include/flutter_desktop_embedding/basic_message_channel.h b/library/common/client_wrapper/include/flutter_desktop_embedding/basic_message_channel.h similarity index 92% rename from library/include/flutter_desktop_embedding/basic_message_channel.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/basic_message_channel.h index 25882e250..2ab900cae 100644 --- a/library/include/flutter_desktop_embedding/basic_message_channel.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/basic_message_channel.h @@ -11,14 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BASIC_MESSAGE_CHANNEL_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BASIC_MESSAGE_CHANNEL_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BASIC_MESSAGE_CHANNEL_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BASIC_MESSAGE_CHANNEL_H_ #include #include #include "binary_messenger.h" -#include "fde_export.h" #include "message_codec.h" namespace flutter_desktop_embedding { @@ -40,7 +39,7 @@ using MessageHandler = // A channel for communicating with the Flutter engine by sending asynchronous // messages. template -class FDE_EXPORT BasicMessageChannel { +class BasicMessageChannel { public: // Creates an instance that sends and receives method calls on the channel // named |name|, encoded with |codec| and dispatched via |messenger|. @@ -103,4 +102,4 @@ class FDE_EXPORT BasicMessageChannel { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BASIC_MESSAGE_CHANNEL_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BASIC_MESSAGE_CHANNEL_H_ diff --git a/library/include/flutter_desktop_embedding/binary_messenger.h b/library/common/client_wrapper/include/flutter_desktop_embedding/binary_messenger.h similarity index 87% rename from library/include/flutter_desktop_embedding/binary_messenger.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/binary_messenger.h index 3252ad596..09a9b07f8 100644 --- a/library/include/flutter_desktop_embedding/binary_messenger.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/binary_messenger.h @@ -11,14 +11,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ #include #include -#include "fde_export.h" - // TODO: Consider adding absl as a dependency and using absl::Span for all of // the message/message_size pairs. namespace flutter_desktop_embedding { @@ -38,7 +36,7 @@ typedef std::function #include "binary_messenger.h" -#include "fde_export.h" #include "method_codec.h" #include "method_result.h" @@ -29,7 +28,7 @@ namespace internal { // Manages the one-time sending of response data. This is an internal helper // class for EngineMethodResult, separated out since the implementation doesn't // vary based on the template type. -class FDE_EXPORT ReplyManager { +class ReplyManager { public: ReplyManager(BinaryReply reply_handler_); ~ReplyManager(); @@ -51,7 +50,7 @@ class FDE_EXPORT ReplyManager { // Implemention of MethodResult that sends a response to the Flutter engine // exactly once, encoded using a given codec. template -class FDE_EXPORT EngineMethodResult : public MethodResult { +class EngineMethodResult : public MethodResult { public: // Creates a result object that will send results to |reply_handler|, encoded // using |codec|. The |codec| pointer must remain valid for as long as this diff --git a/library/include/flutter_desktop_embedding/glfw/flutter_window_controller.h b/library/common/client_wrapper/include/flutter_desktop_embedding/glfw/flutter_window_controller.h similarity index 85% rename from library/include/flutter_desktop_embedding/glfw/flutter_window_controller.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/glfw/flutter_window_controller.h index 7f2ce4f52..03a09520d 100644 --- a/library/include/flutter_desktop_embedding/glfw/flutter_window_controller.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/glfw/flutter_window_controller.h @@ -12,20 +12,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_FLUTTER_WINDOW_CONTROLLER_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_FLUTTER_WINDOW_CONTROLLER_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_FLUTTER_WINDOW_CONTROLLER_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_FLUTTER_WINDOW_CONTROLLER_H_ #include #include -#include "embedder.h" - -#ifdef USE_FLATTENED_INCLUDES -#include "fde_export.h" -#include "plugin_registrar.h" +#ifdef USE_FDE_TREE_PATHS +#include #else -#include "../fde_export.h" +#include +#endif + +#ifdef USE_FDE_TREE_PATHS #include "../plugin_registrar.h" +#else +#include "plugin_registrar.h" #endif namespace flutter_desktop_embedding { @@ -42,7 +44,7 @@ class PluginHandler; // requires control of the application's event loop, and is thus useful // primarily for building a simple one-window shell hosting a Flutter // application. The final implementation and API will be very different. -class FDE_EXPORT FlutterWindowController { +class FlutterWindowController { public: // There must be only one instance of this class in an application at any // given time, as Flutter does not support multiple engines in one process, @@ -91,4 +93,4 @@ class FDE_EXPORT FlutterWindowController { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_FLUTTER_WINDOW_CONTROLLER_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_FLUTTER_WINDOW_CONTROLLER_H_ diff --git a/library/include/flutter_desktop_embedding/json_message_codec.h b/library/common/client_wrapper/include/flutter_desktop_embedding/json_message_codec.h similarity index 84% rename from library/include/flutter_desktop_embedding/json_message_codec.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/json_message_codec.h index 8a824e67f..e1c54db69 100644 --- a/library/include/flutter_desktop_embedding/json_message_codec.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/json_message_codec.h @@ -11,12 +11,11 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_ #include -#include "fde_export.h" #include "message_codec.h" namespace flutter_desktop_embedding { @@ -47,4 +46,4 @@ class JsonMessageCodec : public MessageCodec { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_ diff --git a/library/include/flutter_desktop_embedding/json_method_codec.h b/library/common/client_wrapper/include/flutter_desktop_embedding/json_method_codec.h similarity index 84% rename from library/include/flutter_desktop_embedding/json_method_codec.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/json_method_codec.h index 9b1978830..88cd3497d 100644 --- a/library/include/flutter_desktop_embedding/json_method_codec.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/json_method_codec.h @@ -11,19 +11,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ #include -#include "fde_export.h" #include "method_call.h" #include "method_codec.h" namespace flutter_desktop_embedding { // An implementation of MethodCodec that uses JSON strings as the serialization. -class FDE_EXPORT JsonMethodCodec : public MethodCodec { +class JsonMethodCodec : public MethodCodec { public: // Returns the shared instance of the codec. static const JsonMethodCodec &GetInstance(); @@ -52,4 +51,4 @@ class FDE_EXPORT JsonMethodCodec : public MethodCodec { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ diff --git a/library/include/flutter_desktop_embedding/message_codec.h b/library/common/client_wrapper/include/flutter_desktop_embedding/message_codec.h similarity index 87% rename from library/include/flutter_desktop_embedding/message_codec.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/message_codec.h index 7ad2d518f..a9f07635e 100644 --- a/library/include/flutter_desktop_embedding/message_codec.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/message_codec.h @@ -11,21 +11,19 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_MESSAGE_CODEC_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_MESSAGE_CODEC_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_MESSAGE_CODEC_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_MESSAGE_CODEC_H_ #include #include #include -#include "fde_export.h" - namespace flutter_desktop_embedding { // Translates between a binary message and higher-level method call and // response/error objects. template -class FDE_EXPORT MessageCodec { +class MessageCodec { public: MessageCodec() = default; virtual ~MessageCodec() = default; @@ -58,4 +56,4 @@ class FDE_EXPORT MessageCodec { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_MESSAGE_CODEC_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_MESSAGE_CODEC_H_ diff --git a/library/include/flutter_desktop_embedding/method_call.h b/library/common/client_wrapper/include/flutter_desktop_embedding/method_call.h similarity index 83% rename from library/include/flutter_desktop_embedding/method_call.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/method_call.h index 64c06ecec..4c04f0144 100644 --- a/library/include/flutter_desktop_embedding/method_call.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/method_call.h @@ -11,20 +11,18 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_TYPED_METHOD_CALL_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_TYPED_METHOD_CALL_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_TYPED_METHOD_CALL_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_TYPED_METHOD_CALL_H_ #include #include -#include "fde_export.h" - namespace flutter_desktop_embedding { // An object encapsulating a method call from Flutter whose arguments are of // type T. template -class FDE_EXPORT MethodCall { +class MethodCall { public: // Creates a MethodCall with the given name and arguments. explicit MethodCall(const std::string &method_name, @@ -49,4 +47,4 @@ class FDE_EXPORT MethodCall { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_TYPED_METHOD_CALL_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_TYPED_METHOD_CALL_H_ diff --git a/library/include/flutter_desktop_embedding/method_channel.h b/library/common/client_wrapper/include/flutter_desktop_embedding/method_channel.h similarity index 92% rename from library/include/flutter_desktop_embedding/method_channel.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/method_channel.h index 6016e35d9..7dac0b962 100644 --- a/library/include/flutter_desktop_embedding/method_channel.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/method_channel.h @@ -11,15 +11,14 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ #include #include #include "binary_messenger.h" #include "engine_method_result.h" -#include "fde_export.h" #include "method_call.h" #include "method_codec.h" #include "method_result.h" @@ -37,7 +36,7 @@ using MethodCallHandler = std::function -class FDE_EXPORT MethodChannel { +class MethodChannel { public: // Creates an instance that sends and receives method calls on the channel // named |name|, encoded with |codec| and dispatched via |messenger|. @@ -96,4 +95,4 @@ class FDE_EXPORT MethodChannel { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ diff --git a/library/include/flutter_desktop_embedding/method_codec.h b/library/common/client_wrapper/include/flutter_desktop_embedding/method_codec.h similarity index 91% rename from library/include/flutter_desktop_embedding/method_codec.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/method_codec.h index cc8ed2c87..30a183d95 100644 --- a/library/include/flutter_desktop_embedding/method_codec.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/method_codec.h @@ -11,14 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ #include #include #include -#include "fde_export.h" #include "method_call.h" namespace flutter_desktop_embedding { @@ -26,7 +25,7 @@ namespace flutter_desktop_embedding { // Translates between a binary message and higher-level method call and // response/error objects. template -class FDE_EXPORT MethodCodec { +class MethodCodec { public: MethodCodec() = default; virtual ~MethodCodec() = default; @@ -81,4 +80,4 @@ class FDE_EXPORT MethodCodec { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ diff --git a/library/include/flutter_desktop_embedding/method_result.h b/library/common/client_wrapper/include/flutter_desktop_embedding/method_result.h similarity index 88% rename from library/include/flutter_desktop_embedding/method_result.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/method_result.h index f7a8a5c57..3f6fc748e 100644 --- a/library/include/flutter_desktop_embedding/method_result.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/method_result.h @@ -11,19 +11,17 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ #include -#include "fde_export.h" - namespace flutter_desktop_embedding { // Encapsulates a result sent back to the Flutter engine in response to a // MethodCall. Only one method should be called on any given instance. template -class FDE_EXPORT MethodResult { +class MethodResult { public: MethodResult() = default; virtual ~MethodResult() = default; @@ -62,4 +60,4 @@ class FDE_EXPORT MethodResult { } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ diff --git a/library/include/flutter_desktop_embedding/plugin_registrar.h b/library/common/client_wrapper/include/flutter_desktop_embedding/plugin_registrar.h similarity index 86% rename from library/include/flutter_desktop_embedding/plugin_registrar.h rename to library/common/client_wrapper/include/flutter_desktop_embedding/plugin_registrar.h index c64d144f0..dab4bd88e 100644 --- a/library/include/flutter_desktop_embedding/plugin_registrar.h +++ b/library/common/client_wrapper/include/flutter_desktop_embedding/plugin_registrar.h @@ -11,13 +11,12 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_REGISTRAR_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_REGISTRAR_H_ +#ifndef LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_REGISTRAR_H_ +#define LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_REGISTRAR_H_ #include #include "binary_messenger.h" -#include "fde_export.h" namespace flutter_desktop_embedding { @@ -28,7 +27,7 @@ class Plugin; // Currently this class has very limited functionality, but is expected to // expand over time to more closely match the functionality of // the Flutter mobile plugin APIs' plugin registrars. -class FDE_EXPORT PluginRegistrar { +class PluginRegistrar { public: virtual ~PluginRegistrar() {} @@ -54,11 +53,11 @@ class FDE_EXPORT PluginRegistrar { }; // A plugin that can be registered for ownership by a PluginRegistrar. -class FDE_EXPORT Plugin { +class Plugin { public: virtual ~Plugin() {} }; } // namespace flutter_desktop_embedding -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_REGISTRAR_H_ +#endif // LIBRARY_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_REGISTRAR_H_ diff --git a/library/common/engine_method_result.cc b/library/common/client_wrapper/src/engine_method_result.cc similarity index 95% rename from library/common/engine_method_result.cc rename to library/common/client_wrapper/src/engine_method_result.cc index dd83babf3..5af244872 100644 --- a/library/common/engine_method_result.cc +++ b/library/common/client_wrapper/src/engine_method_result.cc @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "library/include/flutter_desktop_embedding/engine_method_result.h" +#include "flutter_desktop_embedding/engine_method_result.h" #include diff --git a/library/common/glfw/flutter_window_controller.cc b/library/common/client_wrapper/src/glfw/flutter_window_controller.cc similarity index 90% rename from library/common/glfw/flutter_window_controller.cc rename to library/common/client_wrapper/src/glfw/flutter_window_controller.cc index b53fef807..6505a73dc 100644 --- a/library/common/glfw/flutter_window_controller.cc +++ b/library/common/client_wrapper/src/glfw/flutter_window_controller.cc @@ -12,12 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "library/include/flutter_desktop_embedding/glfw/flutter_window_controller.h" +#ifdef USE_FDE_TREE_PATHS +#include "flutter_desktop_embedding/glfw/flutter_window_controller.h" +#else +#include "flutter_desktop_embedding/flutter_window_controller.h" +#endif #include #include -#include "library/common/internal/plugin_handler.h" +#ifdef USE_FDE_TREE_PATHS +#include "../plugin_handler.h" +#else +#include "plugin_handler.h" +#endif namespace flutter_desktop_embedding { diff --git a/library/common/json_message_codec.cc b/library/common/client_wrapper/src/json_message_codec.cc similarity index 96% rename from library/common/json_message_codec.cc rename to library/common/client_wrapper/src/json_message_codec.cc index 8eda6714d..9ad1b8845 100644 --- a/library/common/json_message_codec.cc +++ b/library/common/client_wrapper/src/json_message_codec.cc @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "library/include/flutter_desktop_embedding/json_message_codec.h" +#include "flutter_desktop_embedding/json_message_codec.h" #include #include diff --git a/library/common/json_method_codec.cc b/library/common/client_wrapper/src/json_method_codec.cc similarity index 95% rename from library/common/json_method_codec.cc rename to library/common/client_wrapper/src/json_method_codec.cc index 717f8bc81..60c5a299b 100644 --- a/library/common/json_method_codec.cc +++ b/library/common/client_wrapper/src/json_method_codec.cc @@ -11,9 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "library/include/flutter_desktop_embedding/json_method_codec.h" +#include "flutter_desktop_embedding/json_method_codec.h" -#include "library/include/flutter_desktop_embedding/json_message_codec.h" +#include "flutter_desktop_embedding/json_message_codec.h" namespace flutter_desktop_embedding { diff --git a/library/common/internal/plugin_handler.cc b/library/common/client_wrapper/src/plugin_handler.cc similarity index 94% rename from library/common/internal/plugin_handler.cc rename to library/common/client_wrapper/src/plugin_handler.cc index b66a2d9f4..63a227a4f 100644 --- a/library/common/internal/plugin_handler.cc +++ b/library/common/client_wrapper/src/plugin_handler.cc @@ -11,10 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "library/common/internal/plugin_handler.h" +#include "plugin_handler.h" -#include "library/include/flutter_desktop_embedding/engine_method_result.h" -#include "library/include/flutter_desktop_embedding/method_channel.h" +#include "flutter_desktop_embedding/engine_method_result.h" +#include "flutter_desktop_embedding/method_channel.h" #include diff --git a/library/common/internal/plugin_handler.h b/library/common/client_wrapper/src/plugin_handler.h similarity index 85% rename from library/common/internal/plugin_handler.h rename to library/common/client_wrapper/src/plugin_handler.h index a891286f2..b80b686c8 100644 --- a/library/common/internal/plugin_handler.h +++ b/library/common/client_wrapper/src/plugin_handler.h @@ -19,9 +19,16 @@ #include #include -#include "library/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/include/flutter_desktop_embedding/glfw/embedder.h" -#include "library/include/flutter_desktop_embedding/plugin_registrar.h" +// TODO: Change USE_FDE_TREE_PATHS branches to use project-relative paths +// once Windows clients aren't relying on it. +#ifdef USE_FDE_TREE_PATHS +#include +#else +#include +#endif + +#include "flutter_desktop_embedding/binary_messenger.h" +#include "flutter_desktop_embedding/plugin_registrar.h" namespace flutter_desktop_embedding { diff --git a/library/common/glfw/embedder.cc b/library/common/glfw/embedder.cc index 63d9e2bed..e529e1eac 100644 --- a/library/common/glfw/embedder.cc +++ b/library/common/glfw/embedder.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "library/include/flutter_desktop_embedding/glfw/embedder.h" +#include "library/include/flutter_desktop_embedding_core/glfw/embedder.h" #include #include @@ -29,11 +29,11 @@ #include +#include "library/common/client_wrapper/src/plugin_handler.h" #include "library/common/glfw/key_event_handler.h" #include "library/common/glfw/keyboard_hook_handler.h" #include "library/common/glfw/text_input_plugin.h" #include "library/common/internal/incoming_message_dispatcher.h" -#include "library/common/internal/plugin_handler.h" #ifdef __linux__ // For plugin-compatible event handling (e.g., modal windows). diff --git a/library/common/glfw/key_event_handler.cc b/library/common/glfw/key_event_handler.cc index d2337cd67..08d6d5476 100644 --- a/library/common/glfw/key_event_handler.cc +++ b/library/common/glfw/key_event_handler.cc @@ -16,7 +16,7 @@ #include #include -#include "library/include/flutter_desktop_embedding/json_message_codec.h" +#include "library/common/client_wrapper/include/flutter_desktop_embedding/json_message_codec.h" static constexpr char kChannelName[] = "flutter/keyevent"; diff --git a/library/common/glfw/key_event_handler.h b/library/common/glfw/key_event_handler.h index 5e086db93..446c6170f 100644 --- a/library/common/glfw/key_event_handler.h +++ b/library/common/glfw/key_event_handler.h @@ -18,9 +18,9 @@ #include +#include "library/common/client_wrapper/include/flutter_desktop_embedding/basic_message_channel.h" +#include "library/common/client_wrapper/include/flutter_desktop_embedding/binary_messenger.h" #include "library/common/glfw/keyboard_hook_handler.h" -#include "library/include/flutter_desktop_embedding/basic_message_channel.h" -#include "library/include/flutter_desktop_embedding/binary_messenger.h" namespace flutter_desktop_embedding { diff --git a/library/common/glfw/text_input_plugin.cc b/library/common/glfw/text_input_plugin.cc index d34379537..d0fe6699f 100644 --- a/library/common/glfw/text_input_plugin.cc +++ b/library/common/glfw/text_input_plugin.cc @@ -16,7 +16,7 @@ #include #include -#include "library/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/common/client_wrapper/include/flutter_desktop_embedding/json_method_codec.h" static constexpr char kSetEditingStateMethod[] = "TextInput.setEditingState"; static constexpr char kClearClientMethod[] = "TextInput.clearClient"; diff --git a/library/common/glfw/text_input_plugin.h b/library/common/glfw/text_input_plugin.h index 716229dcf..2ed44a41a 100644 --- a/library/common/glfw/text_input_plugin.h +++ b/library/common/glfw/text_input_plugin.h @@ -17,10 +17,10 @@ #include #include +#include "library/common/client_wrapper/include/flutter_desktop_embedding/method_channel.h" +#include "library/common/client_wrapper/include/flutter_desktop_embedding/plugin_registrar.h" #include "library/common/glfw/keyboard_hook_handler.h" #include "library/common/internal/text_input_model.h" -#include "library/include/flutter_desktop_embedding/method_channel.h" -#include "library/include/flutter_desktop_embedding/plugin_registrar.h" namespace flutter_desktop_embedding { diff --git a/library/common/internal/incoming_message_dispatcher.h b/library/common/internal/incoming_message_dispatcher.h index 36080d51d..3606ae3b0 100644 --- a/library/common/internal/incoming_message_dispatcher.h +++ b/library/common/internal/incoming_message_dispatcher.h @@ -20,7 +20,7 @@ #include #include -#include "library/include/flutter_desktop_embedding/glfw/embedder.h" +#include "library/include/flutter_desktop_embedding_core/glfw/embedder.h" namespace flutter_desktop_embedding { diff --git a/library/include/flutter_desktop_embedding/fde_export.h b/library/include/flutter_desktop_embedding_core/fde_export.h similarity index 82% rename from library/include/flutter_desktop_embedding/fde_export.h rename to library/include/flutter_desktop_embedding_core/fde_export.h index 06b83fb97..9a1b02126 100644 --- a/library/include/flutter_desktop_embedding/fde_export.h +++ b/library/include/flutter_desktop_embedding_core/fde_export.h @@ -11,8 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_FDE_EXPORT_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_FDE_EXPORT_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_CORE_FDE_EXPORT_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_CORE_FDE_EXPORT_H_ #ifdef FLUTTER_DESKTOP_EMBEDDING_IMPL // Add visibiilty/export annotations when building the library. @@ -34,4 +34,4 @@ #endif -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_FDE_EXPORT_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_CORE_FDE_EXPORT_H_ diff --git a/library/include/flutter_desktop_embedding/glfw/embedder.h b/library/include/flutter_desktop_embedding_core/glfw/embedder.h similarity index 95% rename from library/include/flutter_desktop_embedding/glfw/embedder.h rename to library/include/flutter_desktop_embedding_core/glfw/embedder.h index 771b7796d..52e081cbd 100644 --- a/library/include/flutter_desktop_embedding/glfw/embedder.h +++ b/library/include/flutter_desktop_embedding_core/glfw/embedder.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_EMBEDDER_H_ -#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_EMBEDDER_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_CORE_GLFW_EMBEDDER_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_CORE_GLFW_EMBEDDER_H_ #include #include @@ -27,7 +27,7 @@ #endif #endif -#ifdef USE_FLATTENED_INCLUDES +#if defined(USE_FLATTENED_INCLUDES) && USE_FLATTENED_INCLUDES #include "fde_export.h" #else #include "../fde_export.h" @@ -145,4 +145,4 @@ FDE_EXPORT void FlutterEmbedderEnableInputBlocking( } // extern "C" #endif -#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_GLFW_EMBEDDER_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_CORE_GLFW_EMBEDDER_H_ diff --git a/plugins/color_panel/BUILD.gn b/plugins/color_panel/BUILD.gn index abec46c25..f2684b2a2 100644 --- a/plugins/color_panel/BUILD.gn +++ b/plugins/color_panel/BUILD.gn @@ -34,6 +34,7 @@ published_shared_library("color_panel") { deps = [ "//library:flutter_embedder", + "//library/common/client_wrapper:client_wrapper", ] if (is_linux) { diff --git a/plugins/file_chooser/BUILD.gn b/plugins/file_chooser/BUILD.gn index 67f802f44..aa1e5df59 100644 --- a/plugins/file_chooser/BUILD.gn +++ b/plugins/file_chooser/BUILD.gn @@ -34,6 +34,7 @@ published_shared_library("file_chooser") { deps = [ "//library:flutter_embedder", + "//library/common/client_wrapper:client_wrapper", ] if (is_linux) { diff --git a/plugins/menubar/BUILD.gn b/plugins/menubar/BUILD.gn index 2d57864fe..8c0ce48ee 100644 --- a/plugins/menubar/BUILD.gn +++ b/plugins/menubar/BUILD.gn @@ -34,6 +34,7 @@ published_shared_library("menubar") { deps = [ "//library:flutter_embedder", + "//library/common/client_wrapper:client_wrapper", ] if (is_linux) { From 66aeda8d104576618deaf03d015bc643b94776af Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 5 Feb 2019 14:29:04 -0800 Subject: [PATCH 2/5] Fix import/export conflict in wrapper --- library/BUILD.gn | 9 +++++---- library/common/client_wrapper/BUILD.gn | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/library/BUILD.gn b/library/BUILD.gn index 378918aa7..3b3ea658c 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -44,11 +44,12 @@ published_shared_library("flutter_embedder") { "common/internal/text_input_model.cc", "common/internal/text_input_model.h", ] - public += [ - "include/flutter_desktop_embedding_core/fde_export.h", - ] + public += [ "include/flutter_desktop_embedding_core/fde_export.h" ] - deps += ["//library/common/client_wrapper:client_wrapper", "//library/common/client_wrapper:publish_wrapper"] + deps += [ + "//library/common/client_wrapper:client_wrapper_internal", + "//library/common/client_wrapper:publish_wrapper", + ] } defines = [ diff --git a/library/common/client_wrapper/BUILD.gn b/library/common/client_wrapper/BUILD.gn index a52005087..5ee340741 100644 --- a/library/common/client_wrapper/BUILD.gn +++ b/library/common/client_wrapper/BUILD.gn @@ -41,9 +41,28 @@ if (use_glfw) { _wrapper_publish_dir = "$root_out_dir/fde_cpp_wrapper" +# Template for building the wrapper code in two different modes. +# This is needed because the implementation of the embedding library +# uses this code internally, in addition to it being published for +# client use, but the internal version needs to set the flag that +# controls the export macro. +template("client_wrapper") { + template_target_name = target_name + + source_set(template_target_name) { + forward_variables_from(invoker, "*") + } + + source_set("${template_target_name}_internal") { + forward_variables_from(invoker, "*") + + defines += [ "FLUTTER_DESKTOP_EMBEDDING_IMPL" ] + } +} + # A static library version of the client wrapper, for use both within the # framework implementation itself, as well as with the plugin builds. -source_set("client_wrapper") { +client_wrapper("client_wrapper") { sources = _wrapper_sources public = _wrapper_includes @@ -70,7 +89,10 @@ source_set("client_wrapper") { # Explicitly disable flattened headers, since this is being built in-tree. # TODO: Simplify down to one define once Windows is using GN. - defines = [ "USE_FLATTENED_INCLUDES=0", "USE_FDE_TREE_PATHS" ] + defines = [ + "USE_FLATTENED_INCLUDES=0", + "USE_FDE_TREE_PATHS", + ] } # Since this code is intended to be used by clients in a source bundle, the From 292c5061e925e87af053d67dfaf245d3380f1218 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 5 Feb 2019 15:16:11 -0800 Subject: [PATCH 3/5] Update VS projects to use client_wrapper --- example/windows_fde/GLFW Example.vcxproj | 11 +++- .../windows_fde/GLFW Example.vcxproj.filters | 60 ++++++++++++------- library/windows/GLFW Library.vcxproj | 19 +++--- library/windows/GLFW Library.vcxproj.filters | 28 ++++----- 4 files changed, 70 insertions(+), 48 deletions(-) diff --git a/example/windows_fde/GLFW Example.vcxproj b/example/windows_fde/GLFW Example.vcxproj index 42c828237..3e7ba3f65 100644 --- a/example/windows_fde/GLFW Example.vcxproj +++ b/example/windows_fde/GLFW Example.vcxproj @@ -45,13 +45,13 @@ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\;$(IncludePath);$(ProjectDir)..\..\library\windows\;$(ProjectDir)..\..\library\include\ + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\;$(IncludePath);$(ProjectDir)..\..\library\windows\;$(ProjectDir)..\..\library\include\;$(ProjectDir)..\..\library\common\client_wrapper\include\ $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\library\include\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\;$(IncludePath);$(ProjectDir)..\..\library\windows\;$(ProjectDir)..\..\library\include\;$(ProjectDir)..\..\library\common\client_wrapper\include\ $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) @@ -62,6 +62,7 @@ true + _MBCS;%(PreprocessorDefinitions);USE_FDE_TREE_PATHS flutter_embedder.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) @@ -91,6 +92,7 @@ true + _MBCS;%(PreprocessorDefinitions);USE_FDE_TREE_PATHS true @@ -113,6 +115,9 @@ + + + @@ -126,4 +131,4 @@ $(SolutionDir) - \ No newline at end of file + diff --git a/example/windows_fde/GLFW Example.vcxproj.filters b/example/windows_fde/GLFW Example.vcxproj.filters index db892f006..0115b39b8 100644 --- a/example/windows_fde/GLFW Example.vcxproj.filters +++ b/example/windows_fde/GLFW Example.vcxproj.filters @@ -1,22 +1,40 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {2761a4b5-57b2-4d50-a677-d20ddc17a7f1} + + + + + Source Files + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 62c1101b9..c6a99e755 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -48,7 +48,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)..\..\third_party\jsoncpp\src\include\;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)..\..\third_party\jsoncpp\src\include\;$(ProjectDir)..\..\;$(ProjectDir)..\..\library\common\client_wrapper\include\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\JSON\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) @@ -57,7 +57,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)..\..\third_party\jsoncpp\src\include\;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)..\include\;$(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\;$(ProjectDir)..\..\third_party\jsoncpp\src\include\;$(ProjectDir)..\..\;$(ProjectDir)..\..\library\common\client_wrapper\include\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\JSON\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) @@ -68,7 +68,7 @@ true true MultiThreadedDebugDLL - _WINDLL;FLUTTER_DESKTOP_EMBEDDING_IMPL;%(PreprocessorDefinitions) + _WINDLL;FLUTTER_DESKTOP_EMBEDDING_IMPL;USE_FDE_TREE_PATHS;%(PreprocessorDefinitions) flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies);json_vc71_libmtd.lib @@ -111,7 +111,7 @@ true true MultiThreadedDLL - _WINDLL;FLUTTER_DESKTOP_EMBEDDING_IMPL;%(PreprocessorDefinitions) + _WINDLL;FLUTTER_DESKTOP_EMBEDDING_IMPL;USE_FDE_TREE_PATHS;%(PreprocessorDefinitions) true @@ -146,16 +146,15 @@ - + + + + - - - - @@ -163,4 +162,4 @@ - + \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index a98b1102f..07d60b321 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -13,6 +13,9 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {6cc11b49-f23d-438f-b98a-aaaf956b5495} + @@ -21,29 +24,26 @@ Source Files - - Source Files - - - Source Files - Source Files - - Source Files - Source Files - + Source Files - - Source Files + + Source Files\Client Wrapper - - Source Files + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper From 2bb3b9a17b688800b2ac2c192e7f7ca755667a52 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 5 Feb 2019 19:04:29 -0500 Subject: [PATCH 4/5] Improve Makefile and GN handling of wrapper library --- example/linux_fde/Makefile | 10 +++++++--- library/common/client_wrapper/BUILD.gn | 17 +++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/example/linux_fde/Makefile b/example/linux_fde/Makefile index 3d158dc05..5351d5606 100644 --- a/example/linux_fde/Makefile +++ b/example/linux_fde/Makefile @@ -78,10 +78,14 @@ BIN_OUT=$(OUT_DIR)/flutter_embedder_example ICU_DATA_OUT=$(OUT_DATA_DIR)/$(ICU_DATA_NAME) ALL_LIBS_OUT=$(foreach lib,$(ALL_LIBS),$(OUT_LIB_DIR)/$(notdir $(lib))) -# Add the code for the wrapper library, which is intended to be statically +# Add relevant code from the wrapper library, which is intended to be statically # built into the client. WRAPPER_ROOT = $(GN_OUT_DIR)/fde_cpp_wrapper -SOURCES += $(shell find $(WRAPPER_ROOT) -type f -name '*.cc') +WRAPPER_SOURCES = \ + $(WRAPPER_ROOT)/flutter_window_controller.cc \ + $(WRAPPER_ROOT)/plugin_handler.cc \ + $(WRAPPER_ROOT)/engine_method_result.cc +SOURCES += $(WRAPPER_SOURCES) INCLUDE_DIRS += $(WRAPPER_ROOT)/include @@ -111,7 +115,7 @@ $(BIN_OUT): $(SOURCES) $(ALL_LIBS_OUT) $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(SOURCES) $(LDFLAGS) -o $@ .PHONY: gnbuild -gnbuild: $(GN_OUT_DIR) +gnbuild $(WRAPPER_SOURCES): $(GN_OUT_DIR) $(NINJA_BIN) -C $(GN_OUT_DIR) $(FLUTTER_EMBEDDER_LIB_NAME) $(PLUGIN_NAMES) $(GN_OUT_DIR): diff --git a/library/common/client_wrapper/BUILD.gn b/library/common/client_wrapper/BUILD.gn index 5ee340741..4928b821f 100644 --- a/library/common/client_wrapper/BUILD.gn +++ b/library/common/client_wrapper/BUILD.gn @@ -25,6 +25,9 @@ _wrapper_includes = [ "include/flutter_desktop_embedding/method_result.h", "include/flutter_desktop_embedding/plugin_registrar.h", ] + +# TODO: Re-evaluate this once more codecs are supported, since most libraries +# won't need all the codecs. _wrapper_sources = [ "src/engine_method_result.cc", "src/json_message_codec.cc", @@ -33,12 +36,6 @@ _wrapper_sources = [ "src/plugin_handler.h", ] -if (use_glfw) { - _wrapper_includes += - [ "include/flutter_desktop_embedding/glfw/flutter_window_controller.h" ] - _wrapper_sources += [ "src/glfw/flutter_window_controller.cc" ] -} - _wrapper_publish_dir = "$root_out_dir/fde_cpp_wrapper" # Template for building the wrapper code in two different modes. @@ -103,6 +100,10 @@ config("_relative_headers") { copy("_publish_includes") { sources = _wrapper_includes + if (use_glfw) { + sources += + [ "include/flutter_desktop_embedding/glfw/flutter_window_controller.h" ] + } output_dir = "$_wrapper_publish_dir/include/flutter_desktop_embedding" outputs = [ "$output_dir/{{source_file_part}}", @@ -111,6 +112,10 @@ copy("_publish_includes") { copy("_publish_sources") { sources = _wrapper_sources + [ "README" ] + + if (use_glfw) { + sources += [ "src/glfw/flutter_window_controller.cc" ] + } output_dir = "$_wrapper_publish_dir" outputs = [ "$output_dir/{{source_file_part}}", From 46cd00396a67816d2b9359016bcf227db79ff342 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 5 Feb 2019 20:00:24 -0500 Subject: [PATCH 5/5] Fix GN config settings --- build/BUILDCONFIG.gn | 18 ++++++++++++++---- library/common/client_wrapper/BUILD.gn | 12 +++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn index 2583ff86c..7cba24611 100644 --- a/build/BUILDCONFIG.gn +++ b/build/BUILDCONFIG.gn @@ -12,17 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. +default_static_configs = [ "//build:defaults" ] + +default_dynamic_configs = [ + "//build:defaults", + "//build:shared_library_defaults", +] + set_defaults("executable") { - configs = [ "//build:defaults" ] + configs = default_static_configs } set_defaults("static_library") { - configs = [ "//build:defaults" ] + configs = default_static_configs +} +set_defaults("source_set") { + configs = default_static_configs } set_defaults("shared_library") { - configs = [ "//build:defaults", "//build:shared_library_defaults" ] + configs = default_dynamic_configs } set_defaults("published_shared_library") { - configs = [ "//build:defaults", "//build:shared_library_defaults" ] + configs = default_dynamic_configs } if (host_os == "linux") { diff --git a/library/common/client_wrapper/BUILD.gn b/library/common/client_wrapper/BUILD.gn index 4928b821f..e0803f936 100644 --- a/library/common/client_wrapper/BUILD.gn +++ b/library/common/client_wrapper/BUILD.gn @@ -63,14 +63,12 @@ client_wrapper("client_wrapper") { sources = _wrapper_sources public = _wrapper_includes - if (is_linux) { - configs = [ - "//build/linux/config:jsoncpp", + # Use shared library settings since this target will be folded into shared + # libraries. + configs = default_dynamic_configs - # Use shared library settings since this target will be folded into - # shared libraries. - "//build:shared_library_defaults", - ] + if (is_linux) { + configs += [ "//build/linux/config:jsoncpp" ] } if (is_win) { deps = [