Files
tigerbrew/Library/Formula/opencolorio.rb
T
Samuel John 0b50110107 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

78 lines
2.9 KiB
Ruby

require 'formula'
class Opencolorio < Formula
homepage 'http://opencolorio.org/'
url 'https://github.com/imageworks/OpenColorIO/archive/v1.0.8.tar.gz'
sha1 '83b28202bdb1f692f74a80affea95d832354ec23'
head 'https://github.com/imageworks/OpenColorIO.git'
depends_on 'cmake' => :build
depends_on 'pkg-config' => :build
depends_on 'little-cms2'
depends_on :python => :optional
option 'with-tests', 'Verify the build with its unit tests (~1min)'
option 'with-java', 'Build ocio with java bindings'
option 'with-docs', 'Build the documentation'
def install
args = std_cmake_args
args << "-DOCIO_BUILD_JNIGLUE=ON" if build.with? 'java'
args << "-DOCIO_BUILD_TESTS=ON" if build.with? 'tests'
args << "-DOCIO_BUILD_DOCS=ON" if build.with? 'docs'
args << "-DCMAKE_VERBOSE_MAKEFILE=OFF"
# CMake-2.8.7 + CLT + llvm + Lion => CMAKE_CXX_HAS_ISYSROOT "1"
# CMake-2.8.7 + CLT + clang + Lion => CMAKE_CXX_HAS_ISYSROOT ""
# CMake puts a malformed sysroot into CXX_FLAGS in flags.make with llvm.
# Syntax like this gets added:
# -isysroot /Some/Wrong/SDKs/path
# which causes c++ includes not found when compiling with llvm.
# https://github.com/imageworks/OpenColorIO/issues/224
# The current workaround is that the SDK directory structure is mirrored
# in the root directory, e.g.
# Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include
# /usr/include
# So we just set the sysroot to /
# args << "-DCMAKE_OSX_SYSROOT=/" if ENV.compiler == :llvm and MacOS.version >= :lion
# Python note:
# OCIO's PyOpenColorIO.so doubles as a shared library. So it lives in lib, rather
# than the usual HOMEBREW_PREFIX/lib/python2.7/site-packages per developer choice.
if python do
# For Xcode-only systems, the headers of system's python are inside of Xcode:
args << "-DPYTHON_INCLUDE_DIR='#{python.incdir}'"
# Cmake picks up the system's python dylib, even if we have a brewed one:
args << "-DPYTHON_LIBRARY='#{python.libdir}/lib#{python.xy}.dylib'"
end; else
args << "-DOCIO_BUILD_PYGLUE=OFF"
end
args << '..'
mkdir 'macbuild' do
system "cmake", *args
system "make"
system "make test" if build.with? 'tests'
system "make install"
end
end
def caveats
<<-EOS.undent
OpenColorIO requires several environment variables to be set.
You can source the following script in your shell-startup to do that:
#{HOMEBREW_PREFIX}/share/ocio/setup_ocio.sh
Alternatively the documentation describes what env-variables need set:
http://opencolorio.org/installation.html#environment-variables
You will require a config for OCIO to be useful. Sample configuration files
and reference images can be found at:
http://opencolorio.org/downloads.html
EOS
end
end