Skip to content

Commit

Permalink
feat(toolchains): add fd toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
mgred committed May 18, 2024
1 parent 67fca42 commit 8e205fa
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bazel_dep(name = "aspect_bazel_lib", version = "2.3.0")
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)

tools = use_extension("//lib:extensions.bzl", "tools")
tools.fd()
tools.goawk()
tools.jql()
tools.ripgrep()
Expand All @@ -21,6 +22,7 @@ tools.typos()
tools.xsv()
use_repo(
tools,
"fd",
"goawk",
"jql",
"ripgrep",
Expand All @@ -32,6 +34,7 @@ use_repo(
)

register_toolchains(
"@fd//:all",
"@goawk//:all",
"@jql//:all",
"@ripgrep//:all",
Expand Down
1 change: 1 addition & 0 deletions toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load(":toolchains.bzl", "toolchains")
package(default_visibility = ["//visibility:public"])

TOOLS = [
"fd",
"goawk",
"jql",
"ripgrep",
Expand Down
28 changes: 28 additions & 0 deletions toolchains/fd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("//lib:platform_binary.bzl", "platform_binaries")

VERSION = "10.1.0"

SUPPORTED_PLATFORMS = [
"darwin_amd64",
"darwin_arm64",
"linux_amd64",
"linux_arm64",
"windows_amd64",
]

GITHUB_URL = "https://github.com/sharkdp/fd/releases/download/v%s" % VERSION

platform_binaries(
name = "fd",
binary = "fd",
platforms = SUPPORTED_PLATFORMS,
platforms_map = {
"darwin_amd64": "x85_64-apple-darwin",
"darwin_arm64": "aarch64-apple-darwin",
"linux_amd64": "x86_64-unknown-linux-musl",
"linux_arm64": "aarch64-unknown-linux-musl",
"windows_amd64": "x86_64-pc-windows-msvc",
},
prefix = "fd-v%s-{platform}/" % VERSION,
url = "%s/fd-v%s-{platform}.{ext}" % (GITHUB_URL, VERSION),
)
7 changes: 7 additions & 0 deletions toolchains/fd/assets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ASSETS = {
"darwin_amd64": struct(binary = "fd-v10.1.0-x85_64-apple-darwin/fd", url = "https://github.com/sharkdp/fd/releases/download/v10.1.0/fd-v10.1.0-x85_64-apple-darwin.tar.gz", integrity = "sha384-AI+HQg6X3xX+Su/0qIwiSw2Ygga0UNjAFFCZPicIJ8xlzT70tejy5Gx4ZEJ/dHOm"),
"darwin_arm64": struct(binary = "fd-v10.1.0-aarch64-apple-darwin/fd", url = "https://github.com/sharkdp/fd/releases/download/v10.1.0/fd-v10.1.0-aarch64-apple-darwin.tar.gz", integrity = "sha384-MdhcWHZ4NpZ6+WkduY78cCIPG9aWKyXxTMWOz9R8ITYMudB3n2xG5kyjRU/wp0GV"),
"linux_amd64": struct(binary = "fd-v10.1.0-x86_64-unknown-linux-musl/fd", url = "https://github.com/sharkdp/fd/releases/download/v10.1.0/fd-v10.1.0-x86_64-unknown-linux-musl.tar.gz", integrity = "sha384-Z3giBL2DBJ9yRoiN83LSE2AhmQQwG9gLoUIrqJzFdpPI1V5JnVpGjMs2RVp5sj/8"),
"linux_arm64": struct(binary = "fd-v10.1.0-aarch64-unknown-linux-musl/fd", url = "https://github.com/sharkdp/fd/releases/download/v10.1.0/fd-v10.1.0-aarch64-unknown-linux-musl.tar.gz", integrity = "sha384-Su6eTng/Iw809zazoe8vf+XSCJVA6SgIq2np/80TlCz2i+M+Q1Eyy6on9aSedBEG"),
"windows_amd64": struct(binary = "fd-v10.1.0-x86_64-pc-windows-msvc/fd.exe", url = "https://github.com/sharkdp/fd/releases/download/v10.1.0/fd-v10.1.0-x86_64-pc-windows-msvc.zip", integrity = "sha384-VWpoU885tYWt4SZVZVudPm6fvDZIgeh2hT5nv6vCe2J7JJti3D5uFNyQR3zYeKgc"),
}
18 changes: 18 additions & 0 deletions toolchains/toolchains.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# buildifier: disable=module-docstring
load("//lib:toolchains.bzl", "resolved_toolchain_impl")
load("//toolchains/fd:assets.bzl", FD_ASSETS = "ASSETS")
load("//toolchains/goawk:assets.bzl", GOAWK_ASSETS = "ASSETS")
load("//toolchains/jql:assets.bzl", JQL_ASSETS = "ASSETS")
load("//toolchains/ripgrep:assets.bzl", RIPGREP_ASSETS = "ASSETS")
Expand All @@ -10,6 +11,7 @@ load("//toolchains/typos:assets.bzl", TYPOS_ASSETS = "ASSETS")
load("//toolchains/xsv:assets.bzl", XSV_ASSETS = "ASSETS")

TOOLS = {
"fd": FD_ASSETS,
"goawk": GOAWK_ASSETS,
"jql": JQL_ASSETS,
"ripgrep": RIPGREP_ASSETS,
Expand All @@ -20,6 +22,14 @@ TOOLS = {
"xsv": XSV_ASSETS,
}

FD_TOOLCHAIN_TYPE = "@bzlparty_tools//toolchains:fd_toolchain_type"

fd_resolved_toolchain = rule(
implementation = resolved_toolchain_impl(FD_TOOLCHAIN_TYPE),
toolchains = [FD_TOOLCHAIN_TYPE],
incompatible_use_toolchain_transition = True,
)

GOAWK_TOOLCHAIN_TYPE = "@bzlparty_tools//toolchains:goawk_toolchain_type"

goawk_resolved_toolchain = rule(
Expand Down Expand Up @@ -86,6 +96,14 @@ xsv_resolved_toolchain = rule(

# buildifier: disable=function-docstring
def toolchains(name = "toolchains"):
native.toolchain_type(
name = "fd_toolchain_type",
visibility = ["//visibility:public"],
)
fd_resolved_toolchain(
name = "fd",
visibility = ["//visibility:public"],
)
native.toolchain_type(
name = "goawk_toolchain_type",
visibility = ["//visibility:public"],
Expand Down

0 comments on commit 8e205fa

Please sign in to comment.