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" 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 arm64_tahoe: "47ceccf6792941c223a6464f974b6ac56e1d3457e6d72e1f71b4fdb742cef1d0" sha256 arm64_sequoia: "48b32cf2c35011a4b7e9b6ac8a68247aebb872b39f4629dbfc3f343d9f6a2b2d" sha256 arm64_sonoma: "900f3a5db294a038351027a97e5de0c72d3f3fb754b081294dbea4267b69963d" sha256 cellar: :any, sonoma: "29e1095cff0cab11964d27ad12ca18556ff9715f2c6b3216f0deb389ffdba653" sha256 cellar: :any_skip_relocation, arm64_linux: "533706af6bd0f1e62589e7421f190466451755f4e7bc91937661e3b2a13560c3" sha256 cellar: :any_skip_relocation, x86_64_linux: "175119f6f95179930c676c24615133249fea40b9bd86e1f37340c1544c18f9bc" end depends_on "icu4c@78" depends_on "xz" depends_on "zstd" uses_from_macos "bzip2" on_linux do depends_on "zlib-ng-compat" end # 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