Skip to content

Commit

Permalink
Upgrade protobuf to 3.8.0
Browse files Browse the repository at this point in the history
The custom commit contains a fix to make protobuf.bzl compatible with Bazel 0.26 or later version.

Also fix WORKSPACE file to make sure tf_workspace() always takes priority over dependency definitions of other repositories.

PiperOrigin-RevId: 253970221
  • Loading branch information
tensorflower-gardener committed Jun 19, 2019
1 parent a98b781 commit 508f76b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
14 changes: 10 additions & 4 deletions WORKSPACE
Expand Up @@ -12,6 +12,12 @@ http_archive(
],
)

# Load tf_workspace() before loading dependencies for other repository so that
# dependencies like com_google_protobuf won't be overridden.
load("//tensorflow:workspace.bzl", "tf_workspace")
# Please add all new TensorFlow dependencies in workspace.bzl.
tf_workspace()

load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories")

closure_repositories()
Expand Down Expand Up @@ -83,15 +89,15 @@ swift_rules_dependencies()
load("//tensorflow:version_check.bzl", "check_bazel_version_at_least")
check_bazel_version_at_least("0.19.0")

load("//tensorflow:workspace.bzl", "tf_workspace")

load("//third_party/android:android_configure.bzl", "android_configure")
android_configure(name="local_config_android")
load("@local_config_android//:android.bzl", "android_workspace")
android_workspace()

# Please add all new TensorFlow dependencies in workspace.bzl.
tf_workspace()
# If a target is bound twice, the later one wins, so we have to do tf bindings
# at the end of the WORKSPACE file.
load("//tensorflow:workspace.bzl", "tf_bind")
tf_bind()

http_archive(
name = "inception_v1",
Expand Down
19 changes: 14 additions & 5 deletions tensorflow/workspace.bzl
Expand Up @@ -371,16 +371,21 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
},
)

# 5902e759108d14ee8e6b0b07653dac2f4e70ac73 is based on 3.7.1 with a fix for BUILD file.
# 310ba5ee72661c081129eb878c1bbcec936b20f0 is based on 3.8.0 with a fix for protobuf.bzl.
PROTOBUF_URLS = [
"http://mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/5902e759108d14ee8e6b0b07653dac2f4e70ac73.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/5902e759108d14ee8e6b0b07653dac2f4e70ac73.tar.gz",
"http://mirror.tensorflow.org/github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/310ba5ee72661c081129eb878c1bbcec936b20f0.tar.gz",
]
PROTOBUF_SHA256 = "1c020fafc84acd235ec81c6aac22d73f23e85a700871466052ff231d69c1b17a"
PROTOBUF_STRIP_PREFIX = "protobuf-5902e759108d14ee8e6b0b07653dac2f4e70ac73"
PROTOBUF_SHA256 = "b9e92f9af8819bbbc514e2902aec860415b70209f31dfc8c4fa72515a5df9d59"
PROTOBUF_STRIP_PREFIX = "protobuf-310ba5ee72661c081129eb878c1bbcec936b20f0"

# protobuf depends on @zlib, it has to be renamed to @zlib_archive because "zlib" is already
# defined using bind for grpc.
PROTOBUF_PATCH = "//third_party/protobuf:protobuf.patch"

tf_http_archive(
name = "protobuf_archive",
patch_file = PROTOBUF_PATCH,
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
system_build_file = clean_dep("//third_party/systemlibs:protobuf.BUILD"),
Expand All @@ -395,6 +400,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
# Unfortunately there is no way to alias http_archives at the moment.
tf_http_archive(
name = "com_google_protobuf",
patch_file = PROTOBUF_PATCH,
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
system_build_file = clean_dep("//third_party/systemlibs:protobuf.BUILD"),
Expand All @@ -406,6 +412,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):

tf_http_archive(
name = "com_google_protobuf_cc",
patch_file = PROTOBUF_PATCH,
sha256 = PROTOBUF_SHA256,
strip_prefix = PROTOBUF_STRIP_PREFIX,
system_build_file = clean_dep("//third_party/systemlibs:protobuf.BUILD"),
Expand Down Expand Up @@ -920,6 +927,8 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
],
)

def tf_bind():
"""Bind targets for some external repositories"""
##############################################################################
# BIND DEFINITIONS
#
Expand Down
22 changes: 22 additions & 0 deletions third_party/protobuf/protobuf.patch
@@ -0,0 +1,22 @@
diff --git a/BUILD b/BUILD
index 2fb26050..c2744d5b 100644
--- a/BUILD
+++ b/BUILD
@@ -19,7 +19,7 @@ config_setting(
# ZLIB configuration
################################################################################

-ZLIB_DEPS = ["@zlib//:zlib"]
+ZLIB_DEPS = ["@zlib_archive//:zlib"]

################################################################################
# Protobuf Runtime Library
@@ -218,7 +218,7 @@ cc_library(
# TODO(keveman): Remove this target once the support gets added to Bazel.
cc_library(
name = "protobuf_headers",
- hdrs = glob(["src/**/*.h"]),
+ hdrs = glob(["src/**/*.h", "src/**/*.inc"]),
includes = ["src/"],
visibility = ["//visibility:public"],
)

0 comments on commit 508f76b

Please sign in to comment.