From 9f2244c24716e321096e6a5b2f68e1ad40859090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonas=20Pinevi=C4=8Dius?= Date: Sat, 21 Nov 2020 08:04:37 +0200 Subject: [PATCH] Use released protoc binaries (#1142) * Use released protoc binaries Avoid compiling protoc during bazel build. Based on change in rules_proto https://github.com/bazelbuild/rules_proto/pull/36 rules_proto_dependencies() declares a @com_google_protobuf//:protoc which points to released protoc binary. The tricks is to load that before scala_repositories() which has conditional load for @com_google_protobuf * lint fix * Align rules_proto versions * Update readme * Revert "Update readme" This reverts commit b9a3606402336e77b1742720a4dcd7b0606fe270. --- WORKSPACE | 19 ++++++++++++ .../testing/scalatest_repositories/WORKSPACE | 16 ++++++++++ .../specs2_junit_repositories/WORKSPACE | 16 ++++++++++ scala/private/macros/scala_repositories.bzl | 8 ++--- test_version/WORKSPACE.template | 29 ++++++++++--------- third_party/test/proto/WORKSPACE | 21 +++++++------- 6 files changed, 82 insertions(+), 27 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index af83363c1..15df4ac34 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -13,6 +13,25 @@ http_archive( url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), ) +http_archive( + name = "rules_proto", + sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", + strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +# Declares @com_google_protobuf//:protoc pointing to released binary +# This should stop building protoc during bazel build +# See https://github.com/bazelbuild/rules_proto/pull/36 +rules_proto_dependencies() + +rules_proto_toolchains() + _build_tools_release = "3.3.0" http_archive( diff --git a/examples/testing/scalatest_repositories/WORKSPACE b/examples/testing/scalatest_repositories/WORKSPACE index d5d4a1ae6..10fa0594c 100644 --- a/examples/testing/scalatest_repositories/WORKSPACE +++ b/examples/testing/scalatest_repositories/WORKSPACE @@ -11,6 +11,22 @@ http_archive( url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), ) +http_archive( + name = "rules_proto", + sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", + strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + local_repository( name = "io_bazel_rules_scala", path = "../../..", diff --git a/examples/testing/specs2_junit_repositories/WORKSPACE b/examples/testing/specs2_junit_repositories/WORKSPACE index db48ab649..d97e03adf 100644 --- a/examples/testing/specs2_junit_repositories/WORKSPACE +++ b/examples/testing/specs2_junit_repositories/WORKSPACE @@ -11,6 +11,22 @@ http_archive( url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), ) +http_archive( + name = "rules_proto", + sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", + strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + local_repository( name = "io_bazel_rules_scala", path = "../../..", diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index a35fa8f68..ec62c0b36 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -40,11 +40,11 @@ def rules_scala_setup(): if not native.existing_rule("rules_proto"): http_archive( name = "rules_proto", - sha256 = "4d421d51f9ecfe9bf96ab23b55c6f2b809cbaf0eea24952683e397decfbd0dd0", - strip_prefix = "rules_proto-f6b8d89b90a7956f6782a4a3609b2f0eee3ce965", + sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", + strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/f6b8d89b90a7956f6782a4a3609b2f0eee3ce965.tar.gz", - "https://github.com/bazelbuild/rules_proto/archive/f6b8d89b90a7956f6782a4a3609b2f0eee3ce965.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", ], ) diff --git a/test_version/WORKSPACE.template b/test_version/WORKSPACE.template index 37044b6e5..2e3d0cc17 100644 --- a/test_version/WORKSPACE.template +++ b/test_version/WORKSPACE.template @@ -11,6 +11,22 @@ http_archive( url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), ) +http_archive( + name = "rules_proto", + sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", + strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + ], +) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + local_repository( name = "io_bazel_rules_scala", path = "../../" @@ -50,16 +66,3 @@ register_toolchains("@io_bazel_rules_scala//testing:testing_toolchain") load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains") scala_register_unused_deps_toolchains() - -protobuf_version="3.11.3" -protobuf_version_sha256="cf754718b0aa945b00550ed7962ddc167167bd922b842199eeb6505e6f344852" - -http_archive( - name = "com_google_protobuf", - url = "https://github.com/protocolbuffers/protobuf/archive/v%s.tar.gz" % protobuf_version, - strip_prefix = "protobuf-%s" % protobuf_version, - sha256 = protobuf_version_sha256, -) - -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") -protobuf_deps() diff --git a/third_party/test/proto/WORKSPACE b/third_party/test/proto/WORKSPACE index 354d971f0..52527094b 100644 --- a/third_party/test/proto/WORKSPACE +++ b/third_party/test/proto/WORKSPACE @@ -2,20 +2,21 @@ workspace(name = "proto") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -protobuf_version = "3.11.3" - -protobuf_version_sha256 = "cf754718b0aa945b00550ed7962ddc167167bd922b842199eeb6505e6f344852" - http_archive( - name = "com_google_protobuf", - sha256 = protobuf_version_sha256, - strip_prefix = "protobuf-%s" % protobuf_version, - url = "https://github.com/protocolbuffers/protobuf/archive/v%s.tar.gz" % protobuf_version, + name = "rules_proto", + sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", + strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", + ], ) -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() -protobuf_deps() +rules_proto_toolchains() local_repository( name = "io_bazel_rules_scala",