Skip to content

Commit

Permalink
refactor: use new tools version
Browse files Browse the repository at this point in the history
  • Loading branch information
mgred committed Jul 3, 2024
1 parent f2845ae commit 787d5a6
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 93 deletions.
12 changes: 6 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ bazel_dep(name = "rules_license", version = "0.0.8")

# dist:not {
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.1.0")
bazel_dep(name = "aspect_bazel_lib", version = "2.3.0")
bazel_dep(name = "bzlparty_tools")
archive_override(
module_name = "bzlparty_tools",
integrity = "sha384-0yANdDDake+LVcTvKA4FhuMBDC5o4LQN3jlrpOzxZ8BIknduOJnKidBF9e2uJoiE",
strip_prefix = "tools-0.3.0",
urls = "https://github.com/bzlparty/tools/releases/download/v0.3.0/tools-v0.3.0.tar.gz",
integrity = "sha384-uE1Fsp623XbUyHzCn/u8cx3gJa6WN/aVBZWeaeWm7NG8OiK1tPZ2mk90eIvt8mgM",
strip_prefix = "tools-0.3.1",
urls = "https://github.com/bzlparty/tools/releases/download/v0.3.1/tools-v0.3.1.tar.gz",
)
# }

rules_compress_toolchains = use_extension("@bzlparty_rules_compress//:extensions.bzl", "toolchains")
rules_compress_toolchains.s2()
rules_compress_toolchains.zip()
use_repo(rules_compress_toolchains, "s2_toolchains", "zip_toolchains")
use_repo(rules_compress_toolchains, "s2", "zip")

register_toolchains("@s2_toolchains//:all", "@zip_toolchains//:all")
register_toolchains("@s2//:all", "@zip//:all")

bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
6 changes: 3 additions & 3 deletions e2e/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local_path_override(

archive_override(
module_name = "bzlparty_tools",
integrity = "sha384-0yANdDDake+LVcTvKA4FhuMBDC5o4LQN3jlrpOzxZ8BIknduOJnKidBF9e2uJoiE",
strip_prefix = "tools-0.3.0",
urls = "https://github.com/bzlparty/tools/releases/download/v0.3.0/tools-v0.3.0.tar.gz",
integrity = "sha384-uE1Fsp623XbUyHzCn/u8cx3gJa6WN/aVBZWeaeWm7NG8OiK1tPZ2mk90eIvt8mgM",
strip_prefix = "tools-0.3.1",
urls = "https://github.com/bzlparty/tools/releases/download/v0.3.1/tools-v0.3.1.tar.gz",
)
11 changes: 6 additions & 5 deletions extensions.bzl
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
"Module Extensions"

load("//lib:repositories.bzl", "compress_toolchains")
load("@bzlparty_tools//lib:toolchains.bzl", "register_platform_toolchains")
load("//s2:assets.bzl", S2_ASSETS = "ASSETS")
load("//zip:assets.bzl", ZIP_ASSETS = "ASSETS")

TOOLS = {
"s2": S2_ASSETS,
"zip": ZIP_ASSETS,
"s2": struct(assets = S2_ASSETS, toolchain_type = "s2c_toolchain_type"),
"zip": struct(assets = ZIP_ASSETS, toolchain_type = "7zz_toolchain_type"),
}

def _has_tag(module, tag):
return hasattr(module.tags, tag) and len(getattr(module.tags, tag)) > 0

def _toolchains_extension_impl(ctx):
for module in ctx.modules:
for (name, assets) in TOOLS.items():
for (name, config) in TOOLS.items():
if _has_tag(module, name):
compress_toolchains(name, assets)
toolchain_type = "@bzlparty_rules_compress//{}:{}".format(name, config.toolchain_type)
register_platform_toolchains(name, config.assets, toolchain_type)

toolchains = module_extension(
_toolchains_extension_impl,
Expand Down
4 changes: 2 additions & 2 deletions s2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bzlparty_tools//lib:defs.bzl", "platform_binaries")
load("@bzlparty_tools//lib:defs.bzl", "multi_platform_assets")

package(default_visibility = ["//visibility:public"])

Expand All @@ -20,7 +20,7 @@ bzl_library(

GITHUB_URL = "https://github.com/klauspost/compress/releases/download/v1.17.9"

platform_binaries(
multi_platform_assets(
name = "s2c",
binary = "s2c",
platforms = [
Expand Down
18 changes: 9 additions & 9 deletions s2/assets.bzl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ASSETS = {
"darwin_amd64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-darwin_amd64.tar.gz", integrity = "sha384-JAjr6oKZPFFnHnkSDhMVW+cHUrvRmkUunJIDo9OzlcpEqljzg+SYZOTmcGXYb5ZN"),
"darwin_arm64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-darwin_arm64.tar.gz", integrity = "sha384-5oXYvyx6BW5BcesxK6TqW1yPJpjlt18/UbFBneyhZvqYoYx36NsBZv+6+eSfb9of"),
"freebsd_amd64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-freebsd_amd64.tar.gz", integrity = "sha384-P/37jnGNZYxeyQH6Evb2fScRHpbZP57guAoV7t2bbmUCM6H41V30dZxcv3dyrUbb"),
"freebsd_arm64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-freebsd_arm64.tar.gz", integrity = "sha384-yOA1Q4buiJpqpOKtrxN8XZt9nAokLje/KT7fcmxZZ6mcN8gdR5LwG+T1KzDPYxrc"),
"linux_amd64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-linux_amd64.tar.gz", integrity = "sha384-uCOoF2ThSaC62bhmtO4fvlQK7L8+bVro2okD6FCkaqeKkd3JjxBVtpmF+6N35HF2"),
"linux_arm64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-linux_arm64.tar.gz", integrity = "sha384-xEa/+04WQW5QmfpAdvrVVFRGQx8SVz+Z/J+UCknPHmgIaWEp6DdD5Mz9bgWATYrA"),
"netbsd_amd64": struct(binary = "s2c", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-netbsd_amd64.tar.gz", integrity = "sha384-1YbDJBZGcQZYKq0bRaRfJ3mDMwoEfL/4lMz6rUqg4x81x5sOiAG12oEgyTTWNXr4"),
"windows_amd64": struct(binary = "s2c.exe", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-windows_amd64.zip", integrity = "sha384-1J/BC/l7v1dSCOkbopcSlsYc2h2bWbHwln3Jh/CSQOM2N3gJSVPPhUdYlpX6NrDX"),
"windows_arm64": struct(binary = "s2c.exe", url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-windows_arm64.zip", integrity = "sha384-sZPmZc9SdB5pDsRSiawCvw5NYPqyQhxOOqkxfHDUl3JpK9IkHJzHmrdejepchlk1"),
"darwin_amd64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-darwin_amd64.tar.gz", binary = "s2c", integrity = "sha384-JAjr6oKZPFFnHnkSDhMVW+cHUrvRmkUunJIDo9OzlcpEqljzg+SYZOTmcGXYb5ZN"),
"darwin_arm64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-darwin_arm64.tar.gz", binary = "s2c", integrity = "sha384-5oXYvyx6BW5BcesxK6TqW1yPJpjlt18/UbFBneyhZvqYoYx36NsBZv+6+eSfb9of"),
"freebsd_amd64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-freebsd_amd64.tar.gz", binary = "s2c", integrity = "sha384-P/37jnGNZYxeyQH6Evb2fScRHpbZP57guAoV7t2bbmUCM6H41V30dZxcv3dyrUbb"),
"freebsd_arm64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-freebsd_arm64.tar.gz", binary = "s2c", integrity = "sha384-yOA1Q4buiJpqpOKtrxN8XZt9nAokLje/KT7fcmxZZ6mcN8gdR5LwG+T1KzDPYxrc"),
"linux_amd64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-linux_amd64.tar.gz", binary = "s2c", integrity = "sha384-uCOoF2ThSaC62bhmtO4fvlQK7L8+bVro2okD6FCkaqeKkd3JjxBVtpmF+6N35HF2"),
"linux_arm64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-linux_arm64.tar.gz", binary = "s2c", integrity = "sha384-xEa/+04WQW5QmfpAdvrVVFRGQx8SVz+Z/J+UCknPHmgIaWEp6DdD5Mz9bgWATYrA"),
"netbsd_amd64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-netbsd_amd64.tar.gz", binary = "s2c", integrity = "sha384-1YbDJBZGcQZYKq0bRaRfJ3mDMwoEfL/4lMz6rUqg4x81x5sOiAG12oEgyTTWNXr4"),
"windows_amd64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-windows_amd64.zip", binary = "s2c.exe", integrity = "sha384-1J/BC/l7v1dSCOkbopcSlsYc2h2bWbHwln3Jh/CSQOM2N3gJSVPPhUdYlpX6NrDX"),
"windows_arm64": struct(url = "https://github.com/klauspost/compress/releases/download/v1.17.9/s2-windows_arm64.zip", binary = "s2c.exe", integrity = "sha384-sZPmZc9SdB5pDsRSiawCvw5NYPqyQhxOOqkxfHDUl3JpK9IkHJzHmrdejepchlk1"),
}
14 changes: 0 additions & 14 deletions s2/private/toolchain.BUILD.bazel

