Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use released protoc binaries #36

Merged
merged 17 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions proto/private/BUILD.protoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_proto//proto/private:dependencies.bzl", "protoc_binary")

protoc_binary(
comius marked this conversation as resolved.
Show resolved Hide resolved
name = "protoc",
src = "bin/protoc",
executable = "protoc_bin",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be protoc.exe then?

visibility = ["//visibility:public"],
)
8 changes: 8 additions & 0 deletions proto/private/BUILD.protoc_windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("@rules_proto//proto/private:dependencies.bzl", "protoc_binary")

protoc_binary(
name = "protoc",
src = "bin/protoc.exe",
executable = "protoc.exe",
visibility = ["//visibility:public"],
)
157 changes: 157 additions & 0 deletions proto/private/BUILD.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Use precompiled binaries where possible.
alias(
name = "protoc",
actual = select({
":linux-aarch64": "@com_google_protobuf_protoc_linux_aarch64//:protoc",
":linux-ppc": "@com_google_protobuf_protoc_linux_ppc//:protoc",
":linux-s390x": "@com_google_protobuf_protoc_linux_s390x//:protoc",
":linux-x86_32": "@com_google_protobuf_protoc_linux_x86_32//:protoc",
":linux-x86_64": "@com_google_protobuf_protoc_linux_x86_64//:protoc",
":macos-x86_32": "@com_google_protobuf_protoc_macos_x86_32//:protoc",
":macos-x86_64": "@com_google_protobuf_protoc_macos_x86_64//:protoc",
":windows-x86_32": "@com_google_protobuf_protoc_windows_x86_32//:protoc",
":windows-x86_64": "@com_google_protobuf_protoc_windows_x86_64//:protoc",
"//conditions:default": "@com_github_protocolbuffers_protobuf//:protoc",
}),
visibility = ["//visibility:public"],
)

# Use the jars from maven.
alias(
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
name = "protobuf_java",
actual = "@com_google_protobuf_protobuf_java//jar",
visibility = ["//visibility:public"],
)

alias(
name = "protobuf_javalite",
actual = "@com_google_protobuf_protobuf_javalite//jar",
visibility = ["//visibility:public"],
)

proto_lang_toolchain(
comius marked this conversation as resolved.
Show resolved Hide resolved
name = "java_toolchain",
command_line = "--java_out=$(OUT)",
runtime = ":protobuf_java",
visibility = ["//visibility:public"],
)

proto_lang_toolchain(
name = "javalite_toolchain",
command_line = "--java_out=lite:$(OUT)",
runtime = ":protobuf_javalite",
visibility = ["//visibility:public"],
)

# Redirect everything else to the source
redirect_targets = [
"wrappers_proto",
"well_known_protos",
"timestamp_proto",
"struct_proto",
"python_specific_test_protos_genproto",
"python_common_test_protos_genproto",
"protobuf_python_genproto",
"protobuf_python",
"protobuf_objc",
"protobuf_headers",
"objectivec",
"field_mask_proto",
"empty_proto",
"duration_proto",
"compiler_plugin_proto",
"descriptor_proto",
"cc_wkt_protos",
"cc_toolchain",
"cc_test_protos_genproto",
"cc_wkt_protos_genproto",
"api_proto",
"type_proto",
"source_context_proto",
"any_proto",
"protoc_lib",
"protobuf",
"protobuf_lite",
"protobuf_java_util",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to use the maven version for protobuf_java_util (haven't checked)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, just missed it.

]

[
alias(
name = target,
actual = "@com_github_protocolbuffers_protobuf//:" + target,
visibility = ["//visibility:public"],
)
for target in redirect_targets
]

config_setting(
name = "linux-aarch64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:aarch64",
],
)

config_setting(
name = "linux-ppc",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:ppc",
],
)

config_setting(
name = "linux-s390x",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:s390x",
],
)

config_setting(
name = "linux-x86_32",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_32",
],
)

config_setting(
name = "linux-x86_64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "macos-x86_32",
constraint_values = [
"@platforms//os:osx",
"@platforms//cpu:x86_32",
],
)

config_setting(
name = "macos-x86_64",
constraint_values = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "windows-x86_32",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_32",
],
)

config_setting(
name = "windows-x86_64",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
)
144 changes: 123 additions & 21 deletions proto/private/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,119 @@

