77 lines
3.0 KiB
Ruby
77 lines
3.0 KiB
Ruby
class Zstd < Formula
|
|
bottle do
|
|
root_url "https://homebrew.hyprnet/bottles"
|
|
sha256 cellar: :any, arm64_sequoia: "d72adf48460a8384b256f88061cd7b9df4977df7fa2e0794051d427db754a565"
|
|
sha256 cellar: :any, arm64_tahoe: "628a4ef53428d0078e3d76d297171ce8d0294f5ec1de3f20305e08c4dd333565"
|
|
sha256 cellar: :any, sequoia: "8b2443dfa62b9d28cf0321e0e670bb096b2680fe72739999228291f36018311f"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "3d5ca8948526a2e3a487db0cd0acec9f4b415d5a4b08cffe27e2ea0c339c9dbe"
|
|
end
|
|
desc "Zstandard is a real-time compression algorithm"
|
|
homepage "https://facebook.github.io/zstd/"
|
|
url "https://github.com/facebook/zstd/archive/refs/tags/v1.5.7.tar.gz"
|
|
mirror "http://fresh-center.net/linux/misc/zstd-1.5.7.tar.gz"
|
|
mirror "http://fresh-center.net/linux/misc/legacy/zstd-1.5.7.tar.gz"
|
|
sha256 "37d7284556b20954e56e1ca85b80226768902e2edabd3b649e9e72c0c9012ee3"
|
|
license all_of: [
|
|
{ any_of: ["BSD-3-Clause", "GPL-2.0-only"] },
|
|
"BSD-2-Clause", # programs/zstdgrep, lib/libzstd.pc.in
|
|
"MIT", # lib/dictBuilder/divsufsort.c
|
|
]
|
|
revision 1
|
|
compatibility_version 1
|
|
head "https://github.com/facebook/zstd.git", branch: "dev"
|
|
|
|
# The upstream repository contains old, one-off tags (5.5.5, 6.6.6) that are
|
|
# higher than current versions, so we check the "latest" release instead.
|
|
livecheck do
|
|
url :stable
|
|
strategy :github_latest
|
|
end
|
|
|
|
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "lz4"
|
|
depends_on "xz"
|
|
|
|
on_linux do
|
|
depends_on "zlib-ng-compat"
|
|
end
|
|
|
|
def install
|
|
# Legacy support is the default after
|
|
# https://github.com/facebook/zstd/commit/db104f6e839cbef94df4df8268b5fecb58471274
|
|
# Set it to `ON` to be explicit about the configuration.
|
|
system "cmake", "-S", "build/cmake", "-B", "builddir",
|
|
"-DBUILD_SHARED_LIBS=ON", # set CMake libzstd target to shared
|
|
"-DZSTD_PROGRAMS_LINK_SHARED=ON", # link `zstd` to `libzstd`
|
|
"-DZSTD_BUILD_CONTRIB=ON",
|
|
"-DCMAKE_INSTALL_RPATH=#{rpath}",
|
|
"-DZSTD_LEGACY_SUPPORT=ON",
|
|
"-DZSTD_ZLIB_SUPPORT=ON",
|
|
"-DZSTD_LZMA_SUPPORT=ON",
|
|
"-DZSTD_LZ4_SUPPORT=ON",
|
|
"-DCMAKE_CXX_STANDARD=11",
|
|
*std_cmake_args
|
|
system "cmake", "--build", "builddir"
|
|
system "cmake", "--install", "builddir"
|
|
|
|
# Prevent dependents from relying on fragile Cellar paths.
|
|
# https://github.com/ocaml/ocaml/issues/12431
|
|
inreplace lib/"pkgconfig/libzstd.pc", prefix, opt_prefix
|
|
end
|
|
|
|
test do
|
|
[bin/"zstd", bin/"pzstd", "xz", "lz4", "gzip"].each do |prog|
|
|
data = "Hello, #{prog}"
|
|
assert_equal data, pipe_output("#{bin}/zstd -d", pipe_output(prog, data))
|
|
if prog.to_s.end_with?("zstd")
|
|
# `pzstd` can only decompress zstd-compressed data.
|
|
assert_equal data, pipe_output("#{bin}/pzstd -d", pipe_output(prog, data))
|
|
else
|
|
assert_equal data, pipe_output("#{prog} -d", pipe_output("#{bin}/zstd --format=#{prog}", data))
|
|
end
|
|
end
|
|
end
|
|
end
|