From 425e0d1a6bec956f4c9c94acf9d3153283f1aad4 Mon Sep 17 00:00:00 2001 From: KB Sriram Date: Sat, 29 Dec 2018 14:56:31 -0800 Subject: [PATCH] Generate Java protos in BUILD 1. Simplify WORKSPACE and BUILD files 2. Add a Java proto generator See https://github.com/tensorflow/metadata/issues/5 --- WORKSPACE | 42 +++++++++++------------------- tensorflow_metadata/proto/v0/BUILD | 39 ++++++++++++++------------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index db66389..0a10f4f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,39 +1,27 @@ workspace(name = "tensorflow_metadata") -git_repository( - name = "protobuf_bzl", - # v3.4.0 - commit = "80a37e0782d2d702d52234b62dd4b9ec74fd2c95", - remote = "https://github.com/google/protobuf.git", -) -bind( - name = "protobuf", - actual = "@protobuf_bzl//:protobuf", -) -bind( - name = "protobuf_python", - actual = "@protobuf_bzl//:protobuf_python", -) -bind( - name = "protobuf_python_genproto", - actual = "@protobuf_bzl//:protobuf_python_genproto", -) -bind( - name = "protoc", - actual = "@protobuf_bzl//:protoc", -) + # Using protobuf version 3.6.0 +# We need to import the protobuf library under the name com_google_protobuf +# to enable proto_library support in bazel. http_archive( - name = "protobuf_archive", + name = "com_google_protobuf", strip_prefix = "protobuf-3.6.0", - urls = ["https://github.com/google/protobuf/archive/v3.6.0.zip"], + sha256 = "50a5753995b3142627ac55cfd496cebc418a2e575ca0236e29033c67bd5665f4", + urls = [ + "https://mirror.bazel.build/github.com/google/protobuf/archive/v3.6.0.tar.gz", + "https://github.com/google/protobuf/archive/v3.6.0.tar.gz", + ] ) -# required by protobuf_python +# required by @com_google_protobuf//:protobuf_python new_http_archive( name = "six_archive", - build_file = "@protobuf_bzl//:six.BUILD", + build_file = "@com_google_protobuf//:six.BUILD", sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a", - url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55", + urls = [ + "https://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz", + "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz", + ], ) bind( name = "six", diff --git a/tensorflow_metadata/proto/v0/BUILD b/tensorflow_metadata/proto/v0/BUILD index 47330d2..35c495b 100644 --- a/tensorflow_metadata/proto/v0/BUILD +++ b/tensorflow_metadata/proto/v0/BUILD @@ -13,37 +13,36 @@ # limitations under the License. # ============================================================================== - licenses(["notice"]) # Apache 2.0 package(default_visibility = ["//visibility:public"]) -load("@protobuf_archive//:protobuf.bzl", "cc_proto_library", "py_proto_library") +load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") + +METADATA_PROTO_SRCS = [ + "anomalies.proto", + "path.proto", + "schema.proto", + "statistics.proto", +] + +proto_library( + name = "metadata_v0_proto", + srcs = METADATA_PROTO_SRCS, +) cc_proto_library( name = "metadata_v0_proto_cc_pb2", - srcs = [ - "anomalies.proto", - "path.proto", - "schema.proto", - "statistics.proto", - ], - cc_libs = ["@protobuf_archive//:protobuf"], - default_runtime = "@protobuf_archive//:protobuf", - protoc = "@protobuf_archive//:protoc", + deps = [":metadata_v0_proto"], ) py_proto_library( name = "metadata_v0_proto_py_pb2", - srcs = [ - "anomalies.proto", - "path.proto", - "schema.proto", - "statistics.proto", - ], - default_runtime = "@protobuf_archive//:protobuf_python", - protoc = "@protobuf_archive//:protoc", + srcs = METADATA_PROTO_SRCS, srcs_version = "PY2AND3", - deps = ["@protobuf_archive//:protobuf_python"], ) +java_proto_library( + name = "metadata_v0_proto_java_pb2", + deps = [":metadata_v0_proto"], +)