1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- load ("@rules_proto//proto :defs.bzl" , "proto_library " )
17- load ("@rules_cc//cc:defs .bzl" , "cc_binary" , "cc_library" , "cc_proto_library" , "objc_library " )
16+ load ("@rules_cc//cc :defs.bzl" , "cc_binary" , "cc_library" , "objc_library " )
17+ load ("//bazel/tools:brpc_proto_library .bzl" , "brpc_proto_library " )
1818
1919licenses (["notice" ]) # Apache v2
2020
2121exports_files (["LICENSE" ])
2222
2323COPTS = [
2424 "-fno-omit-frame-pointer" ,
25- "-DBTHREAD_USE_FAST_PTHREAD_MUTEX" ,
26- "-D__const__=__unused__" ,
27- "-D_GNU_SOURCE" ,
28- "-DUSE_SYMBOLIZE" ,
29- "-DNO_TCMALLOC" ,
30- "-D__STDC_FORMAT_MACROS" ,
31- "-D__STDC_LIMIT_MACROS" ,
32- "-D__STDC_CONSTANT_MACROS" ,
3325] + select ({
34- "//bazel/config:brpc_with_glog" : ["-DBRPC_WITH_GLOG=1" ],
35- "//conditions:default" : ["-DBRPC_WITH_GLOG=0" ],
36- }) + select ({
37- "//bazel/config:brpc_with_mesalink" : ["-DUSE_MESALINK" ],
38- "//conditions:default" : ["" ],
39- }) + select ({
40- "//bazel/config:brpc_with_thrift" : ["-DENABLE_THRIFT_FRAMED_PROTOCOL=1" ],
41- "//conditions:default" : ["" ],
42- }) + select ({
43- "//bazel/config:brpc_with_thrift_legacy_version" : [],
44- "//conditions:default" : ["-DTHRIFT_STDCXX=std" ],
45- }) + select ({
46- "//bazel/config:brpc_with_rdma" : ["-DBRPC_WITH_RDMA=1" ],
47- "//conditions:default" : ["" ],
48- }) + select ({
49- "//bazel/config:brpc_with_debug_bthread_sche_safety" : ["-DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=1" ],
50- "//conditions:default" : ["-DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=0" ],
51- }) + select ({
52- "//bazel/config:brpc_with_debug_lock" : ["-DBRPC_DEBUG_LOCK=1" ],
53- "//conditions:default" : ["-DBRPC_DEBUG_LOCK=0" ],
54- }) + select ({
5526 "//bazel/config:brpc_with_asan" : ["-fsanitize=address" ],
56- "//conditions:default" : ["" ],
57- }) + select ({
58- "//bazel/config:brpc_with_no_pthread_mutex_hook" : ["-DNO_PTHREAD_MUTEX_HOOK" ],
59- "//conditions:default" : ["" ],
27+ "//conditions:default" : [],
6028})
6129
30+ DEFINES = [
31+ "BTHREAD_USE_FAST_PTHREAD_MUTEX" ,
32+ "__const__=__unused__" ,
33+ "_GNU_SOURCE" ,
34+ "USE_SYMBOLIZE" ,
35+ "NO_TCMALLOC" ,
36+ "__STDC_FORMAT_MACROS" ,
37+ "__STDC_LIMIT_MACROS" ,
38+ "__STDC_CONSTANT_MACROS" ,
39+ ] + select ({
40+ "//bazel/config:brpc_with_glog" : ["BRPC_WITH_GLOG=1" ],
41+ "//conditions:default" : ["BRPC_WITH_GLOG=0" ],
42+ }) + select ({
43+ "//bazel/config:brpc_with_mesalink" : ["USE_MESALINK" ],
44+ "//conditions:default" : [],
45+ }) + select ({
46+ "//bazel/config:brpc_with_thrift" : ["ENABLE_THRIFT_FRAMED_PROTOCOL=1" ],
47+ "//conditions:default" : [],
48+ }) + select ({
49+ "//bazel/config:brpc_with_thrift_legacy_version" : [],
50+ "//conditions:default" : ["THRIFT_STDCXX=std" ],
51+ }) + select ({
52+ "//bazel/config:brpc_with_rdma" : ["BRPC_WITH_RDMA=1" ],
53+ "//conditions:default" : [],
54+ }) + select ({
55+ "//bazel/config:brpc_with_debug_bthread_sche_safety" : ["BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1" ],
56+ "//conditions:default" : ["BRPC_DEBUG_BTHREAD_SCHE_SAFETY=0" ],
57+ }) + select ({
58+ "//bazel/config:brpc_with_debug_lock" : ["BRPC_DEBUG_LOCK=1" ],
59+ "//conditions:default" : ["BRPC_DEBUG_LOCK=0" ],
60+ }) + select ({
61+ "//bazel/config:brpc_with_no_pthread_mutex_hook" : ["NO_PTHREAD_MUTEX_HOOK" ],
62+ "//conditions:default" : [],
63+ })
64+
6265LINKOPTS = [
6366 "-pthread" ,
6467 "-ldl" ,
@@ -93,7 +96,7 @@ LINKOPTS = [
9396 "//conditions:default" : [],
9497}) + select ({
9598 "//bazel/config:brpc_with_asan" : ["-fsanitize=address" ],
96- "//conditions:default" : ["" ],
99+ "//conditions:default" : [],
97100 })
98101
99102genrule (
@@ -331,13 +334,13 @@ cc_library(
331334 "src/butil/third_party/dmg_fp/dtoa.cc" ,
332335 ":config_h" ,
333336 ],
334- copts = COPTS + select ({
337+ defines = DEFINES + select ({
335338 "//bazel/config:brpc_build_for_unittest" : [
336- "-DBVAR_NOT_LINK_DEFAULT_VARIABLES" ,
337- "-DUNIT_TEST" ,
339+ "UNIT_TEST" ,
338340 ],
339341 "//conditions:default" : [],
340342 }),
343+ copts = COPTS ,
341344 includes = [
342345 "src/" ,
343346 ],
@@ -354,8 +357,14 @@ cc_library(
354357 "@bazel_tools//src/conditions:darwin" : [":macos_lib" ],
355358 "//conditions:default" : [],
356359 }) + select ({
357- "//bazel/config:brpc_with_boringssl" : ["@boringssl//:ssl" , "@boringssl//:crypto" ],
358- "//conditions:default" : ["@openssl//:ssl" , "@openssl//:crypto" ],
360+ "//bazel/config:brpc_with_boringssl" : [
361+ "@boringssl//:ssl" ,
362+ "@boringssl//:crypto"
363+ ],
364+ "//conditions:default" : [
365+ "@openssl//:ssl" ,
366+ "@openssl//:crypto"
367+ ],
359368 }),
360369)
361370
@@ -381,14 +390,13 @@ cc_library(
381390 defines = [] + select ({
382391 "//bazel/config:with_babylon_counter" : ["WITH_BABYLON_COUNTER=1" ],
383392 "//conditions:default" : [],
384- }),
385- copts = COPTS + select ({
393+ }) + select ({
386394 "//bazel/config:brpc_build_for_unittest" : [
387- "-DBVAR_NOT_LINK_DEFAULT_VARIABLES" ,
388- "-DUNIT_TEST" ,
395+ "BVAR_NOT_LINK_DEFAULT_VARIABLES" ,
389396 ],
390397 "//conditions:default" : [],
391398 }),
399+ copts = COPTS ,
392400 includes = [
393401 "src/" ,
394402 ],
@@ -475,7 +483,6 @@ cc_library(
475483 deps = [
476484 ":brpc_idl_options_cc_proto" ,
477485 ":butil" ,
478- "@com_google_protobuf//:protoc_lib" ,
479486 ],
480487)
481488
@@ -487,20 +494,11 @@ filegroup(
487494 visibility = ["//visibility:public" ],
488495)
489496
490- proto_library (
491- name = "brpc_idl_options_proto" ,
492- srcs = [":brpc_idl_options_proto_srcs" ],
493- strip_import_prefix = "src" ,
494- visibility = ["//visibility:public" ],
495- deps = [
496- "@com_google_protobuf//:descriptor_proto" ,
497- ],
498- )
499-
500- cc_proto_library (
497+ brpc_proto_library (
501498 name = "brpc_idl_options_cc_proto" ,
499+ srcs = [":brpc_idl_options_proto_srcs" ],
500+ include = "src" ,
502501 visibility = ["//visibility:public" ],
503- deps = [":brpc_idl_options_proto" ],
504502)
505503
506504filegroup (
@@ -512,21 +510,12 @@ filegroup(
512510 visibility = ["//visibility:public" ],
513511)
514512
515- proto_library (
516- name = "brpc_internal_proto" ,
517- srcs = [":brpc_internal_proto_srcs" ],
518- strip_import_prefix = "src" ,
519- visibility = ["//visibility:public" ],
520- deps = [
521- ":brpc_idl_options_proto" ,
522- "@com_google_protobuf//:descriptor_proto" ,
523- ],
524- )
525-
526- cc_proto_library (
513+ brpc_proto_library (
527514 name = "brpc_internal_cc_proto" ,
515+ srcs = [":brpc_internal_proto_srcs" ],
516+ include = "src" ,
517+ deps = [":brpc_idl_options_cc_proto" ],
528518 visibility = ["//visibility:public" ],
529- deps = [":brpc_internal_proto" ],
530519)
531520
532521cc_library (
@@ -587,5 +576,6 @@ cc_binary(
587576 deps = [
588577 ":brpc" ,
589578 ":brpc_idl_options_cc_proto" ,
579+ "@com_google_protobuf//:protoc_lib" ,
590580 ],
591581)
0 commit comments