class Boost < Formula desc "Collection of portable C++ source libraries" homepage "https://www.boost.org/" url "https://github.com/boostorg/boost/releases/download/boost-1.90.0/boost-1.90.0-b2-nodocs.tar.xz" sha256 "9e6bee9ab529fb2b0733049692d57d10a72202af085e553539a05b4204211a6f" 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 arm64_tahoe: "495170d683a37749c1d436ee63ee5790a11a8f85695997dada79eb7bfc5c3341" sha256 arm64_sequoia: "5ea7814760c6eb4bc62db04685931f17f974fc2a82dc385ff75706860cbbf313" sha256 arm64_sonoma: "3a3f2620213f97cccb650f05fa66b042c29621076d7b786d0a7136ca623d0b64" sha256 cellar: :any, sonoma: "c0a827c85fe689dc9db03b31b152ce78868928f020757ef7b0b85b3f81489d67" sha256 cellar: :any_skip_relocation, arm64_linux: "4d154efec46278e4d3dc8f3aa9aa73205f4b10f821725cc6217b525f104d0c4e" sha256 cellar: :any_skip_relocation, x86_64_linux: "b1e65c2f173ce34d451025547d72db68956d69123c94b636c48901a36a83a0c6" end depends_on "icu4c@78" depends_on "xz" depends_on "zstd" uses_from_macos "bzip2" uses_from_macos "zlib" # Fix for `ncmpcpp`, pr ref: https://github.com/boostorg/range/pull/157 patch :p3 do url "https://github.com/boostorg/range/commit/9ac89e9936b826c13e90611cb9a81a7aa0508d20.patch?full_index=1" sha256 "914464ffa1d53b3bf56ee0ff1a78c25799170c99c9a1cda075e6298f730236ad" directory "boost" end 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 = deps.map(&:to_formula).find { |f| f.name.match?(/^icu4c@\d+$/) } bootstrap_args = %W[ --prefix=#{prefix} --libdir=#{lib} --with-icu=#{icu4c.opt_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=system --user-config=user-config.jam install threading=multi link=shared,static ] # Boost is using "clang++ -x c" to select C compiler which breaks C++ # handling in superenv. Using "cxxflags" and "linkflags" still works. # C++17 is due to `icu4c`. args << "cxxflags=-std=c++17" 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 <<~CPP #include #include #include #include #include #include #include #include #include #include using namespace boost::algorithm; using namespace boost::iostreams; using namespace std; int main() { string str("a,b"); vector 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 v; back_insert_device> 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; } CPP system ENV.cxx, "test.cpp", "-std=c++17", "-o", "test", "-L#{lib}", "-lboost_iostreams", "-L#{Formula["zstd"].opt_lib}", "-lzstd" system "./test" end end