homebrew-core/Formula/tbb.rb

59 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/intel/tbb/archive/v2020.1.tar.gz"
version "2020_U1"
sha256 "48d51c63b16787af54e1ee4aaf30042087f20564b4eecf9a032d5568bc2f0bf8"
bottle do
cellar :any
sha256 "6840b9a3fd3f8fdaaf47c21dbaecf8e05c439ebb3f3f3cda844678ecb45ab59f" => :catalina
sha256 "1ea0fab506500b8031ab3058bdca7498f3c2a57b135eb5c675b47f459804a0d0" => :mojave
sha256 "152c900ed0699f87588032d1b02a7dd4d88fe2838070d783bc255a65ff3248f7" => :high_sierra
end
depends_on "cmake" => :build
depends_on "swig" => :build
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", *std_cmake_args,
"-DINSTALL_DIR=lib/cmake/TBB",
"-DSYSTEM_NAME=Darwin",
"-DTBB_VERSION_FILE=#{include}/tbb/tbb_stddef.h",
"-P", "cmake/tbb_config_installer.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