2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-08-31 13:45:04 +00:00
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Clang < Formula
|
2009-11-18 22:08:29 +00:00
|
|
|
homepage 'http://llvm.org/'
|
2013-06-21 15:31:22 +00:00
|
|
|
url 'http://llvm.org/releases/3.3/cfe-3.3.src.tar.gz'
|
|
|
|
sha1 'ccd6dbf2cdb1189a028b70bcb8a22509c25c74c8'
|
2012-04-19 02:37:43 +00:00
|
|
|
|
|
|
|
head 'http://llvm.org/git/clang.git'
|
2009-11-18 22:08:29 +00:00
|
|
|
end
|
|
|
|
|
2013-01-12 21:40:46 +00:00
|
|
|
class CompilerRt < Formula
|
|
|
|
homepage 'http://llvm.org/'
|
2013-06-21 15:31:22 +00:00
|
|
|
url 'http://llvm.org/releases/3.3/compiler-rt-3.3.src.tar.gz'
|
|
|
|
sha1 '745386ec046e3e49742e1ecb6912c560ccd0a002'
|
2013-01-12 21:40:46 +00:00
|
|
|
|
|
|
|
head 'http://llvm.org/git/compiler-rt.git'
|
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Llvm < Formula
|
2009-11-18 22:08:29 +00:00
|
|
|
homepage 'http://llvm.org/'
|
2013-06-21 15:31:22 +00:00
|
|
|
url 'http://llvm.org/releases/3.3/llvm-3.3.src.tar.gz'
|
|
|
|
sha1 'c6c22d5593419e3cb47cbcf16d967640e5cce133'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2012-04-19 02:37:43 +00:00
|
|
|
head 'http://llvm.org/git/llvm.git'
|
|
|
|
|
2013-06-21 15:33:38 +00:00
|
|
|
bottle do
|
|
|
|
sha1 '61854a2cf08a1398577f74fea191a749bec3e72d' => :mountain_lion
|
|
|
|
sha1 'fbe7b85a50f4b283ad55be020c7ddfbf655435ad' => :lion
|
|
|
|
sha1 'f68fdb89d44a72c83db1e55e25444de4dcde5375' => :snow_leopard
|
|
|
|
end
|
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
option :universal
|
|
|
|
option 'with-clang', 'Build Clang C/ObjC/C++ frontend'
|
2013-01-12 21:40:46 +00:00
|
|
|
option 'with-asan', 'Include support for -faddress-sanitizer (from compiler-rt)'
|
2013-01-21 09:33:56 +00:00
|
|
|
option 'disable-shared', "Don't build LLVM as a shared library"
|
2012-08-13 15:55:01 +00:00
|
|
|
option 'all-targets', 'Build all target backends'
|
|
|
|
option 'rtti', 'Build with C++ RTTI'
|
2012-12-06 20:21:07 +00:00
|
|
|
option 'disable-assertions', 'Speeds up LLVM, but provides less debug information'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2013-01-21 09:33:56 +00:00
|
|
|
depends_on :python => :recommended
|
|
|
|
|
2013-05-14 22:49:33 +00:00
|
|
|
env :std if build.universal?
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2013-05-14 22:49:33 +00:00
|
|
|
def install
|
2013-01-21 09:33:56 +00:00
|
|
|
if build.with? 'python' and build.include? 'disable-shared'
|
|
|
|
raise 'The Python bindings need the shared library.'
|
|
|
|
end
|
|
|
|
|
2013-01-12 21:40:46 +00:00
|
|
|
Clang.new("clang").brew do
|
|
|
|
clang_dir.install Dir['*']
|
|
|
|
end if build.include? 'with-clang'
|
|
|
|
|
|
|
|
CompilerRt.new("compiler-rt").brew do
|
|
|
|
(buildpath/'projects/compiler-rt').install Dir['*']
|
|
|
|
end if build.include? 'with-asan'
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
if build.universal?
|
2010-12-08 22:43:28 +00:00
|
|
|
ENV['UNIVERSAL'] = '1'
|
|
|
|
ENV['UNIVERSAL_ARCH'] = 'i386 x86_64'
|
|
|
|
end
|
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
ENV['REQUIRES_RTTI'] = '1' if build.include? 'rtti'
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
args = [
|
2011-12-03 22:56:37 +00:00
|
|
|
"--prefix=#{prefix}",
|
|
|
|
"--enable-optimized",
|
2012-08-11 09:21:42 +00:00
|
|
|
# As of LLVM 3.1, attempting to build ocaml bindings with Homebrew's
|
|
|
|
# OCaml 3.12.1 results in errors.
|
|
|
|
"--disable-bindings",
|
2011-12-03 22:56:37 +00:00
|
|
|
]
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
if build.include? 'all-targets'
|
|
|
|
args << "--enable-targets=all"
|
2011-05-11 22:32:19 +00:00
|
|
|
else
|
2012-08-13 15:55:01 +00:00
|
|
|
args << "--enable-targets=host"
|
2011-05-11 22:32:19 +00:00
|
|
|
end
|
2013-01-21 09:33:56 +00:00
|
|
|
args << "--enable-shared" unless build.include? 'disable-shared'
|
2011-01-09 18:32:58 +00:00
|
|
|
|
2012-12-06 20:21:07 +00:00
|
|
|
args << "--disable-assertions" if build.include? 'disable-assertions'
|
|
|
|
|
2012-08-13 15:55:01 +00:00
|
|
|
system "./configure", *args
|
2010-04-07 05:58:35 +00:00
|
|
|
system "make install"
|
2009-11-18 22:08:29 +00:00
|
|
|
|
2012-08-11 09:21:42 +00:00
|
|
|
# install llvm python bindings
|
2013-01-21 09:33:56 +00:00
|
|
|
if python
|
|
|
|
unless build.head?
|
|
|
|
inreplace buildpath/'bindings/python/llvm/common.py', 'LLVM-3.1svn', "libLLVM-#{version}svn"
|
|
|
|
end
|
|
|
|
python.site_packages.install buildpath/'bindings/python/llvm'
|
|
|
|
end
|
2011-05-18 21:44:54 +00:00
|
|
|
|
2012-08-11 09:21:42 +00:00
|
|
|
# install clang tools and bindings
|
2012-02-21 06:04:21 +00:00
|
|
|
cd clang_dir do
|
2012-09-22 01:00:19 +00:00
|
|
|
system 'make install'
|
2012-08-11 09:21:42 +00:00
|
|
|
(share/'clang/tools').install 'tools/scan-build', 'tools/scan-view'
|
2013-01-21 09:33:56 +00:00
|
|
|
python.site_packages.install 'bindings/python/clang' if python
|
2012-08-13 15:55:01 +00:00
|
|
|
end if build.include? 'with-clang'
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|
2010-10-07 17:13:59 +00:00
|
|
|
|
2012-03-22 17:19:39 +00:00
|
|
|
def test
|
2012-05-15 21:36:45 +00:00
|
|
|
system "#{bin}/llvm-config", "--version"
|
2012-03-22 17:19:39 +00:00
|
|
|
end
|
|
|
|
|
2013-01-21 09:33:56 +00:00
|
|
|
def caveats
|
|
|
|
s = ''
|
|
|
|
s += python.standard_caveats if python
|
|
|
|
s += <<-EOS.undent
|
|
|
|
Extra tools are installed in #{share}/llvm and #{share}/clang.
|
2012-08-11 09:21:42 +00:00
|
|
|
|
2013-01-21 09:33:56 +00:00
|
|
|
If you already have LLVM installed, then "brew upgrade llvm" might not work.
|
|
|
|
Instead, try:
|
|
|
|
brew rm llvm && brew install llvm
|
2010-10-07 17:13:59 +00:00
|
|
|
EOS
|
|
|
|
end
|
2012-02-27 05:01:41 +00:00
|
|
|
|
|
|
|
def clang_dir
|
|
|
|
buildpath/'tools/clang'
|
|
|
|
end
|
2009-08-31 13:45:04 +00:00
|
|
|
end
|