[bazel] Add fixes for --incompatible_load_{cc,java,proto}_rules_from_bzl (Part 2)

This change adds the required loads to examples and zlib.
For full compatibility with --incompatible_load_{cc,java,proto}_rules_from_bzl,
we will need to roll gtest to a newer version.
pull/6467/head
Yannic Bonenberger 5 years ago committed by Adam Cozzette
parent 5b6238e486
commit bf0c69e130
  1. 5
      BUILD
  2. 1
      Makefile.am
  3. 12
      WORKSPACE
  4. 4
      examples/BUILD
  5. 46
      examples/WORKSPACE
  6. 1
      examples/third_party/zlib.BUILD
  7. 6
      protobuf.bzl
  8. 8
      protobuf_deps.bzl
  9. 4
      third_party/zlib.BUILD
  10. 2
      util/python/BUILD

@ -787,12 +787,9 @@ py_library(
name = "python_srcs", name = "python_srcs",
srcs = glob( srcs = glob(
[ [
"python/google/__init__.py", "python/google/**/*.py",
"python/google/protobuf/*.py",
"python/google/protobuf/**/*.py",
], ],
exclude = [ exclude = [
"python/google/protobuf/__init__.py",
"python/google/protobuf/**/__init__.py", "python/google/protobuf/**/__init__.py",
"python/google/protobuf/internal/*_test.py", "python/google/protobuf/internal/*_test.py",
"python/google/protobuf/internal/test_util.py", "python/google/protobuf/internal/test_util.py",

@ -1230,7 +1230,6 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
examples/list_people.py \ examples/list_people.py \
examples/list_people_test.go \ examples/list_people_test.go \
examples/pubspec.yaml \ examples/pubspec.yaml \
examples/third_party/zlib.BUILD \
protobuf.bzl \ protobuf.bzl \
protobuf_deps.bzl \ protobuf_deps.bzl \
python/release/wheel/build_wheel_manylinux.sh \ python/release/wheel/build_wheel_manylinux.sh \

@ -1,5 +1,10 @@
workspace(name = "com_google_protobuf") workspace(name = "com_google_protobuf")
local_repository(
name = "com_google_protobuf_examples",
path = "examples",
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//:protobuf_deps.bzl", "protobuf_deps") load("//:protobuf_deps.bzl", "protobuf_deps")
@ -19,13 +24,6 @@ http_archive(
urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"], urls = ["https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55"],
) )
http_archive(
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)
bind( bind(
name = "python_headers", name = "python_headers",
actual = "//util/python:python_headers", actual = "//util/python:python_headers",

@ -4,6 +4,10 @@
# the WORKSPACE file in the same directory with this BUILD file for an # the WORKSPACE file in the same directory with this BUILD file for an
# example. # example.
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
# For each .proto file, a proto_library target should be defined. This target # For each .proto file, a proto_library target should be defined. This target
# is not bound to any particular language. Instead, it defines the dependency # is not bound to any particular language. Instead, it defines the dependency
# graph of the .proto files (i.e., proto imports) and serves as the provider # graph of the .proto files (i.e., proto imports) and serves as the provider

@ -1,31 +1,24 @@
workspace(name = "com_google_protobuf_examples")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# This com_google_protobuf repository is required for proto_library rule. # This com_google_protobuf repository is required for proto_library rule.
# It provides the protocol compiler binary (i.e., protoc). # It provides the protocol compiler binary (i.e., protoc).
http_archive( #
# We declare it as local_repository so we can test changes
# before they get merged. You'll want to use the following instead:
#
# http_archive(
# name = "com_google_protobuf",
# strip_prefix = "protobuf-master",
# urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
# )
local_repository(
name = "com_google_protobuf", name = "com_google_protobuf",
strip_prefix = "protobuf-master", path = "..",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
) )
# This com_google_protobuf_cc repository is required for cc_proto_library # Similar to com_google_protobuf but for Java lite. If you are building
# rule. It provides protobuf C++ runtime. Note that it actually is the same
# repo as com_google_protobuf but has to be given a different name as
# required by bazel.
http_archive(
name = "com_google_protobuf_cc",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
)
# Similar to com_google_protobuf_cc but for Java (i.e., java_proto_library).
http_archive(
name = "com_google_protobuf_java",
strip_prefix = "protobuf-master",
urls = ["https://github.com/protocolbuffers/protobuf/archive/master.zip"],
)
# Similar to com_google_protobuf_cc but for Java lite. If you are building
# for Android, the lite version should be prefered because it has a much # for Android, the lite version should be prefered because it has a much
# smaller code size. # smaller code size.
http_archive( http_archive(
@ -34,17 +27,6 @@ http_archive(
urls = ["https://github.com/protocolbuffers/protobuf/archive/javalite.zip"], urls = ["https://github.com/protocolbuffers/protobuf/archive/javalite.zip"],
) )
http_archive(
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps() protobuf_deps()
load("@bazel_skylib//lib:versions.bzl", "versions")
versions.check(minimum_bazel_version = "0.5.4")

@ -1 +0,0 @@
../../third_party/zlib.BUILD

@ -1,3 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@bazel_skylib//lib:versions.bzl", "versions") load("@bazel_skylib//lib:versions.bzl", "versions")
def _GetPath(ctx, path): def _GetPath(ctx, path):
@ -276,7 +277,7 @@ def cc_proto_library(
) )
# An empty cc_library to make rule dependency consistent. # An empty cc_library to make rule dependency consistent.
native.cc_library( cc_library(
name = name, name = name,
**kargs **kargs
) )
@ -307,8 +308,7 @@ def cc_proto_library(
cc_libs = cc_libs + [default_runtime] cc_libs = cc_libs + [default_runtime]
if use_grpc_plugin: if use_grpc_plugin:
cc_libs = cc_libs + ["//external:grpc_lib"] cc_libs = cc_libs + ["//external:grpc_lib"]
cc_library(
native.cc_library(
name = name, name = name,
srcs = gen_srcs, srcs = gen_srcs,
hdrs = gen_hdrs, hdrs = gen_hdrs,

@ -5,6 +5,14 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def protobuf_deps(): def protobuf_deps():
"""Loads common dependencies needed to compile the protobuf library.""" """Loads common dependencies needed to compile the protobuf library."""
if not native.existing_rule("bazel_skylib"):
http_archive(
name = "bazel_skylib",
sha256 = "bbccf674aa441c266df9894182d80de104cabd19be98be002f6d478aaa31574d",
strip_prefix = "bazel-skylib-2169ae1c374aab4a09aa90e65efe1a3aad4e279b",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/2169ae1c374aab4a09aa90e65efe1a3aad4e279b.tar.gz"],
)
if not native.existing_rule("zlib"): if not native.existing_rule("zlib"):
http_archive( http_archive(
name = "zlib", name = "zlib",

@ -1,4 +1,4 @@
package(default_visibility = ["//visibility:public"]) load("@rules_cc//cc:defs.bzl", "cc_library")
licenses(["notice"]) # BSD/MIT-like license (for zlib) licenses(["notice"]) # BSD/MIT-like license (for zlib)
@ -26,7 +26,6 @@ genrule(
srcs = _ZLIB_HEADERS, srcs = _ZLIB_HEADERS,
outs = _ZLIB_PREFIXED_HEADERS, outs = _ZLIB_PREFIXED_HEADERS,
cmd = "cp $(SRCS) $(@D)/zlib/include/", cmd = "cp $(SRCS) $(@D)/zlib/include/",
visibility = ["//visibility:private"],
) )
cc_library( cc_library(
@ -60,4 +59,5 @@ cc_library(
], ],
}), }),
includes = ["zlib/include/"], includes = ["zlib/include/"],
visibility = ["//visibility:public"],
) )

@ -1,3 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
# This is a placeholder for python headers. Projects needing to use # This is a placeholder for python headers. Projects needing to use
# fast cpp protos in protobuf's python interface should build with # fast cpp protos in protobuf's python interface should build with
# --define=use_fast_cpp_protos=true, and in addition, provide # --define=use_fast_cpp_protos=true, and in addition, provide

Loading…
Cancel
Save