BUILD 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. load("@rules_cc//cc:defs.bzl", "cc_proto_library")
  2. load("@rules_proto//proto:defs.bzl", "proto_library")
  3. load(":srpc.bzl", "gen_srpc_pb_cc")
  4. load(":srpc.bzl", "gen_srpc_thrift_cc")
  5. proto_library(
  6. name = "message_proto",
  7. srcs = [
  8. 'src/message/rpc_meta.proto',
  9. 'src/message/rpc_meta_brpc.proto',
  10. 'src/message/rpc_meta_trpc.proto',
  11. 'src/message/rpc_span.proto',
  12. ],
  13. strip_import_prefix = "src/message",
  14. )
  15. cc_proto_library(
  16. name = "MessageProto",
  17. deps = [":message_proto"],
  18. )
  19. cc_library(
  20. name = 'srpc_hdrs',
  21. hdrs = glob(['src/include/srpc/*']),
  22. includes = ['src/include'],
  23. deps = [
  24. '@workflow//:workflow_hdrs',
  25. ],
  26. visibility = ["//visibility:public"],
  27. )
  28. cc_library(
  29. name = 'libsrpc',
  30. srcs = glob(['src/**/*.cc']),
  31. hdrs = glob([
  32. 'src/**/*.h',
  33. 'src/**/*.inl',
  34. ]),
  35. includes = ['src', 'src/thrift', 'src/compress', 'src/message', 'src/module'],
  36. deps = [
  37. '@workflow//:http',
  38. '@workflow//:upstream',
  39. '@lz4//:lz4',
  40. '@snappy//:snappy',
  41. ':MessageProto',
  42. ],
  43. visibility = ["//visibility:public"],
  44. )
  45. cc_binary(
  46. name ='srpc_generator',
  47. srcs = glob(['src/generator/*.cc']),
  48. deps = [':libsrpc'],
  49. )
  50. proto_library(
  51. name = "echo_pb_proto",
  52. srcs = [
  53. 'tutorial/echo_pb.proto',
  54. ],
  55. strip_import_prefix = "tutorial",
  56. )
  57. cc_proto_library(
  58. name = "EchoProto",
  59. deps = [":echo_pb_proto"],
  60. )
  61. gen_srpc_pb_cc(
  62. name = "echo_pb",
  63. files = ["tutorial/echo_pb.proto",],
  64. deps_lib = [':EchoProto'],
  65. )
  66. cc_binary(
  67. name = 'srpc_pb_server',
  68. srcs = ['tutorial/tutorial-01-srpc_pb_server.cc'],
  69. deps = [
  70. ':libsrpc',
  71. ':echo_pb_server_cc',
  72. ],
  73. linkopts = [
  74. '-lpthread',
  75. '-lssl',
  76. '-lcrypto',
  77. ],
  78. )
  79. cc_binary(
  80. name = 'srpc_pb_client',
  81. srcs = ['tutorial/tutorial-02-srpc_pb_client.cc'],
  82. deps = [
  83. ':libsrpc',
  84. ':echo_pb_client_cc',
  85. ],
  86. linkopts = [
  87. '-lpthread',
  88. '-lssl',
  89. '-lcrypto',
  90. ],
  91. )
  92. gen_srpc_thrift_cc(
  93. name = "echo_thrift",
  94. files = ["tutorial/echo_thrift.thrift",],
  95. deps_lib = [],
  96. )
  97. cc_binary(
  98. name = 'srpc_thrift_server',
  99. srcs = ['tutorial/tutorial-03-srpc_thrift_server.cc'],
  100. deps = [
  101. ':libsrpc',
  102. ':echo_thrift_server_cc',
  103. ],
  104. linkopts = [
  105. '-lpthread',
  106. '-lssl',
  107. '-lcrypto',
  108. ],
  109. )
  110. cc_binary(
  111. name = 'srpc_thrift_client',
  112. srcs = ['tutorial/tutorial-04-srpc_thrift_client.cc'],
  113. deps = [
  114. ':libsrpc',
  115. ':echo_thrift_client_cc',
  116. ],
  117. linkopts = [
  118. '-lpthread',
  119. '-lssl',
  120. '-lcrypto',
  121. ],
  122. )
  123. cc_binary(
  124. name = 'brpc_pb_server',
  125. srcs = ['tutorial/tutorial-05-brpc_pb_server.cc'],
  126. deps = [
  127. ':libsrpc',
  128. ':echo_pb_server_cc',
  129. ],
  130. linkopts = [
  131. '-lpthread',
  132. '-lssl',
  133. '-lcrypto',
  134. ],
  135. )
  136. cc_binary(
  137. name = 'brpc_pb_client',
  138. srcs = ['tutorial/tutorial-06-brpc_pb_client.cc'],
  139. deps = [
  140. ':libsrpc',
  141. ':echo_pb_client_cc',
  142. ],
  143. linkopts = [
  144. '-lpthread',
  145. '-lssl',
  146. '-lcrypto',
  147. ],
  148. )
  149. cc_binary(
  150. name = 'thrift_thrift_server',
  151. srcs = ['tutorial/tutorial-07-thrift_thrift_server.cc'],
  152. deps = [
  153. ':libsrpc',
  154. ':echo_thrift_server_cc',
  155. ],
  156. linkopts = [
  157. '-lpthread',
  158. '-lssl',
  159. '-lcrypto',
  160. ],
  161. )
  162. cc_binary(
  163. name = 'thrift_thrift_client',
  164. srcs = ['tutorial/tutorial-08-thrift_thrift_client.cc'],
  165. deps = [
  166. ':libsrpc',
  167. ':echo_thrift_client_cc',
  168. ],
  169. linkopts = [
  170. '-lpthread',
  171. '-lssl',
  172. '-lcrypto',
  173. ],
  174. )
  175. cc_binary(
  176. name = 'client_task',
  177. srcs = ['tutorial/tutorial-09-client_task.cc'],
  178. deps = [
  179. ':libsrpc',
  180. ':echo_pb_client_cc',
  181. ],
  182. linkopts = [
  183. '-lpthread',
  184. '-lssl',
  185. '-lcrypto',
  186. ],
  187. )
  188. cc_binary(
  189. name = 'server_async',
  190. srcs = ['tutorial/tutorial-10-server_async.cc'],
  191. deps = [
  192. ':libsrpc',
  193. ':echo_pb_server_cc',
  194. ],
  195. linkopts = [
  196. '-lpthread',
  197. '-lssl',
  198. '-lcrypto',
  199. ],
  200. )
  201. proto_library(
  202. name = "helloworld_proto",
  203. srcs = [
  204. 'tutorial/helloworld.proto',
  205. ],
  206. strip_import_prefix = "tutorial",
  207. )
  208. cc_proto_library(
  209. name = "HelloworldProto",
  210. deps = [":helloworld_proto"],
  211. )
  212. gen_srpc_pb_cc(
  213. name = "helloworld",
  214. files = ["tutorial/helloworld.proto",],
  215. deps_lib = [':HelloworldProto'],
  216. )
  217. cc_binary(
  218. name = 'trpc_pb_server',
  219. srcs = ['tutorial/tutorial-11-trpc_pb_server.cc'],
  220. deps = [
  221. ':libsrpc',
  222. ':helloworld_server_cc',
  223. ],
  224. linkopts = [
  225. '-lpthread',
  226. '-lssl',
  227. '-lcrypto',
  228. ],
  229. )
  230. cc_binary(
  231. name = 'trpc_pb_client',
  232. srcs = ['tutorial/tutorial-12-trpc_pb_client.cc'],
  233. deps = [
  234. ':libsrpc',
  235. ':helloworld_client_cc',
  236. ],
  237. linkopts = [
  238. '-lpthread',
  239. '-lssl',
  240. '-lcrypto',
  241. ],
  242. )
  243. cc_binary(
  244. name = 'trpc_http_server',
  245. srcs = ['tutorial/tutorial-13-trpc_http_server.cc'],
  246. deps = [
  247. ':libsrpc',
  248. ':helloworld_server_cc',
  249. ],
  250. linkopts = [
  251. '-lpthread',
  252. '-lssl',
  253. '-lcrypto',
  254. ],
  255. )
  256. cc_binary(
  257. name = 'trpc_http_client',
  258. srcs = ['tutorial/tutorial-14-trpc_http_client.cc'],
  259. deps = [
  260. ':libsrpc',
  261. ':helloworld_client_cc',
  262. ],
  263. linkopts = [
  264. '-lpthread',
  265. '-lssl',
  266. '-lcrypto',
  267. ],
  268. )