blob: b5682e3eef58938d3198a056cd442f7983b6ece0 [file] [log] [blame]
[email protected]7603bbd12013-08-13 17:33:371# Copyright (c) 2012 The Chromium 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
davidsz041528a2017-05-12 09:19:235import("//build/buildflag_header.gni")
phosek636bceb32015-10-27 03:36:486import("//build/config/nacl/config.gni")
Daniel Chenga75606f2018-03-13 05:01:467import("//ipc/features.gni")
amistryd4aa70d2016-06-23 07:52:378import("//mojo/public/tools/bindings/mojom.gni")
qsrfb5251d12015-01-21 15:57:229import("//testing/test.gni")
ochangcc11d0e2016-04-26 19:58:2610import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
zijiehe84eef4fa2017-07-18 20:39:5011import("//third_party/protobuf/proto_library.gni")
qsrfb5251d12015-01-21 15:57:2212
Scott Violeta35f9a42018-03-22 22:00:4413buildflag_header("ipc_buildflags") {
14 header = "ipc_buildflags.h"
davidsz041528a2017-05-12 09:19:2315
16 flags = [ "IPC_MESSAGE_LOG_ENABLED=$enable_ipc_logging" ]
17}
18
[email protected]7603bbd12013-08-13 17:33:3719component("ipc") {
20 sources = [
Daniel Bratell7c413be2018-10-19 17:50:0221 # These are the param_traits sources needed by all platforms,
22 # including ios. The rest are added in a conditional block below.
[email protected]7603bbd12013-08-13 17:33:3723 "ipc_message_utils.cc",
24 "ipc_message_utils.h",
amistryd4aa70d2016-06-23 07:52:3725 "ipc_mojo_param_traits.cc",
26 "ipc_mojo_param_traits.h",
[email protected]7603bbd12013-08-13 17:33:3727 "param_traits_log_macros.h",
28 "param_traits_macros.h",
29 "param_traits_read_macros.h",
30 "param_traits_write_macros.h",
31 "struct_constructor_macros.h",
[email protected]7603bbd12013-08-13 17:33:3732 ]
33
Daniel Bratell7c413be2018-10-19 17:50:0234 if (!is_ios) {
35 sources += [
36 # Most sources go here since ios only needs the param_traits
37 # code.
38 "ipc_channel.h",
39 "ipc_channel_common.cc",
40 "ipc_channel_factory.cc",
41 "ipc_channel_factory.h",
42 "ipc_channel_handle.h",
43 "ipc_channel_mojo.cc",
44 "ipc_channel_mojo.h",
45 "ipc_channel_proxy.cc",
46 "ipc_channel_proxy.h",
47 "ipc_channel_reader.cc",
48 "ipc_channel_reader.h",
49 "ipc_listener.h",
50 "ipc_logging.cc",
51 "ipc_logging.h",
52 "ipc_message_macros.h",
53 "ipc_message_pipe_reader.cc",
54 "ipc_message_pipe_reader.h",
55 "ipc_message_start.h",
56 "ipc_message_templates.h",
57 "ipc_message_templates_impl.h",
58 "ipc_mojo_bootstrap.cc",
59 "ipc_mojo_bootstrap.h",
60 "ipc_sender.h",
61 "ipc_sync_channel.cc",
62 "ipc_sync_channel.h",
63 "ipc_sync_message_filter.cc",
64 "ipc_sync_message_filter.h",
65 "message_filter.cc",
66 "message_filter.h",
67 "message_filter_router.cc",
68 "message_filter_router.h",
69 "message_router.cc",
70 "message_router.h",
71 ]
72 }
73
phosek636bceb32015-10-27 03:36:4874 if (is_nacl && !is_nacl_nonsfi) {
Daniel Bratell7c413be2018-10-19 17:50:0275 sources += [
[email protected]7603bbd12013-08-13 17:33:3776 "ipc_channel_nacl.cc",
77 "ipc_channel_nacl.h",
78 ]
Daniel Bratell7c413be2018-10-19 17:50:0279 } else {
80 sources += [ "ipc_channel.cc" ]
[email protected]517d5282014-04-02 17:03:3081 }
[email protected]7603bbd12013-08-13 17:33:3782
Ken Rockot3044d212018-01-23 02:44:3983 defines = [ "IS_IPC_IMPL" ]
[email protected]7603bbd12013-08-13 17:33:3784
brettwb7f2c302015-12-08 01:29:2185 public_deps = [
Scott Violeta35f9a42018-03-22 22:00:4486 ":ipc_buildflags",
Ken Rockotfd907632017-09-14 04:23:4187 ":message_support",
rockota628d0b2017-02-09 08:40:1588 ":mojom",
Eve Martin-Jones475e7e62018-02-13 22:57:2589 ":native_handle_type_converters",
brettwb7f2c302015-12-08 01:29:2190 ":param_traits",
Ken Rockot4c5bd802018-07-12 01:37:1191 "//mojo/public/cpp/base",
leon.hanf870ab52016-07-14 15:03:4892 "//mojo/public/cpp/bindings",
rockot6d7be622016-06-15 18:25:1993 "//mojo/public/cpp/system",
brettwb7f2c302015-12-08 01:29:2194 ]
zijiehe84eef4fa2017-07-18 20:39:5095
96 if (!is_nacl_nonsfi) {
Mike Bjorgeb7bf5b92017-07-28 00:43:4997 sources += [ "ipc_message_protobuf_utils.h" ]
zijiehe84eef4fa2017-07-18 20:39:5098
Mike Bjorgeb7bf5b92017-07-28 00:43:4999 public_deps += [ "//third_party/protobuf:protobuf_lite" ]
zijiehe84eef4fa2017-07-18 20:39:50100 }
101
[email protected]7603bbd12013-08-13 17:33:37102 deps = [
103 "//base",
[email protected]7603bbd12013-08-13 17:33:37104 ]
Sergey Ulanov384a29c92015-09-14 17:11:35105
ochangcc11d0e2016-04-26 19:58:26106 if (enable_ipc_fuzzer) {
107 public_configs = [ "//tools/ipc_fuzzer:ipc_fuzzer_config" ]
108 }
[email protected]7603bbd12013-08-13 17:33:37109}
110
Ken Rockotfd907632017-09-14 04:23:41111component("message_support") {
112 sources = [
113 "handle_attachment_win.cc",
114 "handle_attachment_win.h",
115 "handle_win.cc",
116 "handle_win.h",
117 "ipc_message.cc",
118 "ipc_message.h",
119 "ipc_message_attachment.cc",
120 "ipc_message_attachment.h",
121 "ipc_message_attachment_set.cc",
122 "ipc_message_attachment_set.h",
123 "ipc_message_support_export.h",
124 "ipc_mojo_handle_attachment.cc",
125 "ipc_mojo_handle_attachment.h",
126 "ipc_mojo_message_helper.cc",
127 "ipc_mojo_message_helper.h",
128 "ipc_platform_file.cc",
129 "ipc_platform_file.h",
Ken Rockotfd907632017-09-14 04:23:41130 "ipc_sync_message.cc",
131 "ipc_sync_message.h",
132 "mach_port_attachment_mac.cc",
133 "mach_port_attachment_mac.h",
134 "mach_port_mac.cc",
135 "mach_port_mac.h",
136 ]
137
Fabrice de Gans-Riberi3fdec692018-04-20 21:53:59138 if (is_posix || is_fuchsia) {
139 sources += [
140 "ipc_platform_file_attachment_posix.cc",
141 "ipc_platform_file_attachment_posix.h",
142 ]
143 }
144
Ken Rockotfd907632017-09-14 04:23:41145 if (is_fuchsia) {
146 sources += [
147 "handle_attachment_fuchsia.cc",
148 "handle_attachment_fuchsia.h",
149 "handle_fuchsia.cc",
150 "handle_fuchsia.h",
151 ]
152 }
153
154 defines = [ "IPC_MESSAGE_SUPPORT_IMPL" ]
155
156 public_deps = [
Scott Violeta35f9a42018-03-22 22:00:44157 ":ipc_buildflags",
Ken Rockotfd907632017-09-14 04:23:41158 ":param_traits",
159 "//base",
160 "//mojo/public/cpp/system",
161 ]
162
163 if (is_win || is_mac) {
164 # On Windows HandleAttachmentWin needs to generate random IDs.
165 # On Mac MachPortAttachmentMac needs to generate random IDs.
166 deps = [
167 "//crypto",
168 ]
169 }
170}
171
172source_set("native_handle_type_converters") {
173 sources = [
174 "native_handle_type_converters.cc",
175 "native_handle_type_converters.h",
176 ]
177 public_deps = [
178 ":message_support",
Marek Haranczyk07795892018-08-14 09:46:03179 "//mojo/public/interfaces/bindings:bindings_headers",
Ken Rockotfd907632017-09-14 04:23:41180 ]
181}
182
Ken Rockotfe0424e72017-05-13 02:29:08183mojom_component("mojom") {
184 output_prefix = "ipc_mojom"
185 macro_prefix = "IPC_MOJOM"
amistryd4aa70d2016-06-23 07:52:37186 sources = [
187 "ipc.mojom",
188 ]
Yuzhu Shena0a2b362017-08-25 22:31:39189 public_deps = [
Eve Martin-Jones475e7e62018-02-13 22:57:25190 "//mojo/public/interfaces/bindings",
Ken Rockot4c5bd802018-07-12 01:37:11191 "//mojo/public/mojom/base",
Yuzhu Shena0a2b362017-08-25 22:31:39192 ]
Ken Rockotfd907632017-09-14 04:23:41193
194 # Don't generate a variant sources since we depend on generated internal
195 # bindings types and we don't generate or build variants of those.
196 disable_variants = true
197}
198
199mojom("mojom_constants") {
200 sources = [
201 "constants.mojom",
202 ]
amistryd4aa70d2016-06-23 07:52:37203}
204
rockot7c6bf952016-07-14 00:34:11205mojom("test_interfaces") {
206 testonly = true
207 sources = [
208 "ipc_test.mojom",
209 ]
Ken Rockot474df0142017-07-12 13:28:56210 support_lazy_serialization = true
rockot7c6bf952016-07-14 00:34:11211}
212
brettwb7f2c302015-12-08 01:29:21213# This is provided as a separate target so other targets can provide param
214# traits implementations without necessarily linking to all of IPC.
215source_set("param_traits") {
216 public = [
217 "ipc_param_traits.h",
218 ]
219}
220
sdefresne6fd373e2016-05-24 21:24:06221if (!is_ios) {
rockot6d7be622016-06-15 18:25:19222 source_set("run_all_unittests") {
223 testonly = true
224
225 sources = [
226 "run_all_unittests.cc",
227 ]
228
229 deps = [
230 "//base",
231 "//base/test:test_support",
Ken Rockot8a7f35f2018-07-04 19:40:56232 "//mojo/core/embedder",
233 "//mojo/core/test:test_support",
rockot6d7be622016-06-15 18:25:19234 ]
235 }
236
zijiehe84eef4fa2017-07-18 20:39:50237 proto_library("test_proto") {
238 sources = [
239 "test_proto.proto",
240 ]
241 }
242
sdefresne6fd373e2016-05-24 21:24:06243 test("ipc_tests") {
244 sources = [
amistryd4aa70d2016-06-23 07:52:37245 "ipc_channel_mojo_unittest.cc",
sdefresne6fd373e2016-05-24 21:24:06246 "ipc_channel_proxy_unittest.cc",
247 "ipc_channel_reader_unittest.cc",
248 "ipc_fuzzing_tests.cc",
sdefresne6fd373e2016-05-24 21:24:06249 "ipc_message_unittest.cc",
250 "ipc_message_utils_unittest.cc",
amistryd4aa70d2016-06-23 07:52:37251 "ipc_mojo_bootstrap_unittest.cc",
sdefresne6fd373e2016-05-24 21:24:06252 "ipc_sync_channel_unittest.cc",
253 "ipc_sync_message_unittest.cc",
254 "ipc_sync_message_unittest.h",
255 "ipc_test_message_generator.cc",
256 "ipc_test_message_generator.h",
257 "ipc_test_messages.h",
sdefresne6fd373e2016-05-24 21:24:06258 "sync_socket_unittest.cc",
259 ]
pkotwicza553a3b2015-10-16 22:29:46260
Fabrice de Gans-Riberi3fdec692018-04-20 21:53:59261 if (is_posix || is_fuchsia) {
262 sources += [ "ipc_message_attachment_set_posix_unittest.cc" ]
263 }
264
sdefresne6fd373e2016-05-24 21:24:06265 if (!is_ios) {
266 sources += [ "ipc_send_fds_test.cc" ]
267 }
268
sdefresne6fd373e2016-05-24 21:24:06269 deps = [
270 ":ipc",
rockot6d7be622016-06-15 18:25:19271 ":run_all_unittests",
rockot7c6bf952016-07-14 00:34:11272 ":test_interfaces",
zijiehe84eef4fa2017-07-18 20:39:50273 ":test_proto",
sdefresne6fd373e2016-05-24 21:24:06274 ":test_support",
275 "//base",
276 "//base:i18n",
277 "//base/test:test_support",
278 "//crypto",
Ken Rockot8a7f35f2018-07-04 19:40:56279 "//mojo/core/embedder",
280 "//mojo/core/test:test_support",
sdefresne6fd373e2016-05-24 21:24:06281 "//testing/gtest",
282 ]
283
284 if (is_mac) {
285 deps += [ "//sandbox/mac:seatbelt" ]
286 }
Scott Grahamf4b38b42017-06-19 23:09:33287
288 if (is_fuchsia) {
289 sources -= [
290 # No AF_UNIX domain sockets on Fuchsia.
291 "sync_socket_unittest.cc",
292 ]
293 }
zijiehe84eef4fa2017-07-18 20:39:50294
295 if (!is_nacl_nonsfi) {
Mike Bjorgeb7bf5b92017-07-28 00:43:49296 sources += [ "ipc_message_protobuf_utils_unittest.cc" ]
zijiehe84eef4fa2017-07-18 20:39:50297 }
dpranke177c1e22015-07-22 23:07:43298 }
299
sdefresne6fd373e2016-05-24 21:24:06300 test("ipc_perftests") {
301 sources = [
Yuzhu Shen4d50dc42017-09-06 20:39:09302 "ipc_cpu_perftest.cc",
amistryd4aa70d2016-06-23 07:52:37303 "ipc_mojo_perftest.cc",
Yuzhu Shen4d50dc42017-09-06 20:39:09304 "ipc_perftest_messages.cc",
305 "ipc_perftest_messages.h",
306 "ipc_perftest_util.cc",
307 "ipc_perftest_util.h",
amistryd4aa70d2016-06-23 07:52:37308 "run_all_perftests.cc",
sdefresne6fd373e2016-05-24 21:24:06309 ]
310
sdefresne6fd373e2016-05-24 21:24:06311 deps = [
312 ":ipc",
jamca86c9e2017-01-06 19:55:57313 ":test_interfaces",
sdefresne6fd373e2016-05-24 21:24:06314 ":test_support",
315 "//base",
316 "//base:i18n",
317 "//base/test:test_support",
Ken Rockot8a7f35f2018-07-04 19:40:56318 "//mojo/core/embedder",
319 "//mojo/core/test:test_support",
320 "//mojo/core/test:test_support_impl",
sdefresne6fd373e2016-05-24 21:24:06321 "//testing/gtest",
322 ]
brettwa59908d22016-01-21 19:16:48323 }
324
brettw3871f522016-07-14 22:08:34325 static_library("test_support") {
sdefresne6fd373e2016-05-24 21:24:06326 testonly = true
327 sources = [
sdefresne6fd373e2016-05-24 21:24:06328 "ipc_security_test_util.cc",
329 "ipc_security_test_util.h",
330 "ipc_test_base.cc",
331 "ipc_test_base.h",
332 "ipc_test_channel_listener.cc",
333 "ipc_test_channel_listener.h",
334 "ipc_test_sink.cc",
335 "ipc_test_sink.h",
sdefresne6fd373e2016-05-24 21:24:06336 ]
337 public_deps = [
338 ":ipc",
339 ]
340 deps = [
341 "//base",
342 "//base/test:test_support",
Ken Rockot8a7f35f2018-07-04 19:40:56343 "//mojo/core/test:test_support",
sdefresne6fd373e2016-05-24 21:24:06344 "//testing/gtest",
345 ]
kerrneldc059fe2016-04-12 16:39:06346 }
pkotwicza553a3b2015-10-16 22:29:46347}