1# Copyright 2012 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//build/buildflag_header.gni") 6import("//build/config/features.gni") 7import("//build/config/nacl/config.gni") 8import("//ipc/features.gni") 9import("//mojo/public/tools/bindings/mojom.gni") 10import("//testing/test.gni") 11import("//third_party/protobuf/proto_library.gni") 12import("//tools/ipc_fuzzer/ipc_fuzzer.gni") 13 14buildflag_header("ipc_buildflags") { 15 header = "ipc_buildflags.h" 16 17 flags = [ "IPC_MESSAGE_LOG_ENABLED=$enable_ipc_logging" ] 18} 19 20component("ipc") { 21 sources = [ 22 # These are the param_traits sources needed by all platforms, 23 # including ios. The rest are added in a conditional block below. 24 "ipc_message_utils.cc", 25 "ipc_message_utils.h", 26 "ipc_mojo_param_traits.cc", 27 "ipc_mojo_param_traits.h", 28 "param_traits_log_macros.h", 29 "param_traits_macros.h", 30 "param_traits_read_macros.h", 31 "param_traits_write_macros.h", 32 "struct_constructor_macros.h", 33 ] 34 35 if (use_blink) { 36 sources += [ 37 # Most sources go here since ios only needs the param_traits 38 # code. 39 "ipc_channel.h", 40 "ipc_channel_common.cc", 41 "ipc_channel_factory.cc", 42 "ipc_channel_factory.h", 43 "ipc_channel_handle.h", 44 "ipc_channel_mojo.cc", 45 "ipc_channel_mojo.h", 46 "ipc_channel_proxy.cc", 47 "ipc_channel_proxy.h", 48 "ipc_channel_reader.cc", 49 "ipc_channel_reader.h", 50 "ipc_listener.cc", 51 "ipc_listener.h", 52 "ipc_logging.cc", 53 "ipc_logging.h", 54 "ipc_message_macros.h", 55 "ipc_message_pipe_reader.cc", 56 "ipc_message_pipe_reader.h", 57 "ipc_message_start.h", 58 "ipc_message_templates.h", 59 "ipc_message_templates_impl.h", 60 "ipc_mojo_bootstrap.cc", 61 "ipc_mojo_bootstrap.h", 62 "ipc_sender.h", 63 "ipc_sync_channel.cc", 64 "ipc_sync_channel.h", 65 "ipc_sync_message_filter.cc", 66 "ipc_sync_message_filter.h", 67 "message_filter.cc", 68 "message_filter.h", 69 "message_filter_router.cc", 70 "message_filter_router.h", 71 "message_router.cc", 72 "message_router.h", 73 "trace_ipc_message.cc", 74 "trace_ipc_message.h", 75 "urgent_message_observer.h", 76 ] 77 } 78 79 if (is_nacl) { 80 sources += [ 81 "ipc_channel_nacl.cc", 82 "ipc_channel_nacl.h", 83 ] 84 } else { 85 sources += [ "ipc_channel.cc" ] 86 } 87 88 defines = [ "IS_IPC_IMPL" ] 89 90 public_deps = [ 91 ":ipc_buildflags", 92 ":message_support", 93 ":mojom", 94 ":native_handle_type_converters", 95 ":param_traits", 96 "//base", 97 "//mojo/public/cpp/base", 98 "//mojo/public/cpp/bindings", 99 "//mojo/public/cpp/system", 100 "//services/tracing/public/cpp", 101 ] 102 103 deps = [ "//base" ] 104 105 if (enable_ipc_fuzzer) { 106 public_configs = [ "//tools/ipc_fuzzer:ipc_fuzzer_config" ] 107 } 108} 109 110component("message_support") { 111 sources = [ 112 "ipc_message.cc", 113 "ipc_message.h", 114 "ipc_message_attachment.cc", 115 "ipc_message_attachment.h", 116 "ipc_message_attachment_set.cc", 117 "ipc_message_attachment_set.h", 118 "ipc_message_support_export.h", 119 "ipc_mojo_handle_attachment.cc", 120 "ipc_mojo_handle_attachment.h", 121 "ipc_mojo_message_helper.cc", 122 "ipc_mojo_message_helper.h", 123 "ipc_platform_file.cc", 124 "ipc_platform_file.h", 125 "ipc_sync_message.cc", 126 "ipc_sync_message.h", 127 ] 128 129 if (is_win) { 130 sources += [ 131 "handle_attachment_win.cc", 132 "handle_attachment_win.h", 133 "handle_win.cc", 134 "handle_win.h", 135 ] 136 } 137 138 if (is_posix || is_fuchsia) { 139 sources += [ 140 "ipc_platform_file_attachment_posix.cc", 141 "ipc_platform_file_attachment_posix.h", 142 ] 143 } 144 145 if (is_apple) { 146 sources += [ 147 "mach_port_attachment_mac.cc", 148 "mach_port_attachment_mac.h", 149 "mach_port_mac.cc", 150 "mach_port_mac.h", 151 ] 152 } 153 154 if (is_fuchsia) { 155 sources += [ 156 "handle_attachment_fuchsia.cc", 157 "handle_attachment_fuchsia.h", 158 ] 159 } 160 161 defines = [ "IPC_MESSAGE_SUPPORT_IMPL" ] 162 163 public_deps = [ 164 ":ipc_buildflags", 165 ":param_traits", 166 "//base", 167 "//mojo/public/cpp/system", 168 ] 169 170 if (is_win || is_mac) { 171 # On Windows HandleAttachmentWin needs to generate random IDs. 172 # On Mac MachPortAttachmentMac needs to generate random IDs. 173 deps = [ "//crypto" ] 174 } 175} 176 177source_set("native_handle_type_converters") { 178 sources = [ 179 "native_handle_type_converters.cc", 180 "native_handle_type_converters.h", 181 ] 182 public_deps = [ 183 ":message_support", 184 "//mojo/public/interfaces/bindings:bindings_headers", 185 ] 186} 187 188mojom_component("mojom") { 189 output_prefix = "ipc_mojom" 190 macro_prefix = "IPC_MOJOM" 191 sources = [ "ipc.mojom" ] 192 public_deps = [ 193 "//mojo/public/interfaces/bindings", 194 "//mojo/public/mojom/base", 195 ] 196 197 cpp_typemaps = [ 198 { 199 types = [ 200 { 201 mojom = "IPC.mojom.Message" 202 cpp = "::IPC::MessageView" 203 move_only = true 204 }, 205 ] 206 traits_headers = [ "//ipc/message_mojom_traits.h" ] 207 traits_sources = [ 208 "//ipc/message_mojom_traits.cc", 209 "//ipc/message_view.cc", 210 "//ipc/message_view.h", 211 ] 212 traits_public_deps = [ "//ipc:message_support" ] 213 }, 214 ] 215 216 # Don't generate a variant sources since we depend on generated internal 217 # bindings types and we don't generate or build variants of those. 218 disable_variants = true 219} 220 221mojom("mojom_constants") { 222 sources = [ "constants.mojom" ] 223} 224 225mojom("test_interfaces") { 226 testonly = true 227 sources = [ "ipc_test.mojom" ] 228 support_lazy_serialization = true 229} 230 231# This is provided as a separate target so other targets can provide param 232# traits implementations without necessarily linking to all of IPC. 233source_set("param_traits") { 234 public = [ "ipc_param_traits.h" ] 235} 236 237# This is provided as a separate target so other targets can use IPC without 238# necessarily linking to protobuf. 239source_set("protobuf_support") { 240 public = [ "ipc_message_protobuf_utils.h" ] 241 public_deps = [ 242 ":ipc", 243 "//third_party/protobuf:protobuf_lite", 244 ] 245} 246 247static_library("test_sink") { 248 testonly = true 249 sources = [ 250 "ipc_security_test_util.cc", 251 "ipc_security_test_util.h", 252 "ipc_test_sink.cc", 253 "ipc_test_sink.h", 254 ] 255 public_deps = [ ":ipc" ] 256 deps = [ 257 "//base", 258 "//base/test:test_support", 259 "//mojo/core/test:test_support", 260 ] 261} 262 263if (use_blink) { 264 source_set("run_all_unittests") { 265 testonly = true 266 267 sources = [ "run_all_unittests.cc" ] 268 269 deps = [ 270 "//base", 271 "//base/test:test_support", 272 "//mojo/core/embedder", 273 "//mojo/core/test:test_support", 274 "//third_party/ipcz/src:ipcz_test_support_chromium", 275 "//third_party/ipcz/src:test_buildflags", 276 ] 277 } 278 279 proto_library("test_proto") { 280 sources = [ "test_proto.proto" ] 281 } 282 283 test("ipc_tests") { 284 sources = [ 285 "ipc_channel_mojo_unittest.cc", 286 "ipc_channel_proxy_unittest.cc", 287 "ipc_channel_reader_unittest.cc", 288 "ipc_fuzzing_tests.cc", 289 "ipc_message_protobuf_utils_unittest.cc", 290 "ipc_message_unittest.cc", 291 "ipc_message_utils_unittest.cc", 292 "ipc_mojo_bootstrap_unittest.cc", 293 "ipc_sync_channel_unittest.cc", 294 "ipc_sync_message_unittest.cc", 295 "ipc_sync_message_unittest.h", 296 "sync_socket_unittest.cc", 297 ] 298 299 if (is_posix || is_fuchsia) { 300 sources += [ "ipc_message_attachment_set_posix_unittest.cc" ] 301 if (!is_ios) { 302 sources += [ "ipc_send_fds_test.cc" ] 303 } 304 } 305 306 deps = [ 307 ":ipc", 308 ":protobuf_support", 309 ":run_all_unittests", 310 ":test_interfaces", 311 ":test_proto", 312 ":test_support", 313 "//base", 314 "//base:i18n", 315 "//base/test:test_support", 316 "//crypto", 317 "//mojo/core:driver_for_ipcz_tests", 318 "//mojo/core/test:test_support", 319 "//testing/gtest", 320 "//third_party/ipcz/src:ipcz_tests_sources_chromium", 321 ] 322 323 if (is_mac) { 324 deps += [ "//sandbox/mac:seatbelt" ] 325 } 326 } 327 328 test("ipc_perftests") { 329 sources = [ 330 "ipc_cpu_perftest.cc", 331 "ipc_mojo_perftest.cc", 332 "ipc_perftest_messages.cc", 333 "ipc_perftest_messages.h", 334 "ipc_perftest_util.cc", 335 "ipc_perftest_util.h", 336 "run_all_perftests.cc", 337 ] 338 339 deps = [ 340 ":ipc", 341 ":test_interfaces", 342 ":test_support", 343 "//base", 344 "//base:i18n", 345 "//base/test:test_support", 346 "//mojo/core/embedder", 347 "//mojo/core/test:test_support", 348 "//mojo/core/test:test_support_impl", 349 "//testing/gtest", 350 ] 351 } 352 353 static_library("test_support") { 354 testonly = true 355 sources = [ 356 "ipc_test_base.cc", 357 "ipc_test_base.h", 358 "ipc_test_channel_listener.cc", 359 "ipc_test_channel_listener.h", 360 ] 361 public_deps = [ 362 ":ipc", 363 ":test_sink", 364 ] 365 deps = [ 366 "//base", 367 "//base/test:test_support", 368 "//mojo/core/test:test_support", 369 "//testing/gtest", 370 ] 371 } 372} 373