2323# each change must be ported from one to the other.
2424#
2525
26+ """
27+ Contains macros used throughout the repo.
28+ """
29+
2630load ("//bazel:cc_grpc_library.bzl" , "cc_grpc_library" )
2731load ("//bazel:copts.bzl" , "GRPC_DEFAULT_COPTS" )
2832load ("@upb//bazel:upb_proto_library.bzl" , "upb_proto_library" , "upb_proto_reflection_library" )
@@ -48,20 +52,20 @@ def _get_external_deps(external_deps):
4852 ret = []
4953 for dep in external_deps :
5054 if dep == "address_sorting" :
51- ret += [ "//third_party/address_sorting" ]
55+ ret . append ( "//third_party/address_sorting" )
5256 elif dep == "xxhash" :
53- ret += [ "//third_party/xxhash" ]
57+ ret . append ( "//third_party/xxhash" )
5458 elif dep == "cares" :
5559 ret += select ({
5660 "//:grpc_no_ares" : [],
5761 "//conditions:default" : ["//external:cares" ],
5862 })
5963 elif dep == "cronet_c_for_grpc" :
60- ret += [ "//third_party/objective_c/Cronet:cronet_c_for_grpc" ]
64+ ret . append ( "//third_party/objective_c/Cronet:cronet_c_for_grpc" )
6165 elif dep .startswith ("absl/" ):
62- ret += [ "@com_google_absl//" + dep ]
66+ ret . append ( "@com_google_absl//" + dep )
6367 else :
64- ret += [ "//external:" + dep ]
68+ ret . append ( "//external:" + dep )
6569 return ret
6670
6771def _update_visibility (visibility ):
@@ -120,6 +124,27 @@ def grpc_cc_library(
120124 use_cfstream = False ,
121125 tags = [],
122126 linkstatic = False ):
127+ """An internal wrapper around cc_library.
128+
129+ Args:
130+ name: The name of the library.
131+ srcs: The source files.
132+ public_hdrs: The public headers.
133+ hdrs: The headers.
134+ external_deps: External depdendencies to be resolved.
135+ defines: Build defines to use.
136+ deps: cc_library deps.
137+ select_deps: deps included conditionally.
138+ standalone: Unused.
139+ language: The language of the library, e.g. C, C++.
140+ testonly: Whether the target is for tests only.
141+ visibility: The visibility of the target.
142+ alwayslink: Whether to enable alwayslink on the cc_library.
143+ data: Data dependencies.
144+ use_cfstream: Whether to use cfstream.
145+ tags: Tags to apply to the rule.
146+ linkstatic: Whether to enable linkstatic on the cc_library.
147+ """
123148 visibility = _update_visibility (visibility )
124149 copts = []
125150 if use_cfstream :
@@ -197,6 +222,13 @@ def ios_cc_test(
197222 name ,
198223 tags = [],
199224 ** kwargs ):
225+ """An ios C++ test target.
226+
227+ Args:
228+ name: The name of the test.
229+ tags: The tags to apply to the test.
230+ **kwargs: All other arguments to apply.
231+ """
200232 ios_test_adapter = "//third_party/objective_c/google_toolbox_for_mac:GTM_GoogleTestRunner_GTM_USING_XCTEST"
201233
202234 test_lib_ios = name + "_test_lib_ios"
@@ -221,6 +253,28 @@ def ios_cc_test(
221253 )
222254
223255def grpc_cc_test (name , srcs = [], deps = [], external_deps = [], args = [], data = [], uses_polling = True , language = "C++" , size = "medium" , timeout = None , tags = [], exec_compatible_with = [], exec_properties = {}, shard_count = None , flaky = None , copts = []):
256+ """A cc_test target for use in the gRPC repo.
257+
258+ Args:
259+ name: The name of the test.
260+ srcs: The source files.
261+ deps: The target deps.
262+ external_deps: The external deps.
263+ args: The args to supply to the test binary.
264+ data: Data dependencies.
265+ uses_polling: Whether the test uses polling.
266+ language: The language of the test, e.g C, C++.
267+ size: The size of the test.
268+ timeout: The test timeout.
269+ tags: The tags for the test.
270+ exec_compatible_with: A list of constraint values that must be
271+ satisifed for the platform.
272+ exec_properties: A dictionary of strings that will be added to the
273+ exec_properties of a platform selected for this target.
274+ shard_count: The number of shards for this test.
275+ flaky: Whether this test is flaky.
276+ copts: Add these to the compiler invocation.
277+ """
224278 copts = copts + if_mac (["-DGRPC_CFSTREAM" ])
225279 if language .upper () == "C" :
226280 copts = copts + if_not_windows (["-std=c99" ])
@@ -283,6 +337,22 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
283337 )
284338
285339def grpc_cc_binary (name , srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++" , testonly = False , linkshared = False , linkopts = [], tags = [], features = []):
340+ """Generates a cc_binary for use in the gRPC repo.
341+
342+ Args:
343+ name: The name of the target.
344+ srcs: The source files.
345+ deps: The dependencies.
346+ external_deps: The external dependencies.
347+ args: The arguments to supply to the binary.
348+ data: The data dependencies.
349+ language: The language of the binary, e.g. C, C++.
350+ testonly: Whether the binary is for tests only.
351+ linkshared: Enables linkshared on the binary.
352+ linkopts: linkopts to supply to the cc_binary.
353+ tags: Tags to apply to the target.
354+ features: features to be supplied to the cc_binary.
355+ """
286356 copts = []
287357 if language .upper () == "C" :
288358 copts = ["-std=c99" ]
@@ -300,6 +370,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da
300370 features = features ,
301371 )
302372
373+ # buildifier: disable=unnamed-macro
303374def grpc_generate_one_off_targets ():
304375 # In open-source, grpc_objc* libraries depend directly on //:grpc
305376 native .alias (
@@ -345,6 +416,13 @@ def grpc_py_binary(
345416 )
346417
347418def grpc_package (name , visibility = "private" , features = []):
419+ """Creates a package.
420+
421+ Args:
422+ name: The name of the target
423+ visibility: The visibility of the target.
424+ features: The features to enable.
425+ """
348426 if visibility == "tests" :
349427 visibility = ["//test:__subpackages__" ]
350428 elif visibility == "public" :
@@ -355,6 +433,7 @@ def grpc_package(name, visibility = "private", features = []):
355433 fail ("Unknown visibility " + visibility )
356434
357435 if len (visibility ) != 0 :
436+ # buildifier: disable=native-package
358437 native .package (
359438 default_visibility = visibility ,
360439 features = features ,
@@ -402,6 +481,7 @@ def grpc_upb_proto_library(name, deps):
402481def grpc_upb_proto_reflection_library (name , deps ):
403482 upb_proto_reflection_library (name = name , deps = deps )
404483
484+ # buildifier: disable=unnamed-macro
405485def python_config_settings ():
406486 native .config_setting (
407487 name = "python3" ,
0 commit comments