-
Notifications
You must be signed in to change notification settings - Fork 397
/
Copy pathgapic.bzl
87 lines (73 loc) · 2.72 KB
/
gapic.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""A definition for the typical C++ GAPIC library."""
def cc_gapic_library(name, service_dirs = [], googleapis_deps = [], additional_deps = []):
"""Defines targets for the typical fully generated GAPIC library
Args:
name: The name of the library, e.g. `accessapproval`
service_dirs: The list of service directories. e.g. `["v1/"]`
googlapis_deps: The googleapis-defined cc_grpc_library definitions that
this library depends on.
"""
code_glob = [d + i + f for d in service_dirs for i in [
"",
"internal/",
] for f in [
"*.h",
"*.cc",
]]
sources_glob = [d + "internal/*_sources.cc" for d in service_dirs]
native.filegroup(
name = "srcs",
srcs = native.glob(sources_glob, allow_empty = True),
)
native.filegroup(
name = "hdrs",
srcs = native.glob(include = code_glob, exclude = sources_glob, allow_empty = True),
)
native.filegroup(
name = "public_hdrs",
srcs = native.glob([d + "*.h" for d in service_dirs], allow_empty = True),
visibility = ["//:__pkg__"],
)
native.filegroup(
name = "mocks",
srcs = native.glob([d + "mocks/*.h" for d in service_dirs], allow_empty = True),
visibility = ["//:__pkg__"],
)
native.cc_library(
name = "google_cloud_cpp_" + name,
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["//:__pkg__"],
deps = ["//:common", "//:grpc_utils"] + googleapis_deps + additional_deps,
)
native.cc_library(
name = "google_cloud_cpp_" + name + "_mocks",
hdrs = [":mocks"],
visibility = ["//:__pkg__"],
deps = [
":google_cloud_cpp_" + name,
"@com_google_googletest//:gtest",
],
)
[native.cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:" + name,
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in native.glob([d + "samples/*_samples.cc" for d in service_dirs], allow_empty = True)]