homebrew-core/Formula/llvm.rb
Samuel John f6e80bdea2 Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.

To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.

The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:

python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.

Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.

python do
  system python, 'setup.py', "--prefix=#{prefix}"
end

Read more in the Homebrew wiki.
2013-06-03 17:29:43 +02:00

120 lines
3.4 KiB
Ruby

require 'formula'
class Clang < Formula
homepage 'http://llvm.org/'
url 'http://llvm.org/releases/3.2/clang-3.2.src.tar.gz'
sha1 'b0515298c4088aa294edc08806bd671f8819f870'
head 'http://llvm.org/git/clang.git'
end
class CompilerRt < Formula
homepage 'http://llvm.org/'
url 'http://llvm.org/releases/3.2/compiler-rt-3.2.src.tar.gz'
sha1 '718c0249a00e928f8bba32c84771da998ea4d42f'
head 'http://llvm.org/git/compiler-rt.git'
end
class Llvm < Formula
homepage 'http://llvm.org/'
url 'http://llvm.org/releases/3.2/llvm-3.2.src.tar.gz'
sha1 '42d139ab4c9f0c539c60f5ac07486e9d30fc1280'
head 'http://llvm.org/git/llvm.git'
bottle do
revision 1
sha1 '2908621be867da84962d2e4b8d6a083bd6bf4995' => :mountain_lion
sha1 '91dfa26392b9699750a04fa934ee8ec9dc98407a' => :lion
sha1 '259f39608d50dd3aba0eb3ff28b603d795af9eac' => :snow_leopard
end
option :universal
option 'with-clang', 'Build Clang C/ObjC/C++ frontend'
option 'with-asan', 'Include support for -faddress-sanitizer (from compiler-rt)'
option 'disable-shared', "Don't build LLVM as a shared library"
option 'all-targets', 'Build all target backends'
option 'rtti', 'Build with C++ RTTI'
option 'disable-assertions', 'Speeds up LLVM, but provides less debug information'
depends_on :python => :recommended
env :std if build.universal?
def install
if build.with? 'python' and build.include? 'disable-shared'
raise 'The Python bindings need the shared library.'
end
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'
if build.universal?
ENV['UNIVERSAL'] = '1'
ENV['UNIVERSAL_ARCH'] = 'i386 x86_64'
end
ENV['REQUIRES_RTTI'] = '1' if build.include? 'rtti'
args = [
"--prefix=#{prefix}",
"--enable-optimized",
# As of LLVM 3.1, attempting to build ocaml bindings with Homebrew's
# OCaml 3.12.1 results in errors.
"--disable-bindings",
]
if build.include? 'all-targets'
args << "--enable-targets=all"
else
args << "--enable-targets=host"
end
args << "--enable-shared" unless build.include? 'disable-shared'
args << "--disable-assertions" if build.include? 'disable-assertions'
system "./configure", *args
system "make install"
# install llvm python bindings
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
# install clang tools and bindings
cd clang_dir do
system 'make install'
(share/'clang/tools').install 'tools/scan-build', 'tools/scan-view'
python.site_packages.install 'bindings/python/clang' if python
end if build.include? 'with-clang'
end
def test
system "#{bin}/llvm-config", "--version"
end
def caveats
s = ''
s += python.standard_caveats if python
s += <<-EOS.undent
Extra tools are installed in #{share}/llvm and #{share}/clang.
If you already have LLVM installed, then "brew upgrade llvm" might not work.
Instead, try:
brew rm llvm && brew install llvm
EOS
end
def clang_dir
buildpath/'tools/clang'
end
end