blob: 430be198dcaf88529f67cd2b6d09581d858ff1e7 [file]
# Copyright 2014 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Once nested repositories work, this file should cease to exist.
load("//go/private:common.bzl", "MINIMUM_BAZEL_VERSION")
load("//go/private/skylib/lib:versions.bzl", "versions")
load("//go/private:nogo.bzl", "DEFAULT_NOGO", "go_register_nogo")
load("//proto:gogo.bzl", "gogo_special_proto")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def go_rules_dependencies():
"""Declares workspaces the Go rules depend on. Workspaces that use
rules_go should call this.
See https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#overriding-dependencies
for information on each dependency.
Instructions for updating this file are in
https://github.com/bazelbuild/rules_go/wiki/Updating-dependencies.
PRs updating dependencies are NOT ACCEPTED. See
https://github.com/bazelbuild/rules_go/blob/master/go/dependencies.rst#overriding-dependencies
for information on choosing different versions of these repositories
in your own project.
"""
if getattr(native, "bazel_version", None):
versions.check(MINIMUM_BAZEL_VERSION, bazel_version = native.bazel_version)
# Repository of standard constraint settings and values.
# Bazel declares this automatically after 0.28.0, but it's better to
# define an explicit version.
# releaser:upgrade-dep bazelbuild platforms
_maybe(
http_archive,
name = "platforms",
# 0.0.4, latest as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
],
sha256 = "079945598e4b6cc075846f7fd6a9d0857c33a7afc0de868c2ccb96405225135d",
strip_prefix = "",
)
# Needed by rules_go implementation and tests.
# We can't call bazel_skylib_workspace from here. At the moment, it's only
# used to register unittest toolchains, which rules_go does not need.
# releaser:upgrade-dep bazelbuild bazel-skylib
_maybe(
http_archive,
name = "bazel_skylib",
# 1.1.1, latest as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
],
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
strip_prefix = "",
)
# Needed for nogo vet checks and go/packages.
# releaser:upgrade-dep golang tools
_maybe(
http_archive,
name = "org_golang_x_tools",
# v0.1.8, latest as of 2021-12-15
urls = [
"https://mirror.bazel.build/github.com/golang/tools/archive/v0.1.8.zip",
"https://github.com/golang/tools/archive/v0.1.8.zip",
],
sha256 = "aec8a9ade0974bafc290bad1c53fa2b4d2b87ac8a90bf5340ded216ff81d1b2a",
strip_prefix = "tools-0.1.8",
patches = [
# deletegopls removes the gopls subdirectory. It contains a nested
# module with additional dependencies. It's not needed by rules_go.
# releaser:patch-cmd rm -rf gopls
"@io_bazel_rules_go//third_party:org_golang_x_tools-deletegopls.patch",
# releaser:patch-cmd gazelle -repo_root . -go_prefix golang.org/x/tools -go_naming_convention import_alias
"@io_bazel_rules_go//third_party:org_golang_x_tools-gazelle.patch",
],
patch_args = ["-p1"],
)
# releaser:upgrade-dep golang sys
_maybe(
http_archive,
name = "org_golang_x_sys",
# master, as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/golang/sys/archive/2c5d950f24efcc95bc256be158532a2eee20542f.zip",
"https://github.com/golang/sys/archive/2c5d950f24efcc95bc256be158532a2eee20542f.zip",
],
sha256 = "8cbf3990ff9d10ab3dab1322b0895d37e1563839b47c778db835a8fd0fa8fb13",
strip_prefix = "sys-2c5d950f24efcc95bc256be158532a2eee20542f",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix golang.org/x/sys -go_naming_convention import_alias
"@io_bazel_rules_go//third_party:org_golang_x_sys-gazelle.patch",
],
patch_args = ["-p1"],
)
# Needed by golang.org/x/tools/go/packages
# releaser:upgrade-dep golang xerrors
_maybe(
http_archive,
name = "org_golang_x_xerrors",
# master, as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/golang/xerrors/archive/5ec99f83aff198f5fbd629d6c8d8eb38a04218ca.zip",
"https://github.com/golang/xerrors/archive/5ec99f83aff198f5fbd629d6c8d8eb38a04218ca.zip",
],
sha256 = "cd9de801daf63283be91a76d7f91e8a9541798c5c0e8bcfb7ee804b78a493b02",
strip_prefix = "xerrors-5ec99f83aff198f5fbd629d6c8d8eb38a04218ca",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix golang.org/x/xerrors -go_naming_convention import_alias
"@io_bazel_rules_go//third_party:org_golang_x_xerrors-gazelle.patch",
],
patch_args = ["-p1"],
)
# Proto dependencies
# These are limited as much as possible. In most cases, users need to
# declare these on their own (probably via go_repository rules generated
# with 'gazelle update-repos -from_file=go.mod). There are several
# reasons for this:
#
# * com_google_protobuf has its own dependency macro. We can't load
# the macro here.
# * rules_proto also has a dependency macro. It's only needed by tests and
# by gogo_special_proto. Users will need to declare it anyway.
# * org_golang_google_grpc has too many dependencies for us to maintain.
# * In general, declaring dependencies here confuses users when they
# declare their own dependencies later. Bazel ignores these.
# * Most proto repos are updated more frequently than rules_go, and
# we can't keep up.
# Go protobuf runtime library and utilities.
# releaser:upgrade-dep protocolbuffers protobuf-go
_maybe(
http_archive,
name = "org_golang_google_protobuf",
sha256 = "a01b25899f598fbac3c2626376b74fc15229f009904c262658f8da1c1c392386",
# v1.27.1, latest as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf-go/archive/v1.27.1.zip",
"https://github.com/protocolbuffers/protobuf-go/archive/v1.27.1.zip",
],
strip_prefix = "protobuf-go-1.27.1",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix google.golang.org/protobuf -go_naming_convention import_alias -proto disable_global
"@io_bazel_rules_go//third_party:org_golang_google_protobuf-gazelle.patch",
],
patch_args = ["-p1"],
)
# Legacy protobuf compiler, runtime, and utilities.
# We still use protoc-gen-go because the new one doesn't support gRPC, and
# the gRPC compiler doesn't exist yet.
# We need to apply a patch to enable both go_proto_library and
# go_library with pre-generated sources.
# releaser:upgrade-dep golang protobuf
_maybe(
http_archive,
name = "com_github_golang_protobuf",
# v1.5.2, latest as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/golang/protobuf/archive/v1.5.2.zip",
"https://github.com/golang/protobuf/archive/v1.5.2.zip",
],
sha256 = "5bd0a70e2f3829db9d0e340887af4e921c5e0e5bb3f8d1be49a934204cb16445",
strip_prefix = "protobuf-1.5.2",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix github.com/golang/protobuf -go_naming_convention import_alias -proto disable_global
"@io_bazel_rules_go//third_party:com_github_golang_protobuf-gazelle.patch",
],
patch_args = ["-p1"],
)
# Extra protoc plugins and libraries.
# Doesn't belong here, but low maintenance.
# releaser:upgrade-dep mwitkow go-proto-validators
_maybe(
http_archive,
name = "com_github_mwitkow_go_proto_validators",
# v0.3.2, latest as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/mwitkow/go-proto-validators/archive/v0.3.2.zip",
"https://github.com/mwitkow/go-proto-validators/archive/v0.3.2.zip",
],
sha256 = "d8697f05a2f0eaeb65261b480e1e6035301892d9fc07ed945622f41b12a68142",
strip_prefix = "go-proto-validators-0.3.2",
# Bazel support added in v0.3.0, so no patches needed.
)
# releaser:upgrade-dep gogo protobuf
_maybe(
http_archive,
name = "com_github_gogo_protobuf",
# v1.3.2, latest as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/gogo/protobuf/archive/v1.3.2.zip",
"https://github.com/gogo/protobuf/archive/v1.3.2.zip",
],
sha256 = "f89f8241af909ce3226562d135c25b28e656ae173337b3e58ede917aa26e1e3c",
strip_prefix = "protobuf-1.3.2",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix github.com/gogo/protobuf -go_naming_convention import_alias -proto legacy
"@io_bazel_rules_go//third_party:com_github_gogo_protobuf-gazelle.patch",
],
patch_args = ["-p1"],
)
_maybe(
gogo_special_proto,
name = "gogo_special_proto",
)
# go_library targets with pre-generated sources for Well Known Types
# and Google APIs.
# Doesn't belong here, but it would be an annoying source of errors if
# this weren't generated with -proto disable_global.
# releaser:upgrade-dep googleapis go-genproto
_maybe(
http_archive,
name = "org_golang_google_genproto",
# master, as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/googleapis/go-genproto/archive/c76a74d43a8eff9efc7832aa92c6a61ce42c8101.zip",
"https://github.com/googleapis/go-genproto/archive/c76a74d43a8eff9efc7832aa92c6a61ce42c8101.zip",
],
sha256 = "6d5db6630cc481f8e843dd213ac335b8b0231ef815775f39eea05e39057261a8",
strip_prefix = "go-genproto-c76a74d43a8eff9efc7832aa92c6a61ce42c8101",
patches = [
# releaser:patch-cmd gazelle -repo_root . -go_prefix google.golang.org/genproto -go_naming_convention import_alias -proto disable_global
"@io_bazel_rules_go//third_party:org_golang_google_genproto-gazelle.patch",
],
patch_args = ["-p1"],
)
# go_proto_library targets for gRPC and Google APIs.
# TODO(#1986): migrate to com_google_googleapis. This workspace was added
# before the real workspace supported Bazel. Gazelle resolves dependencies
# here. Gazelle should resolve dependencies to com_google_googleapis
# instead, and we should remove this.
# releaser:upgrade-dep googleapis googleapis
_maybe(
http_archive,
name = "go_googleapis",
# master, as of 2021-10-06
urls = [
"https://mirror.bazel.build/github.com/googleapis/googleapis/archive/409e134ffaacc243052b08e6fb8e2d458014ed37.zip",
"https://github.com/googleapis/googleapis/archive/409e134ffaacc243052b08e6fb8e2d458014ed37.zip",
],
sha256 = "a85c6a00e9cf0f004992ebea1d10688e3beea9f8e1a5a04ee53f367e72ee85af",
strip_prefix = "googleapis-409e134ffaacc243052b08e6fb8e2d458014ed37",
patches = [
# releaser:patch-cmd find . -name BUILD.bazel -delete
"@io_bazel_rules_go//third_party:go_googleapis-deletebuild.patch",
# set gazelle directives; change workspace name
"@io_bazel_rules_go//third_party:go_googleapis-directives.patch",
# releaser:patch-cmd gazelle -repo_root .
"@io_bazel_rules_go//third_party:go_googleapis-gazelle.patch",
],
patch_args = ["-E", "-p1"],
)
# This may be overridden by go_register_toolchains, but it's not mandatory
# for users to call that function (they may declare their own @go_sdk and
# register their own toolchains).
_maybe(
go_register_nogo,
name = "io_bazel_rules_nogo",
nogo = DEFAULT_NOGO,
)
def _maybe(repo_rule, name, **kwargs):
if name not in native.existing_rules():
repo_rule(name = name, **kwargs)