From ca22d030b65f1893e40d5bd9c7a910f6a8176ab8 Mon Sep 17 00:00:00 2001 From: Todd Lipcon Date: Thu, 21 Nov 2019 13:40:55 -0800 Subject: [PATCH] test repo for issue #25 --- .../common_cpp_library/BUILD.bazel | 40 +++++++++++++++++++ test_workspaces/common_cpp_library/WORKSPACE | 11 +++++ .../common_cpp_library/common.proto | 12 ++++++ test_workspaces/common_cpp_library/demo.proto | 7 ++++ test_workspaces/common_cpp_library/test.cc | 6 +++ 5 files changed, 76 insertions(+) create mode 100644 test_workspaces/common_cpp_library/BUILD.bazel create mode 100644 test_workspaces/common_cpp_library/WORKSPACE create mode 100644 test_workspaces/common_cpp_library/common.proto create mode 100644 test_workspaces/common_cpp_library/demo.proto create mode 100644 test_workspaces/common_cpp_library/test.cc diff --git a/test_workspaces/common_cpp_library/BUILD.bazel b/test_workspaces/common_cpp_library/BUILD.bazel new file mode 100644 index 000000000..1b47eb618 --- /dev/null +++ b/test_workspaces/common_cpp_library/BUILD.bazel @@ -0,0 +1,40 @@ +package(default_visibility = ["//visibility:private"]) + +load("@rules_proto_grpc//cpp:defs.bzl", "cpp_proto_library") + +# Use the same base proto in two different trees. The rules should not tread +# on each other and try to write the same file. + +proto_library( + name = "proto_lib_a", + srcs = ["common.proto"], + deps = ["@com_google_protobuf//:descriptor_proto"], +) + +proto_library( + name = "proto_lib_b", + srcs = ["demo.proto"], + deps = [":proto_lib_a"], +) + +cpp_proto_library( + name = "cpp_lib_a", + deps = ["proto_lib_a"], +) + +cpp_proto_library( + name = "cpp_lib_b", + deps = ["proto_lib_b"], +) + +cc_test( + name = "test", + srcs = ["test.cc"], + deps = [ + # Depend on both -- this is typically due to a "diamond" pattern in + # some other transitive include graph, rather than "direct" redundant + # dependencies. + "cpp_lib_a", + "cpp_lib_b", + ], +) diff --git a/test_workspaces/common_cpp_library/WORKSPACE b/test_workspaces/common_cpp_library/WORKSPACE new file mode 100644 index 000000000..3631721e0 --- /dev/null +++ b/test_workspaces/common_cpp_library/WORKSPACE @@ -0,0 +1,11 @@ +local_repository( + name = "rules_proto_grpc", + path = "../../", +) + +load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_toolchains", "rules_proto_grpc_repos") +rules_proto_grpc_toolchains() +rules_proto_grpc_repos() + +load("@rules_proto_grpc//cpp:repositories.bzl", "cpp_repos") +cpp_repos() diff --git a/test_workspaces/common_cpp_library/common.proto b/test_workspaces/common_cpp_library/common.proto new file mode 100644 index 000000000..96bb36988 --- /dev/null +++ b/test_workspaces/common_cpp_library/common.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +import "google/protobuf/descriptor.proto"; + +extend google.protobuf.MethodOptions { + bool foo = 50001; +} + +message CommonProto{ + string field = 1; +} + diff --git a/test_workspaces/common_cpp_library/demo.proto b/test_workspaces/common_cpp_library/demo.proto new file mode 100644 index 000000000..ad5277d9f --- /dev/null +++ b/test_workspaces/common_cpp_library/demo.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +import "common.proto"; + +message demo { + CommonProto field = 1; +} diff --git a/test_workspaces/common_cpp_library/test.cc b/test_workspaces/common_cpp_library/test.cc new file mode 100644 index 000000000..9cec53a2c --- /dev/null +++ b/test_workspaces/common_cpp_library/test.cc @@ -0,0 +1,6 @@ +#include "demo.pb.h" + +int main() { + demo x; + return x.ByteSize(); +}