Skip to content

Commit 9116521

Browse files
committed
[engine] Add build support for shell/platform/common
1 parent d56717e commit 9116521

File tree

6 files changed

+311
-0
lines changed

6 files changed

+311
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
config("desktop_library_implementation") {
6+
defines = [ "FLUTTER_DESKTOP_LIBRARY" ]
7+
}
8+
9+
_public_headers = [
10+
"public/flutter_export.h",
11+
"public/flutter_messenger.h",
12+
"public/flutter_plugin_registrar.h",
13+
"public/flutter_texture_registrar.h",
14+
]
15+
16+
# Any files that are built by clients (client_wrapper code, library headers for
17+
# implementations using this shared code, etc.) include the public headers
18+
# assuming they are in the include path. This configuration should be added to
19+
# any such code that is also built by GN to make the includes work.
20+
config("relative_flutter_library_headers") {
21+
include_dirs = [ "public" ]
22+
}
23+
24+
# The headers are a separate source set since the client wrapper is allowed
25+
# to depend on the public headers, but none of the rest of the code.
26+
source_set("common_cpp_library_headers") {
27+
public = _public_headers
28+
29+
configs += [ ":desktop_library_implementation" ]
30+
}
31+
32+
copy("publish_headers") {
33+
sources = _public_headers
34+
outputs = [ "$root_out_dir/public/{{source_file_part}}" ]
35+
}
36+
37+
source_set("common_cpp_input") {
38+
public = [
39+
"text_editing_delta.h",
40+
"text_input_model.h",
41+
"text_range.h",
42+
]
43+
44+
sources = [
45+
"text_editing_delta.cc",
46+
"text_input_model.cc",
47+
]
48+
49+
configs += [ ":desktop_library_implementation" ]
50+
51+
public_configs = [ "//flutter:config" ]
52+
53+
deps = [ "//flutter/fml:fml" ]
54+
}
55+
56+
source_set("common_cpp_accessibility") {
57+
public = [
58+
"accessibility_bridge.h",
59+
"flutter_platform_node_delegate.h",
60+
]
61+
62+
sources = [
63+
"accessibility_bridge.cc",
64+
"flutter_platform_node_delegate.cc",
65+
]
66+
67+
public_configs =
68+
[ "//flutter/third_party/accessibility:accessibility_config" ]
69+
70+
public_deps = [
71+
"//flutter/fml:fml",
72+
"//flutter/shell/platform/embedder:embedder_headers",
73+
"//flutter/third_party/accessibility",
74+
]
75+
}
76+
77+
source_set("common_cpp") {
78+
public = [
79+
"incoming_message_dispatcher.h",
80+
"json_message_codec.h",
81+
"json_method_codec.h",
82+
]
83+
84+
# TODO: Refactor flutter_glfw.cc to move the implementations corresponding
85+
# to the _public_headers above into this target.
86+
sources = [
87+
"incoming_message_dispatcher.cc",
88+
"json_message_codec.cc",
89+
"json_method_codec.cc",
90+
]
91+
92+
configs += [ ":desktop_library_implementation" ]
93+
94+
public_configs = [ "//flutter:config" ]
95+
96+
deps = [
97+
":common_cpp_library_headers",
98+
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
99+
]
100+
101+
public_deps = [
102+
":common_cpp_core",
103+
"//third_party/rapidjson",
104+
]
105+
}
106+
107+
# The portion of common_cpp that has no dependencies on the public/
108+
# headers. This division should be revisited once the Linux GTK
109+
# embedding is further along and it's clearer how much, if any, shared
110+
# API surface there will be.
111+
source_set("common_cpp_core") {
112+
public = [
113+
"geometry.h",
114+
"path_utils.h",
115+
]
116+
117+
sources = [ "path_utils.cc" ]
118+
119+
public_configs = [ "//flutter:config" ]
120+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("core_wrapper_files.gni")
6+
7+
# Client library build for internal use by the shell implementation.
8+
source_set("client_wrapper") {
9+
sources = core_cpp_client_wrapper_sources
10+
public = core_cpp_client_wrapper_includes +
11+
core_cpp_client_wrapper_internal_headers
12+
13+
deps = [ "//flutter/shell/platform/common:common_cpp_library_headers" ]
14+
15+
configs +=
16+
[ "//flutter/shell/platform/common:desktop_library_implementation" ]
17+
18+
public_configs =
19+
[ "//flutter/shell/platform/common:relative_flutter_library_headers" ]
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This code is intended to be built into plugins and applications to provide
2+
higher-level, C++ abstractions for interacting with the Flutter library.
3+
4+
Over time, the goal is to move more of this code into the library in a way that
5+
provides a usable ABI (e.g., does not use standard library in the interfaces).
6+
7+
Note that this wrapper is still in early stages. Expect significant churn in
8+
both the APIs and the structure of the wrapper (e.g., the exact set of files
9+
that need to be built).
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
core_cpp_client_wrapper_includes =
6+
get_path_info([
7+
"include/flutter/basic_message_channel.h",
8+
"include/flutter/binary_messenger.h",
9+
"include/flutter/byte_streams.h",
10+
"include/flutter/encodable_value.h",
11+
"include/flutter/engine_method_result.h",
12+
"include/flutter/event_channel.h",
13+
"include/flutter/event_sink.h",
14+
"include/flutter/event_stream_handler_functions.h",
15+
"include/flutter/event_stream_handler.h",
16+
"include/flutter/message_codec.h",
17+
"include/flutter/method_call.h",
18+
"include/flutter/method_channel.h",
19+
"include/flutter/method_codec.h",
20+
"include/flutter/method_result_functions.h",
21+
"include/flutter/method_result.h",
22+
"include/flutter/plugin_registrar.h",
23+
"include/flutter/plugin_registry.h",
24+
"include/flutter/standard_codec_serializer.h",
25+
"include/flutter/standard_message_codec.h",
26+
"include/flutter/standard_method_codec.h",
27+
"include/flutter/texture_registrar.h",
28+
],
29+
"abspath")
30+
31+
# Headers that aren't public for clients of the wrapper, but are considered
32+
# public for the purpose of BUILD dependencies (e.g., to allow
33+
# windows/client_wrapper implementation files to include them).
34+
core_cpp_client_wrapper_internal_headers =
35+
get_path_info([
36+
"binary_messenger_impl.h",
37+
"byte_buffer_streams.h",
38+
"texture_registrar_impl.h",
39+
],
40+
"abspath")
41+
42+
# TODO: Once the wrapper API is more stable, consolidate to as few files as is
43+
# reasonable (without forcing different kinds of clients to take unnecessary
44+
# code) to simplify use.
45+
core_cpp_client_wrapper_sources = get_path_info([
46+
"core_implementations.cc",
47+
"plugin_registrar.cc",
48+
"standard_codec.cc",
49+
],
50+
"abspath")
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
import("core_wrapper_files.gni")
6+
7+
# Publishes client wrapper files to the output directory for distribution.
8+
# This can be used multiple times to combine various portions of a wrapper
9+
# library into one cohesive library for clients to consume.
10+
#
11+
# Files that should be built by clients go into 'sources', while headers meant
12+
# to be included by the consuming code go into 'public'.
13+
#
14+
# All public code is assumed to be in the 'flutter' namespace.
15+
template("publish_client_wrapper") {
16+
forward_variables_from(invoker, [ "directory_suffix" ])
17+
if (defined(directory_suffix)) {
18+
publish_dir_root = "$root_out_dir/cpp_client_wrapper_$directory_suffix"
19+
} else {
20+
publish_dir_root = "$root_out_dir/cpp_client_wrapper"
21+
}
22+
template_target_name = target_name
23+
namespace = "flutter"
24+
25+
group(template_target_name) {
26+
forward_variables_from(invoker,
27+
[
28+
"public_deps",
29+
"visibility",
30+
])
31+
deps = [
32+
":${template_target_name}_publish_includes",
33+
":${template_target_name}_publish_sources",
34+
]
35+
if (defined(invoker.deps)) {
36+
deps += invoker.deps
37+
}
38+
}
39+
40+
copy("${template_target_name}_publish_includes") {
41+
visibility = [
42+
":$template_target_name",
43+
":${template_target_name}_publish_sources",
44+
]
45+
46+
sources = invoker.public
47+
outputs = [ "$publish_dir_root/include/$namespace/{{source_file_part}}" ]
48+
}
49+
50+
copy("${template_target_name}_publish_sources") {
51+
visibility = [ ":$template_target_name" ]
52+
53+
sources = invoker.sources
54+
outputs = [ "$publish_dir_root/{{source_file_part}}" ]
55+
56+
# GN on Windows appears to do #include checks even for copy
57+
# targets, so add the dependency to the headers to satisfy
58+
# the check.
59+
deps = [ ":${template_target_name}_publish_includes" ]
60+
}
61+
}
62+
63+
_wrapper_readme = get_path_info("README", "abspath")
64+
65+
# Copies the client wrapper code to the output directory.
66+
template("publish_client_wrapper_core") {
67+
publish_client_wrapper(target_name) {
68+
forward_variables_from(invoker,
69+
[
70+
"directory_suffix",
71+
"visibility",
72+
])
73+
public = core_cpp_client_wrapper_includes
74+
sources = core_cpp_client_wrapper_sources +
75+
core_cpp_client_wrapper_internal_headers + [ _wrapper_readme ]
76+
}
77+
}
78+
79+
# A wrapper for publish_client_wrapper that will also
80+
# publish_client_wrapper_core into the same directory.
81+
#
82+
# This is a convenience utility for the common case of wanting to publish
83+
# the core wrapper and a single set of extra wrapper files corresponding to
84+
# the platform.
85+
template("publish_client_wrapper_extension") {
86+
extension_target_name = target_name
87+
core_target_name = "${target_name}_core"
88+
89+
publish_client_wrapper_core(core_target_name) {
90+
visibility = [ ":$extension_target_name" ]
91+
forward_variables_from(invoker, [ "directory_suffix" ])
92+
}
93+
94+
publish_client_wrapper(extension_target_name) {
95+
forward_variables_from(invoker,
96+
[
97+
"public",
98+
"sources",
99+
"directory_suffix",
100+
])
101+
public_deps = [ ":$core_target_name" ]
102+
}
103+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
source_set("embedder_headers") {
6+
public = [ "embedder.h" ]
7+
8+
public_configs = [ "//flutter:config" ]
9+
}

0 commit comments

Comments
 (0)