Avoid duplication in build rules by expanding the grpc_cc_libraries rule-creation macro
diff --git a/BUILD b/BUILD
index 09b17ad..a919a63 100644
--- a/BUILD
+++ b/BUILD
@@ -54,33 +54,46 @@
],
)
-grpc_cc_library(
- name = "grpc",
+grpc_cc_libraries(
+ name_list = ["grpc", "grpc_unsecure",],
srcs = [
"src/core/lib/surface/init.c",
- "src/core/plugin_registry/grpc_plugin_registry.c",
+ ],
+ additional_src_list = [
+ [
+ "src/core/plugin_registry/grpc_plugin_registry.c",
+ ],
+ [
+ "src/core/lib/surface/init_unsecure.c",
+ "src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
+ ],
],
language = "c",
standalone = True,
deps = [
"census",
"grpc_base",
- "grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_pick_first",
"grpc_lb_policy_round_robin",
"grpc_load_reporting",
"grpc_max_age_filter",
- "grpc_resolver_dns_ares",
"grpc_resolver_dns_native",
"grpc_resolver_sockaddr",
- "grpc_secure",
"grpc_transport_chttp2_client_insecure",
- "grpc_transport_chttp2_client_secure",
"grpc_transport_chttp2_server_insecure",
- "grpc_transport_chttp2_server_secure",
"grpc_message_size_filter",
"grpc_deadline_filter",
],
+ additional_dep_list = [
+ [
+ "grpc_secure",
+ "grpc_resolver_dns_ares",
+ "grpc_lb_policy_grpclb_secure",
+ "grpc_transport_chttp2_client_secure",
+ "grpc_transport_chttp2_server_secure",
+ ],
+ [],
+ ],
)
grpc_cc_library(
@@ -99,32 +112,6 @@
)
grpc_cc_library(
- name = "grpc_unsecure",
- srcs = [
- "src/core/lib/surface/init.c",
- "src/core/lib/surface/init_unsecure.c",
- "src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
- ],
- language = "c",
- standalone = True,
- deps = [
- "census",
- "grpc_base",
- "grpc_lb_policy_grpclb",
- "grpc_lb_policy_pick_first",
- "grpc_lb_policy_round_robin",
- "grpc_load_reporting",
- "grpc_max_age_filter",
- "grpc_resolver_dns_native",
- "grpc_resolver_sockaddr",
- "grpc_transport_chttp2_client_insecure",
- "grpc_transport_chttp2_server_insecure",
- "grpc_message_size_filter",
- "grpc_deadline_filter",
- ],
-)
-
-grpc_cc_library(
name = "grpc++",
srcs = [
"src/cpp/client/insecure_credentials.cc",
diff --git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
index 984c06d..a438186 100644
--- a/bazel/grpc_build_system.bzl
+++ b/bazel/grpc_build_system.bzl
@@ -49,14 +49,17 @@
]
)
-def grpc_cc_libraries(name_list, additional_dep_list, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language="C++"):
- for i in range(len(name_list)):
+def grpc_cc_libraries(name_list, additional_src_list = [], additional_dep_list = [], srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language="C++"):
+ names = len(name_list)
+ asl = additional_src_list + [[]]*(names - len(additional_src_list))
+ adl = additional_dep_list + [[]]*(names - len(additional_dep_list))
+ for i in range(names):
grpc_cc_library(
name = name_list[i],
- srcs = srcs,
+ srcs = srcs + asl[i],
hdrs = hdrs,
public_hdrs = public_hdrs,
- deps = deps + additional_dep_list[i],
+ deps = deps + adl[i],
external_deps = external_deps,
standalone = standalone,
language = language