forked from deus0ww/homebrew-tap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibass.rb
77 lines (70 loc) · 2.19 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
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.15.2/libass-0.15.2.tar.xz"
sha256 "1be2df9c4485a57d78bb18c0a8ed157bc87a5a8dd48c661961c625cb112832fd"
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 "nasm" => :build
depends_on "pkg-config" => :build
depends_on "freetype"
depends_on "fribidi"
depends_on "harfbuzz"
on_linux do
depends_on "fontconfig"
end
def install
opts = Hardware::CPU.arm? ? "-mcpu=native " : "-march=native -mtune=native "
opts += "-Ofast -flto=thin -funroll-loops -fomit-frame-pointer "
opts += "-ffunction-sections -fdata-sections -fstrict-vtable-pointers -fwhole-program-vtables "
opts += "-fforce-emit-vtables " if MacOS.version >= :mojave
ENV.append "CFLAGS", opts
ENV.append "CPPFLAGS", opts
ENV.append "CXXFLAGS", opts
ENV.append "OBJCFLAGS", opts
ENV.append "OBJCXXFLAGS", opts
ENV.append "LDFLAGS", opts + " -dead_strip"
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?
system "./configure", *args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<~EOS
#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;
}
}
EOS
system ENV.cc, "test.cpp", "-I#{include}", "-L#{lib}", "-lass", "-o", "test"
system "./test"
end
end