Skip to content

Commit b5c0e2b

Browse files
committed
add more libraries: boost.gil & boost.python (no-numpy support yet)
Build boost.nowide
1 parent 575f9bc commit b5c0e2b

File tree

6 files changed

+114
-7
lines changed

6 files changed

+114
-7
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ Project-Specific Options:
5555
-Diostreams=[bool] Build boost.iostreams library (default: false)
5656
-Djson=[bool] Build boost.json library (default: false)
5757
-Dlog=[bool] Build boost.log library (default: false)
58+
-Dnowide=[bool] Build boost.nowide library (default: false)
5859
-Dprocess=[bool] Build boost.process library (default: false)
60+
-Dpython=[bool] Build boost.python library (default: false)
5961
-Drandom=[bool] Build boost.random library (default: false)
6062
-Dregex=[bool] Build boost.regex library (default: false)
6163
-Dserialization=[bool] Build boost.serialization library (default: false)

build.zig

+85
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ const boost_libs = [_][]const u8{
100100
"local_function",
101101
"format",
102102
"pool",
103+
"gil",
104+
"python",
103105
"proto",
104106
"property_tree",
105107
"exception",
108+
"property_map",
109+
"property_map_parallel",
106110
"multi_index",
107111
"callable_traits",
108112
"compat",
@@ -135,7 +139,9 @@ pub fn build(b: *std.Build) void {
135139
.iostreams = b.option(bool, "iostreams", "Build boost.iostreams library (default: false)") orelse false,
136140
.json = b.option(bool, "json", "Build boost.json library (default: false)") orelse false,
137141
.log = b.option(bool, "log", "Build boost.log library (default: false)") orelse false,
142+
.nowide = b.option(bool, "nowide", "Build boost.nowide library (default: false)") orelse false,
138143
.process = b.option(bool, "process", "Build boost.process library (default: false)") orelse false,
144+
.python = b.option(bool, "python", "Build boost.python library (default: false)") orelse false,
139145
.random = b.option(bool, "random", "Build boost.random library (default: false)") orelse false,
140146
.regex = b.option(bool, "regex", "Build boost.regex library (default: false)") orelse false,
141147
.serialization = b.option(bool, "serialization", "Build boost.serialization library (default: false)") orelse false,
@@ -230,9 +236,15 @@ pub fn boostLibraries(b: *std.Build, config: Config) *std.Build.Step.Compile {
230236
if (module.serialization) {
231237
buildSerialization(b, lib);
232238
}
239+
if (module.nowide) {
240+
buildNoWide(b, lib);
241+
}
233242
if (module.system) {
234243
buildSystem(b, lib);
235244
}
245+
if (module.python) {
246+
buildPython(b, lib);
247+
}
236248
if (module.stacktrace) {
237249
buildStacktrace(b, lib);
238250
}
@@ -274,7 +286,9 @@ const boostLibrariesModules = struct {
274286
iostreams: bool = false,
275287
json: bool = false,
276288
log: bool = false,
289+
nowide: bool = false,
277290
process: bool = false,
291+
python: bool = false,
278292
random: bool = false,
279293
regex: bool = false,
280294
stacktrace: bool = false,
@@ -953,6 +967,77 @@ fn buildLog(b: *std.Build, obj: *std.Build.Step.Compile) void {
953967
});
954968
}
955969

970+
fn buildNoWide(b: *std.Build, obj: *std.Build.Step.Compile) void {
971+
const nwPath = b.dependency("nowide", .{}).path("src");
972+
973+
obj.addIncludePath(nwPath);
974+
obj.addCSourceFiles(.{
975+
.root = nwPath,
976+
.files = &.{
977+
"console_buffer.cpp",
978+
"cstdio.cpp",
979+
"cstdlib.cpp",
980+
"filebuf.cpp",
981+
"iostream.cpp",
982+
"stat.cpp",
983+
},
984+
.flags = cxxFlags,
985+
});
986+
}
987+
988+
fn buildPython(b: *std.Build, obj: *std.Build.Step.Compile) void {
989+
const pyPath = b.dependency("python", .{}).path("src");
990+
991+
obj.linkSystemLibrary("python3");
992+
obj.addCSourceFiles(.{
993+
.root = pyPath,
994+
.files = &.{
995+
"converter/arg_to_python_base.cpp",
996+
"converter/builtin_converters.cpp",
997+
"converter/from_python.cpp",
998+
"converter/registry.cpp",
999+
"converter/type_id.cpp",
1000+
"dict.cpp",
1001+
"errors.cpp",
1002+
"exec.cpp",
1003+
"import.cpp",
1004+
"list.cpp",
1005+
"long.cpp",
1006+
"module.cpp",
1007+
"object/class.cpp",
1008+
"object/enum.cpp",
1009+
"object/function.cpp",
1010+
"object/function_doc_signature.cpp",
1011+
"object/inheritance.cpp",
1012+
"object/iterator.cpp",
1013+
"object/life_support.cpp",
1014+
"object/pickle_support.cpp",
1015+
"object/stl_iterator.cpp",
1016+
"object_operators.cpp",
1017+
"object_protocol.cpp",
1018+
"slice.cpp",
1019+
"str.cpp",
1020+
"tuple.cpp",
1021+
"wrapper.cpp",
1022+
},
1023+
.flags = cxxFlags,
1024+
});
1025+
1026+
// obj.linkSystemLibrary("npymath");
1027+
// obj.addCSourceFiles(.{
1028+
// .root = pyPath,
1029+
// .files = &.{
1030+
// "numpy/dtype.cpp",
1031+
// "numpy/matrix.cpp",
1032+
// "numpy/ndarray.cpp",
1033+
// "numpy/numpy.cpp",
1034+
// "numpy/scalars.cpp",
1035+
// "numpy/ufunc.cpp",
1036+
// },
1037+
// .flags = cxxFlags,
1038+
// });
1039+
}
1040+
9561041
fn buildWave(b: *std.Build, obj: *std.Build.Step.Compile) void {
9571042
const wavePath = b.dependency("wave", .{}).path("src");
9581043

build.zig.zon

+16
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,22 @@
462462
.url = "git+https://github.com/boostorg/multiprecision#boost-1.86.0",
463463
.hash = "12200ebfce9b83b9617018a985bbcec75999ea628f438bd7ad9912af5ba795e5411a",
464464
},
465+
.gil = .{
466+
.url = "git+https://github.com/boostorg/gil#boost-1.86.0",
467+
.hash = "122041474a0277c624c8cf7608d44746cb08c027a0af6687fca27463a2373c62999d",
468+
},
469+
.python = .{
470+
.url = "git+https://github.com/boostorg/python#boost-1.86.0",
471+
.hash = "122065876f46e3dfb99e6177bce74a36932dd6e2bec9d645611b94039544cc58998f",
472+
},
473+
.property_map = .{
474+
.url = "git+https://github.com/boostorg/property_map#boost-1.86.0",
475+
.hash = "1220a0c9bc02ed543a0a19abec48a327ed926e5009fdf83b77e1d86acd021eef57fc",
476+
},
477+
.property_map_parallel = .{
478+
.url = "git+https://github.com/boostorg/property_map_parallel#boost-1.86.0",
479+
.hash = "122001fc1ec7bbcbf86fa2cbcbf6f5ee3f2de247057d9ce7c2fe7527b3070345c7ec",
480+
},
465481
},
466482
.paths = .{""},
467483
}

