137 lines
4.4 KiB
Ruby
137 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 1
|
|
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_monterey: "9005c4f4da1a41353a1069797311dd9da6f007cfd9726508d6d7f6d10cc507c5"
|
|
sha256 cellar: :any, arm64_big_sur: "f6e5027a8f65b955bfdd0ea181aca098cef286f08f5b5c2d532f9ace5fc984b8"
|
|
sha256 cellar: :any, monterey: "032ce4d7839013bdb1c75de46f07e023f51f65814c79b7eb2c67ee795171ce26"
|
|
sha256 cellar: :any, big_sur: "a6d93188e8fe85a659fe0fed0f9afbbd22a049f022825e98ea30acc9b9c2dc40"
|
|
sha256 cellar: :any, catalina: "90bf24b4c813df7af152cb9de6f8b390093a2582aa403472cbb2beeecb05c7d4"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "9f79b77d14b09ee25c73a2b13fae6c583d748f8abd5f19f3b2043eddf52cd8c9"
|
|
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
|