Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@
/csharp/paket.main.bzl linguist-generated=true
/csharp/paket.main_extension.bzl linguist-generated=true

# ripunzip tool
/misc/ripunzip/ripunzip-* filter=lfs diff=lfs merge=lfs -text

# swift prebuilt resources
/swift/third_party/resources/*.zip filter=lfs diff=lfs merge=lfs -text
/swift/third_party/resources/*.tar.zst filter=lfs diff=lfs merge=lfs -text
169 changes: 0 additions & 169 deletions .github/workflows/build-ripunzip.yml

This file was deleted.

26 changes: 9 additions & 17 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -269,24 +269,16 @@ go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//go/extractor:go.mod")
use_repo(go_deps, "org_golang_x_mod", "org_golang_x_tools")

lfs_archive = use_repo_rule("//misc/bazel:lfs.bzl", "lfs_archive")
ripunzip_archive = use_repo_rule("//misc/ripunzip:ripunzip.bzl", "ripunzip_archive")

lfs_archive(
name = "ripunzip-linux",
src = "//misc/ripunzip:ripunzip-Linux.tar.zst",
build_file = "//misc/ripunzip:BUILD.ripunzip.bazel",
)

lfs_archive(
name = "ripunzip-windows",
src = "//misc/ripunzip:ripunzip-Windows.tar.zst",
build_file = "//misc/ripunzip:BUILD.ripunzip.bazel",
)

lfs_archive(
name = "ripunzip-macos",
src = "//misc/ripunzip:ripunzip-macOS.tar.zst",
build_file = "//misc/ripunzip:BUILD.ripunzip.bazel",
# go to https://github.com/GoogleChrome/ripunzip/releases to find latest version and corresponding sha256s
ripunzip_archive(
name = "ripunzip",
sha256_linux = "ee0e8a957687a5dc3a66b2a4b25883bf762df4c9c07f0651af527a32a405054b",
sha256_macos_arm = "8a88eea54eac232d162a72a42065e0429b82dbf4f05e9642915dff9d7a81f846",
sha256_macos_intel = "4457a18bfcc5feabe09f5ea3d1157128e07b4873392cb404a870e611924abf64",
sha256_windows = "66d0c1375301bf5ab815348048f43b110631d3fa7200acd50d50a8ed8655ca62",
version = "2.0.3",
)

register_toolchains(
Expand Down
2 changes: 1 addition & 1 deletion misc/ripunzip/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@rules_shell//shell:sh_binary.bzl", "sh_binary")

alias(
name = "ripunzip",
actual = select({"@platforms//os:" + os: "@ripunzip-%s//:ripunzip" % os for os in ("linux", "windows", "macos")}),
actual = "@ripunzip",
visibility = ["//visibility:public"],
)

Expand Down
2 changes: 1 addition & 1 deletion misc/ripunzip/BUILD.ripunzip.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@bazel_skylib//rules:native_binary.bzl", "native_binary")

native_binary(
name = "ripunzip",
src = glob(["ripunzip-*"])[0],
src = glob(["bin/ripunzip*"])[0],
out = "ripunzip" + select({
"@platforms//os:windows": ".exe",
"//conditions:default": "",
Expand Down
3 changes: 0 additions & 3 deletions misc/ripunzip/ripunzip-Linux.tar.zst

This file was deleted.

3 changes: 0 additions & 3 deletions misc/ripunzip/ripunzip-Windows.tar.zst

This file was deleted.

3 changes: 0 additions & 3 deletions misc/ripunzip/ripunzip-macOS.tar.zst

This file was deleted.

59 changes: 59 additions & 0 deletions misc/ripunzip/ripunzip.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
def _ripunzip_archive_impl(repository_ctx):
version = repository_ctx.attr.version
url_prefix = "https://github.com/GoogleChrome/ripunzip/releases/download/v%s" % version
build_file = Label("//misc/ripunzip:BUILD.ripunzip.bazel")
if "linux" in repository_ctx.os.name:
# ripunzip only provides a deb package for Linux: we fish the binary out of it
# a deb archive contains a data.tar.xz one which contains the files to be installed under usr/bin
repository_ctx.download_and_extract(
url = "%s/ripunzip_%s-1_amd64.deb" % (url_prefix, version),
sha256 = repository_ctx.attr.sha256_linux,
canonical_id = "ripunzip-linux",
output = "deb",
)
repository_ctx.extract(
"deb/data.tar.xz",
strip_prefix = "usr/bin",
output = "bin",
)
elif "windows" in repository_ctx.os.name:
repository_ctx.download_and_extract(
url = "%s/ripunzip_v%s_x86_64-pc-windows-msvc.zip" % (url_prefix, version),
canonical_id = "ripunzip-windows",
sha256 = repository_ctx.attr.sha256_windows,
output = "bin",
)
elif "mac os" in repository_ctx.os.name:
arch = repository_ctx.os.arch
if arch == "x86_64":
suffix = "x86_64-apple-darwin"
sha256 = repository_ctx.attr.sha256_macos_intel
canonical_id = "ripunzip-macos-intel"
elif arch == "aarch64":
suffix = "aarch64-apple-darwin"
sha256 = repository_ctx.attr.sha256_macos_arm
canonical_id = "ripunzip-macos-arm"
else:
fail("Unsupported macOS architecture: %s" % arch)
repository_ctx.download_and_extract(
url = "%s/ripunzip_v%s_%s.tar.gz" % (url_prefix, version, suffix),
sha256 = sha256,
canonical_id = canonical_id,
output = "bin",
)
else:
fail("Unsupported OS: %s" % repository_ctx.os.name)
repository_ctx.file("WORKSPACE.bazel")
repository_ctx.symlink(build_file, "BUILD.bazel")

ripunzip_archive = repository_rule(
implementation = _ripunzip_archive_impl,
doc = "Downloads a prebuilt ripunzip binary for the host platform from https://github.com/GoogleChrome/ripunzip/releases",
attrs = {
"version": attr.string(mandatory = True),
"sha256_linux": attr.string(mandatory = True),
"sha256_windows": attr.string(mandatory = True),
"sha256_macos_intel": attr.string(mandatory = True),
"sha256_macos_arm": attr.string(mandatory = True),
},
)
Loading