This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
/
llvm.rb
201 lines (163 loc) 路 6.05 KB
/
llvm.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
class CodesignRequirement < Requirement
include FileUtils
fatal true
satisfy(:build_env => false) do
mktemp do
touch "llvm_check.txt"
quiet_system "/usr/bin/codesign", "-s", "lldb_codesign", "--dryrun", "llvm_check.txt"
end
end
def message
<<-EOS.undent
lldb_codesign identity must be available to build with LLDB.
See: https://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt
EOS
end
end
class Llvm < Formula
desc "llvm (Low Level Virtual Machine): a next-gen compiler infrastructure"
homepage "http://llvm.org/"
stable do
url "http://llvm.org/releases/3.6.2/llvm-3.6.2.src.tar.xz"
sha256 "f60dc158bfda6822de167e87275848969f0558b3134892ff54fced87e4667b94"
resource "clang" do
url "http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz"
sha256 "ae9180466a23acb426d12444d866b266ff2289b266064d362462e44f8d4699f3"
end
resource "libcxx" do
url "http://llvm.org/releases/3.6.2/libcxx-3.6.2.src.tar.xz"
sha256 "52f3d452f48209c9df1792158fdbd7f3e98ed9bca8ebb51fcd524f67437c8b81"
end
resource "lld" do
url "http://llvm.org/releases/3.6.2/lld-3.6.2.src.tar.xz"
sha256 "43f553c115563600577764262f1f2fac3740f0c639750f81e125963c90030b33"
end
resource "lldb" do
url "http://llvm.org/releases/3.6.2/lldb-3.6.2.src.tar.xz"
sha256 "940dc96b64919b7dbf32c37e0e1d1fc88cc18e1d4b3acf1e7dfe5a46eb6523a9"
end
resource "clang-tools-extra" do
url "http://llvm.org/releases/3.6.2/clang-tools-extra-3.6.2.src.tar.xz"
sha256 "6a0ec627d398f501ddf347060f7a2ccea4802b2494f1d4fd7bda3e0442d04feb"
end
end
bottle do
cellar :any
sha256 "fa04afc62800a236e32880efe30e1dbb61eace1e7e9ec20d2d53393ef9d68636" => :el_capitan
sha256 "a0ec4b17ae8c1c61071e603d0dcf3e1c39a5aae63c3f8237b4363a06701a3319" => :yosemite
sha256 "17a62c19d119c88972fa3dce920cfbc6150af8892ba8e29ce551ae7e2e84f42e" => :mavericks
sha256 "6d780faae2647ebce704b2f0a246b52d4037ebf4a2f796644814607e7751af93" => :mountain_lion
end
head do
url "http://llvm.org/git/llvm.git"
resource "clang" do
url "http://llvm.org/git/clang.git"
end
resource "libcxx" do
url "http://llvm.org/git/libcxx.git"
end
resource "lld" do
url "http://llvm.org/git/lld.git"
end
resource "lldb" do
url "http://llvm.org/git/lldb.git"
end
resource "clang-tools-extra" do
url "http://llvm.org/git/clang-tools-extra.git"
end
end
option :universal
option "with-clang", "Build Clang support library"
option "with-lld", "Build LLD linker"
option "with-lldb", "Build LLDB debugger"
option "with-rtti", "Build with C++ RTTI"
option "with-python", "Build Python bindings against Homebrew Python"
option "without-assertions", "Speeds up LLVM, but provides less debug information"
deprecated_option "rtti" => "with-rtti"
deprecated_option "disable-assertions" => "without-assertions"
if MacOS.version <= :snow_leopard
depends_on :python
else
depends_on :python => :optional
end
depends_on "cmake" => :build
if build.with? "lldb"
depends_on "swig"
depends_on CodesignRequirement
end
keg_only :provided_by_osx
# Apple's libstdc++ is too old to build LLVM
fails_with :gcc
fails_with :llvm
def install
# Apple's libstdc++ is too old to build LLVM
ENV.libcxx if ENV.compiler == :clang
if build.with?("lldb") && build.without?("clang")
raise "Building LLDB needs Clang support library."
end
if build.with? "clang"
(buildpath/"projects/libcxx").install resource("libcxx")
(buildpath/"tools/clang").install resource("clang")
(buildpath/"tools/clang/tools/extra").install resource("clang-tools-extra")
end
(buildpath/"tools/lld").install resource("lld") if build.with? "lld"
(buildpath/"tools/lldb").install resource("lldb") if build.with? "lldb"
args = %w[
-DLLVM_OPTIMIZED_TABLEGEN=On
]
args << "-DLLVM_ENABLE_RTTI=On" if build.with? "rtti"
if build.with? "assertions"
args << "-DLLVM_ENABLE_ASSERTIONS=On"
else
args << "-DCMAKE_CXX_FLAGS_RELEASE='-DNDEBUG'"
end
if build.universal?
ENV.permit_arch_flags
args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}"
end
mktemp do
system "cmake", "-G", "Unix Makefiles", buildpath, *(std_cmake_args + args)
system "make"
system "make", "install"
end
if build.with? "clang"
system "make", "-C", "projects/libcxx", "install",
"DSTROOT=#{prefix}", "SYMROOT=#{buildpath}/projects/libcxx"
(share/"clang/tools").install Dir["tools/clang/tools/scan-{build,view}"]
if build.head?
inreplace "#{share}/clang/tools/scan-build/bin/scan-build", "$RealBin/bin/clang", "#{bin}/clang"
bin.install_symlink share/"clang/tools/scan-build/bin/scan-build", share/"clang/tools/scan-view/bin/scan-view"
man1.install_symlink share/"clang/tools/scan-build/man/scan-build.1"
else
inreplace "#{share}/clang/tools/scan-build/scan-build", "$RealBin/bin/clang", "#{bin}/clang"
bin.install_symlink share/"clang/tools/scan-build/scan-build", share/"clang/tools/scan-view/scan-view"
man1.install_symlink share/"clang/tools/scan-build/scan-build.1"
end
end
# install llvm python bindings
(lib/"python2.7/site-packages").install buildpath/"bindings/python/llvm"
(lib/"python2.7/site-packages").install buildpath/"tools/clang/bindings/python/clang" if build.with? "clang"
end
def caveats
<<-EOS.undent
LLVM executables are installed in #{opt_bin}.
Extra tools are installed in #{opt_share}/llvm.
EOS
end
test do
assert_equal prefix.to_s, shell_output("#{bin}/llvm-config --prefix").chomp
if build.with? "clang"
(testpath/"test.cpp").write <<-EOS.undent
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
EOS
system "#{bin}/clang++", "test.cpp", "-o", "test"
system "./test"
end
end
end