From 8e205facad9feea3cb87f5c28cd885cad9aa17c7 Mon Sep 17 00:00:00 2001 From: Marc Redemske Date: Sat, 18 May 2024 17:33:23 +0200 Subject: [PATCH] feat(toolchains): add fd toolchain --- MODULE.bazel | 3 +++ toolchains/BUILD.bazel | 1 + toolchains/fd/BUILD.bazel | 28 ++++++++++++++++++++++++++++ toolchains/fd/assets.bzl | 7 +++++++ toolchains/toolchains.bzl | 18 ++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 toolchains/fd/BUILD.bazel create mode 100644 toolchains/fd/assets.bzl diff --git a/MODULE.bazel b/MODULE.bazel index dc2d30e..97ff161 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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() @@ -21,6 +22,7 @@ tools.typos() tools.xsv() use_repo( tools, + "fd", "goawk", "jql", "ripgrep", @@ -32,6 +34,7 @@ use_repo( ) register_toolchains( + "@fd//:all", "@goawk//:all", "@jql//:all", "@ripgrep//:all", diff --git a/toolchains/BUILD.bazel b/toolchains/BUILD.bazel index 5c03ada..f25fc8c 100644 --- a/toolchains/BUILD.bazel +++ b/toolchains/BUILD.bazel @@ -5,6 +5,7 @@ load(":toolchains.bzl", "toolchains") package(default_visibility = ["//visibility:public"]) TOOLS = [ + "fd", "goawk", "jql", "ripgrep", diff --git a/toolchains/fd/BUILD.bazel b/toolchains/fd/BUILD.bazel new file mode 100644 index 0000000..0b46680 --- /dev/null +++ b/toolchains/fd/BUILD.bazel @@ -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), +) diff --git a/toolchains/fd/assets.bzl b/toolchains/fd/assets.bzl new file mode 100644 index 0000000..8d2a861 --- /dev/null +++ b/toolchains/fd/assets.bzl @@ -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"), +} diff --git a/toolchains/toolchains.bzl b/toolchains/toolchains.bzl index d255cd0..4dab16a 100644 --- a/toolchains/toolchains.bzl +++ b/toolchains/toolchains.bzl @@ -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") @@ -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, @@ -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( @@ -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"],