diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..a25fa8ce8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "third_party/protobuf"] + path = third_party/protobuf + url = https://github.com/google/protobuf +[submodule "third_party/zlib"] + path = third_party/zlib + url = https://github.com/makdharma/zlib +[submodule "third_party/boringssl-with-bazel"] + path = third_party/boringssl-with-bazel + url = https://boringssl.googlesource.com/boringssl +[submodule "third_party/nanopb"] + path = third_party/nanopb + url = https://github.com/nanopb/nanopb diff --git a/BUILD b/BUILD new file mode 100644 index 000000000..da25e6425 --- /dev/null +++ b/BUILD @@ -0,0 +1 @@ +# empty BUILD file diff --git a/README.md b/README.md index 5f7514c09..138c10bd3 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,11 @@ entire repository. It is not for generating linkable client library for a specific API. Please see other repositories under https://github.com/googleapis for generating linkable client libraries. +### Using bazel with gRPC +Bazel build now works for a subset of the repository. You can use build +targets from this repo as dependency into your grpc code. For example, +this works: ```bazel build //google/monitoring/v3:metric_service``` + ### Go gRPC Source Code It is difficult to generate Go gRPC source code from this repository, since Go has different directory structure. diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 000000000..c403fc73f --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,73 @@ +# nanopb +bind( + name = "nanopb", + actual = "//third_party/nanopb", +) + +# Boringssl +bind( + name = "libssl", + actual = "@submodule_boringssl//:ssl", +) + +new_local_repository( + name = "submodule_boringssl", + build_file = "third_party/boringssl-with-bazel/BUILD", + path = "third_party/boringssl-with-bazel", +) + +# Zlib +bind( + name = "zlib", + actual = "@submodule_zlib//:z", +) + +local_repository( + name = "submodule_zlib", + path = "third_party/zlib", +) + +# Protobuf +bind( + name = "protobuf", + actual = "@submodule_protobuf//:protobuf", +) + +bind( + name = "protobuf_clib", + actual = "@submodule_protobuf//:protoc_lib", +) + +bind( + name = "protocol_compiler", + actual = "@submodule_protobuf//:protoc", +) + +new_local_repository( + name = "submodule_protobuf", + build_file = "third_party/protobuf/BUILD", + path = "third_party/protobuf", +) + +# grpc +bind( + name = "grpc++", + actual = "@submodule_grpc//:grpc++", +) + +bind( + name = "grpc++_codegen_proto", + actual = "@submodule_grpc//:grpc++_codegen_proto", +) + +bind( + name = "grpc_cpp_plugin", + actual = "@submodule_grpc//:grpc_cpp_plugin", +) + +git_repository( + name = "submodule_grpc", + remote = "https://github.com/grpc/grpc", + # TODO(makdharma): replace with version when bazel file fix is released + commit = "eb064ec7b81b60c5e1eb47d6124d0c05056b3097", +) diff --git a/google/api/BUILD b/google/api/BUILD new file mode 100644 index 000000000..ed4678d8f --- /dev/null +++ b/google/api/BUILD @@ -0,0 +1,58 @@ + +package(default_visibility = ["//visibility:public"]) + +load("@submodule_grpc//bazel:grpc_build_system.bzl", "grpc_proto_library") + +grpc_proto_library( + name = "http", + srcs = [ + "http.proto", + ], + use_external = True, +) + +grpc_proto_library( + name = "label", + srcs = [ + "label.proto", + ], + use_external = True, +) + +grpc_proto_library( + name = "distribution", + srcs = ["distribution.proto"], + deps = [ + ":annotations", + ], + well_known_protos = "@submodule_protobuf//:well_known_protos", + use_external = True, +) + +grpc_proto_library( + name = "metric", + srcs = ["metric.proto"], + deps = [ + "//google/api:label", + ], + use_external = True, +) + +grpc_proto_library( + name = "annotations", + srcs = ["annotations.proto"], + deps = [ + ":http", + ], + well_known_protos = "@submodule_protobuf//:well_known_protos", + use_external = True, +) + +grpc_proto_library( + name = "monitored_resource", + srcs = ["monitored_resource.proto"], + deps = [ + ":label", + ], + use_external = True, +) diff --git a/google/monitoring/v3/BUILD b/google/monitoring/v3/BUILD new file mode 100644 index 000000000..3d40b4cae --- /dev/null +++ b/google/monitoring/v3/BUILD @@ -0,0 +1,42 @@ + +package(default_visibility = ["//visibility:public"]) + +load("@submodule_grpc//bazel:grpc_build_system.bzl", "grpc_proto_library") + +grpc_proto_library(name = "metric", + srcs = ["metric.proto"], + deps = [ + "//google/api:metric", + "//google/api:monitored_resource", + ":common", + ], + well_known_protos = "@submodule_protobuf//:well_known_protos", + use_external = True, +) + +grpc_proto_library( + name = "common", + srcs = ["common.proto"], + deps = [ + "//google/api:distribution", + "//google/api:annotations", + ], + well_known_protos = "@submodule_protobuf//:well_known_protos", + use_external = True, +) + +grpc_proto_library( + name = "metric_service", + srcs = ["metric_service.proto"], + deps = [ + "//google/api:annotations", + "//google/api:metric", + "//google/api:monitored_resource", + "//google/api:label", + "//google/rpc:status", + ":common", + ":metric", + ], + well_known_protos = "@submodule_protobuf//:well_known_protos", + use_external = True, +) diff --git a/google/rpc/BUILD b/google/rpc/BUILD new file mode 100644 index 000000000..2e3234e48 --- /dev/null +++ b/google/rpc/BUILD @@ -0,0 +1,11 @@ + +package(default_visibility = ["//visibility:public"]) + +load("@submodule_grpc//bazel:grpc_build_system.bzl", "grpc_proto_library") + +grpc_proto_library( + name = "status", + srcs = ["status.proto"], + well_known_protos = "@submodule_protobuf//:well_known_protos", + use_external = True, +) diff --git a/third_party/boringssl-with-bazel b/third_party/boringssl-with-bazel new file mode 160000 index 000000000..886e7d753 --- /dev/null +++ b/third_party/boringssl-with-bazel @@ -0,0 +1 @@ +Subproject commit 886e7d75368e3f4fab3f4d0d3584e4abfc557755 diff --git a/third_party/nanopb b/third_party/nanopb new file mode 160000 index 000000000..ac6405b4b --- /dev/null +++ b/third_party/nanopb @@ -0,0 +1 @@ +Subproject commit ac6405b4b8c7b3f449bd19bc3f8b84e6bc9fff77 diff --git a/third_party/protobuf b/third_party/protobuf new file mode 160000 index 000000000..593e917c1 --- /dev/null +++ b/third_party/protobuf @@ -0,0 +1 @@ +Subproject commit 593e917c176b5bc5aafa57bf9f6030d749d91cd5 diff --git a/third_party/zlib b/third_party/zlib new file mode 160000 index 000000000..8003d572d --- /dev/null +++ b/third_party/zlib @@ -0,0 +1 @@ +Subproject commit 8003d572d7a41438a37e58af14302c2c5928cdd5