BUILD.gn 8.4 KB

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