-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
boost.rb
136 lines (116 loc) 路 4.48 KB
/
boost.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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.85.0/boost-1.85.0-b2-nodocs.tar.xz"
sha256 "09f0628bded81d20b0145b30925d7d7492fd99583671586525d5d66d4c28266a"
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_sonoma: "01c57670b0218a69dccf37142a2f79b5836350114c694adef930f2116df8d7eb"
sha256 cellar: :any, arm64_ventura: "c4e5b89b1dfeee3d39ad4dfda2be0acef88e4490fcbad82c61df8222cf96b547"
sha256 cellar: :any, arm64_monterey: "4784f99d2e99d5cbcac457b05b89ec26338ceb0766394c7182be71b2843e32c6"
sha256 cellar: :any, sonoma: "29cda46fdde152b849eaed96d533842b5ef144de8ff44010831ef9ed79932272"
sha256 cellar: :any, ventura: "de000507f16d623fdcf935bd3aa16891c9dc25647b7389791d01858a04842217"
sha256 cellar: :any, monterey: "322f5cad5fc34613d2e617138276ca390ac6e16c1cb52286381af98fea9b3526"
sha256 cellar: :any_skip_relocation, x86_64_linux: "24719603623f93428cd585e5a8abba44d7412aee3f9fe4743e2ff7432a2aeb9c"
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