Skip to content

Commit

Permalink
Add a check_protobuf_required_bazel_version() for use in WORKSPACEs
Browse files Browse the repository at this point in the history
  • Loading branch information
fahhem committed Dec 4, 2017
1 parent 6de51ca commit 35119e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ http_archive(
strip_prefix = "protobuf-master",
urls = ["https://github.com/google/protobuf/archive/master.zip"],
)
load("@com_google_protobuf//:protobuf.bzl", "check_protobuf_required_bazel_version")
check_protobuf_required_bazel_version()

# This com_google_protobuf_cc repository is required for cc_proto_library
# rule. It provides protobuf C++ runtime. Note that it actually is the same
Expand Down
12 changes: 12 additions & 0 deletions protobuf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,15 @@ def internal_protobuf_py_tests(
srcs=[s],
main=s,
**kargs)


def check_protobuf_required_bazel_version():
"""For WORKSPACE files, to check the installed version of bazel.
This ensures bazel supports our approach to proto_library() depending on a
copied filegroup. (Fixed in bazel 0.5.4)
"""
expected = apple_common.dotted_version("0.5.4")
current = apple_common.dotted_version(native.bazel_version)
if current.compare_to(expected) < 0:
fail("Bazel must be newer than 0.5.4")

0 comments on commit 35119e3

Please sign in to comment.