-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
/
jpeg-xl.rb
114 lines (102 loc) · 4.3 KB
/
jpeg-xl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
class JpegXl < Formula
desc "New file format for still image compression"
homepage "https://jpeg.org/jpegxl/index.html"
url "https://github.com/libjxl/libjxl/archive/refs/tags/v0.9.1.tar.gz"
sha256 "a0e72e9ece26878147069ad4888ac3382021d4bbee71c2e1b687d5bde7fd7e01"
license "BSD-3-Clause"
livecheck do
url :stable
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any, arm64_sonoma: "9717b3a20f72b2c9338ecba113f827bd692651bec59579c8073d7e682089b251"
sha256 cellar: :any, arm64_ventura: "95fefc2f6ff4380170eb5e5994fa51c3d92e510c85e08c8b4ac2c6812efa7013"
sha256 cellar: :any, arm64_monterey: "c7296788164ccec3dc2794d0585b4964bf60eef76508244c31dbe8fbeb96db4a"
sha256 cellar: :any, sonoma: "82798cf0cd1e27e27bb939073859fc77deecebfb49b5081d6e202d9815d18532"
sha256 cellar: :any, ventura: "3f2c8f02c4a1eb328bfce0f33c1d7f2128d7ffe95ab0d5d04e523f73ce649534"
sha256 cellar: :any, monterey: "ad77301a874d06c2b3c2a583f0fd8ca574444f95793c27842fa33b95f4b4c131"
sha256 cellar: :any_skip_relocation, x86_64_linux: "59698c2ed849067386f59d23dc9c665858698184b6bbe399495492cc4a28ff33"
end
depends_on "asciidoc" => :build
depends_on "cmake" => :build
depends_on "docbook-xsl" => :build
depends_on "doxygen" => :build
depends_on "pkg-config" => :build
depends_on "sphinx-doc" => :build
depends_on "pkg-config" => :test
depends_on "brotli"
depends_on "giflib"
depends_on "highway"
depends_on "imath"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "little-cms2"
depends_on "openexr"
depends_on "webp"
uses_from_macos "libxml2" => :build
uses_from_macos "libxslt" => :build # for xsltproc
uses_from_macos "python"
fails_with gcc: "5"
fails_with gcc: "6"
# These resources are versioned according to the script supplied with jpeg-xl to download the dependencies:
# https://github.com/libjxl/libjxl/tree/v#{version}/third_party
resource "sjpeg" do
url "https://github.com/webmproject/sjpeg.git",
revision: "e5ab13008bb214deb66d5f3e17ca2f8dbff150bf"
end
def install
ENV.append_path "XML_CATALOG_FILES", HOMEBREW_PREFIX/"etc/xml/catalog"
resources.each { |r| r.stage buildpath/"third_party"/r.name }
system "cmake", "-S", ".", "-B", "build",
"-DJPEGXL_FORCE_SYSTEM_BROTLI=ON",
"-DJPEGXL_FORCE_SYSTEM_LCMS2=ON",
"-DJPEGXL_FORCE_SYSTEM_HWY=ON",
"-DJPEGXL_ENABLE_JNI=OFF",
"-DJPEGXL_ENABLE_JPEGLI=OFF",
"-DJPEGXL_ENABLE_SKCMS=OFF",
"-DJPEGXL_VERSION=#{version}",
"-DJPEGXL_ENABLE_MANPAGES=ON",
"-DCMAKE_INSTALL_RPATH=#{rpath}",
"-DPython_EXECUTABLE=#{Formula["asciidoc"].libexec/"bin/python"}",
"-DPython3_EXECUTABLE=#{Formula["asciidoc"].libexec/"bin/python3"}",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--build", "build", "--target", "install"
end
test do
system "#{bin}/cjxl", test_fixtures("test.jpg"), "test.jxl"
assert_predicate testpath/"test.jxl", :exist?
(testpath/"jxl_test.c").write <<~EOS
#include <jxl/encode.h>
#include <stdlib.h>
int main()
{
JxlEncoder* enc = JxlEncoderCreate(NULL);
if (enc == NULL) {
return EXIT_FAILURE;
}
JxlEncoderDestroy(enc);
return EXIT_SUCCESS;
}
EOS
jxl_flags = shell_output("pkg-config --cflags --libs libjxl").chomp.split
system ENV.cc, "jxl_test.c", *jxl_flags, "-o", "jxl_test"
system "./jxl_test"
(testpath/"jxl_threads_test.c").write <<~EOS
#include <jxl/thread_parallel_runner.h>
#include <stdlib.h>
int main()
{
void* runner = JxlThreadParallelRunnerCreate(NULL, 1);
if (runner == NULL) {
return EXIT_FAILURE;
}
JxlThreadParallelRunnerDestroy(runner);
return EXIT_SUCCESS;
}
EOS
jxl_threads_flags = shell_output("pkg-config --cflags --libs libjxl_threads").chomp.split
system ENV.cc, "jxl_threads_test.c", *jxl_threads_flags, "-o", "jxl_threads_test"
system "./jxl_threads_test"
end
end