73 lines
2.4 KiB
Ruby
73 lines
2.4 KiB
Ruby
class BoostPython < Formula
|
|
desc "C++ library for C++/Python2 interoperability"
|
|
homepage "https://www.boost.org/"
|
|
url "https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.tar.bz2"
|
|
sha256 "2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba"
|
|
head "https://github.com/boostorg/boost.git"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "af466a98257575e4f0e39c7bdc449fd83cd61f4ff93693ea749b84940f4bf918" => :high_sierra
|
|
sha256 "b5c3bcb8c612b597cd2a26158a5a17eca681d9e4356cd2f72c8f2e4154ce55c4" => :sierra
|
|
sha256 "5dbe82c61533303630269f2e07591ad572829ec7f3af800af7553bc359baf07a" => :el_capitan
|
|
end
|
|
|
|
depends_on "boost"
|
|
|
|
needs :cxx11
|
|
|
|
def install
|
|
# "layout" should be synchronized with boost
|
|
args = ["--prefix=#{prefix}",
|
|
"--libdir=#{lib}",
|
|
"-d2",
|
|
"-j#{ENV.make_jobs}",
|
|
"--layout=tagged",
|
|
"threading=multi,single",
|
|
"link=shared,static"]
|
|
|
|
# Trunk starts using "clang++ -x c" to select C compiler which breaks C++11
|
|
# handling using ENV.cxx11. Using "cxxflags" and "linkflags" still works.
|
|
args << "cxxflags=-std=c++11"
|
|
if ENV.compiler == :clang
|
|
args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++"
|
|
end
|
|
|
|
pyver = Language::Python.major_minor_version "python"
|
|
|
|
system "./bootstrap.sh", "--prefix=#{prefix}", "--libdir=#{lib}",
|
|
"--with-libraries=python", "--with-python=python"
|
|
|
|
system "./b2", "--build-dir=build-python", "--stagedir=stage-python",
|
|
"python=#{pyver}", *args
|
|
|
|
lib.install Dir["stage-python/lib/*py*"]
|
|
doc.install Dir["libs/python/doc/*"]
|
|
end
|
|
|
|
test do
|
|
(testpath/"hello.cpp").write <<~EOS
|
|
#include <boost/python.hpp>
|
|
char const* greet() {
|
|
return "Hello, world!";
|
|
}
|
|
BOOST_PYTHON_MODULE(hello)
|
|
{
|
|
boost::python::def("greet", greet);
|
|
}
|
|
EOS
|
|
|
|
pyincludes = Utils.popen_read("python-config --includes").chomp.split(" ")
|
|
pylib = Utils.popen_read("python-config --ldflags").chomp.split(" ")
|
|
|
|
system ENV.cxx, "-shared", "hello.cpp", "-L#{lib}", "-lboost_python27", "-o",
|
|
"hello.so", *pyincludes, *pylib
|
|
|
|
output = <<~EOS
|
|
from __future__ import print_function
|
|
import hello
|
|
print(hello.greet())
|
|
EOS
|
|
assert_match "Hello, world!", pipe_output("python", output, 0)
|
|
end
|
|
end
|