Skip to content

Commit

Permalink
bazel: update gapic.bzl to work with REST transport (#14895)
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthart authored Dec 11, 2024
1 parent e2ed1e6 commit e750718
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 126 deletions.
4 changes: 2 additions & 2 deletions bazel/gapic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"""A definition for the typical C++ GAPIC library."""

def cc_gapic_library(name, service_dirs = [], googleapis_deps = []):
def cc_gapic_library(name, service_dirs = [], googleapis_deps = [], additional_deps = []):
"""Defines targets for the typical fully generated GAPIC library
Args:
Expand Down Expand Up @@ -63,7 +63,7 @@ def cc_gapic_library(name, service_dirs = [], googleapis_deps = []):
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["//:__pkg__"],
deps = ["//:common", "//:grpc_utils"] + googleapis_deps,
deps = ["//:common", "//:grpc_utils"] + googleapis_deps + additional_deps,
)

native.cc_library(
Expand Down
73 changes: 11 additions & 62 deletions google/cloud/bigquerycontrol/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:gapic.bzl", "cc_gapic_library")

package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0
Expand All @@ -20,71 +22,18 @@ service_dirs = [
"v2/",
]

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]

filegroup(
name = "srcs",
srcs = glob(sources_glob),
)

filegroup(
name = "hdrs",
srcs = glob(
include = code_glob,
exclude = sources_glob,
),
)

filegroup(
name = "public_hdrs",
srcs = glob([d + "*.h" for d in service_dirs]),
visibility = ["//:__pkg__"],
)
src_dirs = service_dirs + [d + "internal/" for d in service_dirs]

filegroup(
name = "mocks",
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
visibility = ["//:__pkg__"],
)
googleapis_deps = [
"@com_google_googleapis//google/cloud/bigquery/v2:bigquery_cc_proto",
]

cc_library(
name = "google_cloud_cpp_bigquerycontrol",
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["//:__pkg__"],
deps = [
"//:common",
"//:grpc_utils",
cc_gapic_library(
name = "bigquerycontrol",
additional_deps = [
"//google/cloud:google_cloud_cpp_rest_internal",
"//google/cloud:google_cloud_cpp_rest_protobuf_internal",
"@com_google_googleapis//google/cloud/bigquery/v2:bigquery_cc_proto",
],
googleapis_deps = googleapis_deps,
service_dirs = service_dirs,
)

cc_library(
name = "google_cloud_cpp_bigquerycontrol_mocks",
hdrs = [":mocks"],
visibility = ["//:__pkg__"],
deps = [
":google_cloud_cpp_bigquerycontrol",
"@com_google_googletest//:gtest",
],
)

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:bigquerycontrol",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]
73 changes: 11 additions & 62 deletions google/cloud/sql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,77 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:gapic.bzl", "cc_gapic_library")

package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

service_dirs = ["v1/"]

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]

filegroup(
name = "srcs",
srcs = glob(sources_glob),
)

filegroup(
name = "hdrs",
srcs = glob(
include = code_glob,
exclude = sources_glob,
),
)

filegroup(
name = "public_hdrs",
srcs = glob([d + "*.h" for d in service_dirs]),
visibility = ["//:__pkg__"],
)
src_dirs = service_dirs + [d + "internal/" for d in service_dirs]

filegroup(
name = "mocks",
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
visibility = ["//:__pkg__"],
)
googleapis_deps = [
"@com_google_googleapis//google/cloud/sql/v1:sql_cc_proto",
]

cc_library(
name = "google_cloud_cpp_sql",
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["//:__pkg__"],
deps = [
"//:common",
"//:grpc_utils",
cc_gapic_library(
name = "sql",
additional_deps = [
"//google/cloud:google_cloud_cpp_rest_internal",
"//google/cloud:google_cloud_cpp_rest_protobuf_internal",
"@com_google_googleapis//google/cloud/sql/v1:sql_cc_proto",
],
googleapis_deps = googleapis_deps,
service_dirs = service_dirs,
)

cc_library(
name = "google_cloud_cpp_sql_mocks",
hdrs = [":mocks"],
visibility = ["//:__pkg__"],
deps = [
":google_cloud_cpp_sql",
"@com_google_googletest//:gtest",
],
)

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:sql",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]

0 comments on commit e750718

Please sign in to comment.