homebrew-core/Formula/boost.rb

138 lines
4.6 KiB
Ruby

class Boost < Formula
desc "Collection of portable C++ source libraries"
homepage "https://www.boost.org/"
url "https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.bz2"
sha256 "71feeed900fbccca04a3b4f2f84a7c217186f28a940ed8b7ed4725986baf99fa"
license "BSL-1.0"
head "https://github.com/boostorg/boost.git", branch: "master"
livecheck do
url "https://www.boost.org/users/download/"
regex(/href=.*?boost[._-]v?(\d+(?:[._]\d+)+)\.t/i)
strategy :page_match do |page, regex|
page.scan(regex).map { |match| match.first.tr("_", ".") }
end
end
bottle do
sha256 cellar: :any, arm64_ventura: "aa3d546bc5fd86a73ed3019e7dd1b04bda025798bd43d99e643f1114cbfef558"
sha256 cellar: :any, arm64_monterey: "147b71e637f2ab396c580f62f8a16917010efa4494be26d6ec4a3339f980087f"
sha256 cellar: :any, arm64_big_sur: "572093eec4c68d13f95b3682e2c673a2610097bae1912ab4d6e2b2b857ef9122"
sha256 cellar: :any, ventura: "9fd4dfa222b28d6972ef3c60648972122e9491c4e4c74b436871bb0646a670d7"
sha256 cellar: :any, monterey: "cc487497f5beaa3726ed3e8772e8066e968ad494917b35c58c94f9e5febc7944"
sha256 cellar: :any, big_sur: "35c01f163d0d54afc7cdf2b492245fb34d64faf42ac410d1c77d211f00789f14"
sha256 cellar: :any, catalina: "a75afcf9ab1eee0eecb59282070b0559c56b7a00d5b3ab29c6a2d52c9b51b8a5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "6d54fe09e3343863c9b2e7ba034ad2eaa2fce83651cc338da59e2895bbea0034"
end
depends_on "icu4c"
depends_on "xz"
depends_on "zstd"
uses_from_macos "bzip2"
uses_from_macos "zlib"
def install
# Force boost to compile with the desired compiler
open("user-config.jam", "a") do |file|
if OS.mac?
file.write "using darwin : : #{ENV.cxx} ;\n"
else
file.write "using gcc : : #{ENV.cxx} ;\n"
end
end
# libdir should be set by --prefix but isn't
icu4c_prefix = Formula["icu4c"].opt_prefix
bootstrap_args = %W[
--prefix=#{prefix}
--libdir=#{lib}
--with-icu=#{icu4c_prefix}
]
# Handle libraries that will not be built.
without_libraries = ["python", "mpi"]
# Boost.Log cannot be built using Apple GCC at the moment. Disabled
# on such systems.
without_libraries << "log" if ENV.compiler == :gcc
bootstrap_args << "--without-libraries=#{without_libraries.join(",")}"
# layout should be synchronized with boost-python and boost-mpi
args = %W[
--prefix=#{prefix}
--libdir=#{lib}
-d2
-j#{ENV.make_jobs}
--layout=tagged-1.66
--user-config=user-config.jam
install
threading=multi,single
link=shared,static
]
# Boost is using "clang++ -x c" to select C compiler which breaks C++14
# handling using ENV.cxx14. Using "cxxflags" and "linkflags" still works.
args << "cxxflags=-std=c++14"
args << "cxxflags=-stdlib=libc++" << "linkflags=-stdlib=libc++" if ENV.compiler == :clang
system "./bootstrap.sh", *bootstrap_args
system "./b2", "headers"
system "./b2", *args
end
test do
(testpath/"test.cpp").write <<~EOS
#include <boost/algorithm/string.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/zstd.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/stream.hpp>
#include <string>
#include <iostream>
#include <vector>
#include <assert.h>
using namespace boost::algorithm;
using namespace boost::iostreams;
using namespace std;
int main()
{
string str("a,b");
vector<string> strVec;
split(strVec, str, is_any_of(","));
assert(strVec.size()==2);
assert(strVec[0]=="a");
assert(strVec[1]=="b");
// Test boost::iostreams::zstd_compressor() linking
std::vector<char> v;
back_insert_device<std::vector<char>> snk{v};
filtering_ostream os;
os.push(zstd_compressor());
os.push(snk);
os << "Boost" << std::flush;
os.pop();
array_source src{v.data(), v.size()};
filtering_istream is;
is.push(zstd_decompressor());
is.push(src);
std::string s;
is >> s;
assert(s == "Boost");
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-std=c++14", "-o", "test", "-L#{lib}", "-lboost_iostreams",
"-L#{Formula["zstd"].opt_lib}", "-lzstd"
system "./test"
end
end