Skip to content

Move most C++ library code to common/ and include/ #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion example/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) \
Expand Down
7 changes: 6 additions & 1 deletion example/linux/flutter_embedder_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@

#include <color_panel/color_panel_plugin.h>
#include <file_chooser/file_chooser_plugin.h>
#include <flutter_desktop_embedding/embedder.h>
#include <menubar/menubar_plugin.h>

#ifdef USE_FLATTENED_INCLUDES
#include <flutter_desktop_embedding/embedder.h>
#else
#include <flutter_desktop_embedding/linux/embedder.h>
#endif

namespace {

// Returns the path of the directory containing this executable, or an empty
Expand Down
73 changes: 42 additions & 31 deletions library/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,51 @@ 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/key_event_handler.cc",
"linux/src/internal/key_event_handler.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",
]
public = [
"linux/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",
"include/flutter_desktop_embedding/linux/embedder.h",
]
}
if (is_linux || is_win) {
sources += [
"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",
]
}
# GLFW-specific code.
if (is_linux || is_win) {
sources += [
"common/glfw/key_event_handler.cc",
"common/glfw/key_event_handler.h",
"common/glfw/keyboard_hook_handler.h",
"common/glfw/text_input_plugin.cc",
"common/glfw/text_input_plugin.h",
]
}

Expand Down
6 changes: 5 additions & 1 deletion library/GN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "library/linux/src/internal/key_event_handler.h"
#include "library/common/glfw/key_event_handler.h"

#include <json/json.h>
#include <iostream>

#include "library/linux/src/internal/json_message_codec.h"
#include "library/common/internal/json_message_codec.h"

static constexpr char kChannelName[] = "flutter/keyevent";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#ifndef LIBRARY_LINUX_SRC_INTERNAL_KEY_EVENT_HANDLER_H_
#define LIBRARY_LINUX_SRC_INTERNAL_kEY_EVENT_HANDLER_H_
#ifndef LIBRARY_COMMON_GLFW_KEY_EVENT_HANDLER_H_
#define LIBRARY_COMMON_GLFW_kEY_EVENT_HANDLER_H_

#include "library/linux/include/flutter_desktop_embedding/binary_messenger.h"
#include "library/linux/src/internal/keyboard_hook_handler.h"
#include "library/common/glfw/keyboard_hook_handler.h"
#include "library/include/flutter_desktop_embedding/binary_messenger.h"

