Skip to content

Commit

Permalink
Use released protoc binaries
Browse files Browse the repository at this point in the history
Avoid compiling protoc during bazel build.

Based on change in rules_proto
bazelbuild/rules_proto#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
  • Loading branch information
simuons committed Nov 18, 2020
1 parent 8866f55 commit 7f10296
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 23 deletions.
18 changes: 18 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@ 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(
Expand Down
16 changes: 16 additions & 0 deletions examples/testing/scalatest_repositories/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "../../..",
Expand Down
16 changes: 16 additions & 0 deletions examples/testing/specs2_junit_repositories/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "../../..",
Expand Down
29 changes: 16 additions & 13 deletions test_version/WORKSPACE.template
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "../../"
Expand Down Expand Up @@ -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()
21 changes: 11 additions & 10 deletions third_party/test/proto/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7f10296

Please sign in to comment.