Skip to content

Commit b082b9a

Browse files
authored
fix: export headers with top-level Bazel targets (googleapis#12762)
1 parent 164d8ab commit b082b9a

128 files changed

Lines changed: 1016 additions & 67 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILD.bazel

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exports_files([
2121
])
2222

2323
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
24-
load("//bazel:library_dir_name.bzl", "google_cloud_cpp_library_dir_name")
24+
load("//bazel:library_names.bzl", "hdrs_filegroup_name", "library_dir_name", "mocks_filegroup_name")
2525
load(":libraries.bzl", "GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES", "GOOGLE_CLOUD_CPP_GA_LIBRARIES", "GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES")
2626

2727
EXPERIMENTAL_LIBRARIES = GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES
@@ -34,74 +34,99 @@ NO_MOCK_LIBRARIES = ["oauth2"]
3434

3535
[cc_library(
3636
name = "experimental-{library}".format(library = library),
37+
hdrs = ["//google/cloud/{dir}:{group}".format(
38+
dir = library_dir_name(library),
39+
group = hdrs_filegroup_name(library),
40+
)],
3741
deps = [
38-
"//google/cloud/{library_dir}:google_cloud_cpp_{library}".format(
42+
"//google/cloud/{dir}:google_cloud_cpp_{library}".format(
43+
dir = library_dir_name(library),
3944
library = library,
40-
library_dir = google_cloud_cpp_library_dir_name(library),
4145
),
4246
],
4347
) for library in EXPERIMENTAL_LIBRARIES]
4448

4549
[cc_library(
4650
name = "experimental-{library}_mocks".format(library = library),
4751
testonly = True,
52+
hdrs = ["//google/cloud/{dir}:{group}".format(
53+
dir = library_dir_name(library),
54+
group = mocks_filegroup_name(library),
55+
)],
4856
deps = [
49-
"//google/cloud/{library_dir}:google_cloud_cpp_{library}_mocks".format(
57+
"//google/cloud/{dir}:google_cloud_cpp_{library}_mocks".format(
58+
dir = library_dir_name(library),
5059
library = library,
51-
library_dir = google_cloud_cpp_library_dir_name(library),
5260
),
5361
],
5462
) for library in EXPERIMENTAL_LIBRARIES if library not in NO_MOCK_LIBRARIES]
5563

5664
[cc_library(
5765
name = "experimental-{library}".format(library = library),
66+
hdrs = ["//google/cloud/{dir}:{group}".format(
67+
dir = library_dir_name(library),
68+
group = hdrs_filegroup_name(library),
69+
)],
5870
deprecation = "this library is now GA, please use //:{library} instead.".format(library = library),
5971
tags = ["manual"],
6072
deps = [
61-
"//google/cloud/{library_dir}:google_cloud_cpp_{library}".format(
73+
"//google/cloud/{dir}:google_cloud_cpp_{library}".format(
74+
dir = library_dir_name(library),
6275
library = library,
63-
library_dir = google_cloud_cpp_library_dir_name(library),
6476
),
6577
],
6678
) for library in TRANSITION_LIBRARIES]
6779

6880
[cc_library(
6981
name = "experimental-{library}_mocks".format(library = library),
7082
testonly = True,
83+
hdrs = ["//google/cloud/{dir}:{group}".format(
84+
dir = library_dir_name(library),
85+
group = mocks_filegroup_name(library),
86+
)],
7187
deprecation = "this library is now GA, please use //:{library}_mocks instead.".format(library = library),
7288
tags = ["manual"],
7389
deps = [
74-
"//google/cloud/{library_dir}:google_cloud_cpp_{library}_mocks".format(
90+
"//google/cloud/{dir}:google_cloud_cpp_{library}_mocks".format(
91+
dir = library_dir_name(library),
7592
library = library,
76-
library_dir = google_cloud_cpp_library_dir_name(library),
7793
),
7894
],
79-
) for library in TRANSITION_LIBRARIES]
95+
) for library in TRANSITION_LIBRARIES if library not in NO_MOCK_LIBRARIES]
8096

8197
[cc_library(
8298
name = "{library}".format(library = library),
99+
hdrs = ["//google/cloud/{dir}:{group}".format(
100+
dir = library_dir_name(library),
101+
group = hdrs_filegroup_name(library),
102+
)],
83103
deps = [
84-
"//google/cloud/{library_dir}:google_cloud_cpp_{library}".format(
104+
"//google/cloud/{dir}:google_cloud_cpp_{library}".format(
105+
dir = library_dir_name(library),
85106
library = library,
86-
library_dir = google_cloud_cpp_library_dir_name(library),
87107
),
88108
],
89109
) for library in GA_LIBRARIES + TRANSITION_LIBRARIES]
90110

91111
[cc_library(
92112
name = "{library}_mocks".format(library = library),
93113
testonly = True,
114+
hdrs = ["//google/cloud/{dir}:{group}".format(
115+
dir = library_dir_name(library),
116+
group = mocks_filegroup_name(library),
117+
)],
94118
deps = [
95-
"//google/cloud/{library_dir}:google_cloud_cpp_{library}_mocks".format(
119+
"//google/cloud/{dir}:google_cloud_cpp_{library}_mocks".format(
120+
dir = library_dir_name(library),
96121
library = library,
97-
library_dir = google_cloud_cpp_library_dir_name(library),
98122
),
99123
],
100124
) for library in GA_LIBRARIES + TRANSITION_LIBRARIES if library not in NO_MOCK_LIBRARIES]
101125

102126
cc_library(
103127
name = "bigquery-mocks",
104128
testonly = True,
129+
hdrs = ["//google/cloud/bigquery:mocks"],
105130
deprecation = "please use //:bigquery_mocks instead.",
106131
tags = ["manual"],
107132
deps = [
@@ -112,6 +137,7 @@ cc_library(
112137
cc_library(
113138
name = "iam-mocks",
114139
testonly = True,
140+
hdrs = ["//google/cloud/iam:mocks"],
115141
deprecation = "please use //:iam_mocks instead.",
116142
tags = ["manual"],
117143
deps = [
@@ -127,6 +153,7 @@ bool_flag(
127153

128154
cc_library(
129155
name = "experimental-storage_grpc",
156+
hdrs = ["//google/cloud/storage:public_grpc_hdrs"],
130157
tags = ["manual"],
131158
deps = [
132159
"//google/cloud/storage:google_cloud_cpp_storage_grpc",
@@ -136,6 +163,7 @@ cc_library(
136163
# TODO(12698) - remove transition name (experimental-storage-grpc)
137164
cc_library(
138165
name = "experimental-storage-grpc",
166+
hdrs = ["//google/cloud/storage:public_grpc_hdrs"],
139167
tags = ["manual"],
140168
deps = [
141169
":experimental-storage_grpc",
@@ -144,13 +172,15 @@ cc_library(
144172

145173
cc_library(
146174
name = "common",
175+
hdrs = ["//google/cloud:common_hdrs"],
147176
deps = [
148177
"//google/cloud:google_cloud_cpp_common_private",
149178
],
150179
)
151180

152181
cc_library(
153182
name = "grpc_utils",
183+
hdrs = ["//google/cloud:grpc_utils_hdrs"],
154184
deps = [
155185
"//google/cloud:google_cloud_cpp_grpc_utils_private",
156186
],
@@ -159,13 +189,15 @@ cc_library(
159189
cc_library(
160190
name = "mocks",
161191
testonly = True,
192+
hdrs = ["//google/cloud:mocks"],
162193
deps = [
163194
"//google/cloud:google_cloud_cpp_mocks",
164195
],
165196
)
166197

167198
cc_library(
168199
name = "experimental-opentelemetry",
200+
hdrs = ["//google/cloud/opentelemetry:public_hdrs"],
169201
deprecation = "this library is now GA, please use //:opentelemetry instead.",
170202
tags = ["manual"],
171203
deps = [
@@ -175,6 +207,7 @@ cc_library(
175207

176208
cc_library(
177209
name = "opentelemetry",
210+
hdrs = ["//google/cloud/opentelemetry:public_hdrs"],
178211
deps = [
179212
"//google/cloud/opentelemetry:google_cloud_cpp_opentelemetry",
180213
],
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
def google_cloud_cpp_library_dir_name(library):
15+
def library_dir_name(library):
1616
if library.startswith("compute_"):
1717
return "compute"
1818
return library
19+
20+
def mocks_filegroup_name(library):
21+
if library.startswith("compute_"):
22+
return library.removeprefix("compute_") + "_mock_hdrs"
23+
return "mocks"
24+
25+
def hdrs_filegroup_name(library):
26+
if library.startswith("compute_"):
27+
return library.removeprefix("compute_") + "_public_hdrs"
28+
return "public_hdrs"

generator/internal/scaffold_generator.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,16 @@ filegroup(
398398
srcs = glob([d + "*.h" for d in src_dirs]),
399399
)
400400
401+
filegroup(
402+
name = "public_hdrs",
403+
srcs = glob([d + "*.h" for d in service_dirs]),
404+
visibility = ["//:__pkg__"],
405+
)
406+
401407
filegroup(
402408
name = "mocks",
403409
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
410+
visibility = ["//:__pkg__"],
404411
)
405412
406413
cc_library(

google/cloud/BUILD.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ config_setting(
6767
},
6868
)
6969

70+
filegroup(
71+
name = "common_hdrs",
72+
srcs = [h for h in google_cloud_cpp_common_hdrs if not h.startswith("internal/")],
73+
visibility = ["//:__pkg__"],
74+
)
75+
7076
cc_library(
7177
name = "google_cloud_cpp_common_private",
7278
srcs = google_cloud_cpp_common_srcs + ["internal/build_info.cc"],
@@ -161,6 +167,12 @@ cc_library(
161167
],
162168
) for benchmark in google_cloud_cpp_common_benchmarks]
163169

170+
filegroup(
171+
name = "grpc_utils_hdrs",
172+
srcs = [h for h in google_cloud_cpp_grpc_utils_hdrs if ("/internal/" not in h and "grpc_utils/" not in h)],
173+
visibility = ["//:__pkg__"],
174+
)
175+
164176
cc_library(
165177
name = "google_cloud_cpp_grpc_utils_private",
166178
srcs = google_cloud_cpp_grpc_utils_srcs,
@@ -242,6 +254,12 @@ cc_library(
242254
],
243255
) for test in google_cloud_cpp_grpc_utils_benchmarks]
244256

257+
filegroup(
258+
name = "mocks",
259+
srcs = [h for h in google_cloud_cpp_mocks_hdrs if not h.startswith("internal/")],
260+
visibility = ["//:__pkg__"],
261+
)
262+
245263
cc_library(
246264
name = "google_cloud_cpp_mocks",
247265
testonly = True,

google/cloud/accessapproval/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ filegroup(
3333
srcs = glob([d + "*.h" for d in src_dirs]),
3434
)
3535

36+
filegroup(
37+
name = "public_hdrs",
38+
srcs = glob([d + "*.h" for d in service_dirs]),
39+
visibility = ["//:__pkg__"],
40+
)
41+
3642
filegroup(
3743
name = "mocks",
3844
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
45+
visibility = ["//:__pkg__"],
3946
)
4047

4148
cc_library(

google/cloud/accesscontextmanager/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ filegroup(
3333
srcs = glob([d + "*.h" for d in src_dirs]),
3434
)
3535

36+
filegroup(
37+
name = "public_hdrs",
38+
srcs = glob([d + "*.h" for d in service_dirs]),
39+
visibility = ["//:__pkg__"],
40+
)
41+
3642
filegroup(
3743
name = "mocks",
3844
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
45+
visibility = ["//:__pkg__"],
3946
)
4047

4148
cc_library(

google/cloud/advisorynotifications/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ filegroup(
3030
srcs = glob([d + "*.h" for d in src_dirs]),
3131
)
3232

33+
filegroup(
34+
name = "public_hdrs",
35+
srcs = glob([d + "*.h" for d in service_dirs]),
36+
visibility = ["//:__pkg__"],
37+
)
38+
3339
filegroup(
3440
name = "mocks",
3541
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
42+
visibility = ["//:__pkg__"],
3643
)
3744

3845
cc_library(

google/cloud/aiplatform/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ filegroup(
3030
srcs = glob([d + "*.h" for d in src_dirs]),
3131
)
3232

33+
filegroup(
34+
name = "public_hdrs",
35+
srcs = glob([d + "*.h" for d in service_dirs]),
36+
visibility = ["//:__pkg__"],
37+
)
38+
3339
filegroup(
3440
name = "mocks",
3541
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
42+
visibility = ["//:__pkg__"],
3643
)
3744

3845
cc_library(

google/cloud/alloydb/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,16 @@ filegroup(
3030
srcs = glob([d + "*.h" for d in src_dirs]),
3131
)
3232

33+
filegroup(
34+
name = "public_hdrs",
35+
srcs = glob([d + "*.h" for d in service_dirs]),
36+
visibility = ["//:__pkg__"],
37+
)
38+
3339
filegroup(
3440
name = "mocks",
3541
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
42+
visibility = ["//:__pkg__"],
3643
)
3744

3845
cc_library(

google/cloud/apigateway/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ filegroup(
3333
srcs = glob([d + "*.h" for d in src_dirs]),
3434
)
3535

36+
filegroup(
37+
name = "public_hdrs",
38+
srcs = glob([d + "*.h" for d in service_dirs]),
39+
visibility = ["//:__pkg__"],
40+
)
41+
3642
filegroup(
3743
name = "mocks",
3844
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
45+
visibility = ["//:__pkg__"],
3946
)
4047

4148
cc_library(

0 commit comments

Comments
 (0)