95 lines
3.1 KiB
Ruby
95 lines
3.1 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.71.0/source/boost_1_71_0.tar.bz2"
|
|
sha256 "d73a8da01e8bf8c7eda40b4c84915071a8c8a0df4a6734537ddde4a8580524ee"
|
|
revision 1
|
|
head "https://github.com/boostorg/boost.git"
|
|
|
|
bottle do
|
|
rebuild 1
|
|
sha256 "e4fde273f5ea74d733c71978810d9510e54a2fcaca64459982dec9f43c500610" => :catalina
|
|
sha256 "a6f535dfd42e05dd080e53d11642356087cf657b40b2113aa613cf50f93791d5" => :mojave
|
|
sha256 "6dd48ed4e5a7b42f61e34a0f3b75fa1aa4837a920a58b6d131763b8850f6f00c" => :high_sierra
|
|
end
|
|
|
|
depends_on "boost"
|
|
depends_on "open-mpi"
|
|
|
|
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"
|
|
if ENV.compiler == :clang
|
|
args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++"
|
|
end
|
|
|
|
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
|