dependencies = {
"bazel_skylib": {
"sha256": "9245b0549e88e356cd6a25bf79f97aa19332083890b7ac6481a2affb6ada9752",
"strip_prefix": "bazel-skylib-0.9.0",
"sha256": "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/archive/0.9.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/archive/0.9.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
],
},
"com_google_protobuf": {
"com_github_protocolbuffers_protobuf": {
"sha256": "cf754718b0aa945b00550ed7962ddc167167bd922b842199eeb6505e6f344852",
"strip_prefix": "protobuf-3.11.3",
"urls": [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.11.3.tar.gz",
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
"https://github.com/protocolbuffers/protobuf/archive/v3.11.3.tar.gz",
],
},
# Dependency of `com_google_protobuf`.
"com_google_protobuf_protoc_linux_aarch64": {
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "3994233e61c287a377a9134e658ca3034924849f0e3a82d12b0e6efa2bed4b46",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-linux-aarch_64.zip",

This comment was marked as resolved.

],
},
"com_google_protobuf_protoc_linux_ppc": {
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "0dc5bf7eea3ee742ea7f56f51a229dac18e2deef330d5ccaef75c6d629469be7",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-linux-ppcle_64.zip",
],
},
"com_google_protobuf_protoc_linux_s390x": {
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "81d8647b168af8f2cb3b1c2a665e35648a2c2906f3cb59382f39c7842ae639e3",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-linux-s390x_64.zip",
],
},
"com_google_protobuf_protoc_linux_x86_32": {
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "840d0f8ef9886707b12414de4c100f62e6a5135b533040d3117e4b80db09e8ac",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-linux-x86_32.zip",
],
},
"com_google_protobuf_protoc_linux_x86_64": {
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "39f5d64b0f31117c94651c880d0a776159e49eab42b2066229569934b936a5e7",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-linux-x86_64.zip",
],
},
"com_google_protobuf_protoc_macos_x86_32": {
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "b9684666c28cb37b532470df4df85f0238a3df610d3b9a5d03ce4222b0cd5e12",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-osx-x86_32.zip",
],
},
"com_google_protobuf_protoc_macos_x86_64": {
"build_file": "@rules_proto//proto/private:BUILD.protoc",
"sha256": "a02dc07c3776de214c3dff4025b33269aebd0fc03aa8e791e7025df43c06e219",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-osx-x86_64.zip",
],
},
"com_google_protobuf_protoc_windows_x86_32": {
"build_file": "@rules_proto//proto/private:BUILD.protoc_windows",
"sha256": "63755dd0018e005293b8ef0cd21e348f420d466b94c54285e3e2593c22e8a74c",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-win32.zip",
],
},
"com_google_protobuf_protoc_windows_x86_64": {
"build_file": "@rules_proto//proto/private:BUILD.protoc_windows",
"sha256": "1490944d3bbf77b58bcbd175fef6fbf14cc9c20f79be06c4be827641af1c6ca2",
"urls": [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-win64.zip",
],
},
# Dependency of `com_github_protocolbuffers_protobuf`.
"rules_cc": {
"sha256": "bb8320b0bc1d8d01dc8c8e8c50edced8553655c03776960c1287d03dfbcac3e5",
"strip_prefix": "rules_cc-401380cd2279b83da0dcb86ecbac04a04805405b",
"sha256": "29daf0159f0cf552fcff60b49d8bcd4f08f08506d2da6e41b07058ec50cfeaec",
"strip_prefix": "rules_cc-b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/401380cd2279b83da0dcb86ecbac04a04805405b.tar.gz",
"https://github.com/bazelbuild/rules_cc/archive/401380cd2279b83da0dcb86ecbac04a04805405b.tar.gz",
"https://github.com/bazelbuild/rules_cc/archive/b7fe9697c0c76ab2fd431a891dbb9a6a32ed7c3e.tar.gz",
],
},
# Dependency of `com_google_protobuf`.
# Dependency of `com_github_protocolbuffers_protobuf`.
"rules_java": {
"sha256": "4e2f33528a66e3a9909910eaa5a562fb22f5b422513cdc3816fd01fbb6e2d08d",
"strip_prefix": "rules_java-166a046a27e118d578127759b413ee0b06aca3cd",
"sha256": "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3",
"strip_prefix": "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/archive/166a046a27e118d578127759b413ee0b06aca3cd.tar.gz",
"https://github.com/bazelbuild/rules_java/archive/166a046a27e118d578127759b413ee0b06aca3cd.tar.gz",
"https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz",
],
},
# Dependency of `com_google_protobuf`.
# Dependency of `com_github_protocolbuffers_protobuf`.
"rules_python": {
"sha256": "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6",
"strip_prefix": "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27",
"urls": [
"https://mirror.bazel.build/github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz",
"https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz",
],
},
# Dependency of `com_google_protobuf`.
# Dependency of `com_github_protocolbuffers_protobuf`.
"six": {
"build_file": "@com_google_protobuf//:third_party/six.BUILD",
"build_file": "@com_github_protocolbuffers_protobuf//:third_party/six.BUILD",
"sha256": "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73",
"urls": [
"https://mirror.bazel.build/pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz",
"https://pypi.python.org/packages/source/s/six/six-1.12.0.tar.gz",
],
},
# Dependency of `com_google_protobuf`.
# Dependency of `com_github_protocolbuffers_protobuf`.
"zlib": {
"build_file": "@com_google_protobuf//:third_party/zlib.BUILD",
"build_file": "@com_github_protocolbuffers_protobuf//:third_party/zlib.BUILD",
"sha256": "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1",
"strip_prefix": "zlib-1.2.11",
"urls": [
Expand All @@ -78,3 +137,46 @@ dependencies = {
],
},
}

