-
Notifications
You must be signed in to change notification settings - Fork 7
/
libass.rb
78 lines (68 loc) · 2.01 KB
/
libass.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
class Libass < Formula
desc "Subtitle renderer for the ASS/SSA subtitle format"
homepage "https://github.com/libass/libass"
url "https://github.com/libass/libass/releases/download/0.17.3/libass-0.17.3.tar.xz"
sha256 "eae425da50f0015c21f7b3a9c7262a910f0218af469e22e2931462fed3c50959"
license "ISC"
head do
url "https://github.com/libass/libass.git", branch: "master"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "pkgconf" => :build
depends_on "freetype"
depends_on "fribidi"
depends_on "harfbuzz"
depends_on "libunibreak"
on_macos do
depends_on "fontconfig" => :optional
end
on_linux do
depends_on "fontconfig"
end
on_intel do
depends_on "nasm" => :build
end
def install
ENV.append "CFLAGS", (Hardware::CPU.arm? ? "-mcpu=native" : "-march=native -mtune=native") + " -Ofast -flto=thin"
system "autoreconf", "-i" if build.head?
args = %W[
--disable-dependency-tracking
--prefix=#{prefix}
--enable-large-tiles
]
# libass uses coretext on macOS, fontconfig on Linux
args << "--disable-fontconfig" if OS.mac? && (build.without? "fontconfig")
system "autoreconf", "--force", "--install", "--verbose" if build.head?
system "./configure", *args, *std_configure_args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~CPP
#include "ass/ass.h"
int main() {
ASS_Library *library;
ASS_Renderer *renderer;
library = ass_library_init();
if (library) {
renderer = ass_renderer_init(library);
if (renderer) {
ass_renderer_done(renderer);
ass_library_done(library);
return 0;
}
else {
ass_library_done(library);
return 1;
}
}
else {
return 1;
}
}
CPP
system ENV.cc, "test.cpp", "-I#{include}", "-L#{lib}", "-lass", "-o", "test"
system "./test"
end
end