homebrew-core/Formula/tbb.rb
2019-03-20 10:36:28 +01:00

60 lines
1.9 KiB
Ruby

class Tbb < Formula
desc "Rich and complete approach to parallelism in C++"
homepage "https://www.threadingbuildingblocks.org/"
url "https://github.com/01org/tbb/archive/2019_U4.tar.gz"
version "2019_U4"
sha256 "342a0a2cd583879850658284b86e9351ea019b4f3fcd731f4c18456f0ce9f900"
bottle do
cellar :any
sha256 "0f2810f2137cc02f4ed9dcd19e10c9c305b9be6c4b1b24ecbf8ef543ae6c91e2" => :mojave
sha256 "4d50a2091e3e275f1fbe9c25f29cf1448ae01887862924bc2a94702e67f3adee" => :high_sierra
sha256 "877768fb618aa28de419e5cabdb11ae9bc77c82bf6d73e843b220814029c1854" => :sierra
end
depends_on "cmake" => :build
depends_on "swig" => :build
# requires malloc features first introduced in Lion
# https://github.com/Homebrew/homebrew/issues/32274
depends_on "python"
def install
compiler = (ENV.compiler == :clang) ? "clang" : "gcc"
system "make", "tbb_build_prefix=BUILDPREFIX", "compiler=#{compiler}"
lib.install Dir["build/BUILDPREFIX_release/*.dylib"]
# Build and install static libraries
system "make", "tbb_build_prefix=BUILDPREFIX", "compiler=#{compiler}",
"extra_inc=big_iron.inc"
lib.install Dir["build/BUILDPREFIX_release/*.a"]
include.install "include/tbb"
cd "python" do
ENV["TBBROOT"] = prefix
system "python3", *Language::Python.setup_install_args(prefix)
end
system "cmake", "-DTBB_ROOT=#{prefix}",
"-DTBB_OS=Darwin",
"-DSAVE_TO=lib/cmake/TBB",
"-P", "cmake/tbb_config_generator.cmake"
(lib/"cmake"/"TBB").install Dir["lib/cmake/TBB/*.cmake"]
end
test do
(testpath/"test.cpp").write <<~EOS
#include <tbb/task_scheduler_init.h>
#include <iostream>
int main()
{
std::cout << tbb::task_scheduler_init::default_num_threads();
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-L#{lib}", "-ltbb", "-o", "test"
system "./test"
end
end