tests/build.zig

+7-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn buildTests(b: *std.Build, options: struct {
4242
exe.root_module.include_dirs.append(b.allocator, include_dir) catch unreachable;
4343
}
4444
// if not header-only, link library
45-
exe.linkLibrary(artifact);
45+
if (std.mem.endsWith(u8, exe.name, "server"))
46+
exe.linkLibrary(artifact);
4647
}
4748

4849
for (options.files) |file| {
@@ -65,9 +66,11 @@ fn buildTests(b: *std.Build, options: struct {
6566
}
6667

6768
// for boost::asio/boost::beast/boost::cobalt
68-
if (exe.rootModuleTarget().os.tag == .windows) {
69-
exe.linkSystemLibrary("ws2_32");
70-
exe.linkSystemLibrary("mswsock");
69+
if (std.mem.endsWith(u8, exe.name, "server")) {
70+
if (exe.rootModuleTarget().os.tag == .windows) {
71+
exe.linkSystemLibrary("ws2_32");
72+
exe.linkSystemLibrary("mswsock");
73+
}
7174
}
7275

7376
b.installArtifact(exe);

tests/include_all.cc

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <boost/algorithm/algorithm.hpp>
44
#include <boost/any.hpp>
55
#include <boost/array.hpp>
6-
#include <boost/asio.hpp>
76
#include <boost/bind.hpp>
87
#include <boost/callable_traits.hpp>
98
#include <boost/config.hpp>
@@ -47,8 +46,6 @@ int main() {
4746
std::cout << "Boost version " << BOOST_VERSION / 100000 << "."
4847
<< BOOST_VERSION / 100 % 1000 << "." << BOOST_VERSION % 100 << "\n";
4948

50-
asio::io_context io_service;
51-
5249
testCRC();
5350
testSafeIntegers();
5451
testVariants();

update_zon.sh

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ GIT_URLS=(
119119
"git+https://github.com/boostorg/random#$BOOST_VERSION"
120120
"git+https://github.com/boostorg/dll#$BOOST_VERSION"
121121
"git+https://github.com/boostorg/multiprecision#$BOOST_VERSION"
122+
"git+https://github.com/boostorg/gil#$BOOST_VERSION"
123+
"git+https://github.com/boostorg/python#$BOOST_VERSION"
124+
"git+https://github.com/boostorg/property_map#$BOOST_VERSION"
125+
"git+https://github.com/boostorg/property_map_parallel#$BOOST_VERSION"
122126

123127
## Add more URLs here
124128
)

0 commit comments

Comments
 (0)