BUILD.bazel 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. # Bazel build
  2. # C/C++ documentation: https://docs.bazel.build/versions/master/be/c-cpp.html
  3. load("@rules_proto_grpc//python:defs.bzl", "python_proto_compile")
  4. load("//bazel:ray.bzl", "COPTS", "copy_to_workspace")
  5. proto_library(
  6. name = "streaming_proto",
  7. srcs = ["src/protobuf/streaming.proto"],
  8. strip_import_prefix = "src",
  9. visibility = ["//visibility:public"],
  10. )
  11. proto_library(
  12. name = "streaming_queue_proto",
  13. srcs = ["src/protobuf/streaming_queue.proto"],
  14. strip_import_prefix = "src",
  15. )
  16. proto_library(
  17. name = "remote_call_proto",
  18. srcs = ["src/protobuf/remote_call.proto"],
  19. strip_import_prefix = "src",
  20. visibility = ["//visibility:public"],
  21. deps = [
  22. "streaming_proto",
  23. "@com_google_protobuf//:any_proto",
  24. ],
  25. )
  26. cc_proto_library(
  27. name = "streaming_cc_proto",
  28. deps = [":streaming_proto"],
  29. )
  30. cc_proto_library(
  31. name = "streaming_queue_cc_proto",
  32. deps = ["streaming_queue_proto"],
  33. )
  34. # Use `linkshared` to ensure ray related symbols are not packed into streaming libs
  35. # to avoid duplicate symbols. In runtime we expose ray related symbols, which can
  36. # be linked into streaming libs by dynamic linker. See bazel rule `//:_raylet`
  37. cc_binary(
  38. name = "ray_util.so",
  39. copts = COPTS,
  40. linkshared = 1,
  41. visibility = ["//visibility:public"],
  42. deps = ["//:ray_util"],
  43. )
  44. cc_binary(
  45. name = "ray_common.so",
  46. copts = COPTS,
  47. linkshared = 1,
  48. visibility = ["//visibility:public"],
  49. deps = ["//:ray_common"],
  50. )
  51. cc_binary(
  52. name = "stats_lib.so",
  53. copts = COPTS,
  54. linkshared = 1,
  55. visibility = ["//visibility:public"],
  56. deps = ["//:stats_lib"],
  57. )
  58. cc_binary(
  59. name = "core_worker_lib.so",
  60. copts = COPTS,
  61. linkshared = 1,
  62. deps = ["//:core_worker_lib"],
  63. )
  64. cc_binary(
  65. name = "exported_streaming_internal.so",
  66. copts = COPTS,
  67. linkshared = 1,
  68. deps = ["//:exported_streaming_internal"],
  69. )
  70. cc_library(
  71. name = "streaming_util",
  72. srcs = glob([
  73. "src/util/*.cc",
  74. ]),
  75. hdrs = glob([
  76. "src/util/*.h",
  77. ]),
  78. copts = COPTS,
  79. includes = ["src"],
  80. visibility = ["//visibility:public"],
  81. deps = [
  82. "ray_common.so",
  83. "ray_util.so",
  84. "@boost//:any",
  85. "@com_google_googletest//:gtest",
  86. ],
  87. )
  88. cc_library(
  89. name = "streaming_metrics",
  90. srcs = glob([
  91. "src/metrics/*.cc",
  92. ]),
  93. hdrs = glob([
  94. "src/metrics/*.h",
  95. ]),
  96. copts = COPTS,
  97. strip_include_prefix = "src",
  98. visibility = ["//visibility:public"],
  99. deps = [
  100. "stats_lib.so",
  101. ":streaming_config",
  102. ":streaming_util",
  103. ],
  104. )
  105. cc_library(
  106. name = "streaming_config",
  107. srcs = glob([
  108. "src/config/*.cc",
  109. ]),
  110. hdrs = glob([
  111. "src/config/*.h",
  112. ]),
  113. copts = COPTS,
  114. strip_include_prefix = "src",
  115. deps = [
  116. "ray_common.so",
  117. ":streaming_cc_proto",
  118. ":streaming_util",
  119. ],
  120. )
  121. cc_library(
  122. name = "streaming_message",
  123. srcs = glob([
  124. "src/message/*.cc",
  125. ]),
  126. hdrs = glob([
  127. "src/message/*.h",
  128. ]),
  129. copts = COPTS,
  130. strip_include_prefix = "src",
  131. deps = [
  132. "ray_common.so",
  133. ":streaming_config",
  134. ":streaming_util",
  135. ],
  136. )
  137. cc_library(
  138. name = "streaming_queue",
  139. srcs = glob([
  140. "src/queue/*.cc",
  141. ]),
  142. hdrs = glob([
  143. "src/queue/*.h",
  144. ]),
  145. copts = COPTS,
  146. strip_include_prefix = "src",
  147. deps = [
  148. "ray_common.so",
  149. "ray_util.so",
  150. ":streaming_config",
  151. ":streaming_message",
  152. ":streaming_queue_cc_proto",
  153. ":streaming_util",
  154. "@boost//:asio",
  155. "@boost//:thread",
  156. ] + select({
  157. "@bazel_tools//src/conditions:windows": [
  158. # TODO(mehrdadn): This is to resolve symbols on Windows for now. Should remove this later. (See d7f8d18.)
  159. "//:core_worker_lib",
  160. "//:exported_streaming_internal",
  161. ],
  162. "//conditions:default": [
  163. "core_worker_lib.so",
  164. "exported_streaming_internal.so",
  165. ],
  166. }),
  167. )
  168. cc_library(
  169. name = "streaming_channel",
  170. srcs = glob(["src/channel/*.cc"]),
  171. hdrs = glob(["src/channel/*.h"]),
  172. copts = COPTS,
  173. visibility = ["//visibility:public"],
  174. deps = [
  175. ":streaming_common",
  176. ":streaming_message",
  177. ":streaming_queue",
  178. ":streaming_ring_buffer",
  179. ":streaming_util",
  180. ],
  181. )
  182. cc_library(
  183. name = "streaming_reliability",
  184. srcs = glob(["src/reliability/*.cc"]),
  185. hdrs = glob(["src/reliability/*.h"]),
  186. copts = COPTS,
  187. includes = ["src/"],
  188. visibility = ["//visibility:public"],
  189. deps = [
  190. ":streaming_channel",
  191. ":streaming_message",
  192. ":streaming_util",
  193. ],
  194. )
  195. cc_library(
  196. name = "streaming_ring_buffer",
  197. srcs = glob(["src/ring_buffer/*.cc"]),
  198. hdrs = glob(["src/ring_buffer/*.h"]),
  199. copts = COPTS,
  200. includes = ["src/"],
  201. visibility = ["//visibility:public"],
  202. deps = [
  203. "core_worker_lib.so",
  204. ":ray_common.so",
  205. ":ray_util.so",
  206. ":streaming_message",
  207. "@boost//:circular_buffer",
  208. "@boost//:thread",
  209. ],
  210. )
  211. cc_library(
  212. name = "streaming_common",
  213. srcs = glob(["src/common/*.cc"]),
  214. hdrs = glob(["src/common/*.h"]),
  215. copts = COPTS,
  216. includes = ["src/"],
  217. visibility = ["//visibility:public"],
  218. deps = [],
  219. )
  220. cc_library(
  221. name = "streaming_lib",
  222. srcs = glob([
  223. "src/*.cc",
  224. ]),
  225. hdrs = glob([
  226. "src/*.h",
  227. "src/queue/*.h",
  228. "src/test/*.h",
  229. ]),
  230. copts = COPTS,
  231. strip_include_prefix = "src",
  232. visibility = ["//visibility:public"],
  233. deps = [
  234. "ray_common.so",
  235. "ray_util.so",
  236. ":streaming_channel",
  237. ":streaming_common",
  238. ":streaming_config",
  239. ":streaming_message",
  240. ":streaming_metrics",
  241. ":streaming_queue",
  242. ":streaming_reliability",
  243. ":streaming_util",
  244. ],
  245. )
  246. test_common_deps = [
  247. "//:exported_streaming_internal",
  248. ":streaming_lib",
  249. "//:ray_common",
  250. "//:ray_util",
  251. "//:core_worker_lib",
  252. ]
  253. # streaming queue mock actor binary
  254. cc_binary(
  255. name = "streaming_test_worker",
  256. srcs = glob(["src/test/*.h"]) + [
  257. "src/test/mock_actor.cc",
  258. ],
  259. copts = COPTS,
  260. deps = test_common_deps,
  261. )
  262. # use src/test/run_streaming_queue_test.sh to run this test
  263. cc_binary(
  264. name = "streaming_queue_tests",
  265. srcs = glob(["src/test/*.h"]) + [
  266. "src/test/streaming_queue_tests.cc",
  267. ],
  268. copts = COPTS,
  269. deps = test_common_deps,
  270. )
  271. cc_test(
  272. name = "streaming_message_ring_buffer_tests",
  273. srcs = [
  274. "src/test/ring_buffer_tests.cc",
  275. ],
  276. copts = COPTS,
  277. tags = ["team:ant-group"],
  278. deps = test_common_deps,
  279. )
  280. cc_test(
  281. name = "barrier_helper_tests",
  282. srcs = [
  283. "src/test/barrier_helper_tests.cc",
  284. ],
  285. copts = COPTS,
  286. tags = ["team:ant-group"],
  287. deps = test_common_deps,
  288. )
  289. cc_test(
  290. name = "streaming_message_serialization_tests",
  291. srcs = [
  292. "src/test/message_serialization_tests.cc",
  293. ],
  294. copts = COPTS,
  295. tags = ["team:ant-group"],
  296. deps = test_common_deps,
  297. )
  298. cc_test(
  299. name = "streaming_mock_transfer",
  300. srcs = [
  301. "src/test/mock_transfer_tests.cc",
  302. ],
  303. copts = COPTS,
  304. tags = ["team:ant-group"],
  305. deps = test_common_deps,
  306. )
  307. cc_test(
  308. name = "streaming_util_tests",
  309. srcs = [
  310. "src/test/streaming_util_tests.cc",
  311. ],
  312. copts = COPTS,
  313. tags = ["team:ant-group"],
  314. deps = test_common_deps,
  315. )
  316. cc_test(
  317. name = "streaming_perf_tests",
  318. srcs = [
  319. "src/test/streaming_perf_tests.cc",
  320. ],
  321. copts = COPTS,
  322. tags = ["team:ant-group"],
  323. deps = test_common_deps,
  324. )
  325. cc_test(
  326. name = "event_service_tests",
  327. srcs = [
  328. "src/test/event_service_tests.cc",
  329. ],
  330. copts = COPTS,
  331. tags = ["team:ant-group"],
  332. deps = test_common_deps,
  333. )
  334. cc_test(
  335. name = "queue_protobuf_tests",
  336. srcs = [
  337. "src/test/queue_protobuf_tests.cc",
  338. ],
  339. tags = ["team:ant-group"],
  340. deps = test_common_deps,
  341. )
  342. cc_test(
  343. name = "data_writer_tests",
  344. srcs = [
  345. "src/test/data_writer_tests.cc",
  346. ],
  347. copts = COPTS,
  348. tags = ["team:ant-group"],
  349. deps = test_common_deps,
  350. )
  351. python_proto_compile(
  352. name = "streaming_py_proto",
  353. deps = [":streaming_proto"],
  354. )
  355. python_proto_compile(
  356. name = "remote_call_py_proto",
  357. deps = [":remote_call_proto"],
  358. )
  359. filegroup(
  360. name = "all_py_proto",
  361. srcs = [
  362. ":remote_call_py_proto",
  363. ":streaming_py_proto",
  364. ],
  365. )
  366. copy_to_workspace(
  367. name = "cp_all_py_proto",
  368. srcs = [":all_py_proto"],
  369. dstdir = "streaming/python/generated",
  370. )
  371. genrule(
  372. name = "copy_streaming_py_proto",
  373. srcs = [
  374. ":cp_all_py_proto",
  375. ],
  376. outs = [
  377. "copy_streaming_py_proto.out",
  378. ],
  379. cmd = """
  380. GENERATED_DIR="streaming/python/generated"
  381. mkdir -p "$$GENERATED_DIR"
  382. touch "$$GENERATED_DIR/__init__.py"
  383. # Use this `sed` command to change the import path in the generated file.
  384. sed -i -E 's/from streaming.src.protobuf/from ./' "$$GENERATED_DIR/remote_call_pb2.py"
  385. sed -i -E 's/from protobuf/from ./' "$$GENERATED_DIR/remote_call_pb2.py"
  386. date > $@
  387. """,
  388. local = 1,
  389. visibility = ["//visibility:public"],
  390. )
  391. cc_binary(
  392. name = "libstreaming_java.so",
  393. srcs = glob([
  394. "src/lib/java/*.cc",
  395. "src/lib/java/*.h",
  396. ]),
  397. copts = COPTS,
  398. linkshared = 1,
  399. visibility = ["//visibility:public"],
  400. deps = [
  401. ":streaming_lib",
  402. "@bazel_tools//tools/jdk:jni",
  403. ],
  404. )