generated from bzlparty/rules-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
704 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# buildifier: disable=module-docstring | ||
def _typos_impl(ctx): | ||
output = ctx.actions.declare_file("%s.bash" % ctx.attr.name) | ||
typos = ctx.toolchains["@bzlparty_tools//toolchains:typos_toolchain_type"].binary_info.binary | ||
ctx.actions.write( | ||
output = output, | ||
content = """\ | ||
#!/usr/bin/env bash | ||
set -o pipefail -o errexit | ||
typos_bin=$(realpath "{path}"); | ||
workspace=$(dirname "$(realpath "{workspace}")") | ||
eval "$typos_bin $workspace" | ||
""".format( | ||
path = typos.path, | ||
workspace = ctx.file.workspace.path, | ||
), | ||
is_executable = True, | ||
) | ||
|
||
return [ | ||
DefaultInfo( | ||
files = depset([output]), | ||
runfiles = ctx.runfiles(files = [typos, ctx.file.workspace]), | ||
executable = output, | ||
), | ||
] | ||
|
||
_typos_test = rule( | ||
_typos_impl, | ||
attrs = { | ||
"workspace": attr.label(allow_single_file = True, default = Label("//:MODULE.bazel")), | ||
}, | ||
toolchains = ["@bzlparty_tools//toolchains:typos_toolchain_type"], | ||
test = True, | ||
) | ||
|
||
# buildifier: disable=function-docstring | ||
def typos_test(**kwargs): | ||
if kwargs.get("no_sandbox", True): | ||
tags = kwargs.get("tags", []) | ||
|
||
for t in ["no-sandbox", "no-cache", "external"]: | ||
if t not in tags: | ||
tags.append(t) | ||
|
||
kwargs["tags"] = tags | ||
_typos_test(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# buildifier: disable=module-docstring | ||
def _resolved_toolchain_impl(toolchain): | ||
def _impl(ctx): | ||
toolchain_info = ctx.toolchains[toolchain] | ||
return [ | ||
toolchain_info, | ||
toolchain_info.default, | ||
toolchain_info.binary_info, | ||
toolchain_info.template_variables, | ||
] | ||
|
||
return _impl | ||
|
||
GOAWK_TOOLCHAIN_TYPE = "@bzlparty_tools//toolchains:goawk_toolchain_type" | ||
RIPGREP_TOOLCHAIN_TYPE = "@bzlparty_tools//toolchains:ripgrep_toolchain_type" | ||
TYPOS_TOOLCHAIN_TYPE = "@bzlparty_tools//toolchains:typos_toolchain_type" | ||
XSV_TOOLCHAIN_TYPE = "@bzlparty_tools//toolchains:xsv_toolchain_type" | ||
|
||
goawk_resolved_toolchain = rule( | ||
implementation = _resolved_toolchain_impl(GOAWK_TOOLCHAIN_TYPE), | ||
toolchains = [GOAWK_TOOLCHAIN_TYPE], | ||
incompatible_use_toolchain_transition = True, | ||
) | ||
|
||
ripgrep_resolved_toolchain = rule( | ||
implementation = _resolved_toolchain_impl(RIPGREP_TOOLCHAIN_TYPE), | ||
toolchains = [RIPGREP_TOOLCHAIN_TYPE], | ||
incompatible_use_toolchain_transition = True, | ||
) | ||
|
||
typos_resolved_toolchain = rule( | ||
implementation = _resolved_toolchain_impl(TYPOS_TOOLCHAIN_TYPE), | ||
toolchains = [TYPOS_TOOLCHAIN_TYPE], | ||
incompatible_use_toolchain_transition = True, | ||
) | ||
|
||
xsv_resolved_toolchain = rule( | ||
implementation = _resolved_toolchain_impl(XSV_TOOLCHAIN_TYPE), | ||
toolchains = [XSV_TOOLCHAIN_TYPE], | ||
incompatible_use_toolchain_transition = True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("//lib:platform_binary.bzl", "platform_binaries") | ||
|
||
VERSION = "1.21.0" | ||
|
||
SUPPORTED_PLATFORMS = [ | ||
"darwin_amd64", | ||
"darwin_arm64", | ||
"linux_amd64", | ||
"linux_arm64", | ||
"windows_amd64", | ||
"windows_arm64", | ||
] | ||
|
||
GITHUB_URL = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-%s" % VERSION | ||
|
||
platform_binaries( | ||
name = "typos", | ||
binary = "typos", | ||
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", | ||
"windows_arm64": "aarch64-pc-windows-msvc", | ||
}, | ||
url = "%s/{platform}.tar.gz" % GITHUB_URL, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ASSETS = { | ||
"darwin_amd64": struct(binary = "typos", url = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-1.21.0/x85_64-apple-darwin.tar.gz", integrity = "sha384-AI+HQg6X3xX+Su/0qIwiSw2Ygga0UNjAFFCZPicIJ8xlzT70tejy5Gx4ZEJ/dHOm"), | ||
"darwin_arm64": struct(binary = "typos", url = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-1.21.0/aarch64-apple-darwin.tar.gz", integrity = "sha384-8nOMf5jj3iggOtsS/dChGnhHJBdHkPkJw+2DoGkuOncJfI1TVfxfiOMlNx6cYBjr"), | ||
"linux_amd64": struct(binary = "typos", url = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-1.21.0/x86_64-unknown-linux-musl.tar.gz", integrity = "sha384-YdD3XLwJTKSKSftpdZ6JbNoiKouHkZ0D/BGQk3736KlzsvQ9sefTkoAYvYIU96Zg"), | ||
"linux_arm64": struct(binary = "typos", url = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-1.21.0/aarch64-unknown-linux-musl.tar.gz", integrity = "sha384-AkCCxhe7jU4ykyZwW9A6R6sihsi0+21/tZ0kWaFhyV2UqwlZC85qN2qPokprTkow"), | ||
"windows_amd64": struct(binary = "typos.exe", url = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-1.21.0/x86_64-pc-windows-msvc.tar.gz", integrity = "sha384-B45/wcXU/Q5zB7oxY6kuZNDmj4lu1Shnn47/5Eij12JCJQpoMHqlc2NE+CswBJhS"), | ||
"windows_arm64": struct(binary = "typos.exe", url = "https://github.com/cargo-prebuilt/index/releases/download/typos-cli-1.21.0/aarch64-pc-windows-msvc.tar.gz", integrity = "sha384-AuGDiX1gA1199GW2oUL9KqjIhdOpa+N8WFBxq3xNtOOk6FbOIHCLnL0tOmU5dB+N"), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
load("//lib:platform_binary.bzl", "platform_binaries") | ||
|
||
VERSION = "0.13.0" | ||
|
||
SUPPORTED_PLATFORMS = [ | ||
"darwin_amd64", | ||
"darwin_arm64", | ||
"linux_amd64", | ||
"linux_arm64", | ||
"windows_amd64", | ||
"windows_arm64", | ||
] | ||
|
||
GITHUB_URL = "https://github.com/cargo-prebuilt/index/releases/download/xsv-%s" % VERSION | ||
|
||
platform_binaries( | ||
name = "xsv", | ||
binary = "xsv", | ||
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", | ||
"windows_arm64": "aarch64-pc-windows-msvc", | ||
}, | ||
url = "%s/{platform}.tar.gz" % GITHUB_URL, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ASSETS = { | ||
"darwin_amd64": struct(binary = "xsv", url = "https://github.com/cargo-prebuilt/index/releases/download/xsv-0.13.0/x85_64-apple-darwin.tar.gz", integrity = "sha384-AI+HQg6X3xX+Su/0qIwiSw2Ygga0UNjAFFCZPicIJ8xlzT70tejy5Gx4ZEJ/dHOm"), | ||
"darwin_arm64": struct(binary = "xsv", url = "https://github.com/cargo-prebuilt/index/releases/download/xsv-0.13.0/aarch64-apple-darwin.tar.gz", integrity = "sha384-LNKs3vYVqUzH09ylwPhkdKMMhV26tmSro8+lXkqvOVtlaCbKWjdYMiaipQ9L+jcb"), | ||
"linux_amd64": struct(binary = "xsv", url = "https://github.com/cargo-prebuilt/index/releases/download/xsv-0.13.0/x86_64-unknown-linux-musl.tar.gz", integrity = "sha384-a9R7blrnvbuiwK3fxRdPvRErETlXLQUnVRnq0TRaVNLQ5ppbXhYZcvbrHd9WuHK8"), | ||
"linux_arm64": struct(binary = "xsv", url = "https://github.com/cargo-prebuilt/index/releases/download/xsv-0.13.0/aarch64-unknown-linux-musl.tar.gz", integrity = "sha384-S+MRIKADdpHoFvJd5IJVvAu6QbK4lQxAqopDIZbYZC1dZGzHwiKBFtYbAqWS0gea"), | ||
"windows_amd64": struct(binary = "xsv.exe", url = "https://github.com/cargo-prebuilt/index/releases/download/xsv-0.13.0/x86_64-pc-windows-msvc.tar.gz", integrity = "sha384-IxVWBJuknchdv83BQ6HjbPkUwTDX8cQzdqhRMNmMrB1/DiJn0Hhq3atrCeYhQngx"), | ||
"windows_arm64": struct(binary = "xsv.exe", url = "https://github.com/cargo-prebuilt/index/releases/download/xsv-0.13.0/aarch64-pc-windows-msvc.tar.gz", integrity = "sha384-X72q7PrI9fLqaLWjEd/SwKljfaADYKNsuA/jvFHEPiyMSkMt/LDmWUuhTroIam4d"), | ||
} |