74 lines
2.9 KiB
Ruby
74 lines
2.9 KiB
Ruby
class JpegTurbo < Formula
|
|
bottle do
|
|
root_url "https://homebrew.hyprnet/bottles"
|
|
sha256 cellar: :any, arm64_sequoia: "511445b91fe45351e3f7ae238ee7be0159fe92bb1e240a57489f62ded7fd1632"
|
|
sha256 cellar: :any, arm64_tahoe: "516f4fcf68020aea477a82ac745d5a89bff9fb4908e01c7529c191a563fd1a7b"
|
|
sha256 cellar: :any, x86_64_linux: "586635840c2b99e9e68e823ebd0b88dbd69bb2dbdeeef63f28d7202af68be9b1"
|
|
end
|
|
desc "JPEG image codec that aids compression and decompression"
|
|
homepage "https://www.libjpeg-turbo.org/"
|
|
url "https://github.com/libjpeg-turbo/libjpeg-turbo/releases/download/3.2.0/libjpeg-turbo-3.2.0.tar.gz"
|
|
sha256 "6f30092cef9fb839779646608f4ee14ae3cbac989c47fa05e841b0841f09878e"
|
|
license all_of: [
|
|
"IJG", # libjpeg API library and programs
|
|
"Zlib", # libjpeg-turbo SIMD source code
|
|
"BSD-3-Clause", # TurboJPEG API library and programs
|
|
]
|
|
compatibility_version 1
|
|
head "https://github.com/libjpeg-turbo/libjpeg-turbo.git", branch: "main"
|
|
|
|
livecheck do
|
|
url :stable
|
|
strategy :github_latest
|
|
end
|
|
|
|
|
|
|
|
depends_on "cmake" => :build
|
|
|
|
on_intel do
|
|
# Required only for x86 SIMD extensions.
|
|
depends_on "nasm" => :build
|
|
end
|
|
|
|
# These conflict with `jpeg`, which is now keg-only.
|
|
link_overwrite "bin/cjpeg", "bin/djpeg", "bin/jpegtran", "bin/rdjpgcom", "bin/wrjpgcom"
|
|
link_overwrite "include/jconfig.h", "include/jerror.h", "include/jmorecfg.h", "include/jpeglib.h"
|
|
link_overwrite "lib/libjpeg.dylib", "lib/libjpeg.so", "lib/libjpeg.a", "lib/pkgconfig/libjpeg.pc"
|
|
link_overwrite "share/man/man1/cjpeg.1", "share/man/man1/djpeg.1", "share/man/man1/jpegtran.1",
|
|
"share/man/man1/rdjpgcom.1", "share/man/man1/wrjpgcom.1"
|
|
|
|
def install
|
|
args = ["-DWITH_JPEG8=1", "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath,#{rpath}"]
|
|
if Hardware::CPU.arm? && OS.mac?
|
|
if MacOS.version >= :ventura
|
|
# https://github.com/libjpeg-turbo/libjpeg-turbo/issues/709
|
|
args += ["-DFLOATTEST8=fp-contract",
|
|
"-DFLOATTEST12=fp-contract"]
|
|
elsif MacOS.version == :monterey
|
|
# https://github.com/libjpeg-turbo/libjpeg-turbo/issues/734
|
|
args << "-DFLOATTEST12=no-fp-contract"
|
|
end
|
|
end
|
|
args += std_cmake_args.reject { |arg| arg["CMAKE_INSTALL_LIBDIR"].present? }
|
|
|
|
system "cmake", "-S", ".", "-B", "build", *args
|
|
system "cmake", "--build", "build"
|
|
system "ctest", "--test-dir", "build", "--rerun-failed", "--output-on-failure", "--parallel", ENV.make_jobs
|
|
system "cmake", "--install", "build"
|
|
|
|
# Avoid rebuilding dependents that hard-code the prefix.
|
|
inreplace [lib/"pkgconfig/libjpeg.pc", lib/"pkgconfig/libturbojpeg.pc"],
|
|
prefix, opt_prefix
|
|
end
|
|
|
|
test do
|
|
system bin/"jpegtran", "-crop", "1x1",
|
|
"-transpose",
|
|
"-perfect",
|
|
"-outfile", "out.jpg",
|
|
test_fixtures("test.jpg")
|
|
assert_path_exists testpath/"out.jpg"
|
|
end
|
|
end
|