- Notifications
You must be signed in to change notification settings - Fork 342
/
Copy pathbuf.bzl
51 lines (40 loc) · 1.51 KB
/
buf.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
The module fetches buf binary to be used by bazel smoke test
"""
BUF_BUILD="""
package(default_visibility = ["//visibility:public"])
exports_files(["buf"])
"""
VERSION="1.46.0"
SHA256= {
"Darwin-arm64": "bb039f69ed1e00dd07ab4f1ee88cdceb663f448150ca8092f9348e2f66df475f",
"Darwin-x86_64": "95a4b42bbf808194ffe5807fa869d622b6af37893c500d8ba4e3cfe2fe662e97",
"Linux-x86_64": "04c92815f92431bea637d834bee9d2941e979b1c821c59805667c032e2e8fc1f",
}
URL="https://github.com/bufbuild/buf/releases/download/v{version}/buf-{platform}"
def_buf_impl(repository_ctx):
os_arch=repository_ctx.os.arch
ifos_arch=="x86_64"oros_arch=="amd64":
arch="x86_64"
elifos_arch=="aarch64":
arch="arm64"
else:
fail("Unsupported architecture: '"+os_arch+"'")
os_name=repository_ctx.os.name
ifos_name=="linux":
platform="Linux-"+arch
elifos_name=="mac os x":
platform="Darwin-"+arch
else:
fail("Unsupported operating system: "+os_name)
ifplatformnotinSHA256:
fail("Unsupported platform: '"+platform+"'")
repository_ctx.report_progress("Fetching "+repository_ctx.name)
repository_ctx.download(url=URL.format(version=VERSION, platform=platform), sha256=SHA256[platform], executable=True, output="buf")
repository_ctx.file("BUILD.bazel", BUF_BUILD, executable=True)
_buf=repository_rule(
implementation=_buf_impl,
attrs= {},
)
defbuf(name):
_buf(name=name)