# TODO: should these be mirrored to mirror.bazel.build?
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
maven_dependencies = {
"com_google_protobuf_protobuf_java": {
"jar_sha256": "4e567f364f5608606616ef764e801d66a52e5241577ad7405f519a3a8a6802bb",
"jar_urls": ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.11.3/protobuf-java-3.11.3.jar"],
"licenses": ["notice"],
"srcjar_sha256": "9d2ee817e71c63f197271d425b11dac1414926302eea1d2eaae5e4fd2ca31d5d",
"srcjar_urls": ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/3.11.3/protobuf-java-3.11.3-sources.jar"],
},
"com_google_protobuf_protobuf_javalite": {
"jar_sha256": "5ff32ba40ce12b859898600a967a69094ae38bb57f619cf08c2160ae376174b6",
"jar_urls": ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-javalite/3.11.3/protobuf-javalite-3.11.3.jar"],
"licenses": ["notice"],
"srcjar_sha256": "6eeb3fa7f7bae8b41847cf49858454b1dd1a6859f0cfe50ffb6f846c5e027d49",
"srcjar_urls": ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-javalite/3.11.3/protobuf-javalite-3.11.3-sources.jar"],
},
}

def _protobuf_workspace_impl(ctx):
ctx.symlink(ctx.attr._build, "BUILD")
ctx.symlink(ctx.attr._protobuf_bzl, "protobuf.bzl")
ctx.symlink(ctx.attr._protobuf_deps_bzl, "protobuf_deps.bzl")

protobuf_workspace = repository_rule(
implementation = _protobuf_workspace_impl,
attrs = {
"_build": attr.label(default = "@rules_proto//proto/private:BUILD.release"),
"_protobuf_bzl": attr.label(default = "@com_github_protocolbuffers_protobuf//:protobuf.bzl"),
"_protobuf_deps_bzl": attr.label(default = "@com_github_protocolbuffers_protobuf//:protobuf.bzl"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/protobuf.bzl/protobuf_deps.bzl

},
)

def protoc_binary(name, src, executable, **kwargs):
native.genrule(
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
name = name,
executable = True,
srcs = [src],
outs = [executable],
cmd_bash = "cp $< $@&&chmod +x $@",
cmd_bat = "copy $< $@",
**kwargs
)
6 changes: 5 additions & 1 deletion proto/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
"""Dependencies and toolchains required to use rules_proto."""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:java.bzl", "java_import_external")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//proto/private:dependencies.bzl", "dependencies")
load("//proto/private:dependencies.bzl", "dependencies", "maven_dependencies", "protobuf_workspace")

def rules_proto_dependencies():
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
for name in dependencies:
maybe(http_archive, name, **dependencies[name])
for name in maven_dependencies:
maybe(java_import_external, name, **maven_dependencies[name])
protobuf_workspace(name = "com_google_protobuf")

def rules_proto_toolchains():
ribrdb marked this conversation as resolved.
Show resolved Hide resolved
# Nothing to do here (yet).
Expand Down