138 lines
4.4 KiB
Ruby
138 lines
4.4 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.79.0/source/boost_1_79_0.tar.bz2"
|
|
sha256 "475d589d51a7f8b3ba2ba4eda022b170e562ca3b760ee922c146b6c65856ef39"
|
|
license "BSL-1.0"
|
|
revision 2
|
|
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
|
|
rebuild 1
|
|
sha256 cellar: :any, arm64_monterey: "e2cd0f9c9ca7372ff8d925d504ff3f7323c14c1d8e090a34543974cea14b096c"
|
|
sha256 cellar: :any, arm64_big_sur: "c8fc72c5d654e6069632a47db821a92c6ead0d919d3293e4a91df684ffa2f2d3"
|
|
sha256 cellar: :any, monterey: "f7715741c0cb730f1be6820040eaf1e7143a65e6925060d736158787ca57a61d"
|
|
sha256 cellar: :any, big_sur: "d61e612ba714d42c690aa71ac7040531fea94c40236e56796e8c25a482f8c2e1"
|
|
sha256 cellar: :any, catalina: "2a22d5c701dd7acd5845a1530f646fe21e6e494d01cb751c8f2da1d2d14fd07c"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "d2a4ee924f2a565bbbcc814842b47164e5708092a86d90c15a10e2b56bcdcc23"
|
|
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
|