Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions buf/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ See https://bazel.build/docs/bzlmod#extension-definition
load("//buf/internal:repo.bzl", "buf_dependencies")
load("//buf/internal:toolchain.bzl", "buf_download_releases")

_DEFAULT_VERSION = "v1.47.2"
_DEFAULT_SHA256 = "1b37b75dc0a777a0cba17fa2604bc9906e55bb4c578823d8b7a8fe3fc9fe4439"
_DEFAULT_VERSION = "v1.75.0"
_DEFAULT_SHA256 = "b05b543026f48418579c3e37b9c4f9b776b895085e453775ded018a06e631823"
_DEFAULT_TOOLCHAIN_NAME = "rules_buf_toolchains"
_DEFAULT_DEPS = "buf_deps"

Expand Down
36 changes: 30 additions & 6 deletions buf/internal/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,30 @@ def _detect_host_platform(ctx):
goarch = "arm64"
elif goarch == "x86_64":
goarch = "amd64"
elif goarch == "armv7l":
goarch = "arm"

return goos, goarch

# Earliest buf (major, minor) release with binaries for each host, keyed by the
# (os, cpu) pair returned from _detect_host_platform.
_MIN_SUPPORTED_VERSIONS = {
("darwin", "amd64"): (0, 0),
("darwin", "arm64"): (0, 0),
("freebsd", "amd64"): (1, 67),
("freebsd", "arm64"): (1, 67),
("linux", "amd64"): (0, 0),
("linux", "arm"): (1, 47),
("linux", "arm64"): (0, 0),
("linux", "ppc64le"): (1, 54),
("linux", "riscv64"): (1, 54),
("linux", "s390x"): (1, 56),
("openbsd", "amd64"): (1, 67),
("openbsd", "arm64"): (1, 67),
("windows", "amd64"): (0, 0),
("windows", "arm64"): (0, 0),
}

def _buf_download_releases_impl(ctx):
version = ctx.attr.version
repository_url = ctx.attr.repository_url
Expand All @@ -120,16 +141,15 @@ def _buf_download_releases_impl(ctx):
major_version = int(version_number[0])
minor_version = int(version_number[1])
os, cpu = _detect_host_platform(ctx)
if os not in ["linux", "darwin", "windows"] or cpu not in ["arm64", "amd64", "ppc64le", "s390x"]:
fail("Unsupported operating system or cpu architecture ")
min_version = _MIN_SUPPORTED_VERSIONS.get((os, cpu))
if min_version == None or (major_version, minor_version) < min_version:
fail("buf {} has no release for {}/{}".format(version, os, cpu))
if os == "linux" and cpu == "arm64":
cpu = "aarch64"
if cpu == "amd64":
cpu = "x86_64"
if cpu == "ppc64le" and (major_version < 1 or (major_version == 1 and minor_version < 54)):
fail("Unsupported operating system or cpu architecture ")
if cpu == "s390x" and (major_version < 1 or (major_version == 1 and minor_version < 56)):
fail("Unsupported operating system or cpu architecture ")
if cpu == "arm":
cpu = "armv7"

ctx.report_progress("Downloading buf release hash")
url = "{}/{}/sha256.txt".format(repository_url, version)
Expand Down Expand Up @@ -170,6 +190,10 @@ def _buf_download_releases_impl(ctx):
if os == "darwin":
os = "osx"

# Bazel's host platform uses @platforms//cpu:arm (aarch32), not armv7.
if cpu == "armv7":
cpu = "arm"

ctx.file(
"BUILD",
_BUILD_FILE.format(
Expand Down
2 changes: 1 addition & 1 deletion examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local_path_override(
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")

# Override the default version of buf
buf.toolchains(version = "v1.47.2")
buf.toolchains(version = "v1.75.0")

# See https://buf.build/docs/build-systems/bazel#buf-dependencies
buf.dependency(module = "buf.build/envoyproxy/protoc-gen-validate:eac44469a7af47e7839a7f1f3d7ac004")
Expand Down
6 changes: 3 additions & 3 deletions examples/bzlmod/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/echo/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")

# Override the default version of buf
buf.toolchains(
sha256 = "1b37b75dc0a777a0cba17fa2604bc9906e55bb4c578823d8b7a8fe3fc9fe4439",
version = "v1.47.2",
sha256 = "b05b543026f48418579c3e37b9c4f9b776b895085e453775ded018a06e631823",
version = "v1.75.0",
)

# Allow people to use `bazel run @rules_buf_toolchains//:buf -- --version`
Expand Down
8 changes: 4 additions & 4 deletions examples/echo/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/toolchain/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local_path_override(
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")

# Override the default version of buf
buf.toolchains(version = "v1.47.2")
buf.toolchains(version = "v1.75.0")

# See https://buf.build/docs/build-systems/bazel#buf-dependencies
buf.dependency(module = "buf.build/envoyproxy/protoc-gen-validate:eac44469a7af47e7839a7f1f3d7ac004")
Expand Down
6 changes: 3 additions & 3 deletions examples/toolchain/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/unused/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local_path_override(
buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")

# Override the default version of buf
buf.toolchains(version = "v1.47.2")
buf.toolchains(version = "v1.75.0")

# See https://buf.build/docs/build-systems/bazel#buf-dependencies
buf.dependency(module = "buf.build/envoyproxy/protoc-gen-validate:eac44469a7af47e7839a7f1f3d7ac004")
Expand Down
6 changes: 3 additions & 3 deletions examples/unused/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading