From db6c4348bdc50a757d9d406d7ea1dd2150996dc9 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 19:58:10 -0800 Subject: [PATCH 01/21] Move linux headers to shared --- .../binary_messenger.h | 0 .../json_method_call.h | 0 .../flutter_desktop_embedding/json_plugin.h | 0 .../flutter_desktop_embedding/method_call.h | 0 .../method_channel.h | 0 .../flutter_desktop_embedding/method_codec.h | 0 .../flutter_desktop_embedding/method_result.h | 0 .../flutter_desktop_embedding/plugin.h | 0 .../src/internal/keyboard_hook_handler.h | 0 .../src/internal/plugin_handler.cc | 0 .../src/internal/plugin_handler.h | 4 +- .../src/internal/text_input_model.cc | 0 .../src/internal/text_input_model.h | 0 .../src/internal/text_input_plugin.cc | 0 .../src/internal/text_input_plugin.h | 6 +- library/windows/GLFW Library.vcxproj | 4 +- library/windows/embedder.cpp | 128 +++++++++++++++--- library/windows/embedder.h | 14 +- 18 files changed, 128 insertions(+), 28 deletions(-) rename library/{linux => shared}/include/flutter_desktop_embedding/binary_messenger.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/json_method_call.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/json_plugin.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/method_call.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/method_channel.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/method_codec.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/method_result.h (100%) rename library/{linux => shared}/include/flutter_desktop_embedding/plugin.h (100%) rename library/{linux => shared}/src/internal/keyboard_hook_handler.h (100%) rename library/{linux => shared}/src/internal/plugin_handler.cc (100%) rename library/{linux => shared}/src/internal/plugin_handler.h (94%) rename library/{linux => shared}/src/internal/text_input_model.cc (100%) rename library/{linux => shared}/src/internal/text_input_model.h (100%) rename library/{linux => shared}/src/internal/text_input_plugin.cc (100%) rename library/{linux => shared}/src/internal/text_input_plugin.h (90%) diff --git a/library/linux/include/flutter_desktop_embedding/binary_messenger.h b/library/shared/include/flutter_desktop_embedding/binary_messenger.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/binary_messenger.h rename to library/shared/include/flutter_desktop_embedding/binary_messenger.h diff --git a/library/linux/include/flutter_desktop_embedding/json_method_call.h b/library/shared/include/flutter_desktop_embedding/json_method_call.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/json_method_call.h rename to library/shared/include/flutter_desktop_embedding/json_method_call.h diff --git a/library/linux/include/flutter_desktop_embedding/json_plugin.h b/library/shared/include/flutter_desktop_embedding/json_plugin.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/json_plugin.h rename to library/shared/include/flutter_desktop_embedding/json_plugin.h diff --git a/library/linux/include/flutter_desktop_embedding/method_call.h b/library/shared/include/flutter_desktop_embedding/method_call.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/method_call.h rename to library/shared/include/flutter_desktop_embedding/method_call.h diff --git a/library/linux/include/flutter_desktop_embedding/method_channel.h b/library/shared/include/flutter_desktop_embedding/method_channel.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/method_channel.h rename to library/shared/include/flutter_desktop_embedding/method_channel.h diff --git a/library/linux/include/flutter_desktop_embedding/method_codec.h b/library/shared/include/flutter_desktop_embedding/method_codec.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/method_codec.h rename to library/shared/include/flutter_desktop_embedding/method_codec.h diff --git a/library/linux/include/flutter_desktop_embedding/method_result.h b/library/shared/include/flutter_desktop_embedding/method_result.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/method_result.h rename to library/shared/include/flutter_desktop_embedding/method_result.h diff --git a/library/linux/include/flutter_desktop_embedding/plugin.h b/library/shared/include/flutter_desktop_embedding/plugin.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/plugin.h rename to library/shared/include/flutter_desktop_embedding/plugin.h diff --git a/library/linux/src/internal/keyboard_hook_handler.h b/library/shared/src/internal/keyboard_hook_handler.h similarity index 100% rename from library/linux/src/internal/keyboard_hook_handler.h rename to library/shared/src/internal/keyboard_hook_handler.h diff --git a/library/linux/src/internal/plugin_handler.cc b/library/shared/src/internal/plugin_handler.cc similarity index 100% rename from library/linux/src/internal/plugin_handler.cc rename to library/shared/src/internal/plugin_handler.cc diff --git a/library/linux/src/internal/plugin_handler.h b/library/shared/src/internal/plugin_handler.h similarity index 94% rename from library/linux/src/internal/plugin_handler.h rename to library/shared/src/internal/plugin_handler.h index 46c1e06c1..853f99ae7 100644 --- a/library/linux/src/internal/plugin_handler.h +++ b/library/shared/src/internal/plugin_handler.h @@ -20,8 +20,8 @@ #include -#include "library/linux/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/linux/include/flutter_desktop_embedding/plugin.h" +#include "library/shared/include/flutter_desktop_embedding/binary_messenger.h" +#include "library/shared/include/flutter_desktop_embedding/plugin.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/internal/text_input_model.cc b/library/shared/src/internal/text_input_model.cc similarity index 100% rename from library/linux/src/internal/text_input_model.cc rename to library/shared/src/internal/text_input_model.cc diff --git a/library/linux/src/internal/text_input_model.h b/library/shared/src/internal/text_input_model.h similarity index 100% rename from library/linux/src/internal/text_input_model.h rename to library/shared/src/internal/text_input_model.h diff --git a/library/linux/src/internal/text_input_plugin.cc b/library/shared/src/internal/text_input_plugin.cc similarity index 100% rename from library/linux/src/internal/text_input_plugin.cc rename to library/shared/src/internal/text_input_plugin.cc diff --git a/library/linux/src/internal/text_input_plugin.h b/library/shared/src/internal/text_input_plugin.h similarity index 90% rename from library/linux/src/internal/text_input_plugin.h rename to library/shared/src/internal/text_input_plugin.h index 9c0c5e3d8..686f5d062 100644 --- a/library/linux/src/internal/text_input_plugin.h +++ b/library/shared/src/internal/text_input_plugin.h @@ -17,9 +17,9 @@ #include #include -#include "library/linux/include/flutter_desktop_embedding/json_plugin.h" -#include "library/linux/src/internal/keyboard_hook_handler.h" -#include "library/linux/src/internal/text_input_model.h" +#include "library/shared/include/flutter_desktop_embedding/json_plugin.h" +#include "library/shared/src/internal/keyboard_hook_handler.h" +#include "library/shared/src/internal/text_input_model.h" namespace flutter_desktop_embedding { diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 2df1af2eb..c6cd7ed2d 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -75,7 +75,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) @@ -270,4 +270,4 @@ - + \ No newline at end of file diff --git a/library/windows/embedder.cpp b/library/windows/embedder.cpp index a601c9c73..1b6d1d78b 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/embedder.cpp @@ -21,13 +21,30 @@ #include +#include "library/shared/src/internal/keyboard_hook_handler.h" +#include "library/shared/src/internal/plugin_handler.h" +#include "library/shared/src/internal/text_input_plugin.h" + static_assert(FLUTTER_ENGINE_VERSION == 1, ""); +// Struct for storing state within an instance of the GLFW Window. +struct FlutterEmbedderState { + FlutterEngine engine; + std::unique_ptr plugin_handler; + + // plugin_handler owns these pointers. Destruction happens when this struct is + // deleted from the heap. + std::vector + keyboard_hook_handlers; +}; + static constexpr char kDefaultWindowTitle[] = "Flutter"; -bool FlutterInit() { return glfwInit(); } -void FlutterTerminate() { glfwTerminate(); } +static FlutterEmbedderState *GetSavedEmbedderState(GLFWwindow *window) { + return reinterpret_cast( + glfwGetWindowUserPointer(window)); +} static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, FlutterPointerPhase phase, @@ -41,8 +58,7 @@ static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); - FlutterEngineSendPointerEvent( - reinterpret_cast(glfwGetWindowUserPointer(window)), &event, + FlutterEngineSendPointerEvent(GetSavedEmbedderState(window)->engine, &event, 1); } @@ -65,9 +81,20 @@ static void GLFWmouseButtonCallback(GLFWwindow *window, int key, int action, } } +static void GLFWCharCallback(GLFWwindow *window, unsigned int code_point) { + for (flutter_desktop_embedding::KeyboardHookHandler *handler : + GetSavedEmbedderState(window)->keyboard_hook_handlers) { + handler->CharHook(window, code_point); + } +} + static void GLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { + for (flutter_desktop_embedding::KeyboardHookHandler *handler : + GetSavedEmbedderState(window)->keyboard_hook_handlers) { + handler->KeyboardHook(window, key, scancode, action, mods); + } + if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { glfwSetWindowShouldClose(window, GLFW_TRUE); } } @@ -79,11 +106,41 @@ static void GLFWwindowSizeCallback(GLFWwindow *window, int width, int height) { event.height = height; // TODO: Handle pixel ratio for different DPI monitors. event.pixel_ratio = 1.0; - FlutterEngineSendWindowMetricsEvent( - reinterpret_cast(glfwGetWindowUserPointer(window)), + FlutterEngineSendWindowMetricsEvent(GetSavedEmbedderState(window)->engine, &event); } +// Flushes event queue and then assigns default window callbacks. +static void GLFWAssignEventCallbacks(GLFWwindow *window) { + glfwPollEvents(); + glfwSetKeyCallback(window, GLFWKeyCallback); + glfwSetCharCallback(window, GLFWCharCallback); + glfwSetMouseButtonCallback(window, GLFWmouseButtonCallback); +} + +// Clears default window events. +static void GLFWClearEventCallbacks(GLFWwindow *window) { + glfwSetKeyCallback(window, nullptr); + glfwSetCharCallback(window, nullptr); + glfwSetMouseButtonCallback(window, nullptr); +} + +static void GLFWOnFlutterPlatformMessage(const FlutterPlatformMessage *message, + void *user_data) { + if (message->struct_size != sizeof(FlutterPlatformMessage)) { + std::cerr << "Invalid message size received. Expected: " + << sizeof(FlutterPlatformMessage) << " but received " + << message->struct_size << std::endl; + return; + } + + GLFWwindow *window = reinterpret_cast(user_data); + auto state = GetSavedEmbedderState(window); + state->plugin_handler->HandleMethodCallMessage( + message, [window] { GLFWClearEventCallbacks(window); }, + [window] { GLFWAssignEventCallbacks(window); }); +} + static bool GLFWMakeContextCurrent(void *user_data) { GLFWwindow *window = reinterpret_cast(user_data); glfwMakeContextCurrent(window); @@ -152,6 +209,7 @@ static FlutterEngine RunFlutterEngine( args.icu_data_path = icu_data_path.c_str(); args.command_line_argc = argv.size(); args.command_line_argv = &argv[0]; + args.platform_message_callback = GLFWOnFlutterPlatformMessage; FlutterEngine engine = nullptr; auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args, window, &engine); @@ -161,6 +219,27 @@ static FlutterEngine RunFlutterEngine( return engine; } +namespace flutter_desktop_embedding { + +bool FlutterInit() { return glfwInit(); } + +void FlutterTerminate() { glfwTerminate(); } + +bool AddPlugin(GLFWwindow *flutter_window, + std::unique_ptr plugin) { + auto state = GetSavedEmbedderState(flutter_window); + plugin->set_flutter_engine(state->engine); + return state->plugin_handler->AddPlugin(std::move(plugin)); +} + +GLFWwindow *CreateFlutterWindowInSnapshotMode( + size_t initial_width, size_t initial_height, const std::string &assets_path, + const std::string &icu_data_path, + const std::vector &arguments) { + return CreateFlutterWindow(initial_width, initial_height, "", assets_path, "", + icu_data_path, arguments); +} + GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, const std::string &main_path, const std::string &assets_path, @@ -173,35 +252,44 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, return nullptr; } GLFWClearCanvas(window); - auto flutter_engine_run_result = RunFlutterEngine( + auto engine = RunFlutterEngine( window, main_path, assets_path, packages_path, icu_data_path, arguments); - if (flutter_engine_run_result == nullptr) { + if (engine == nullptr) { glfwDestroyWindow(window); return nullptr; } - glfwSetWindowUserPointer(window, flutter_engine_run_result); + + FlutterEmbedderState *state = new FlutterEmbedderState(); + state->plugin_handler = std::make_unique(engine); + state->engine = engine; + auto input_plugin = + std::make_unique(); + state->keyboard_hook_handlers.push_back(input_plugin.get()); + + glfwSetWindowUserPointer(window, state); + + AddPlugin(window, std::move(input_plugin)); + int width, height; glfwGetWindowSize(window, &width, &height); GLFWwindowSizeCallback(window, width, height); glfwSetKeyCallback(window, GLFWKeyCallback); glfwSetWindowSizeCallback(window, GLFWwindowSizeCallback); glfwSetMouseButtonCallback(window, GLFWmouseButtonCallback); + GLFWAssignEventCallbacks(window); return window; } -GLFWwindow *CreateFlutterWindowInSnapshotMode( - size_t initial_width, size_t initial_height, const std::string &assets_path, - const std::string &icu_data_path, - const std::vector &arguments) { - return CreateFlutterWindow(initial_width, initial_height, "", assets_path, "", - icu_data_path, arguments); -} - void FlutterWindowLoop(GLFWwindow *flutter_window) { while (!glfwWindowShouldClose(flutter_window)) { glfwWaitEvents(); + // TODO(awdavies): This will be deprecated soon. + __FlutterEngineFlushPendingTasksNow(); } - FlutterEngineShutdown(reinterpret_cast( - glfwGetWindowUserPointer(flutter_window))); + auto state = GetSavedEmbedderState(flutter_window); + FlutterEngineShutdown(state->engine); + delete state; glfwDestroyWindow(flutter_window); } + +} // namespace flutter_desktop_embedding \ No newline at end of file diff --git a/library/windows/embedder.h b/library/windows/embedder.h index 5d52c1c18..623710a0a 100644 --- a/library/windows/embedder.h +++ b/library/windows/embedder.h @@ -18,7 +18,11 @@ #include #include -#include +#include "library/shared/include/flutter_desktop_embedding/plugin.h" + +#include + +namespace flutter_desktop_embedding { // Calls glfwInit() // @@ -65,6 +69,12 @@ GLFWwindow *CreateFlutterWindowInSnapshotMode( const std::string &icu_data_path, const std::vector &arguments); +// Adds a plugin to the flutter_window. +// +// If a plugin already exists for this plugin's channel, returns false. +// Otherwise returns true. +bool AddPlugin(GLFWwindow *flutter_window, std::unique_ptr plugin); + // Loops on flutter window events until termination. // // Must be used instead of glfwWindowShouldClose as it cleans up engine state @@ -74,4 +84,6 @@ GLFWwindow *CreateFlutterWindowInSnapshotMode( // cleanup. void FlutterWindowLoop(GLFWwindow *flutter_window); +} // namespace flutter_desktop_embedding + #endif // WINDOWS_LIBRARY_EMBEDDER_H_ From 45caf82e5286664767520b8bb3aedb2f776dcf12 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 20:00:58 -0800 Subject: [PATCH 02/21] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3acb573cf..30206d268 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ out/ .DS_Store +library/windows/dependencies \ No newline at end of file From 79558642f4f69f546e3a45ebf58286023e2d6e3e Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 20:09:07 -0800 Subject: [PATCH 03/21] Fix adding plugin --- library/windows/embedder.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/library/windows/embedder.cpp b/library/windows/embedder.cpp index 1b6d1d78b..4a2239c70 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/embedder.cpp @@ -228,7 +228,6 @@ void FlutterTerminate() { glfwTerminate(); } bool AddPlugin(GLFWwindow *flutter_window, std::unique_ptr plugin) { auto state = GetSavedEmbedderState(flutter_window); - plugin->set_flutter_engine(state->engine); return state->plugin_handler->AddPlugin(std::move(plugin)); } From ea67a73c98723538e8eeaac431e7f9509336fa43 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 21:05:00 -0800 Subject: [PATCH 04/21] WIP --- .../src/internal/engine_method_result.cc | 0 .../src/internal/engine_method_result.h | 6 +- library/shared/src/internal/plugin_handler.cc | 6 +- library/windows/GLFW Library.vcxproj | 2 + library/windows/GLFW Library.vcxproj.filters | 65 ++++++++++--------- 5 files changed, 42 insertions(+), 37 deletions(-) rename library/{linux => shared}/src/internal/engine_method_result.cc (100%) rename library/{linux => shared}/src/internal/engine_method_result.h (89%) diff --git a/library/linux/src/internal/engine_method_result.cc b/library/shared/src/internal/engine_method_result.cc similarity index 100% rename from library/linux/src/internal/engine_method_result.cc rename to library/shared/src/internal/engine_method_result.cc diff --git a/library/linux/src/internal/engine_method_result.h b/library/shared/src/internal/engine_method_result.h similarity index 89% rename from library/linux/src/internal/engine_method_result.h rename to library/shared/src/internal/engine_method_result.h index 23d9427d8..8537181dc 100644 --- a/library/linux/src/internal/engine_method_result.h +++ b/library/shared/src/internal/engine_method_result.h @@ -17,9 +17,9 @@ #include #include -#include "library/linux/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/linux/include/flutter_desktop_embedding/method_codec.h" -#include "library/linux/include/flutter_desktop_embedding/method_result.h" +#include "library/shared/include/flutter_desktop_embedding/binary_messenger.h" +#include "library/shared/include/flutter_desktop_embedding/method_codec.h" +#include "library/shared/include/flutter_desktop_embedding/method_result.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/internal/plugin_handler.cc b/library/shared/src/internal/plugin_handler.cc index 4acb94e5f..35064da9e 100644 --- a/library/shared/src/internal/plugin_handler.cc +++ b/library/shared/src/internal/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/linux/src/internal/plugin_handler.h" +#include "library/shared/src/internal/plugin_handler.h" -#include "library/linux/include/flutter_desktop_embedding/method_channel.h" -#include "library/linux/src/internal/engine_method_result.h" +#include "library/shared/include/flutter_desktop_embedding/method_channel.h" +#include "library/shared/src/internal/engine_method_result.h" #include diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index c6cd7ed2d..e454565d4 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -77,6 +77,7 @@ .dll $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)..\..\library\shared\src\internal;$(SourcePath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ @@ -259,6 +260,7 @@ + diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index 58963352d..d9993d9bb 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -1,32 +1,35 @@ - - - - - {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 - - - - - Header Files - - - - - 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 + + + + + Source Files + + + Source Files + + + + + Header Files + + + + + Source Files + + \ No newline at end of file From 76ff507bb3f6d9e8463179f6e91e1036d6e3be6e Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 21:18:00 -0800 Subject: [PATCH 05/21] WIP --- library/shared/src/internal/engine_method_result.cc | 2 +- library/shared/src/internal/plugin_handler.cc | 8 ++++---- library/shared/src/internal/text_input_model.cc | 2 +- library/shared/src/internal/text_input_plugin.cc | 2 +- library/windows/GLFW Library.vcxproj | 3 +++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/library/shared/src/internal/engine_method_result.cc b/library/shared/src/internal/engine_method_result.cc index 46850f3f2..4be18358a 100644 --- a/library/shared/src/internal/engine_method_result.cc +++ b/library/shared/src/internal/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/linux/src/internal/engine_method_result.h" +#include "library/shared/src/internal/engine_method_result.h" #include diff --git a/library/shared/src/internal/plugin_handler.cc b/library/shared/src/internal/plugin_handler.cc index 35064da9e..97d9eada3 100644 --- a/library/shared/src/internal/plugin_handler.cc +++ b/library/shared/src/internal/plugin_handler.cc @@ -81,10 +81,10 @@ void PluginHandler::HandleMethodCallMessage( void PluginHandler::Send(const std::string &channel, const uint8_t *message, const size_t message_size) const { FlutterPlatformMessage platform_message = { - .struct_size = sizeof(FlutterPlatformMessage), - .channel = channel.c_str(), - .message = message, - .message_size = message_size, + sizeof(FlutterPlatformMessage), + channel.c_str(), + message, + message_size, }; FlutterEngineSendPlatformMessage(engine_, &platform_message); } diff --git a/library/shared/src/internal/text_input_model.cc b/library/shared/src/internal/text_input_model.cc index 127b370b5..5b97fb8b6 100644 --- a/library/shared/src/internal/text_input_model.cc +++ b/library/shared/src/internal/text_input_model.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/linux/src/internal/text_input_model.h" +#include "library/shared/src/internal/text_input_model.h" #include diff --git a/library/shared/src/internal/text_input_plugin.cc b/library/shared/src/internal/text_input_plugin.cc index ffef8ecbd..5a04ea684 100644 --- a/library/shared/src/internal/text_input_plugin.cc +++ b/library/shared/src/internal/text_input_plugin.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/linux/src/internal/text_input_plugin.h" +#include "library/shared/src/internal/text_input_plugin.h" #include #include diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index e454565d4..24efc8ad6 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -260,7 +260,10 @@ + + + From a20bdc6c219dfe143a7ffe9e42e51c29706a68d8 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 21:35:10 -0800 Subject: [PATCH 06/21] WIP --- .../flutter_desktop_embedding/json_method_codec.h | 0 .../src/internal/json_message_codec.cc | 2 +- .../src/internal/json_message_codec.h | 0 library/{linux => shared}/src/json_method_call.cc | 2 +- library/{linux => shared}/src/json_method_codec.cc | 6 +++--- library/{linux => shared}/src/json_plugin.cc | 4 ++-- library/{linux => shared}/src/method_channel.cc | 4 ++-- library/{linux => shared}/src/method_codec.cc | 2 +- library/{linux => shared}/src/method_result.cc | 2 +- library/{linux => shared}/src/plugin.cc | 4 ++-- library/windows/GLFW Library.vcxproj | 13 +++++++++++-- 11 files changed, 24 insertions(+), 15 deletions(-) rename library/{linux => shared}/include/flutter_desktop_embedding/json_method_codec.h (100%) rename library/{linux => shared}/src/internal/json_message_codec.cc (96%) rename library/{linux => shared}/src/internal/json_message_codec.h (100%) rename library/{linux => shared}/src/json_method_call.cc (92%) rename library/{linux => shared}/src/json_method_codec.cc (93%) rename library/{linux => shared}/src/json_plugin.cc (92%) rename library/{linux => shared}/src/method_channel.cc (93%) rename library/{linux => shared}/src/method_codec.cc (95%) rename library/{linux => shared}/src/method_result.cc (93%) rename library/{linux => shared}/src/plugin.cc (89%) diff --git a/library/linux/include/flutter_desktop_embedding/json_method_codec.h b/library/shared/include/flutter_desktop_embedding/json_method_codec.h similarity index 100% rename from library/linux/include/flutter_desktop_embedding/json_method_codec.h rename to library/shared/include/flutter_desktop_embedding/json_method_codec.h diff --git a/library/linux/src/internal/json_message_codec.cc b/library/shared/src/internal/json_message_codec.cc similarity index 96% rename from library/linux/src/internal/json_message_codec.cc rename to library/shared/src/internal/json_message_codec.cc index ad40e807b..de2b14625 100644 --- a/library/linux/src/internal/json_message_codec.cc +++ b/library/shared/src/internal/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/linux/src/internal/json_message_codec.h" +#include "library/shared/src/internal/json_message_codec.h" #include #include diff --git a/library/linux/src/internal/json_message_codec.h b/library/shared/src/internal/json_message_codec.h similarity index 100% rename from library/linux/src/internal/json_message_codec.h rename to library/shared/src/internal/json_message_codec.h diff --git a/library/linux/src/json_method_call.cc b/library/shared/src/json_method_call.cc similarity index 92% rename from library/linux/src/json_method_call.cc rename to library/shared/src/json_method_call.cc index 3acdfaf9e..b7cfded02 100644 --- a/library/linux/src/json_method_call.cc +++ b/library/shared/src/json_method_call.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/linux/include/flutter_desktop_embedding/json_method_call.h" +#include "library/shared/include/flutter_desktop_embedding/json_method_call.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/json_method_codec.cc b/library/shared/src/json_method_codec.cc similarity index 93% rename from library/linux/src/json_method_codec.cc rename to library/shared/src/json_method_codec.cc index 29107110f..99dcd92d5 100644 --- a/library/linux/src/json_method_codec.cc +++ b/library/shared/src/json_method_codec.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/linux/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/shared/include/flutter_desktop_embedding/json_method_codec.h" -#include "library/linux/include/flutter_desktop_embedding/json_method_call.h" -#include "library/linux/src/internal/json_message_codec.h" +#include "library/shared/include/flutter_desktop_embedding/json_method_call.h" +#include "library/shared/src/internal/json_message_codec.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/json_plugin.cc b/library/shared/src/json_plugin.cc similarity index 92% rename from library/linux/src/json_plugin.cc rename to library/shared/src/json_plugin.cc index 2cb7b56d9..503467c0e 100644 --- a/library/linux/src/json_plugin.cc +++ b/library/shared/src/json_plugin.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/linux/include/flutter_desktop_embedding/json_plugin.h" +#include "library/shared/include/flutter_desktop_embedding/json_plugin.h" -#include "library/linux/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/shared/include/flutter_desktop_embedding/json_method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/method_channel.cc b/library/shared/src/method_channel.cc similarity index 93% rename from library/linux/src/method_channel.cc rename to library/shared/src/method_channel.cc index b4201310f..ceb40cced 100644 --- a/library/linux/src/method_channel.cc +++ b/library/shared/src/method_channel.cc @@ -11,11 +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. -#include "library/linux/include/flutter_desktop_embedding/method_channel.h" +#include "library/shared/include/flutter_desktop_embedding/method_channel.h" #include -#include "library/linux/src/internal/engine_method_result.h" +#include "library/shared/src/internal/engine_method_result.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/method_codec.cc b/library/shared/src/method_codec.cc similarity index 95% rename from library/linux/src/method_codec.cc rename to library/shared/src/method_codec.cc index 03fb44bb2..a72f0ddee 100644 --- a/library/linux/src/method_codec.cc +++ b/library/shared/src/method_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/linux/include/flutter_desktop_embedding/method_codec.h" +#include "library/shared/include/flutter_desktop_embedding/method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/method_result.cc b/library/shared/src/method_result.cc similarity index 93% rename from library/linux/src/method_result.cc rename to library/shared/src/method_result.cc index 58ed27fce..56cb5afae 100644 --- a/library/linux/src/method_result.cc +++ b/library/shared/src/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/linux/include/flutter_desktop_embedding/method_result.h" +#include "library/shared/include/flutter_desktop_embedding/method_result.h" namespace flutter_desktop_embedding { diff --git a/library/linux/src/plugin.cc b/library/shared/src/plugin.cc similarity index 89% rename from library/linux/src/plugin.cc rename to library/shared/src/plugin.cc index aaf63642e..f6a63ef05 100644 --- a/library/linux/src/plugin.cc +++ b/library/shared/src/plugin.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/linux/include/flutter_desktop_embedding/plugin.h" +#include "library/shared/include/flutter_desktop_embedding/plugin.h" -#include "library/linux/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/shared/include/flutter_desktop_embedding/json_method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 24efc8ad6..ce604821d 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -76,7 +76,7 @@ flutter_embedder .dll $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\shared\src\internal;$(SourcePath) @@ -109,9 +109,10 @@ Disabled true true + MultiThreadedDebug - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies);json_vc71_libmt.lib exports.def @@ -261,9 +262,17 @@ + + + + + + + + From de5263c81adddf96afd312312da87a83da71032f Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 27 Nov 2018 21:38:25 -0800 Subject: [PATCH 07/21] WIP --- library/{linux => shared}/src/method_call.cc | 2 +- library/windows/GLFW Library.vcxproj | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename library/{linux => shared}/src/method_call.cc (91%) diff --git a/library/linux/src/method_call.cc b/library/shared/src/method_call.cc similarity index 91% rename from library/linux/src/method_call.cc rename to library/shared/src/method_call.cc index adbcbc972..c7784947d 100644 --- a/library/linux/src/method_call.cc +++ b/library/shared/src/method_call.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/linux/include/flutter_desktop_embedding/method_call.h" +#include "library/shared/include/flutter_desktop_embedding/method_call.h" namespace flutter_desktop_embedding { diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index ce604821d..3bcf4be72 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -269,6 +269,7 @@ + From 86abb4cbabf08ac0f948c9329e6f2ef7030fd664 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 29 Nov 2018 23:19:56 -0800 Subject: [PATCH 08/21] Fix up things --- example/windows/flutter_embedder_example.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/windows/flutter_embedder_example.cpp b/example/windows/flutter_embedder_example.cpp index d8485e70f..d62469738 100644 --- a/example/windows/flutter_embedder_example.cpp +++ b/example/windows/flutter_embedder_example.cpp @@ -15,7 +15,9 @@ #include #include -#include +#include "embedder.h" + +using namespace flutter_desktop_embedding; int main(int argc, char **argv) { if (!FlutterInit()) { From acdec7c64bc08f1b02717ba2ffcae30e5bafafab Mon Sep 17 00:00:00 2001 From: James Clarke Date: Mon, 3 Dec 2018 20:19:09 -0800 Subject: [PATCH 09/21] Update projects --- example/windows/GLFW Example.vcxproj | 6 +++--- library/windows/GLFW Library.vcxproj | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/example/windows/GLFW Example.vcxproj b/example/windows/GLFW Example.vcxproj index 1da8b14ed..e15a6eda7 100644 --- a/example/windows/GLFW Example.vcxproj +++ b/example/windows/GLFW Example.vcxproj @@ -72,7 +72,7 @@ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\;$(IncludePath);$(ProjectDir)..\..\library\windows\ $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) @@ -84,7 +84,7 @@ $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ - $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(ProjectDir)..\..\library\windows\;$(IncludePath) + $(ProjectDir)..\..\library\windows\dependencies\;$(ProjectDir)..\..\;$(IncludePath);$(ProjectDir)..\..\library\windows\ $(ProjectDir)..\..\library\windows\dependencies\GLFW\;$(SolutionDir)bin\$(Platform)\$(Configuration)\GLFW Library\;$(LibraryPath) @@ -227,4 +227,4 @@ $(SolutionDir) - + \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 3bcf4be72..7f20ed4a5 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -76,7 +76,7 @@ flutter_embedder .dll $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\debug;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\shared\src\internal;$(SourcePath) @@ -92,8 +92,9 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(IncludePath) - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\release;;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) + $(ProjectDir)..\..\library\shared\src\internal;$(SourcePath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ @@ -109,10 +110,10 @@ Disabled true true - MultiThreadedDebug + MultiThreadedDebugDLL - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies);json_vc71_libmt.lib + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies);json_vc71_libmtd.lib exports.def @@ -188,11 +189,12 @@ true true true + MultiThreadedDLL true true - flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies) + flutter_engine.dll.lib;glfw3.lib;opengl32.lib;%(AdditionalDependencies);json_vc71_libmt.lib exports.def $(OutDir)$(TargetName)$(TargetExt) $(OutDir)$(TargetName).lib From 24689ffaffa5b561a5763ed69910746a74a6b7e3 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 4 Dec 2018 04:55:44 -0800 Subject: [PATCH 10/21] Fixup linux paths --- library/BUILD.gn | 58 +++++++++++++++++++++--------------------- library/linux/BUILD.gn | 1 + library/linux/Makefile | 1 + 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/library/BUILD.gn b/library/BUILD.gn index 6a08b7663..64ead918f 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -19,38 +19,38 @@ import("//library/engine.gni") published_shared_library("flutter_embedder") { if (is_linux) { sources = [ - "linux/src/internal/engine_method_result.cc", - "linux/src/internal/engine_method_result.h", - "linux/src/internal/json_message_codec.cc", - "linux/src/internal/json_message_codec.h", - "linux/src/internal/keyboard_hook_handler.h", - "linux/src/internal/plugin_handler.cc", - "linux/src/internal/plugin_handler.h", - "linux/src/internal/text_input_model.cc", - "linux/src/internal/text_input_model.h", - "linux/src/internal/text_input_plugin.cc", - "linux/src/internal/text_input_plugin.h", - "linux/src/embedder.cc", - "linux/src/json_method_call.cc", - "linux/src/json_method_codec.cc", - "linux/src/json_plugin.cc", - "linux/src/method_call.cc", - "linux/src/method_channel.cc", - "linux/src/method_codec.cc", - "linux/src/method_result.cc", - "linux/src/plugin.cc", + "shared/src/internal/engine_method_result.cc", + "shared/src/internal/engine_method_result.h", + "shared/src/internal/json_message_codec.cc", + "shared/src/internal/json_message_codec.h", + "shared/src/internal/keyboard_hook_handler.h", + "shared/src/internal/plugin_handler.cc", + "shared/src/internal/plugin_handler.h", + "shared/src/internal/text_input_model.cc", + "shared/src/internal/text_input_model.h", + "shared/src/internal/text_input_plugin.cc", + "shared/src/internal/text_input_plugin.h", + "shared/src/embedder.cc", + "shared/src/json_method_call.cc", + "shared/src/json_method_codec.cc", + "shared/src/json_plugin.cc", + "shared/src/method_call.cc", + "shared/src/method_channel.cc", + "shared/src/method_codec.cc", + "shared/src/method_result.cc", + "shared/src/plugin.cc", ] public = [ - "linux/include/flutter_desktop_embedding/binary_messenger.h", + "shared/include/flutter_desktop_embedding/binary_messenger.h", "linux/include/flutter_desktop_embedding/embedder.h", - "linux/include/flutter_desktop_embedding/json_method_call.h", - "linux/include/flutter_desktop_embedding/json_method_codec.h", - "linux/include/flutter_desktop_embedding/json_plugin.h", - "linux/include/flutter_desktop_embedding/method_call.h", - "linux/include/flutter_desktop_embedding/method_channel.h", - "linux/include/flutter_desktop_embedding/method_codec.h", - "linux/include/flutter_desktop_embedding/method_result.h", - "linux/include/flutter_desktop_embedding/plugin.h", + "shared/include/flutter_desktop_embedding/json_method_call.h", + "shared/include/flutter_desktop_embedding/json_method_codec.h", + "shared/include/flutter_desktop_embedding/json_plugin.h", + "shared/include/flutter_desktop_embedding/method_call.h", + "shared/include/flutter_desktop_embedding/method_channel.h", + "shared/include/flutter_desktop_embedding/method_codec.h", + "shared/include/flutter_desktop_embedding/method_result.h", + "shared/include/flutter_desktop_embedding/plugin.h", ] } diff --git a/library/linux/BUILD.gn b/library/linux/BUILD.gn index c9e903509..be8094bd5 100644 --- a/library/linux/BUILD.gn +++ b/library/linux/BUILD.gn @@ -20,6 +20,7 @@ import("//library/engine.gni") config("relative_public_headers") { include_dirs = [ "include", + "../shared/include" ] } diff --git a/library/linux/Makefile b/library/linux/Makefile index e2f2b4b07..eaa0031ac 100644 --- a/library/linux/Makefile +++ b/library/linux/Makefile @@ -32,6 +32,7 @@ LDFLAGS= -L$(CURDIR) \ LIBRARIES=$(FLUTTER_ENGINE_LIB_FILE) HEADERS=$(shell find include/ -type f -name '*.h') +SHAREDHEADERS=$(shell find ../shared/include/ -type f -name '*.h') SOURCES=$(shell find src/ -type f -name '*.cc') .PHONY: all From 6a15943b74915a8bb42669aef7cf7843beb0ca2e Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 4 Dec 2018 05:32:44 -0800 Subject: [PATCH 11/21] add script to fetch the json library --- library/windows/GLFW Library.vcxproj | 2 +- library/windows/scripts/get_jsonlib.bat | 35 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 library/windows/scripts/get_jsonlib.bat diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 7f20ed4a5..c28046b52 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -205,7 +205,7 @@ - $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW + $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\get_jsonlib Get the flutter engine, engine artifacts and GLFW diff --git a/library/windows/scripts/get_jsonlib.bat b/library/windows/scripts/get_jsonlib.bat new file mode 100644 index 000000000..3151a664c --- /dev/null +++ b/library/windows/scripts/get_jsonlib.bat @@ -0,0 +1,35 @@ +:: Copyright 2018 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. +@echo off + +set DEPENDSDIREXISTS=true +if not exist %~dp0..\dependencies set DEPENDSDIREXISTS=false + +if %DEPENDSDIREXISTS% == false ( + mkdir %~dp0..\dependencies +) + +set JSONEXISTS=true +if not exist %~dp0..\dependencies\json\json.h set JSONEXISTS=false + +if %JSONEXISTS%==false ( + PowerShell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing -Uri https://github.com/clarkezone/jsoncpp/releases/download/1.8.4/jsoncpp.zip -OutFile "%~dp0..\dependencies\jsoncpp.zip + PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive -LiteralPath %~dp0..\dependencies\jsoncpp.zip -DestinationPath "%~dp0..\dependencies\json + DEL %~dp0..\dependencies\jsoncpp.zip +) else ( + ECHO JSON dependencies found. +) + +:DONE + From caadc2e732de3df891f92c6257704fd72d0dd3e9 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sun, 9 Dec 2018 13:34:51 -0800 Subject: [PATCH 12/21] PR Feedback part 1: reorder headers, removing using, move git ignore, remove binary dependency on jsoncpp and compile from source instead. --- example/windows/flutter_embedder_example.cpp | 12 +-- library/windows/.gitignore | 4 + library/windows/GLFW Library.vcxproj | 4 +- library/windows/dependencies/json/.gitkeep | 0 library/windows/embedder.h | 4 +- library/windows/scripts/build_jsonlib.bat | 100 +++++++++++++++++++ library/windows/scripts/get_jsonlib.bat | 35 ------- 7 files changed, 113 insertions(+), 46 deletions(-) create mode 100644 library/windows/dependencies/json/.gitkeep create mode 100644 library/windows/scripts/build_jsonlib.bat delete mode 100644 library/windows/scripts/get_jsonlib.bat diff --git a/example/windows/flutter_embedder_example.cpp b/example/windows/flutter_embedder_example.cpp index d62469738..165bbd55e 100644 --- a/example/windows/flutter_embedder_example.cpp +++ b/example/windows/flutter_embedder_example.cpp @@ -17,10 +17,8 @@ #include "embedder.h" -using namespace flutter_desktop_embedding; - int main(int argc, char **argv) { - if (!FlutterInit()) { + if (!flutter_desktop_embedding::FlutterInit()) { std::cout << "Couldn't init GLFW" << std::endl; } // Arguments for the Flutter Engine. @@ -33,15 +31,15 @@ int main(int argc, char **argv) { #endif // Start the engine. // TODO: Make paths relative to the executable so it can be run from anywhere. - auto window = CreateFlutterWindowInSnapshotMode( + auto window = flutter_desktop_embedding::CreateFlutterWindowInSnapshotMode( 640, 480, "..\\..\\example\\flutter_app\\build\\flutter_assets", "..\\..\\library\\windows\\dependencies\\engine\\icudtl.dat", arguments); if (window == nullptr) { - FlutterTerminate(); + flutter_desktop_embedding::FlutterTerminate(); return EXIT_FAILURE; } - FlutterWindowLoop(window); - FlutterTerminate(); + flutter_desktop_embedding::FlutterWindowLoop(window); + flutter_desktop_embedding::FlutterTerminate(); return EXIT_SUCCESS; } diff --git a/library/windows/.gitignore b/library/windows/.gitignore index f431ddc7c..91e1d6b70 100644 --- a/library/windows/.gitignore +++ b/library/windows/.gitignore @@ -327,3 +327,7 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ + +# dependencies +dependencies +third_party \ No newline at end of file diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index c28046b52..c47ff96de 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -126,7 +126,7 @@ - $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW + $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\build_jsonlib Get the flutter engine, engine artifacts and GLFW @@ -205,7 +205,7 @@ - $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\get_jsonlib + $(ProjectDir)scripts\update_flutter_engine && $(ProjectDir)scripts\get_engine_artifacts && $(ProjectDir)scripts\get_GLFW && $(ProjectDir)scripts\build_jsonlib Get the flutter engine, engine artifacts and GLFW diff --git a/library/windows/dependencies/json/.gitkeep b/library/windows/dependencies/json/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/library/windows/embedder.h b/library/windows/embedder.h index 623710a0a..83aeb565d 100644 --- a/library/windows/embedder.h +++ b/library/windows/embedder.h @@ -15,11 +15,11 @@ #ifndef WINDOWS_LIBRARY_EMBEDDER_H_ #define WINDOWS_LIBRARY_EMBEDDER_H_ +#include "library/shared/include/flutter_desktop_embedding/plugin.h" + #include #include -#include "library/shared/include/flutter_desktop_embedding/plugin.h" - #include namespace flutter_desktop_embedding { diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat new file mode 100644 index 000000000..6bcd67a29 --- /dev/null +++ b/library/windows/scripts/build_jsonlib.bat @@ -0,0 +1,100 @@ +:: Copyright 2018 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. +@echo off + +:: Find where VS lives and start a VC command prompt +set pre=Microsoft.VisualStudio.Product. +set ids=%pre%Community %pre%Professional %pre%Enterprise %pre%BuildTools + +pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" +for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -products *`) do (if /i "%%i"=="installationPath" set InstallDir=%%j) +popd + +pushd %InstallDir%\VC\Auxiliary\Build +call vcvarsall.bat x86_amd64 +popd + +set DEPENDDIREXISTS=true +if not exist %~dp0..\dependencies\json\allocator.h set DEPENDDIREXISTS=false + +if %DEPENDDIREXISTS% == true ( + echo jsoncpp found. + goto DONE +) + +set THIRDPARTYDIREXISTS=true +if not exist %~dp0..\third_party set THIRDPARTYDIREXISTS=false + +if %THIRDPARTYDIREXISTS% == false ( + mkdir %~dp0..\third_party +) + +set JSONDIREXISTS=true +if not exist %~dp0..\third_party\jsoncpp set JSONDIREXISTS=false + +if %JSONDIREXISTS% == false ( + mkdir %~dp0..\third_party\jsoncpp +) + +set JSONEXISTS=true +if not exist %~dp0..\third_party\jsoncpp\README.md set JSONEXISTS=false + +:: Clone source +if %JSONEXISTS% == false ( + echo Cloning via git clone --branch supportvs2017 https://github.com/clarkezone/jsoncpp.git %~dp0..\third_party\jsoncpp + call git clone --branch supportvs2017 https://github.com/clarkezone/jsoncpp.git %~dp0..\third_party\jsoncpp +) + +:: Copy headers +copy %~dp0..\third_party\jsoncpp\include\json\*.h %~dp0..\dependencies\json\. + + +:: Build debug lib +echo Building debug lib: msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj +msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj + +set DEPBINDIREXISTS=true +if not exist %~dp0..\dependencies\json\x64 set DEPBINDIREXISTS=false + +if %DEPBINDIREXISTS% == false ( + mkdir %~dp0..\dependencies\json\x64 +) + +set DEPBINDBGDIREXISTS=true +if not exist %~dp0..\dependencies\json\x64\debug set DEPBINDBGDIREXISTS=false + +if %DEPBINDBGDIREXISTS% == false ( + mkdir %~dp0..\dependencies\json\x64\debug +) + +copy %~dp0..\third_party\jsoncpp\makefiles\msvc2017\x64\debug\json_vc71_libmtd.lib %~dp0..\dependencies\json\x64\debug\. + +:: Build release lib +echo Building release lib: msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj /p:Configuration=Release +msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj /p:Configuration=Release + +set DEPBINRELDIREXISTS=true +if not exist %~dp0..\dependencies\json\x64\release set DEPBINRELDIREXISTS=false + +if %DEPBINRELDIREXISTS% == false ( + mkdir %~dp0..\dependencies\json\x64\release +) + +copy %~dp0..\third_party\jsoncpp\makefiles\msvc2017\x64\release\json_vc71_libmt.lib %~dp0..\dependencies\json\x64\release\. + +:: Remove source +rmdir /s /q %~dp0..\third_party + +:DONE +echo jsoncpplib complete. \ No newline at end of file diff --git a/library/windows/scripts/get_jsonlib.bat b/library/windows/scripts/get_jsonlib.bat deleted file mode 100644 index 3151a664c..000000000 --- a/library/windows/scripts/get_jsonlib.bat +++ /dev/null @@ -1,35 +0,0 @@ -:: Copyright 2018 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. -@echo off - -set DEPENDSDIREXISTS=true -if not exist %~dp0..\dependencies set DEPENDSDIREXISTS=false - -if %DEPENDSDIREXISTS% == false ( - mkdir %~dp0..\dependencies -) - -set JSONEXISTS=true -if not exist %~dp0..\dependencies\json\json.h set JSONEXISTS=false - -if %JSONEXISTS%==false ( - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing -Uri https://github.com/clarkezone/jsoncpp/releases/download/1.8.4/jsoncpp.zip -OutFile "%~dp0..\dependencies\jsoncpp.zip - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "Expand-Archive -LiteralPath %~dp0..\dependencies\jsoncpp.zip -DestinationPath "%~dp0..\dependencies\json - DEL %~dp0..\dependencies\jsoncpp.zip -) else ( - ECHO JSON dependencies found. -) - -:DONE - From 166fedc44896f66d888ed1d673dafc6aecc9d02b Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sun, 9 Dec 2018 19:38:26 -0800 Subject: [PATCH 13/21] PR feedback part 2: shared->common, add some comments to some embedder functions, text input plugin headers / source into a glfw director --- .../binary_messenger.h | 0 .../json_method_call.h | 0 .../json_method_codec.h | 0 .../flutter_desktop_embedding/json_plugin.h | 0 .../flutter_desktop_embedding/method_call.h | 0 .../method_channel.h | 0 .../flutter_desktop_embedding/method_codec.h | 0 .../flutter_desktop_embedding/method_result.h | 0 .../flutter_desktop_embedding/plugin.h | 0 .../src/glfw}/keyboard_hook_handler.h | 0 .../src/glfw}/text_input_plugin.cc | 2 +- .../src/glfw}/text_input_plugin.h | 6 ++--- .../src/internal/engine_method_result.cc | 2 +- .../src/internal/engine_method_result.h | 6 ++--- .../src/internal/json_message_codec.cc | 2 +- .../src/internal/json_message_codec.h | 0 .../src/internal/plugin_handler.cc | 6 ++--- .../src/internal/plugin_handler.h | 4 +-- .../src/internal/text_input_model.cc | 2 +- .../src/internal/text_input_model.h | 0 .../src/json_method_call.cc | 2 +- .../src/json_method_codec.cc | 6 ++--- library/{shared => common}/src/json_plugin.cc | 4 +-- library/{shared => common}/src/method_call.cc | 2 +- .../{shared => common}/src/method_channel.cc | 4 +-- .../{shared => common}/src/method_codec.cc | 2 +- .../{shared => common}/src/method_result.cc | 2 +- library/{shared => common}/src/plugin.cc | 4 +-- library/windows/GLFW Library.vcxproj | 26 +++++++++---------- library/windows/embedder.cpp | 14 +++++++--- library/windows/embedder.h | 2 +- 31 files changed, 52 insertions(+), 46 deletions(-) rename library/{shared => common}/include/flutter_desktop_embedding/binary_messenger.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/json_method_call.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/json_method_codec.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/json_plugin.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/method_call.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/method_channel.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/method_codec.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/method_result.h (100%) rename library/{shared => common}/include/flutter_desktop_embedding/plugin.h (100%) rename library/{shared/src/internal => common/src/glfw}/keyboard_hook_handler.h (100%) rename library/{shared/src/internal => common/src/glfw}/text_input_plugin.cc (99%) rename library/{shared/src/internal => common/src/glfw}/text_input_plugin.h (91%) rename library/{shared => common}/src/internal/engine_method_result.cc (97%) rename library/{shared => common}/src/internal/engine_method_result.h (91%) rename library/{shared => common}/src/internal/json_message_codec.cc (96%) rename library/{shared => common}/src/internal/json_message_codec.h (100%) rename library/{shared => common}/src/internal/plugin_handler.cc (94%) rename library/{shared => common}/src/internal/plugin_handler.h (95%) rename library/{shared => common}/src/internal/text_input_model.cc (98%) rename library/{shared => common}/src/internal/text_input_model.h (100%) rename library/{shared => common}/src/json_method_call.cc (94%) rename library/{shared => common}/src/json_method_codec.cc (93%) rename library/{shared => common}/src/json_plugin.cc (93%) rename library/{shared => common}/src/method_call.cc (92%) rename library/{shared => common}/src/method_channel.cc (94%) rename library/{shared => common}/src/method_codec.cc (95%) rename library/{shared => common}/src/method_result.cc (94%) rename library/{shared => common}/src/plugin.cc (90%) diff --git a/library/shared/include/flutter_desktop_embedding/binary_messenger.h b/library/common/include/flutter_desktop_embedding/binary_messenger.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/binary_messenger.h rename to library/common/include/flutter_desktop_embedding/binary_messenger.h diff --git a/library/shared/include/flutter_desktop_embedding/json_method_call.h b/library/common/include/flutter_desktop_embedding/json_method_call.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/json_method_call.h rename to library/common/include/flutter_desktop_embedding/json_method_call.h diff --git a/library/shared/include/flutter_desktop_embedding/json_method_codec.h b/library/common/include/flutter_desktop_embedding/json_method_codec.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/json_method_codec.h rename to library/common/include/flutter_desktop_embedding/json_method_codec.h diff --git a/library/shared/include/flutter_desktop_embedding/json_plugin.h b/library/common/include/flutter_desktop_embedding/json_plugin.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/json_plugin.h rename to library/common/include/flutter_desktop_embedding/json_plugin.h diff --git a/library/shared/include/flutter_desktop_embedding/method_call.h b/library/common/include/flutter_desktop_embedding/method_call.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/method_call.h rename to library/common/include/flutter_desktop_embedding/method_call.h diff --git a/library/shared/include/flutter_desktop_embedding/method_channel.h b/library/common/include/flutter_desktop_embedding/method_channel.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/method_channel.h rename to library/common/include/flutter_desktop_embedding/method_channel.h diff --git a/library/shared/include/flutter_desktop_embedding/method_codec.h b/library/common/include/flutter_desktop_embedding/method_codec.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/method_codec.h rename to library/common/include/flutter_desktop_embedding/method_codec.h diff --git a/library/shared/include/flutter_desktop_embedding/method_result.h b/library/common/include/flutter_desktop_embedding/method_result.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/method_result.h rename to library/common/include/flutter_desktop_embedding/method_result.h diff --git a/library/shared/include/flutter_desktop_embedding/plugin.h b/library/common/include/flutter_desktop_embedding/plugin.h similarity index 100% rename from library/shared/include/flutter_desktop_embedding/plugin.h rename to library/common/include/flutter_desktop_embedding/plugin.h diff --git a/library/shared/src/internal/keyboard_hook_handler.h b/library/common/src/glfw/keyboard_hook_handler.h similarity index 100% rename from library/shared/src/internal/keyboard_hook_handler.h rename to library/common/src/glfw/keyboard_hook_handler.h diff --git a/library/shared/src/internal/text_input_plugin.cc b/library/common/src/glfw/text_input_plugin.cc similarity index 99% rename from library/shared/src/internal/text_input_plugin.cc rename to library/common/src/glfw/text_input_plugin.cc index 5a04ea684..56dde0f5b 100644 --- a/library/shared/src/internal/text_input_plugin.cc +++ b/library/common/src/glfw/text_input_plugin.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/shared/src/internal/text_input_plugin.h" +#include "library/common/src/glfw/text_input_plugin.h" #include #include diff --git a/library/shared/src/internal/text_input_plugin.h b/library/common/src/glfw/text_input_plugin.h similarity index 91% rename from library/shared/src/internal/text_input_plugin.h rename to library/common/src/glfw/text_input_plugin.h index 686f5d062..0cd8f5973 100644 --- a/library/shared/src/internal/text_input_plugin.h +++ b/library/common/src/glfw/text_input_plugin.h @@ -17,9 +17,9 @@ #include #include -#include "library/shared/include/flutter_desktop_embedding/json_plugin.h" -#include "library/shared/src/internal/keyboard_hook_handler.h" -#include "library/shared/src/internal/text_input_model.h" +#include "library/common/include/flutter_desktop_embedding/json_plugin.h" +#include "library/common/src/glfw/keyboard_hook_handler.h" +#include "library/common/src/internal/text_input_model.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/internal/engine_method_result.cc b/library/common/src/internal/engine_method_result.cc similarity index 97% rename from library/shared/src/internal/engine_method_result.cc rename to library/common/src/internal/engine_method_result.cc index 4be18358a..db5590da4 100644 --- a/library/shared/src/internal/engine_method_result.cc +++ b/library/common/src/internal/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/shared/src/internal/engine_method_result.h" +#include "library/common/src/internal/engine_method_result.h" #include diff --git a/library/shared/src/internal/engine_method_result.h b/library/common/src/internal/engine_method_result.h similarity index 91% rename from library/shared/src/internal/engine_method_result.h rename to library/common/src/internal/engine_method_result.h index 8537181dc..89c3e8f7f 100644 --- a/library/shared/src/internal/engine_method_result.h +++ b/library/common/src/internal/engine_method_result.h @@ -17,9 +17,9 @@ #include #include -#include "library/shared/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/shared/include/flutter_desktop_embedding/method_codec.h" -#include "library/shared/include/flutter_desktop_embedding/method_result.h" +#include "library/common/include/flutter_desktop_embedding/binary_messenger.h" +#include "library/common/include/flutter_desktop_embedding/method_codec.h" +#include "library/common/include/flutter_desktop_embedding/method_result.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/internal/json_message_codec.cc b/library/common/src/internal/json_message_codec.cc similarity index 96% rename from library/shared/src/internal/json_message_codec.cc rename to library/common/src/internal/json_message_codec.cc index de2b14625..90c7fb3fd 100644 --- a/library/shared/src/internal/json_message_codec.cc +++ b/library/common/src/internal/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/shared/src/internal/json_message_codec.h" +#include "library/common/src/internal/json_message_codec.h" #include #include diff --git a/library/shared/src/internal/json_message_codec.h b/library/common/src/internal/json_message_codec.h similarity index 100% rename from library/shared/src/internal/json_message_codec.h rename to library/common/src/internal/json_message_codec.h diff --git a/library/shared/src/internal/plugin_handler.cc b/library/common/src/internal/plugin_handler.cc similarity index 94% rename from library/shared/src/internal/plugin_handler.cc rename to library/common/src/internal/plugin_handler.cc index 97d9eada3..20b383b47 100644 --- a/library/shared/src/internal/plugin_handler.cc +++ b/library/common/src/internal/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/shared/src/internal/plugin_handler.h" +#include "library/common/src/internal/plugin_handler.h" -#include "library/shared/include/flutter_desktop_embedding/method_channel.h" -#include "library/shared/src/internal/engine_method_result.h" +#include "library/common/include/flutter_desktop_embedding/method_channel.h" +#include "library/common/src/internal/engine_method_result.h" #include diff --git a/library/shared/src/internal/plugin_handler.h b/library/common/src/internal/plugin_handler.h similarity index 95% rename from library/shared/src/internal/plugin_handler.h rename to library/common/src/internal/plugin_handler.h index 853f99ae7..ac331c209 100644 --- a/library/shared/src/internal/plugin_handler.h +++ b/library/common/src/internal/plugin_handler.h @@ -20,8 +20,8 @@ #include -#include "library/shared/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/shared/include/flutter_desktop_embedding/plugin.h" +#include "library/common/include/flutter_desktop_embedding/binary_messenger.h" +#include "library/common/include/flutter_desktop_embedding/plugin.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/internal/text_input_model.cc b/library/common/src/internal/text_input_model.cc similarity index 98% rename from library/shared/src/internal/text_input_model.cc rename to library/common/src/internal/text_input_model.cc index 5b97fb8b6..fb3f82bdf 100644 --- a/library/shared/src/internal/text_input_model.cc +++ b/library/common/src/internal/text_input_model.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/shared/src/internal/text_input_model.h" +#include "library/common/src/internal/text_input_model.h" #include diff --git a/library/shared/src/internal/text_input_model.h b/library/common/src/internal/text_input_model.h similarity index 100% rename from library/shared/src/internal/text_input_model.h rename to library/common/src/internal/text_input_model.h diff --git a/library/shared/src/json_method_call.cc b/library/common/src/json_method_call.cc similarity index 94% rename from library/shared/src/json_method_call.cc rename to library/common/src/json_method_call.cc index b7cfded02..a4211e5cd 100644 --- a/library/shared/src/json_method_call.cc +++ b/library/common/src/json_method_call.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/shared/include/flutter_desktop_embedding/json_method_call.h" +#include "library/common/include/flutter_desktop_embedding/json_method_call.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/json_method_codec.cc b/library/common/src/json_method_codec.cc similarity index 93% rename from library/shared/src/json_method_codec.cc rename to library/common/src/json_method_codec.cc index 99dcd92d5..fe7cb8cf0 100644 --- a/library/shared/src/json_method_codec.cc +++ b/library/common/src/json_method_codec.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/shared/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/common/include/flutter_desktop_embedding/json_method_codec.h" -#include "library/shared/include/flutter_desktop_embedding/json_method_call.h" -#include "library/shared/src/internal/json_message_codec.h" +#include "library/common/include/flutter_desktop_embedding/json_method_call.h" +#include "library/common/src/internal/json_message_codec.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/json_plugin.cc b/library/common/src/json_plugin.cc similarity index 93% rename from library/shared/src/json_plugin.cc rename to library/common/src/json_plugin.cc index 503467c0e..85b728822 100644 --- a/library/shared/src/json_plugin.cc +++ b/library/common/src/json_plugin.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/shared/include/flutter_desktop_embedding/json_plugin.h" +#include "library/common/include/flutter_desktop_embedding/json_plugin.h" -#include "library/shared/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/common/include/flutter_desktop_embedding/json_method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/method_call.cc b/library/common/src/method_call.cc similarity index 92% rename from library/shared/src/method_call.cc rename to library/common/src/method_call.cc index c7784947d..91772e555 100644 --- a/library/shared/src/method_call.cc +++ b/library/common/src/method_call.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/shared/include/flutter_desktop_embedding/method_call.h" +#include "library/common/include/flutter_desktop_embedding/method_call.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/method_channel.cc b/library/common/src/method_channel.cc similarity index 94% rename from library/shared/src/method_channel.cc rename to library/common/src/method_channel.cc index ceb40cced..3619d86eb 100644 --- a/library/shared/src/method_channel.cc +++ b/library/common/src/method_channel.cc @@ -11,11 +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. -#include "library/shared/include/flutter_desktop_embedding/method_channel.h" +#include "library/common/include/flutter_desktop_embedding/method_channel.h" #include -#include "library/shared/src/internal/engine_method_result.h" +#include "library/common/src/internal/engine_method_result.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/method_codec.cc b/library/common/src/method_codec.cc similarity index 95% rename from library/shared/src/method_codec.cc rename to library/common/src/method_codec.cc index a72f0ddee..cdfcf9c39 100644 --- a/library/shared/src/method_codec.cc +++ b/library/common/src/method_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/shared/include/flutter_desktop_embedding/method_codec.h" +#include "library/common/include/flutter_desktop_embedding/method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/method_result.cc b/library/common/src/method_result.cc similarity index 94% rename from library/shared/src/method_result.cc rename to library/common/src/method_result.cc index 56cb5afae..55885a7d4 100644 --- a/library/shared/src/method_result.cc +++ b/library/common/src/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/shared/include/flutter_desktop_embedding/method_result.h" +#include "library/common/include/flutter_desktop_embedding/method_result.h" namespace flutter_desktop_embedding { diff --git a/library/shared/src/plugin.cc b/library/common/src/plugin.cc similarity index 90% rename from library/shared/src/plugin.cc rename to library/common/src/plugin.cc index f6a63ef05..3e865c152 100644 --- a/library/shared/src/plugin.cc +++ b/library/common/src/plugin.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/shared/include/flutter_desktop_embedding/plugin.h" +#include "library/common/include/flutter_desktop_embedding/plugin.h" -#include "library/shared/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/common/include/flutter_desktop_embedding/json_method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index c47ff96de..2bdddf14a 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -263,19 +263,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/library/windows/embedder.cpp b/library/windows/embedder.cpp index 4a2239c70..fc56aa1cb 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/embedder.cpp @@ -21,9 +21,9 @@ #include -#include "library/shared/src/internal/keyboard_hook_handler.h" -#include "library/shared/src/internal/plugin_handler.h" -#include "library/shared/src/internal/text_input_plugin.h" +#include "library/common/src/glfw/keyboard_hook_handler.h" +#include "library/common/src/internal/plugin_handler.h" +#include "library/common/src/glfw/text_input_plugin.h" static_assert(FLUTTER_ENGINE_VERSION == 1, ""); @@ -40,12 +40,13 @@ struct FlutterEmbedderState { static constexpr char kDefaultWindowTitle[] = "Flutter"; - +// Retreaves state bag for the window in question from the GLFWWindow static FlutterEmbedderState *GetSavedEmbedderState(GLFWwindow *window) { return reinterpret_cast( glfwGetWindowUserPointer(window)); } +// When GLFW calls back to the window with a cursor position move, forward to FlutterEngine as a pointer event with appropriate phase static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, FlutterPointerPhase phase, double x, double y) { @@ -62,6 +63,7 @@ static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, 1); } +// Report cursor move to engine static void GLFWcursorPositionCallback(GLFWwindow *window, double x, double y) { GLFWcursorPositionCallbackAtPhase(window, FlutterPointerPhase::kMove, x, y); } @@ -125,6 +127,7 @@ static void GLFWClearEventCallbacks(GLFWwindow *window) { glfwSetMouseButtonCallback(window, nullptr); } +// The Flutter Engine calls out to this function when new platform messages are available static void GLFWOnFlutterPlatformMessage(const FlutterPlatformMessage *message, void *user_data) { if (message->struct_size != sizeof(FlutterPlatformMessage)) { @@ -221,10 +224,13 @@ static FlutterEngine RunFlutterEngine( namespace flutter_desktop_embedding { +// Initialize glfw bool FlutterInit() { return glfwInit(); } +// Tear down glfw void FlutterTerminate() { glfwTerminate(); } +// set up embedder state and add the plugin to the plugin_handler bool AddPlugin(GLFWwindow *flutter_window, std::unique_ptr plugin) { auto state = GetSavedEmbedderState(flutter_window); diff --git a/library/windows/embedder.h b/library/windows/embedder.h index 83aeb565d..372304296 100644 --- a/library/windows/embedder.h +++ b/library/windows/embedder.h @@ -15,7 +15,7 @@ #ifndef WINDOWS_LIBRARY_EMBEDDER_H_ #define WINDOWS_LIBRARY_EMBEDDER_H_ -#include "library/shared/include/flutter_desktop_embedding/plugin.h" +#include "library/common/include/flutter_desktop_embedding/plugin.h" #include #include From 0f65d0dba433b3fbbd738d5c8412e25859cf33b5 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 10 Dec 2018 19:40:47 -0500 Subject: [PATCH 14/21] Move include up a level, and update include guards Collapses common/src/ to just common/ since there's no longer another directory in common/. Also moves linux embedder.h into include/linux to unify include dir. --- example/linux/flutter_embedder_example.cc | 2 +- .../{src => }/glfw/keyboard_hook_handler.h | 0 .../{src => }/glfw/text_input_plugin.cc | 2 +- .../common/{src => }/glfw/text_input_plugin.h | 6 ++-- .../internal/engine_method_result.cc | 2 +- .../{src => }/internal/engine_method_result.h | 6 ++-- .../{src => }/internal/json_message_codec.cc | 2 +- .../{src => }/internal/json_message_codec.h | 0 .../{src => }/internal/plugin_handler.cc | 6 ++-- .../{src => }/internal/plugin_handler.h | 4 +-- .../{src => }/internal/text_input_model.cc | 2 +- .../{src => }/internal/text_input_model.h | 0 library/common/{src => }/json_method_call.cc | 2 +- library/common/{src => }/json_method_codec.cc | 6 ++-- library/common/{src => }/json_plugin.cc | 4 +-- library/common/{src => }/method_call.cc | 2 +- library/common/{src => }/method_channel.cc | 4 +-- library/common/{src => }/method_codec.cc | 2 +- library/common/{src => }/method_result.cc | 2 +- library/common/{src => }/plugin.cc | 4 +-- .../binary_messenger.h | 6 ++-- .../json_method_call.h | 6 ++-- .../json_method_codec.h | 6 ++-- .../flutter_desktop_embedding/json_plugin.h | 6 ++-- .../linux}/embedder.h | 8 ++--- .../flutter_desktop_embedding/method_call.h | 6 ++-- .../method_channel.h | 6 ++-- .../flutter_desktop_embedding/method_codec.h | 6 ++-- .../flutter_desktop_embedding/method_result.h | 6 ++-- .../flutter_desktop_embedding/plugin.h | 6 ++-- library/linux/src/embedder.cc | 2 +- library/windows/GLFW Library.vcxproj | 32 +++++++++---------- library/windows/GLFW Library.vcxproj.filters | 4 +-- library/windows/embedder.cpp | 8 ++--- library/windows/embedder.h | 2 +- 35 files changed, 84 insertions(+), 84 deletions(-) rename library/common/{src => }/glfw/keyboard_hook_handler.h (100%) rename library/common/{src => }/glfw/text_input_plugin.cc (99%) rename library/common/{src => }/glfw/text_input_plugin.h (91%) rename library/common/{src => }/internal/engine_method_result.cc (97%) rename library/common/{src => }/internal/engine_method_result.h (89%) rename library/common/{src => }/internal/json_message_codec.cc (96%) rename library/common/{src => }/internal/json_message_codec.h (100%) rename library/common/{src => }/internal/plugin_handler.cc (94%) rename library/common/{src => }/internal/plugin_handler.h (94%) rename library/common/{src => }/internal/text_input_model.cc (98%) rename library/common/{src => }/internal/text_input_model.h (100%) rename library/common/{src => }/json_method_call.cc (92%) rename library/common/{src => }/json_method_codec.cc (93%) rename library/common/{src => }/json_plugin.cc (92%) rename library/common/{src => }/method_call.cc (91%) rename library/common/{src => }/method_channel.cc (93%) rename library/common/{src => }/method_codec.cc (95%) rename library/common/{src => }/method_result.cc (93%) rename library/common/{src => }/plugin.cc (89%) rename library/{common => }/include/flutter_desktop_embedding/binary_messenger.h (90%) rename library/{common => }/include/flutter_desktop_embedding/json_method_call.h (88%) rename library/{common => }/include/flutter_desktop_embedding/json_method_codec.h (88%) rename library/{common => }/include/flutter_desktop_embedding/json_plugin.h (91%) rename library/{linux/include/flutter_desktop_embedding => include/flutter_desktop_embedding/linux}/embedder.h (93%) rename library/{common => }/include/flutter_desktop_embedding/method_call.h (87%) rename library/{common => }/include/flutter_desktop_embedding/method_channel.h (91%) rename library/{common => }/include/flutter_desktop_embedding/method_codec.h (92%) rename library/{common => }/include/flutter_desktop_embedding/method_result.h (91%) rename library/{common => }/include/flutter_desktop_embedding/plugin.h (94%) diff --git a/example/linux/flutter_embedder_example.cc b/example/linux/flutter_embedder_example.cc index 92232f139..d2a8d6ed9 100644 --- a/example/linux/flutter_embedder_example.cc +++ b/example/linux/flutter_embedder_example.cc @@ -21,7 +21,7 @@ #include #include -#include +#include #include namespace { diff --git a/library/common/src/glfw/keyboard_hook_handler.h b/library/common/glfw/keyboard_hook_handler.h similarity index 100% rename from library/common/src/glfw/keyboard_hook_handler.h rename to library/common/glfw/keyboard_hook_handler.h diff --git a/library/common/src/glfw/text_input_plugin.cc b/library/common/glfw/text_input_plugin.cc similarity index 99% rename from library/common/src/glfw/text_input_plugin.cc rename to library/common/glfw/text_input_plugin.cc index 56dde0f5b..d9890d13f 100644 --- a/library/common/src/glfw/text_input_plugin.cc +++ b/library/common/glfw/text_input_plugin.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/common/src/glfw/text_input_plugin.h" +#include "library/common/glfw/text_input_plugin.h" #include #include diff --git a/library/common/src/glfw/text_input_plugin.h b/library/common/glfw/text_input_plugin.h similarity index 91% rename from library/common/src/glfw/text_input_plugin.h rename to library/common/glfw/text_input_plugin.h index 0cd8f5973..d5b57ba63 100644 --- a/library/common/src/glfw/text_input_plugin.h +++ b/library/common/glfw/text_input_plugin.h @@ -17,9 +17,9 @@ #include #include -#include "library/common/include/flutter_desktop_embedding/json_plugin.h" -#include "library/common/src/glfw/keyboard_hook_handler.h" -#include "library/common/src/internal/text_input_model.h" +#include "library/common/glfw/keyboard_hook_handler.h" +#include "library/common/internal/text_input_model.h" +#include "library/include/flutter_desktop_embedding/json_plugin.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/internal/engine_method_result.cc b/library/common/internal/engine_method_result.cc similarity index 97% rename from library/common/src/internal/engine_method_result.cc rename to library/common/internal/engine_method_result.cc index db5590da4..91a7d73d1 100644 --- a/library/common/src/internal/engine_method_result.cc +++ b/library/common/internal/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/common/src/internal/engine_method_result.h" +#include "library/common/internal/engine_method_result.h" #include diff --git a/library/common/src/internal/engine_method_result.h b/library/common/internal/engine_method_result.h similarity index 89% rename from library/common/src/internal/engine_method_result.h rename to library/common/internal/engine_method_result.h index 89c3e8f7f..e2f34f8d6 100644 --- a/library/common/src/internal/engine_method_result.h +++ b/library/common/internal/engine_method_result.h @@ -17,9 +17,9 @@ #include #include -#include "library/common/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/common/include/flutter_desktop_embedding/method_codec.h" -#include "library/common/include/flutter_desktop_embedding/method_result.h" +#include "library/include/flutter_desktop_embedding/binary_messenger.h" +#include "library/include/flutter_desktop_embedding/method_codec.h" +#include "library/include/flutter_desktop_embedding/method_result.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/internal/json_message_codec.cc b/library/common/internal/json_message_codec.cc similarity index 96% rename from library/common/src/internal/json_message_codec.cc rename to library/common/internal/json_message_codec.cc index 90c7fb3fd..8cf5dfb64 100644 --- a/library/common/src/internal/json_message_codec.cc +++ b/library/common/internal/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/common/src/internal/json_message_codec.h" +#include "library/common/internal/json_message_codec.h" #include #include diff --git a/library/common/src/internal/json_message_codec.h b/library/common/internal/json_message_codec.h similarity index 100% rename from library/common/src/internal/json_message_codec.h rename to library/common/internal/json_message_codec.h diff --git a/library/common/src/internal/plugin_handler.cc b/library/common/internal/plugin_handler.cc similarity index 94% rename from library/common/src/internal/plugin_handler.cc rename to library/common/internal/plugin_handler.cc index 20b383b47..9454d84b9 100644 --- a/library/common/src/internal/plugin_handler.cc +++ b/library/common/internal/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/src/internal/plugin_handler.h" +#include "library/common/internal/plugin_handler.h" -#include "library/common/include/flutter_desktop_embedding/method_channel.h" -#include "library/common/src/internal/engine_method_result.h" +#include "library/common/internal/engine_method_result.h" +#include "library/include/flutter_desktop_embedding/method_channel.h" #include diff --git a/library/common/src/internal/plugin_handler.h b/library/common/internal/plugin_handler.h similarity index 94% rename from library/common/src/internal/plugin_handler.h rename to library/common/internal/plugin_handler.h index ac331c209..121984a63 100644 --- a/library/common/src/internal/plugin_handler.h +++ b/library/common/internal/plugin_handler.h @@ -20,8 +20,8 @@ #include -#include "library/common/include/flutter_desktop_embedding/binary_messenger.h" -#include "library/common/include/flutter_desktop_embedding/plugin.h" +#include "library/include/flutter_desktop_embedding/binary_messenger.h" +#include "library/include/flutter_desktop_embedding/plugin.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/internal/text_input_model.cc b/library/common/internal/text_input_model.cc similarity index 98% rename from library/common/src/internal/text_input_model.cc rename to library/common/internal/text_input_model.cc index fb3f82bdf..579f5cf1c 100644 --- a/library/common/src/internal/text_input_model.cc +++ b/library/common/internal/text_input_model.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/common/src/internal/text_input_model.h" +#include "library/common/internal/text_input_model.h" #include diff --git a/library/common/src/internal/text_input_model.h b/library/common/internal/text_input_model.h similarity index 100% rename from library/common/src/internal/text_input_model.h rename to library/common/internal/text_input_model.h diff --git a/library/common/src/json_method_call.cc b/library/common/json_method_call.cc similarity index 92% rename from library/common/src/json_method_call.cc rename to library/common/json_method_call.cc index a4211e5cd..db2d847ff 100644 --- a/library/common/src/json_method_call.cc +++ b/library/common/json_method_call.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/common/include/flutter_desktop_embedding/json_method_call.h" +#include "library/include/flutter_desktop_embedding/json_method_call.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/json_method_codec.cc b/library/common/json_method_codec.cc similarity index 93% rename from library/common/src/json_method_codec.cc rename to library/common/json_method_codec.cc index fe7cb8cf0..69c3d4f16 100644 --- a/library/common/src/json_method_codec.cc +++ b/library/common/json_method_codec.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/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/include/flutter_desktop_embedding/json_method_codec.h" -#include "library/common/include/flutter_desktop_embedding/json_method_call.h" -#include "library/common/src/internal/json_message_codec.h" +#include "library/common/internal/json_message_codec.h" +#include "library/include/flutter_desktop_embedding/json_method_call.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/json_plugin.cc b/library/common/json_plugin.cc similarity index 92% rename from library/common/src/json_plugin.cc rename to library/common/json_plugin.cc index 85b728822..5f4b12ef9 100644 --- a/library/common/src/json_plugin.cc +++ b/library/common/json_plugin.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/common/include/flutter_desktop_embedding/json_plugin.h" +#include "library/include/flutter_desktop_embedding/json_plugin.h" -#include "library/common/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/include/flutter_desktop_embedding/json_method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/method_call.cc b/library/common/method_call.cc similarity index 91% rename from library/common/src/method_call.cc rename to library/common/method_call.cc index 91772e555..4dcd4c1cb 100644 --- a/library/common/src/method_call.cc +++ b/library/common/method_call.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/common/include/flutter_desktop_embedding/method_call.h" +#include "library/include/flutter_desktop_embedding/method_call.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/method_channel.cc b/library/common/method_channel.cc similarity index 93% rename from library/common/src/method_channel.cc rename to library/common/method_channel.cc index 3619d86eb..8ba9b406b 100644 --- a/library/common/src/method_channel.cc +++ b/library/common/method_channel.cc @@ -11,11 +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. -#include "library/common/include/flutter_desktop_embedding/method_channel.h" +#include "library/include/flutter_desktop_embedding/method_channel.h" #include -#include "library/common/src/internal/engine_method_result.h" +#include "library/common/internal/engine_method_result.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/method_codec.cc b/library/common/method_codec.cc similarity index 95% rename from library/common/src/method_codec.cc rename to library/common/method_codec.cc index cdfcf9c39..9899041d5 100644 --- a/library/common/src/method_codec.cc +++ b/library/common/method_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/common/include/flutter_desktop_embedding/method_codec.h" +#include "library/include/flutter_desktop_embedding/method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/method_result.cc b/library/common/method_result.cc similarity index 93% rename from library/common/src/method_result.cc rename to library/common/method_result.cc index 55885a7d4..c81c28fbd 100644 --- a/library/common/src/method_result.cc +++ b/library/common/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/common/include/flutter_desktop_embedding/method_result.h" +#include "library/include/flutter_desktop_embedding/method_result.h" namespace flutter_desktop_embedding { diff --git a/library/common/src/plugin.cc b/library/common/plugin.cc similarity index 89% rename from library/common/src/plugin.cc rename to library/common/plugin.cc index 3e865c152..d6587f08f 100644 --- a/library/common/src/plugin.cc +++ b/library/common/plugin.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/common/include/flutter_desktop_embedding/plugin.h" +#include "library/include/flutter_desktop_embedding/plugin.h" -#include "library/common/include/flutter_desktop_embedding/json_method_codec.h" +#include "library/include/flutter_desktop_embedding/json_method_codec.h" namespace flutter_desktop_embedding { diff --git a/library/common/include/flutter_desktop_embedding/binary_messenger.h b/library/include/flutter_desktop_embedding/binary_messenger.h similarity index 90% rename from library/common/include/flutter_desktop_embedding/binary_messenger.h rename to library/include/flutter_desktop_embedding/binary_messenger.h index d08bd6a3b..4e6f73b13 100644 --- a/library/common/include/flutter_desktop_embedding/binary_messenger.h +++ b/library/include/flutter_desktop_embedding/binary_messenger.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ #include #include @@ -59,4 +59,4 @@ class BinaryMessenger { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_BINARY_MESSENGER_H_ diff --git a/library/common/include/flutter_desktop_embedding/json_method_call.h b/library/include/flutter_desktop_embedding/json_method_call.h similarity index 88% rename from library/common/include/flutter_desktop_embedding/json_method_call.h rename to library/include/flutter_desktop_embedding/json_method_call.h index 7cb5b3ccd..bfc552468 100644 --- a/library/common/include/flutter_desktop_embedding/json_method_call.h +++ b/library/include/flutter_desktop_embedding/json_method_call.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CALL_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CALL_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CALL_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CALL_H_ #include @@ -50,4 +50,4 @@ class JsonMethodCall : public MethodCall { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CALL_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CALL_H_ diff --git a/library/common/include/flutter_desktop_embedding/json_method_codec.h b/library/include/flutter_desktop_embedding/json_method_codec.h similarity index 88% rename from library/common/include/flutter_desktop_embedding/json_method_codec.h rename to library/include/flutter_desktop_embedding/json_method_codec.h index 38ac8fcc6..a34da1b65 100644 --- a/library/common/include/flutter_desktop_embedding/json_method_codec.h +++ b/library/include/flutter_desktop_embedding/json_method_codec.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ #include "method_codec.h" @@ -51,4 +51,4 @@ class JsonMethodCodec : public MethodCodec { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_METHOD_CODEC_H_ diff --git a/library/common/include/flutter_desktop_embedding/json_plugin.h b/library/include/flutter_desktop_embedding/json_plugin.h similarity index 91% rename from library/common/include/flutter_desktop_embedding/json_plugin.h rename to library/include/flutter_desktop_embedding/json_plugin.h index 0eaefde2e..59d4a85b4 100644 --- a/library/common/include/flutter_desktop_embedding/json_plugin.h +++ b/library/include/flutter_desktop_embedding/json_plugin.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_PLUGIN_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_PLUGIN_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_PLUGIN_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_PLUGIN_H_ #include #include @@ -64,4 +64,4 @@ class JsonPlugin : public Plugin { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_PLUGIN_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_PLUGIN_H_ diff --git a/library/linux/include/flutter_desktop_embedding/embedder.h b/library/include/flutter_desktop_embedding/linux/embedder.h similarity index 93% rename from library/linux/include/flutter_desktop_embedding/embedder.h rename to library/include/flutter_desktop_embedding/linux/embedder.h index 217b5a10f..a045a336d 100644 --- a/library/linux/include/flutter_desktop_embedding/embedder.h +++ b/library/include/flutter_desktop_embedding/linux/embedder.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_EMBEDDER_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_EMBEDDER_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_LINUX_EMBEDDER_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_LINUX_EMBEDDER_H_ // Epoxy must be included before any graphics-related code. #include @@ -22,7 +22,7 @@ #include #include -#include "plugin.h" +#include "../plugin.h" namespace flutter_desktop_embedding { @@ -78,4 +78,4 @@ void FlutterWindowLoop(GLFWwindow *flutter_window); } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_EMBEDDER_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_LINUX_EMBEDDER_H_ diff --git a/library/common/include/flutter_desktop_embedding/method_call.h b/library/include/flutter_desktop_embedding/method_call.h similarity index 87% rename from library/common/include/flutter_desktop_embedding/method_call.h rename to library/include/flutter_desktop_embedding/method_call.h index 6616165a6..1e801718b 100644 --- a/library/common/include/flutter_desktop_embedding/method_call.h +++ b/library/include/flutter_desktop_embedding/method_call.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CALL_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CALL_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CALL_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CALL_H_ #include @@ -43,4 +43,4 @@ class MethodCall { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CALL_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CALL_H_ diff --git a/library/common/include/flutter_desktop_embedding/method_channel.h b/library/include/flutter_desktop_embedding/method_channel.h similarity index 91% rename from library/common/include/flutter_desktop_embedding/method_channel.h rename to library/include/flutter_desktop_embedding/method_channel.h index 6f4f0f604..22b5cf4cd 100644 --- a/library/common/include/flutter_desktop_embedding/method_channel.h +++ b/library/include/flutter_desktop_embedding/method_channel.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ #include @@ -69,4 +69,4 @@ class MethodChannel { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CHANNEL_H_ diff --git a/library/common/include/flutter_desktop_embedding/method_codec.h b/library/include/flutter_desktop_embedding/method_codec.h similarity index 92% rename from library/common/include/flutter_desktop_embedding/method_codec.h rename to library/include/flutter_desktop_embedding/method_codec.h index d563c20b4..fc34f4d82 100644 --- a/library/common/include/flutter_desktop_embedding/method_codec.h +++ b/library/include/flutter_desktop_embedding/method_codec.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ #include #include @@ -65,4 +65,4 @@ class MethodCodec { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_CODEC_H_ diff --git a/library/common/include/flutter_desktop_embedding/method_result.h b/library/include/flutter_desktop_embedding/method_result.h similarity index 91% rename from library/common/include/flutter_desktop_embedding/method_result.h rename to library/include/flutter_desktop_embedding/method_result.h index f1c072d7a..205ca1f51 100644 --- a/library/common/include/flutter_desktop_embedding/method_result.h +++ b/library/include/flutter_desktop_embedding/method_result.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ #include @@ -59,4 +59,4 @@ class MethodResult { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_METHOD_RESULT_H_ diff --git a/library/common/include/flutter_desktop_embedding/plugin.h b/library/include/flutter_desktop_embedding/plugin.h similarity index 94% rename from library/common/include/flutter_desktop_embedding/plugin.h rename to library/include/flutter_desktop_embedding/plugin.h index 02affff86..c69483739 100644 --- a/library/common/include/flutter_desktop_embedding/plugin.h +++ b/library/include/flutter_desktop_embedding/plugin.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_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_H_ -#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_H_ +#ifndef LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_H_ +#define LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_H_ #include #include @@ -84,4 +84,4 @@ class Plugin { } // namespace flutter_desktop_embedding -#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_H_ +#endif // LIBRARY_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_PLUGIN_H_ diff --git a/library/linux/src/embedder.cc b/library/linux/src/embedder.cc index 41e36ef97..821dd72e1 100644 --- a/library/linux/src/embedder.cc +++ b/library/linux/src/embedder.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 +#include #include #include diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index 2bdddf14a..cee5b9197 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -77,7 +77,7 @@ .dll $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\debug;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) - $(ProjectDir)..\..\library\shared\src\internal;$(SourcePath) + $(ProjectDir)..\..\library\common\internal;$(SourcePath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ @@ -94,7 +94,7 @@ .dll $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\release;;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) - $(ProjectDir)..\..\library\shared\src\internal;$(SourcePath) + $(ProjectDir)..\..\library\common\internal;$(SourcePath) $(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\ @@ -263,19 +263,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -287,4 +287,4 @@ - \ No newline at end of file + diff --git a/library/windows/GLFW Library.vcxproj.filters b/library/windows/GLFW Library.vcxproj.filters index d9993d9bb..02a3922cf 100644 --- a/library/windows/GLFW Library.vcxproj.filters +++ b/library/windows/GLFW Library.vcxproj.filters @@ -18,7 +18,7 @@ Source Files - + Source Files @@ -32,4 +32,4 @@ Source Files - \ No newline at end of file + diff --git a/library/windows/embedder.cpp b/library/windows/embedder.cpp index fc56aa1cb..bc3bb7e04 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/embedder.cpp @@ -21,9 +21,9 @@ #include -#include "library/common/src/glfw/keyboard_hook_handler.h" -#include "library/common/src/internal/plugin_handler.h" -#include "library/common/src/glfw/text_input_plugin.h" +#include "library/common/glfw/keyboard_hook_handler.h" +#include "library/common/glfw/text_input_plugin.h" +#include "library/common/internal/plugin_handler.h" static_assert(FLUTTER_ENGINE_VERSION == 1, ""); @@ -297,4 +297,4 @@ void FlutterWindowLoop(GLFWwindow *flutter_window) { glfwDestroyWindow(flutter_window); } -} // namespace flutter_desktop_embedding \ No newline at end of file +} // namespace flutter_desktop_embedding diff --git a/library/windows/embedder.h b/library/windows/embedder.h index 372304296..e2976bb3e 100644 --- a/library/windows/embedder.h +++ b/library/windows/embedder.h @@ -15,7 +15,7 @@ #ifndef WINDOWS_LIBRARY_EMBEDDER_H_ #define WINDOWS_LIBRARY_EMBEDDER_H_ -#include "library/common/include/flutter_desktop_embedding/plugin.h" +#include "library/include/flutter_desktop_embedding/plugin.h" #include #include From e0edde0eb928b2bace6b910730d90b31a613cb5c Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 11 Dec 2018 13:12:07 -0500 Subject: [PATCH 15/21] Fix Linux Make build --- example/linux/Makefile | 2 +- library/linux/.gitignore | 2 +- library/linux/Makefile | 17 +++++++++++------ library/linux/src/embedder.cc | 6 +++--- plugins/color_panel/linux/Makefile | 12 +++++++----- plugins/file_chooser/linux/Makefile | 12 +++++++----- plugins/menubar/linux/Makefile | 12 +++++++----- 7 files changed, 37 insertions(+), 26 deletions(-) diff --git a/example/linux/Makefile b/example/linux/Makefile index 13bacd7e7..2a07be7c5 100644 --- a/example/linux/Makefile +++ b/example/linux/Makefile @@ -37,7 +37,7 @@ ALL_LIBS=$(FLUTTER_EMBEDDER_LIB) $(FLUTTER_ENGINE_LIB) $(PLUGIN_LIBS) # Headers PLUGIN_DIRS=$(patsubst %,$(PLUGINS_DIR)/%/linux,$(PLUGIN_NAMES)) LIBRARY_DIRS=$(FLUTTER_EMBEDDER_LIB_DIR) $(PLUGIN_DIRS) -INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS)) +INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS)) $(PROJECT_ROOT)/library/include # Tools BUILD_ASSETS_BIN=$(TOOLS_DIR)/build_flutter_assets diff --git a/library/linux/.gitignore b/library/linux/.gitignore index 61d1051b1..55d8c0ddd 100644 --- a/library/linux/.gitignore +++ b/library/linux/.gitignore @@ -1,3 +1,3 @@ .last_engine_version *.so -flutter_embedder.h +include diff --git a/library/linux/Makefile b/library/linux/Makefile index eaa0031ac..7c7f4db47 100644 --- a/library/linux/Makefile +++ b/library/linux/Makefile @@ -14,6 +14,8 @@ FLUTTER_ENGINE_LIB_NAME=flutter_engine FLUTTER_ENGINE_LIB_FILE=lib$(FLUTTER_ENGINE_LIB_NAME).so FLUTTER_ENGINE_HEADER=flutter_embedder.h +# Use an include/ directory for the engine header for consistency. +FLUTTER_ENGINE_HEADER_DIR=$(CURDIR)/include PROJECT_ROOT=../.. TOOLS_DIR=$(PROJECT_ROOT)/tools ENGINE_UPDATER=$(TOOLS_DIR)/update_flutter_engine @@ -22,7 +24,8 @@ LIBRARY_OUT=libflutter_embedder.so CXX=g++ -std=c++14 CXXFLAGS= -Wall -Werror -shared -fPIC \ -I$(PROJECT_ROOT) \ - -I$(CURDIR)/include \ + -I$(PROJECT_ROOT)/library/include \ + -I$(FLUTTER_ENGINE_HEADER_DIR) \ $(shell pkg-config --cflags gtk+-3.0 epoxy x11 jsoncpp) LDFLAGS= -L$(CURDIR) \ $(shell pkg-config --libs gtk+-3.0 epoxy x11 jsoncpp) \ @@ -31,9 +34,9 @@ LDFLAGS= -L$(CURDIR) \ LIBRARIES=$(FLUTTER_ENGINE_LIB_FILE) -HEADERS=$(shell find include/ -type f -name '*.h') -SHAREDHEADERS=$(shell find ../shared/include/ -type f -name '*.h') -SOURCES=$(shell find src/ -type f -name '*.cc') +HEADERS=$(shell find $(PROJECT_ROOT)/library/include/ -type f -name '*.h') \ + $(FLUTTER_ENGINE_HEADER_DIR)/$(FLUTTER_ENGINE_HEADER) +SOURCES=$(shell find src/ $(PROJECT_ROOT)/library/common/ -type f -name '*.cc') .PHONY: all all: $(LIBRARY_OUT) @@ -46,10 +49,12 @@ $(LIBRARY_OUT): $(SOURCES) $(HEADERS) $(LIBRARIES) # time. Instead, this duplicates the dependency information that the script # already has, and makes things slightly more fragile, in exchange for # avoiding unnecessary relinks. -$(FLUTTER_ENGINE_LIB_FILE): $(FLUTTER_DIR)/bin/internal/engine.version +$(FLUTTER_ENGINE_LIB_FILE) $(FLUTTER_ENGINE_HEADER_DIR)/$(FLUTTER_ENGINE_HEADER): \ + $(FLUTTER_DIR)/bin/internal/engine.version $(ENGINE_UPDATER) --flutter_root=$(FLUTTER_DIR) ./ if [ -f $(FLUTTER_ENGINE_HEADER) ]; then \ - mv $(FLUTTER_ENGINE_HEADER) include/; \ + mkdir -p $(FLUTTER_ENGINE_HEADER_DIR) && \ + mv $(FLUTTER_ENGINE_HEADER) $(FLUTTER_ENGINE_HEADER_DIR)/; \ fi .PHONY: clean diff --git a/library/linux/src/embedder.cc b/library/linux/src/embedder.cc index 821dd72e1..c0735a665 100644 --- a/library/linux/src/embedder.cc +++ b/library/linux/src/embedder.cc @@ -26,9 +26,9 @@ #include -#include "library/linux/src/internal/keyboard_hook_handler.h" -#include "library/linux/src/internal/plugin_handler.h" -#include "library/linux/src/internal/text_input_plugin.h" +#include "library/common/glfw/keyboard_hook_handler.h" +#include "library/common/glfw/text_input_plugin.h" +#include "library/common/internal/plugin_handler.h" // GLFW_TRUE & GLFW_FALSE are introduced since libglfw-3.3, // add definitions here to compile under the old versions. diff --git a/plugins/color_panel/linux/Makefile b/plugins/color_panel/linux/Makefile index b753a32df..4f8e167a8 100644 --- a/plugins/color_panel/linux/Makefile +++ b/plugins/color_panel/linux/Makefile @@ -15,21 +15,23 @@ LIBRARY_OUT=libflutter_embedder_color_panel.so PROJECT_ROOT=$(CURDIR)/../../.. # For dependency on the embedder shared library. -EMBEDDER_LIBRARY_DIR=$(PROJECT_ROOT)/library/linux +EMBEDDER_LIBRARY_DIR=$(PROJECT_ROOT)/library +EMBEDDER_LIBRARY_OUT_DIR=$(EMBEDDER_LIBRARY_DIR)/linux +EMBEDDER_LIBRARY_HEADER_DIR=$(EMBEDDER_LIBRARY_DIR)/include EMBEDDER_LIB_NAME=flutter_engine -EMBEDDER_LIB_FILE=$(EMBEDDER_LIBRARY_DIR)/lib$(EMBEDDER_LIB_NAME).so +EMBEDDER_LIB_FILE=$(EMBEDDER_LIBRARY_OUT_DIR)/lib$(EMBEDDER_LIB_NAME).so COMMON_DIR=$(CURDIR)/../common CXX=g++ -std=c++14 CXXFLAGS= -Wall -Werror -shared -fPIC \ -I$(PROJECT_ROOT) \ - -I$(EMBEDDER_LIBRARY_DIR)/include \ + -I$(EMBEDDER_LIBRARY_HEADER_DIR) \ $(shell pkg-config --cflags gtk+-3.0 jsoncpp) -LDFLAGS= -L$(EMBEDDER_LIBRARY_DIR) \ +LDFLAGS= -L$(EMBEDDER_LIBRARY_OUT_DIR) \ $(shell pkg-config --libs gtk+-3.0 jsoncpp) \ -l$(EMBEDDER_LIB_NAME) \ - -Wl,-rpath=$(EMBEDDER_LIBRARY_DIR) + -Wl,-rpath=$(EMBEDDER_LIBRARY_OUT_DIR) LIBRARIES=$(EMBEDDER_LIB_FILE) HEADERS=$(shell find include/ $(COMMON_DIR)/ -type f -name '*.h') diff --git a/plugins/file_chooser/linux/Makefile b/plugins/file_chooser/linux/Makefile index 419f5de08..bb2bf3f87 100644 --- a/plugins/file_chooser/linux/Makefile +++ b/plugins/file_chooser/linux/Makefile @@ -15,21 +15,23 @@ LIBRARY_OUT=libflutter_embedder_file_chooser.so PROJECT_ROOT=$(CURDIR)/../../.. # For dependency on the embedder shared library. -EMBEDDER_LIBRARY_DIR=$(PROJECT_ROOT)/library/linux +EMBEDDER_LIBRARY_DIR=$(PROJECT_ROOT)/library +EMBEDDER_LIBRARY_OUT_DIR=$(EMBEDDER_LIBRARY_DIR)/linux +EMBEDDER_LIBRARY_HEADER_DIR=$(EMBEDDER_LIBRARY_DIR)/include EMBEDDER_LIB_NAME=flutter_engine -EMBEDDER_LIB_FILE=$(EMBEDDER_LIBRARY_DIR)/lib$(EMBEDDER_LIB_NAME).so +EMBEDDER_LIB_FILE=$(EMBEDDER_LIBRARY_OUT_DIR)/lib$(EMBEDDER_LIB_NAME).so COMMON_DIR=$(CURDIR)/../common CXX=g++ -std=c++14 CXXFLAGS= -Wall -Werror -shared -fPIC \ -I$(PROJECT_ROOT) \ - -I$(EMBEDDER_LIBRARY_DIR)/include \ + -I$(EMBEDDER_LIBRARY_HEADER_DIR) \ $(shell pkg-config --cflags gtk+-3.0 jsoncpp) -LDFLAGS= -L$(EMBEDDER_LIBRARY_DIR) \ +LDFLAGS= -L$(EMBEDDER_LIBRARY_OUT_DIR) \ $(shell pkg-config --libs gtk+-3.0 jsoncpp) \ -l$(EMBEDDER_LIB_NAME) \ - -Wl,-rpath=$(EMBEDDER_LIBRARY_DIR) + -Wl,-rpath=$(EMBEDDER_LIBRARY_OUT_DIR) LIBRARIES=$(EMBEDDER_LIB_FILE) HEADERS=$(shell find include/ $(COMMON_DIR)/ -type f -name '*.h') diff --git a/plugins/menubar/linux/Makefile b/plugins/menubar/linux/Makefile index e867b8131..0ee350ef1 100644 --- a/plugins/menubar/linux/Makefile +++ b/plugins/menubar/linux/Makefile @@ -15,21 +15,23 @@ LIBRARY_OUT=libflutter_embedder_menubar.so PROJECT_ROOT=$(CURDIR)/../../.. # For dependency on the embedder shared library. -EMBEDDER_LIBRARY_DIR=$(PROJECT_ROOT)/library/linux +EMBEDDER_LIBRARY_DIR=$(PROJECT_ROOT)/library +EMBEDDER_LIBRARY_OUT_DIR=$(EMBEDDER_LIBRARY_DIR)/linux +EMBEDDER_LIBRARY_HEADER_DIR=$(EMBEDDER_LIBRARY_DIR)/include EMBEDDER_LIB_NAME=flutter_engine -EMBEDDER_LIB_FILE=$(EMBEDDER_LIBRARY_DIR)/lib$(EMBEDDER_LIB_NAME).so +EMBEDDER_LIB_FILE=$(EMBEDDER_LIBRARY_OUT_DIR)/lib$(EMBEDDER_LIB_NAME).so COMMON_DIR=$(CURDIR)/../common CXX=g++ -std=c++14 CXXFLAGS= -Wall -Werror -shared -fPIC \ -I$(PROJECT_ROOT) \ - -I$(EMBEDDER_LIBRARY_DIR)/include \ + -I$(EMBEDDER_LIBRARY_HEADER_DIR) \ $(shell pkg-config --cflags gtk+-3.0 jsoncpp) -LDFLAGS= -L$(EMBEDDER_LIBRARY_DIR) \ +LDFLAGS= -L$(EMBEDDER_LIBRARY_OUT_DIR) \ $(shell pkg-config --libs gtk+-3.0 jsoncpp) \ -l$(EMBEDDER_LIB_NAME) \ - -Wl,-rpath=$(EMBEDDER_LIBRARY_DIR) + -Wl,-rpath=$(EMBEDDER_LIBRARY_OUT_DIR) LIBRARIES=$(EMBEDDER_LIB_FILE) HEADERS=$(shell find include/ $(COMMON_DIR)/ -type f -name '*.h') From f30d7cc24072dabac925cdd3105515ed2dfc5cf5 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 11 Dec 2018 14:03:15 -0500 Subject: [PATCH 16/21] Fix GN build --- example/linux/Makefile | 3 + example/linux/flutter_embedder_example.cc | 7 +- library/BUILD.gn | 66 ++++++++++--------- library/GN.md | 6 +- .../linux/embedder.h | 4 ++ library/linux/BUILD.gn | 3 +- plugins/color_panel/BUILD.gn | 2 + plugins/file_chooser/BUILD.gn | 2 + plugins/menubar/BUILD.gn | 2 + 9 files changed, 61 insertions(+), 34 deletions(-) diff --git a/example/linux/Makefile b/example/linux/Makefile index 2a07be7c5..5cf7fa045 100644 --- a/example/linux/Makefile +++ b/example/linux/Makefile @@ -85,6 +85,9 @@ endif CXX=g++ -std=c++14 CXXFLAGS=-Wall -Werror $(shell pkg-config --cflags jsoncpp) CPPFLAGS=$(patsubst %,-I%,$(INCLUDE_DIRS)) +ifdef USE_GN +CPPFLAGS+=-DUSE_FLATTENED_INCLUDES +endif LDFLAGS=-L$(OUT_LIB_DIR) \ -lglfw \ $(shell pkg-config --libs jsoncpp) \ diff --git a/example/linux/flutter_embedder_example.cc b/example/linux/flutter_embedder_example.cc index d2a8d6ed9..1a030828e 100644 --- a/example/linux/flutter_embedder_example.cc +++ b/example/linux/flutter_embedder_example.cc @@ -21,9 +21,14 @@ #include #include -#include #include +#ifdef USE_FLATTENED_INCLUDES +#include +#else +#include +#endif + namespace { // Returns the path of the directory containing this executable, or an empty diff --git a/library/BUILD.gn b/library/BUILD.gn index 64ead918f..e36f8271e 100644 --- a/library/BUILD.gn +++ b/library/BUILD.gn @@ -19,38 +19,44 @@ import("//library/engine.gni") published_shared_library("flutter_embedder") { if (is_linux) { sources = [ - "shared/src/internal/engine_method_result.cc", - "shared/src/internal/engine_method_result.h", - "shared/src/internal/json_message_codec.cc", - "shared/src/internal/json_message_codec.h", - "shared/src/internal/keyboard_hook_handler.h", - "shared/src/internal/plugin_handler.cc", - "shared/src/internal/plugin_handler.h", - "shared/src/internal/text_input_model.cc", - "shared/src/internal/text_input_model.h", - "shared/src/internal/text_input_plugin.cc", - "shared/src/internal/text_input_plugin.h", - "shared/src/embedder.cc", - "shared/src/json_method_call.cc", - "shared/src/json_method_codec.cc", - "shared/src/json_plugin.cc", - "shared/src/method_call.cc", - "shared/src/method_channel.cc", - "shared/src/method_codec.cc", - "shared/src/method_result.cc", - "shared/src/plugin.cc", + "linux/src/embedder.cc", ] public = [ - "shared/include/flutter_desktop_embedding/binary_messenger.h", - "linux/include/flutter_desktop_embedding/embedder.h", - "shared/include/flutter_desktop_embedding/json_method_call.h", - "shared/include/flutter_desktop_embedding/json_method_codec.h", - "shared/include/flutter_desktop_embedding/json_plugin.h", - "shared/include/flutter_desktop_embedding/method_call.h", - "shared/include/flutter_desktop_embedding/method_channel.h", - "shared/include/flutter_desktop_embedding/method_codec.h", - "shared/include/flutter_desktop_embedding/method_result.h", - "shared/include/flutter_desktop_embedding/plugin.h", + "include/flutter_desktop_embedding/linux/embedder.h", + ] + } + if (is_linux || is_win) { + sources += [ + "common/glfw/keyboard_hook_handler.h", + "common/glfw/text_input_plugin.cc", + "common/glfw/text_input_plugin.h", + "common/internal/engine_method_result.cc", + "common/internal/engine_method_result.h", + "common/internal/json_message_codec.cc", + "common/internal/json_message_codec.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_method_call.cc", + "common/json_method_codec.cc", + "common/json_plugin.cc", + "common/method_call.cc", + "common/method_channel.cc", + "common/method_codec.cc", + "common/method_result.cc", + "common/plugin.cc", + ] + public += [ + "include/flutter_desktop_embedding/binary_messenger.h", + "include/flutter_desktop_embedding/json_method_call.h", + "include/flutter_desktop_embedding/json_method_codec.h", + "include/flutter_desktop_embedding/json_plugin.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.h", ] } diff --git a/library/GN.md b/library/GN.md index 32cb98977..2288ee985 100644 --- a/library/GN.md +++ b/library/GN.md @@ -24,7 +24,11 @@ $ tools/gn_dart gen out $ ninja -C out flutter_embedder ``` -The build results will be in the top-level `out/` directory. +The build results will be in the top-level `out/` directory. `out/include/` will +have the public headers for all build libraries, so you can point dependent +builds at that single location rather than the `include/` directories in the +source tree. You will need to set USE\_FLATTENED\_INCLUDES in your build, since +the embedding header library layout is slightly different under `out/include/`. Subsequent builds only require the `ninja` step, as the build will automatically re-run GN generation if necessary. diff --git a/library/include/flutter_desktop_embedding/linux/embedder.h b/library/include/flutter_desktop_embedding/linux/embedder.h index a045a336d..3fc973595 100644 --- a/library/include/flutter_desktop_embedding/linux/embedder.h +++ b/library/include/flutter_desktop_embedding/linux/embedder.h @@ -22,7 +22,11 @@ #include #include +#ifdef USE_FLATTENED_INCLUDES +#include "plugin.h" +#else #include "../plugin.h" +#endif namespace flutter_desktop_embedding { diff --git a/library/linux/BUILD.gn b/library/linux/BUILD.gn index be8094bd5..6b049638c 100644 --- a/library/linux/BUILD.gn +++ b/library/linux/BUILD.gn @@ -19,8 +19,7 @@ import("//library/engine.gni") # inculdes for its header rather than project-relative. config("relative_public_headers") { include_dirs = [ - "include", - "../shared/include" + "../include" ] } diff --git a/plugins/color_panel/BUILD.gn b/plugins/color_panel/BUILD.gn index 60ce61462..0b6bf3c8e 100644 --- a/plugins/color_panel/BUILD.gn +++ b/plugins/color_panel/BUILD.gn @@ -30,6 +30,8 @@ published_shared_library("color_panel") { ] } + defines = ["USE_FLATTENED_INCLUDES"] + deps = [ "//library:flutter_embedder", ] diff --git a/plugins/file_chooser/BUILD.gn b/plugins/file_chooser/BUILD.gn index f38e4baef..86b3e8837 100644 --- a/plugins/file_chooser/BUILD.gn +++ b/plugins/file_chooser/BUILD.gn @@ -30,6 +30,8 @@ published_shared_library("file_chooser") { ] } + defines = ["USE_FLATTENED_INCLUDES"] + deps = [ "//library:flutter_embedder", ] diff --git a/plugins/menubar/BUILD.gn b/plugins/menubar/BUILD.gn index c4f8aa690..ab431f8ef 100644 --- a/plugins/menubar/BUILD.gn +++ b/plugins/menubar/BUILD.gn @@ -30,6 +30,8 @@ published_shared_library("menubar") { ] } + defines = ["USE_FLATTENED_INCLUDES"] + deps = [ "//library:flutter_embedder", ] From 0ae2927c814f26c40fd0d6c96d4c8835fcc9e2db Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 27 Dec 2018 12:41:37 -0800 Subject: [PATCH 17/21] More code review feedback --- library/windows/.gitignore | 6 ++-- library/windows/dependencies/.gitignore | 1 + library/windows/scripts/build_jsonlib.bat | 38 ++++++++++++++++------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/library/windows/.gitignore b/library/windows/.gitignore index 91e1d6b70..099c5cb6a 100644 --- a/library/windows/.gitignore +++ b/library/windows/.gitignore @@ -1,3 +1,6 @@ +# Ignore third party code fetched as part of build process of the Flutter embedding library +third_party + ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## @@ -328,6 +331,3 @@ ASALocalRun/ # MFractors (Xamarin productivity tool) working folder .mfractor/ -# dependencies -dependencies -third_party \ No newline at end of file diff --git a/library/windows/dependencies/.gitignore b/library/windows/dependencies/.gitignore index 443ccd53a..7f1435b47 100644 --- a/library/windows/dependencies/.gitignore +++ b/library/windows/dependencies/.gitignore @@ -3,3 +3,4 @@ flutter_engine.* .last_engine_version icudtl.dat glfw3.* +json diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat index 6bcd67a29..36a743d54 100644 --- a/library/windows/scripts/build_jsonlib.bat +++ b/library/windows/scripts/build_jsonlib.bat @@ -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. -@echo off +::@echo off :: Find where VS lives and start a VC command prompt set pre=Microsoft.VisualStudio.Product. @@ -25,12 +25,22 @@ pushd %InstallDir%\VC\Auxiliary\Build call vcvarsall.bat x86_amd64 popd -set DEPENDDIREXISTS=true -if not exist %~dp0..\dependencies\json\allocator.h set DEPENDDIREXISTS=false +set JSONHEADERSEXIST=true +if not exist %~dp0..\dependencies\json\allocator.h set JSONHEADERSEXIST=false -if %DEPENDDIREXISTS% == true ( - echo jsoncpp found. - goto DONE +set JSONDEBUGLIBEXISTS=true +if not exist %~dp0..\dependencies\json\x64\debug\json_vc71_libmtd.lib set JSONDEBUGLIBEXISTS=false + +set JSONRELEASELIBEXISTS=true +if not exist %~dp0..\dependencies\json\x64\release\json_vc71_libmt.lib set JSONRELEASELIBEXISTS=false + +if %JSONHEADERSEXIST% == true ( + if %JSONDEBUGLIBEXISTS% == true ( + if %JSONRELEASELIBEXISTS% == true ( + echo jsoncpp found. + goto DONE + ) + ) ) set THIRDPARTYDIREXISTS=true @@ -52,13 +62,22 @@ if not exist %~dp0..\third_party\jsoncpp\README.md set JSONEXISTS=false :: Clone source if %JSONEXISTS% == false ( + :: PR opened on json cpp for VS2017 support: https://github.com/open-source-parsers/jsoncpp/pull/853 echo Cloning via git clone --branch supportvs2017 https://github.com/clarkezone/jsoncpp.git %~dp0..\third_party\jsoncpp call git clone --branch supportvs2017 https://github.com/clarkezone/jsoncpp.git %~dp0..\third_party\jsoncpp + + pushd %~dp0..\third_party\jsoncpp + + call git checkout 3ae7e8073a425c93329c8577a3c813c206322ca4 + + popd ) :: Copy headers -copy %~dp0..\third_party\jsoncpp\include\json\*.h %~dp0..\dependencies\json\. - +if %JSONHEADERSEXIST% == false ( + echo Copying jsoncpp headers + copy %~dp0..\third_party\jsoncpp\include\json\*.h %~dp0..\dependencies\json\. +) :: Build debug lib echo Building debug lib: msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj @@ -93,8 +112,5 @@ if %DEPBINRELDIREXISTS% == false ( copy %~dp0..\third_party\jsoncpp\makefiles\msvc2017\x64\release\json_vc71_libmt.lib %~dp0..\dependencies\json\x64\release\. -:: Remove source -rmdir /s /q %~dp0..\third_party - :DONE echo jsoncpplib complete. \ No newline at end of file From d5583a75eb5c48075104d256da211f6e246586e9 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sat, 29 Dec 2018 08:36:08 -0800 Subject: [PATCH 18/21] Restore echo off to build_jsonlib.bat --- library/windows/scripts/build_jsonlib.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat index 36a743d54..72cbda7d8 100644 --- a/library/windows/scripts/build_jsonlib.bat +++ b/library/windows/scripts/build_jsonlib.bat @@ -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. -::@echo off +@echo off :: Find where VS lives and start a VC command prompt set pre=Microsoft.VisualStudio.Product. From d299a820ece54c518e0b7bf30f1742866514a4df Mon Sep 17 00:00:00 2001 From: James Clarke Date: Sun, 30 Dec 2018 21:07:43 -0800 Subject: [PATCH 19/21] Code review feedback --- .gitignore | 3 +-- README.md | 1 - library/windows/GLFW Library.vcxproj | 6 +++--- library/windows/embedder.h | 4 ++-- library/windows/scripts/build_jsonlib.bat | 19 ++++--------------- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 30206d268..d45549ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ out/ -.DS_Store -library/windows/dependencies \ No newline at end of file +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index b008af414..3e668cd8c 100644 --- a/README.md +++ b/README.md @@ -82,4 +82,3 @@ speed up the debugging process. request, or [write a plugin](plugins/README.md#writing-your-own-plugins)! * The Linux and Windows implementations currently use GLFW. This is not going to be the final implementation for either platform. -* Plugins and text input do not yet work on Windows. diff --git a/library/windows/GLFW Library.vcxproj b/library/windows/GLFW Library.vcxproj index cee5b9197..634ea94d9 100644 --- a/library/windows/GLFW Library.vcxproj +++ b/library/windows/GLFW Library.vcxproj @@ -75,7 +75,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)third_party\jsoncpp\include;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\debug;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) @@ -92,7 +92,7 @@ $(SolutionDir)bin\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ flutter_embedder .dll - $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)..\..\;$(IncludePath) + $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies;$(ProjectDir)third_party\jsoncpp\include;$(ProjectDir)..\..\;$(IncludePath) $(ProjectDir)dependencies\engine\;$(ProjectDir)dependencies\json\x64\release;;$(ProjectDir)dependencies\GLFW\;$(LibraryPath) $(ProjectDir)..\..\library\common\internal;$(SourcePath) @@ -287,4 +287,4 @@ - + \ No newline at end of file diff --git a/library/windows/embedder.h b/library/windows/embedder.h index e2976bb3e..028d418fb 100644 --- a/library/windows/embedder.h +++ b/library/windows/embedder.h @@ -15,13 +15,13 @@ #ifndef WINDOWS_LIBRARY_EMBEDDER_H_ #define WINDOWS_LIBRARY_EMBEDDER_H_ -#include "library/include/flutter_desktop_embedding/plugin.h" - #include #include #include +#include "library/include/flutter_desktop_embedding/plugin.h" + namespace flutter_desktop_embedding { // Calls glfwInit() diff --git a/library/windows/scripts/build_jsonlib.bat b/library/windows/scripts/build_jsonlib.bat index 72cbda7d8..17f663456 100644 --- a/library/windows/scripts/build_jsonlib.bat +++ b/library/windows/scripts/build_jsonlib.bat @@ -25,21 +25,16 @@ pushd %InstallDir%\VC\Auxiliary\Build call vcvarsall.bat x86_amd64 popd -set JSONHEADERSEXIST=true -if not exist %~dp0..\dependencies\json\allocator.h set JSONHEADERSEXIST=false - set JSONDEBUGLIBEXISTS=true if not exist %~dp0..\dependencies\json\x64\debug\json_vc71_libmtd.lib set JSONDEBUGLIBEXISTS=false set JSONRELEASELIBEXISTS=true if not exist %~dp0..\dependencies\json\x64\release\json_vc71_libmt.lib set JSONRELEASELIBEXISTS=false -if %JSONHEADERSEXIST% == true ( - if %JSONDEBUGLIBEXISTS% == true ( - if %JSONRELEASELIBEXISTS% == true ( - echo jsoncpp found. - goto DONE - ) +if %JSONDEBUGLIBEXISTS% == true ( + if %JSONRELEASELIBEXISTS% == true ( + echo jsoncpp found. + goto DONE ) ) @@ -73,12 +68,6 @@ if %JSONEXISTS% == false ( popd ) -:: Copy headers -if %JSONHEADERSEXIST% == false ( - echo Copying jsoncpp headers - copy %~dp0..\third_party\jsoncpp\include\json\*.h %~dp0..\dependencies\json\. -) - :: Build debug lib echo Building debug lib: msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj msbuild %~dp0..\third_party\jsoncpp\makefiles\msvc2017\lib_json.vcxproj From 02446e948e6f93fbbf3d95e4ee85e0c0a62ec2ea Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 31 Dec 2018 18:46:54 -0800 Subject: [PATCH 20/21] Revert newline change --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d45549ed7..3acb573cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ out/ -.DS_Store \ No newline at end of file +.DS_Store From edf602e874f43dafad172aebf0596ad0353ed6cf Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 31 Dec 2018 18:50:13 -0800 Subject: [PATCH 21/21] clang-format --- library/windows/embedder.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/library/windows/embedder.cpp b/library/windows/embedder.cpp index bc3bb7e04..e76f35f9a 100644 --- a/library/windows/embedder.cpp +++ b/library/windows/embedder.cpp @@ -46,7 +46,8 @@ static FlutterEmbedderState *GetSavedEmbedderState(GLFWwindow *window) { glfwGetWindowUserPointer(window)); } -// When GLFW calls back to the window with a cursor position move, forward to FlutterEngine as a pointer event with appropriate phase +// When GLFW calls back to the window with a cursor position move, forward to +// FlutterEngine as a pointer event with appropriate phase static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, FlutterPointerPhase phase, double x, double y) { @@ -60,7 +61,7 @@ static void GLFWcursorPositionCallbackAtPhase(GLFWwindow *window, std::chrono::high_resolution_clock::now().time_since_epoch()) .count(); FlutterEngineSendPointerEvent(GetSavedEmbedderState(window)->engine, &event, - 1); + 1); } // Report cursor move to engine @@ -96,7 +97,7 @@ static void GLFWKeyCallback(GLFWwindow *window, int key, int scancode, GetSavedEmbedderState(window)->keyboard_hook_handlers) { handler->KeyboardHook(window, key, scancode, action, mods); } - if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { + if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) { glfwSetWindowShouldClose(window, GLFW_TRUE); } } @@ -108,8 +109,8 @@ static void GLFWwindowSizeCallback(GLFWwindow *window, int width, int height) { event.height = height; // TODO: Handle pixel ratio for different DPI monitors. event.pixel_ratio = 1.0; - FlutterEngineSendWindowMetricsEvent(GetSavedEmbedderState(window)->engine, - &event); + FlutterEngineSendWindowMetricsEvent(GetSavedEmbedderState(window)->engine, + &event); } // Flushes event queue and then assigns default window callbacks. @@ -127,7 +128,8 @@ static void GLFWClearEventCallbacks(GLFWwindow *window) { glfwSetMouseButtonCallback(window, nullptr); } -// The Flutter Engine calls out to this function when new platform messages are available +// The Flutter Engine calls out to this function when new platform messages are +// available static void GLFWOnFlutterPlatformMessage(const FlutterPlatformMessage *message, void *user_data) { if (message->struct_size != sizeof(FlutterPlatformMessage)) { @@ -223,7 +225,7 @@ static FlutterEngine RunFlutterEngine( } namespace flutter_desktop_embedding { - + // Initialize glfw bool FlutterInit() { return glfwInit(); } @@ -231,8 +233,7 @@ bool FlutterInit() { return glfwInit(); } void FlutterTerminate() { glfwTerminate(); } // set up embedder state and add the plugin to the plugin_handler -bool AddPlugin(GLFWwindow *flutter_window, - std::unique_ptr plugin) { +bool AddPlugin(GLFWwindow *flutter_window, std::unique_ptr plugin) { auto state = GetSavedEmbedderState(flutter_window); return state->plugin_handler->AddPlugin(std::move(plugin)); } @@ -257,8 +258,8 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, return nullptr; } GLFWClearCanvas(window); - auto engine = RunFlutterEngine( - window, main_path, assets_path, packages_path, icu_data_path, arguments); + auto engine = RunFlutterEngine(window, main_path, assets_path, packages_path, + icu_data_path, arguments); if (engine == nullptr) { glfwDestroyWindow(window); return nullptr; @@ -267,8 +268,7 @@ GLFWwindow *CreateFlutterWindow(size_t initial_width, size_t initial_height, FlutterEmbedderState *state = new FlutterEmbedderState(); state->plugin_handler = std::make_unique(engine); state->engine = engine; - auto input_plugin = - std::make_unique(); + auto input_plugin = std::make_unique(); state->keyboard_hook_handlers.push_back(input_plugin.get()); glfwSetWindowUserPointer(window, state);