Skip to content

Commit

Permalink
Expose grpc++_binder through grpc++ (#27891)
Browse files Browse the repository at this point in the history
A config option is provided so user can pass --define=grpc_no_binder=true to bazel, or passing `-DGRPC_NO_BINDER` to compiler to disable the dependency.
  • Loading branch information
sifmelcara authored Nov 3, 2021
1 parent f2b9600 commit d92baa9
Show file tree
Hide file tree
Showing 26 changed files with 265 additions and 115 deletions.
47 changes: 39 additions & 8 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ config_setting(
values = {"define": "grpc_no_xds=true"},
)

# When gRPC is build as shared library, binder transport code might still
# get included even when user's code does not depend on it. In that case
# --define=grpc_no_binder=true can be used to disable binder transport
# related code to reduce binary size.
# For users using build system other than bazel, they can define
# GRPC_NO_BINDER to achieve the same effect.
config_setting(
name = "grpc_no_binder_define",
values = {"define": "grpc_no_binder=true"},
)

config_setting(
name = "android",
values = {"crosstool_top": "//external:android/crosstool"},
Expand All @@ -72,6 +83,15 @@ selects.config_setting_group(
],
)

selects.config_setting_group(
name = "grpc_no_binder",
match_any = [
":grpc_no_binder_define",
# We do not need binder on ios.
":ios",
],
)

selects.config_setting_group(
name = "grpc_no_rls",
match_any = [
Expand Down Expand Up @@ -452,13 +472,21 @@ grpc_cc_library(
],
language = "c++",
public_hdrs = GRPCXX_PUBLIC_HDRS,
select_deps = [{
"grpc_no_xds": [],
"//conditions:default": [
"grpc++_xds_client",
"grpc++_xds_server",
],
}],
select_deps = [
{
"grpc_no_xds": [],
"//conditions:default": [
"grpc++_xds_client",
"grpc++_xds_server",
],
},
{
"grpc_no_binder": [],
"//conditions:default": [
"grpc++_binder",
],
},
],
standalone = True,
visibility = [
"@grpc:public",
Expand Down Expand Up @@ -556,6 +584,10 @@ grpc_cc_library(
"src/core/ext/transport/binder/wire_format/wire_reader_impl.h",
"src/core/ext/transport/binder/wire_format/wire_writer.h",
],
defines = select({
"grpc_no_binder": ["GRPC_NO_BINDER"],
"//conditions:default": [],
}),
external_deps = [
"absl/base:core_headers",
"absl/container:flat_hash_map",
Expand All @@ -572,7 +604,6 @@ grpc_cc_library(
"include/grpcpp/create_channel_binder.h",
"include/grpcpp/security/binder_credentials.h",
],
visibility = ["@grpc:public"],
deps = [
"gpr",
"gpr_base",
Expand Down
54 changes: 20 additions & 34 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 38 additions & 70 deletions build_autogenerated.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cc_library(
"-Wl,--no-undefined",
],
deps = [
"//:grpc++_binder",
"//:grpc++",
"//examples/protos:helloworld_cc_grpc",
],
alwayslink = True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ cc_library(
],
deps = [
"//:grpc++",
"//:grpc++_binder",
"//examples/protos:helloworld_cc_grpc",
],
alwayslink = True,
Expand Down
Loading

0 comments on commit d92baa9

Please sign in to comment.