Skip to content

Commit

Permalink
more libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Sep 1, 2024
1 parent b76fc73 commit 24a9ca6
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 54 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ pub fn build(b: *std.Build) !void {
const boost_dep = b.dependency("boost", .{
.target = target,
.optimize = optimize,
.@"headers-only" = true,
// default is true (recommended)
// .@"headers-only" = false,
});
const boost_artifact = boost_dep.artifact("boost");
Expand Down
16 changes: 13 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ const boost_libs = [_][]const u8{
"optional",
"date_time",
"mysql",
"compute",
"compute", // need OpenCL
"odeint",
"ublas",
"serialization",
"iostreams",
"safe_numerics",
"smart_ptr",
"math",
Expand All @@ -52,6 +56,9 @@ const boost_libs = [_][]const u8{
"io",
"json",
"type_index",
"type_erasure",
"typeof",
"units",
"timer",
"stacktrace",
"sort",
Expand All @@ -73,6 +80,7 @@ const boost_libs = [_][]const u8{
"fusion",
"function",
"spirit",
"function_types",
"cobalt",
"phoenix",
"nowide",
Expand All @@ -86,6 +94,7 @@ const boost_libs = [_][]const u8{
"tokenizer",
"geometry",
"crc",
"callable_traits",
"compat",
"bimap",
};
Expand All @@ -97,7 +106,7 @@ pub fn build(b: *std.Build) !void {
const boost = boostLibraries(b, .{
.target = target,
.optimize = optimize,
.header_only = b.option(bool, "headers-only", "Build header-only libraries") orelse true,
.header_only = b.option(bool, "headers-only", "Build header-only libraries (default: true)") orelse true,
});
b.installArtifact(boost);
}
Expand All @@ -106,7 +115,7 @@ const cxxFlags: []const []const u8 = &.{
"-Wall",
"-Wextra",
"-Wpedantic",
"-std=c++17",
"-Wformat",
};

const boost_version: std.SemanticVersion = .{ .major = 0, .minor = 86, .patch = 0 };
Expand Down Expand Up @@ -136,6 +145,7 @@ pub fn boostLibraries(b: *std.Build, config: Config) *std.Build.Step.Compile {
.flags = cxxFlags,
});
} else {
// WIP
const boostJson = b.dependency("json", .{}).path("");
const boostContainer = b.dependency("container", .{}).path("");
lib.addCSourceFiles(.{
Expand Down
36 changes: 36 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,42 @@
.url = "git+https://github.com/boostorg/parameter#boost-1.86.0",
.hash = "122053c2d2c58149a0a1a84491b6a7dbb156d6cf3410d7e04a6683ca2671611bf578",
},
.callable_traits = .{
.url = "git+https://github.com/boostorg/callable_traits#boost-1.86.0",
.hash = "1220a956282e6fb69220481426884bce23895c3981de280c3fb33c80271a63ee6647",
},
.odeint = .{
.url = "git+https://github.com/boostorg/odeint#boost-1.86.0",
.hash = "1220e863b9cb75d3f1d5cad9bd5ad59f5e5083dbc72b8bd7c2afbe696699e191bbb4",
},
.ublas = .{
.url = "git+https://github.com/boostorg/ublas#boost-1.86.0",
.hash = "122023a13199b57fea71f87a8500ccd9c6e445b3d70fb7f1bbc858a7efb138b18d79",
},
.serialization = .{
.url = "git+https://github.com/boostorg/serialization#boost-1.86.0",
.hash = "1220ece5d24e3f2900bd4f06ec99042eb1a773b0b4303e1e785c640e54aecdc3c6c5",
},
.iostreams = .{
.url = "git+https://github.com/boostorg/iostreams#boost-1.86.0",
.hash = "1220f9afc0c9fcab849cd746877887ea9616f5f4b1853bf473301d105c1032a839b3",
},
.type_erasure = .{
.url = "git+https://github.com/boostorg/type_erasure#boost-1.86.0",
.hash = "1220816eff54217c0608bbbf4fbfd98474452f8f41cfdbccab3ef4c8dc94a24677c0",
},
.typeof = .{
.url = "git+https://github.com/boostorg/typeof#boost-1.86.0",
.hash = "1220f40340f02be8e64048c4bc60dd0eac40b19d7e433f71d1ce00b2a12beabf54db",
},
.units = .{
.url = "git+https://github.com/boostorg/units#boost-1.86.0",
.hash = "1220e483898c1488946a2a6e721df4696ed341dc72e21084d97edee0db7cdc22f3b2",
},
.function_types = .{
.url = "git+https://github.com/boostorg/function_types#boost-1.86.0",
.hash = "1220f599b1bb1592228351732048027d2ada614198be92c4972fc3fe811a698201ce",
},
},
.paths = .{""},
}
30 changes: 19 additions & 11 deletions tests/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ pub fn build(b: *std.Build) void {
const boost_dep = b.dependency("boost", .{
.target = target,
.optimize = optimize,
// .@"headers-only" = false, // need link-library artifact
});

buildTests(b, .{
.target = target,
.optimize = optimize,
.files = &.{
"include_all.cc",
},
.name = "include_tests",
.dependency = boost_dep,
});
inline for (&.{
"include_all.cc",
}) |file| {
buildTests(b, .{
.target = target,
.optimize = optimize,
.files = &.{file},
.name = b.fmt("test_{s}", .{file[0 .. file.len - 3]}),
.dependency = boost_dep,
});
}
}
fn buildTests(b: *std.Build, options: struct {
target: std.Build.ResolvedTarget,
Expand All @@ -37,13 +40,18 @@ fn buildTests(b: *std.Build, options: struct {
for (artifact.root_module.include_dirs.items) |include_dir| {
exe.root_module.include_dirs.append(b.allocator, include_dir) catch unreachable;
}
// if not header-only, link library
// exe.linkLibrary(artifact);
}

for (options.files) |file| {
exe.addCSourceFile(.{
.file = b.path(file),
.flags = &.{"-std=c++20"},
.flags = &.{
"-std=c++20", "-Wall",
"-Wextra", "-Wpedantic",
"-Wformat",
},
});
}
if (exe.rootModuleTarget().abi != .msvc) {
Expand All @@ -58,6 +66,6 @@ fn buildTests(b: *std.Build, options: struct {

b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
const run_step = b.step("run", b.fmt("Run the {s}", .{exe.name}));
const run_step = b.step(exe.name, b.fmt("Run the {s}", .{exe.name}));
run_step.dependOn(&run_cmd.step);
}
Loading

0 comments on commit 24a9ca6

Please sign in to comment.