cartographer/cartographer_grpc/BUILD.bazel

136 lines
3.3 KiB
Python

# Copyright 2018 The Cartographer Authors
#
# 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
#
# http://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.
# Top-level proto and C++ targets for Cartographer's gRPC server.
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
proto_library(
name = "protos",
srcs = glob(
[
"**/*.proto",
],
exclude = [
"**/*_service.proto",
],
),
deps = [
"//cartographer:protos",
"@com_google_protobuf//:empty_proto",
],
)
cc_proto_library(
name = "cc_protos",
deps = [":protos"],
)
# TODO(rodrigoq): This special rule name is required by cc_grpc_library. This
# makes :protos look like it was created by
# cc_grpc_library(proto_only=True, ...)
proto_library(
name = "_cc_protos_only",
deps = [
":protos",
"//cartographer:protos",
"@com_google_protobuf//:empty_proto",
],
)
# TODO(rodrigoq): this doesn't work when it is in an external repository. If
# you want to use it, you can vendor cartographer in your main workspace.
cc_grpc_library(
name = "proto_map_builder_service_grpc_cc",
srcs = ["proto/map_builder_service.proto"],
generate_mock = False,
proto_only = False,
use_external = True,
well_known_protos = True,
deps = [
":cc_protos",
],
)
cc_library(
name = "cartographer_grpc",
srcs = glob(
[
"**/*.cc",
],
exclude = [
"**/*_main.cc",
"**/*_test.cc",
],
),
hdrs = glob([
"**/*.h",
]),
includes = ["."],
deps = [
":cc_protos",
":proto_map_builder_service_grpc_cc",
"//cartographer",
"@com_github_grpc_grpc//:grpc++",
"@com_google_glog//:glog",
"@com_google_protobuf//:cc_wkt_protos",
],
)
cc_binary(
name = "cartographer_grpc_server",
srcs = ["map_builder_server_main.cc"],
deps = [
":cartographer_grpc",
"@com_github_gflags_gflags//:gflags",
"@com_google_glog//:glog",
],
)
# TODO(rodrigoq): these tests need to read the configuration files, but they're
# not able to find them.
EXCLUDED_TESTS = [
"client_server_test.cc",
]
# This service is only used by the tests.
cc_grpc_library(
name = "framework_proto_math_service_grpc_cc",
srcs = ["framework/proto/math_service.proto"],
generate_mock = False,
proto_only = False,
use_external = True,
well_known_protos = True,
deps = [
":cc_protos",
],
)
[cc_test(
name = src.replace("/", "_").replace(".cc", ""),
srcs = [src],
deps = [
":cartographer_grpc",
":framework_proto_math_service_grpc_cc",
"@com_google_googletest//:gtest_main",
],
) for src in glob(
["**/*_test.cc"],
exclude = EXCLUDED_TESTS,
)]