This file was deleted.

17 changes: 0 additions & 17 deletions s2/private/toolchains.BUILD.bazel

This file was deleted.

6 changes: 3 additions & 3 deletions zip/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bzlparty_tools//lib:platform_binary.bzl", "platform_binaries")
load("@bzlparty_tools//lib:defs.bzl", "multi_platform_assets")

package(default_visibility = ["//visibility:public"])

Expand All @@ -25,7 +25,7 @@ VERSION_INT = VERSION.replace(".", "")

GITHUB_URL = "https://github.com/ip7z/7zip/releases/download/%s" % VERSION

platform_binaries(
multi_platform_assets(
name = "7zz",
binary = "7zz",
platforms = [
Expand All @@ -44,5 +44,5 @@ platform_binaries(
)

toolchain_type(
name = "zip_toolchain_type",
name = "7zz_toolchain_type",
)
8 changes: 4 additions & 4 deletions zip/assets.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ASSETS = {
"darwin_amd64": struct(binary = "7zz", url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-mac.tar.xz", integrity = "sha384-xl0HW3pHOySG+NRdSnf/fhIDKpHlwjOC2dpqUOXYEXH2Ifh8jrg2FnjKz09W0F+G"),
"darwin_arm64": struct(binary = "7zz", url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-mac.tar.xz", integrity = "sha384-xl0HW3pHOySG+NRdSnf/fhIDKpHlwjOC2dpqUOXYEXH2Ifh8jrg2FnjKz09W0F+G"),
"linux_amd64": struct(binary = "7zz", url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-linux-x64.tar.xz", integrity = "sha384-nsopQowWAMD63n2PE7NpPl+ySf6c1/l4oMrHMC+rXTS+NeIXik5Hsar253TSmHtq"),
"linux_arm64": struct(binary = "7zz", url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-linux-arm64.tar.xz", integrity = "sha384-VeJ8StL8Ra8anxxS70xVZaBxhb+tNJWo4mMcUVYEK09pfgFaVJdp5sA/D9+7O5IG"),
"darwin_amd64": struct(url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-mac.tar.xz", binary = "7zz", integrity = "sha384-xl0HW3pHOySG+NRdSnf/fhIDKpHlwjOC2dpqUOXYEXH2Ifh8jrg2FnjKz09W0F+G"),
"darwin_arm64": struct(url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-mac.tar.xz", binary = "7zz", integrity = "sha384-xl0HW3pHOySG+NRdSnf/fhIDKpHlwjOC2dpqUOXYEXH2Ifh8jrg2FnjKz09W0F+G"),
"linux_amd64": struct(url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-linux-x64.tar.xz", binary = "7zz", integrity = "sha384-nsopQowWAMD63n2PE7NpPl+ySf6c1/l4oMrHMC+rXTS+NeIXik5Hsar253TSmHtq"),
"linux_arm64": struct(url = "https://github.com/ip7z/7zip/releases/download/24.07/7z2407-linux-arm64.tar.xz", binary = "7zz", integrity = "sha384-VeJ8StL8Ra8anxxS70xVZaBxhb+tNJWo4mMcUVYEK09pfgFaVJdp5sA/D9+7O5IG"),
}
11 changes: 0 additions & 11 deletions zip/private/toolchain.BUILD.bazel

This file was deleted.

17 changes: 0 additions & 17 deletions zip/private/toolchains.BUILD.bazel

This file was deleted.

4 changes: 2 additions & 2 deletions zip/private/zip.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ZipFileInfo = provider(
)

def _zip_impl(ctx):
toolchain = ctx.toolchains["@bzlparty_rules_compress//zip:zip_toolchain_type"].binary_info
toolchain = ctx.toolchains["@bzlparty_rules_compress//zip:7zz_toolchain_type"].binary_info

if ctx.outputs.out.basename.endswith(".gz") and len(ctx.files.srcs) > 1:
fail("gz can only compress a single file! %s files given" % len(ctx.files.srcs))
Expand Down Expand Up @@ -68,5 +68,5 @@ This rule runs `7zz` to compress an input file.
See https://7-zip.org/ for details.
""",
toolchains = ["@bzlparty_rules_compress//zip:zip_toolchain_type"],
toolchains = ["@bzlparty_rules_compress//zip:7zz_toolchain_type"],
)

0 comments on commit 787d5a6

Please sign in to comment.