- Notifications
You must be signed in to change notification settings - Fork 342
/
Copy pathruff.bzl
51 lines (40 loc) · 1.6 KB
/
ruff.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 ruff binary to be used by bazel smoke
"""
RUFF_BUILD="""
package(default_visibility = ["//visibility:public"])
exports_files(["ruff"])
"""
VERSION="0.6.8"
SHA256= {
"aarch64-apple-darwin": "e554d55281391138e44b30ccd38c666388e4aeb05417c9ffb98a6cbb014aef0d",
"x86_64-apple-darwin": "44039cea2aed4787cedcda0c35e5b352530d6ca2178f39c8bd4ff63526c43aef",
"x86_64-unknown-linux-gnu": "7edce7075bf6d43b1ef2a9383b76a43310bbf5d70fa4471330fd5aaf655192b0",
}
URL="https://github.com/astral-sh/ruff/releases/download/{version}/ruff-{platform}.tar.gz"
def_ruff_impl(repository_ctx):
os_arch=repository_ctx.os.arch
ifos_arch=="x86_64"oros_arch=="amd64":
arch="x86_64"
elifos_arch=="aarch64":
arch="aarch64"
else:
fail("Unsupported architecture: '"+os_arch+"'")
os_name=repository_ctx.os.name
ifos_name=="linux":
platform=arch+"-unknown-linux-gnu"
elifos_name=="mac os x":
platform=arch+"-apple-darwin"
else:
fail("Unsupported operating system: "+os_name)
ifplatformnotinSHA256:
fail("Unsupported platform: '"+platform+"'")
repository_ctx.report_progress("Fetching "+repository_ctx.name)
repository_ctx.download_and_extract(url=URL.format(version=VERSION, platform=platform), sha256=SHA256[platform], stripPrefix="ruff-{platform}".format(platform=platform))
repository_ctx.file("BUILD.bazel", RUFF_BUILD, executable=True)
_ruff=repository_rule(
implementation=_ruff_impl,
attrs= {},
)
defruff(name):
_ruff(name=name)