namespace flutter_desktop_embedding {

Expand All @@ -41,4 +41,4 @@ class KeyEventHandler : public KeyboardHookHandler {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_SRC_INTERNAL_KEY_EVENT_HANDLER_H_
#endif // LIBRARY_COMMON_GLFW_KEY_EVENT_HANDLER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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_SRC_INTERNAL_INPUT_KEYBOARD_HOOK_HANDLER_H_
#define LIBRARY_LINUX_SRC_INTERNAL_INPUT_KEYBOARD_HOOK_HANDLER_H_
#ifndef LIBRARY_COMMON_GLFW_KEYBOARD_HOOK_HANDLER_H_
#define LIBRARY_COMMON_GLFW_KEYBOARD_HOOK_HANDLER_H_

#include <GLFW/glfw3.h>

Expand All @@ -31,4 +31,4 @@ class KeyboardHookHandler {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_SRC_INTERNAL_INPUT_KEYBOARD_HOOK_HANDLER_H_
#endif // LIBRARY_COMMON_GLFW_KEYBOARD_HOOK_HANDLER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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/common/glfw/text_input_plugin.h"

#include <cstdint>
#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
// 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_SRC_INTERNAL_TEXT_INPUT_PLUGIN_H_
#define LIBRARY_LINUX_SRC_INTERNAL_TEXT_INPUT_PLUGIN_H_
#ifndef LIBRARY_COMMON_GLFW_TEXT_INPUT_PLUGIN_H_
#define LIBRARY_COMMON_GLFW_TEXT_INPUT_PLUGIN_H_

#include <map>
#include <memory>

#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/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 {

Expand Down Expand Up @@ -58,4 +58,4 @@ class TextInputPlugin : public KeyboardHookHandler, public JsonPlugin {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_SRC_INTERNAL_TEXT_INPUT_PLUGIN_H_
#endif // LIBRARY_COMMON_GLFW_TEXT_INPUT_PLUGIN_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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/common/internal/engine_method_result.h"

#include <iostream>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
// 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_SRC_INTERNAL_ENGINE_METHOD_RESULT_H_
#define LIBRARY_LINUX_SRC_INTERNAL_ENGINE_METHOD_RESULT_H_
#ifndef LIBRARY_COMMON_INTERNAL_ENGINE_METHOD_RESULT_H_
#define LIBRARY_COMMON_INTERNAL_ENGINE_METHOD_RESULT_H_

#include <string>
#include <vector>

#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/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 {

Expand Down Expand Up @@ -54,4 +54,4 @@ class EngineMethodResult : public MethodResult {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_SRC_INTERNAL_ENGINE_METHOD_RESULT_H_
#endif // LIBRARY_COMMON_INTERNAL_ENGINE_METHOD_RESULT_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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/common/internal/json_message_codec.h"

#include <iostream>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_MESSAGE_CODEC_H_
#define LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_
#ifndef LIBRARY_COMMON_INTERNAL_JSON_MESSAGE_CODEC_H_
#define LIBRARY_COMMON_INTERNAL_JSON_MESSAGE_CODEC_H_

#include <memory>
#include <vector>
Expand Down Expand Up @@ -56,4 +56,4 @@ class JsonMessageCodec {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_INCLUDE_FLUTTER_DESKTOP_EMBEDDING_JSON_MESSAGE_CODEC_H_
#endif // LIBRARY_COMMON_INTERNAL_JSON_MESSAGE_CODEC_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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/common/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/common/internal/engine_method_result.h"
#include "library/include/flutter_desktop_embedding/method_channel.h"

#include <iostream>

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef LIBRARY_LINUX_SRC_INTERNAL_PLUGIN_HANDLER_H_
#define LIBRARY_LINUX_SRC_INTERNAL_PLUGIN_HANDLER_H_
#ifndef LIBRARY_COMMON_INTERNAL_PLUGIN_HANDLER_H_
#define LIBRARY_COMMON_INTERNAL_PLUGIN_HANDLER_H_

#include <map>
#include <memory>
#include <string>

#include <flutter_embedder.h>

#include "library/linux/include/flutter_desktop_embedding/binary_messenger.h"
#include "library/linux/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 {

Expand Down Expand Up @@ -74,4 +74,4 @@ class PluginHandler : public BinaryMessenger {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_SRC_INTERNAL_PLUGIN_HANDLER_H_
#endif // LIBRARY_COMMON_INTERNAL_PLUGIN_HANDLER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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/common/internal/text_input_model.h"

#include <iostream>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_SRC_INTERNAL_TEXT_INPUT_MODEL_H_
#define LIBRARY_LINUX_SRC_INTERNAL_TEXT_INPUT_MODEL_H_
#ifndef LIBRARY_COMMON_INTERNAL_TEXT_INPUT_MODEL_H_
#define LIBRARY_COMMON_INTERNAL_TEXT_INPUT_MODEL_H_

#include <string>

Expand Down Expand Up @@ -95,4 +95,4 @@ class TextInputModel {

} // namespace flutter_desktop_embedding

#endif // LIBRARY_LINUX_SRC_INTERNAL_TEXT_INPUT_MODEL_H_
#endif // LIBRARY_COMMON_INTERNAL_TEXT_INPUT_MODEL_H_
Original file line number Diff line number Diff line change
Expand Up @@ -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/include/flutter_desktop_embedding/json_method_call.h"

namespace flutter_desktop_embedding {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/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/common/internal/json_message_codec.h"
#include "library/include/flutter_desktop_embedding/json_method_call.h"

namespace flutter_desktop_embedding {

Expand Down
Loading