101 lines
3.4 KiB
Ruby
101 lines
3.4 KiB
Ruby
class BoostMpi < Formula
|
|
desc "C++ library for C++/MPI interoperability"
|
|
homepage "https://www.boost.org/"
|
|
url "https://dl.bintray.com/boostorg/release/1.73.0/source/boost_1_73_0.tar.bz2"
|
|
mirror "https://dl.bintray.com/homebrew/mirror/boost_1_73_0.tar.bz2"
|
|
sha256 "4eb3b8d442b426dc35346235c8733b5ae35ba431690e38c6a8263dce9fcbb402"
|
|
license "BSL-1.0"
|
|
head "https://github.com/boostorg/boost.git"
|
|
|
|
bottle do
|
|
sha256 "c9f768e84953960f029ca0e4742169492ce7f78f63b70c9262efd6f483014006" => :catalina
|
|
sha256 "23ea2a6c362ba43697d1d583b90c56446030faadf5878cdd12a0a369a2cb872f" => :mojave
|
|
sha256 "2d02ebd7d916d416d0921b58b454e1f7e214450f0f61b1823bc49eafcbf98f38" => :high_sierra
|
|
end
|
|
|
|
depends_on "boost"
|
|
depends_on "open-mpi"
|
|
|
|
# Fix build on Xcode 11.4
|
|
patch do
|
|
url "https://github.com/boostorg/build/commit/b3a59d265929a213f02a451bb63cea75d668a4d9.patch?full_index=1"
|
|
sha256 "04a4df38ed9c5a4346fbb50ae4ccc948a1440328beac03cb3586c8e2e241be08"
|
|
directory "tools/build"
|
|
end
|
|
|
|
def install
|
|
# "layout" should be synchronized with boost
|
|
args = %W[
|
|
-d2
|
|
-j#{ENV.make_jobs}
|
|
--layout=tagged-1.66
|
|
--user-config=user-config.jam
|
|
install
|
|
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"
|
|
args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++" if ENV.compiler == :clang
|
|
|
|
open("user-config.jam", "a") do |file|
|
|
file.write "using darwin : : #{ENV.cxx} ;\n"
|
|
file.write "using mpi ;\n"
|
|
end
|
|
|
|
system "./bootstrap.sh", "--prefix=#{prefix}", "--libdir=#{lib}", "--with-libraries=mpi"
|
|
|
|
system "./b2",
|
|
"--prefix=install-mpi",
|
|
"--libdir=install-mpi/lib",
|
|
*args
|
|
|
|
lib.install Dir["install-mpi/lib/*mpi*"]
|
|
(lib/"cmake").install Dir["install-mpi/lib/cmake/*mpi*"]
|
|
|
|
# libboost_mpi links to libboost_serialization, which comes from the main boost formula
|
|
boost = Formula["boost"]
|
|
MachO::Tools.change_install_name("#{lib}/libboost_mpi-mt.dylib",
|
|
"libboost_serialization-mt.dylib",
|
|
"#{boost.lib}/libboost_serialization-mt.dylib")
|
|
MachO::Tools.change_install_name("#{lib}/libboost_mpi.dylib",
|
|
"libboost_serialization.dylib",
|
|
"#{boost.lib}/libboost_serialization.dylib")
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#include <boost/mpi.hpp>
|
|
#include <iostream>
|
|
#include <boost/serialization/string.hpp>
|
|
namespace mpi = boost::mpi;
|
|
|
|
int main(int argc, char* argv[])
|
|
{
|
|
mpi::environment env(argc, argv);
|
|
mpi::communicator world;
|
|
|
|
if (world.rank() == 0) {
|
|
world.send(1, 0, std::string("Hello"));
|
|
std::string msg;
|
|
world.recv(1, 1, msg);
|
|
std::cout << msg << "!" << std::endl;
|
|
} else {
|
|
std::string msg;
|
|
world.recv(0, 0, msg);
|
|
std::cout << msg << ", ";
|
|
std::cout.flush();
|
|
world.send(0, 1, std::string("world"));
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
EOS
|
|
boost = Formula["boost"]
|
|
system "mpic++", "test.cpp", "-L#{lib}", "-L#{boost.lib}", "-lboost_mpi", "-lboost_serialization", "-o", "test"
|
|
system "mpirun", "-np", "2", "./test"
|
|
end
|
|
end
|