Skip to content

Commit

Permalink
sticked to boost-1.86.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Aug 30, 2024
1 parent e3fe649 commit 1e4f860
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 191 deletions.
167 changes: 76 additions & 91 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,13 +1,68 @@
const std = @import("std");

const boost_libs = [_][]const u8{
"core",
"algorithm",
"config",
"assert",
"type_traits",
"mp11",
"range",
"functional",
"preprocessor",
"container_hash",
"describe",
"mpl",
"iterator",
"static_assert",
"move",
"detail",
"throw_exception",
"tuple",
"predef",
"concept_check",
"utility",
"endian",
"regex",
"asio",
"align",
"system",
"intrusive",
"hana",
"outcome",
"bind",
"pfr",
"graph",
"optional",
"date_time",
"smart_ptr",
"math",
"beast",
"numeric_conversion",
"logic",
"lexical_cast",
"unordered",
"static_string",
"io",
"json",
"type_index",
"container",
"variant",
"variant2",
"winapi",
"chrono",
"any",
"url",
};

pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const boost = boostLibraries(b, .{
.target = target,
.optimize = optimize,
.header_only = b.option(bool, "headers-only", "Build header-only libraries") orelse false,
.header_only = b.option(bool, "headers-only", "Build header-only libraries") orelse true,
});
b.installArtifact(boost);
}
Expand All @@ -16,66 +71,38 @@ const cxxFlags: []const []const u8 = &.{
"-Wall",
"-Wextra",
"-Wpedantic",
"-std=c++17",
};

fn boostLibraries(b: *std.Build, config: Config) *std.Build.Step.Compile {
const boost_version: std.SemanticVersion = .{ .major = 0, .minor = 86, .patch = 0 };

pub fn boostLibraries(b: *std.Build, config: Config) *std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{
.name = "boost",
.target = config.target,
.optimize = config.optimize,
.version = boost_version,
});

const boostCore = b.dependency("core", .{}).path("");
const boostAlg = b.dependency("algorithm", .{}).path("");
const boostConfig = b.dependency("config", .{}).path("");
const boostAssert = b.dependency("assert", .{}).path("");
const boostTraits = b.dependency("type_traits", .{}).path("");
const boostMP11 = b.dependency("mp11", .{}).path("");
const boostRange = b.dependency("range", .{}).path("");
const boostFunctional = b.dependency("functional", .{}).path("");
const boostPreprocessor = b.dependency("preprocessor", .{}).path("");
const boostHash = b.dependency("container_hash", .{}).path("");
const boostDescribe = b.dependency("describe", .{}).path("");
const boostMpl = b.dependency("mpl", .{}).path("");
const boostIterator = b.dependency("iterator", .{}).path("");
const boostStaticAssert = b.dependency("static_assert", .{}).path("");
const boostMove = b.dependency("move", .{}).path("");
const boostDetail = b.dependency("detail", .{}).path("");
const boostThrow = b.dependency("throw_exception", .{}).path("");
const boostTuple = b.dependency("tuple", .{}).path("");
const boostPredef = b.dependency("predef", .{}).path("");
const boostCCheck = b.dependency("concept_check", .{}).path("");
const boostUtil = b.dependency("utility", .{}).path("");
const boostEndian = b.dependency("endian", .{}).path("");
const boostRegex = b.dependency("regex", .{}).path("");
const boostAsio = b.dependency("asio", .{}).path("");
const boostAlign = b.dependency("align", .{}).path("");
const boostSystem = b.dependency("system", .{}).path("");
const boostIntrusive = b.dependency("intrusive", .{}).path("");
const boostHana = b.dependency("hana", .{}).path("");
const boostOutcome = b.dependency("outcome", .{}).path("");
const boostBind = b.dependency("bind", .{}).path("");
const boostOptional = b.dependency("optional", .{}).path("");
const boostDateTime = b.dependency("date_time", .{}).path("");
const boostSmartPtr = b.dependency("smart_ptr", .{}).path("");
const boostNumeric = b.dependency("numeric_conversion", .{}).path("");
const boostLogic = b.dependency("logic", .{}).path("");
const boostStaticStr = b.dependency("static_string", .{}).path("");
const boostIO = b.dependency("io", .{}).path("");
const boostJson = b.dependency("json", .{}).path("");
const boostContainer = b.dependency("container", .{}).path("");
const boostVariant2 = b.dependency("variant2", .{}).path("");
const boostWinApi = b.dependency("winapi", .{}).path("");
inline for (boost_libs) |name| {
const boostLib = b.dependency(name, .{}).path("include");
lib.addIncludePath(boostLib);
}

if (config.header_only) {
// zig-pkg bypass (no header-only)
const empty = b.addWriteFile("empty.cc", "// bypass");
// zig-pkg bypass (artifact need source file)
const empty = b.addWriteFile("empty.cc",
\\ #include <boost/config.hpp>
);
lib.step.dependOn(&empty.step);
lib.addCSourceFiles(.{
.root = empty.getDirectory(),
.files = &.{"empty.cc"},
.flags = cxxFlags,
});
} else {
const boostJson = b.dependency("json", .{}).path("");
const boostContainer = b.dependency("container", .{}).path("");
lib.addCSourceFiles(.{
.root = boostContainer,
.files = &.{
Expand All @@ -94,53 +121,11 @@ fn boostLibraries(b: *std.Build, config: Config) *std.Build.Step.Compile {
},
.flags = cxxFlags,
});
if (lib.rootModuleTarget().abi == .msvc)
lib.linkLibC()
else
lib.linkLibCpp();
}
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostCore.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAlg.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostConfig.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAssert.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostFunctional.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostMP11.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostTraits.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostRange.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostPreprocessor.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostHash.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostDescribe.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostMpl.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostStaticAssert.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostIterator.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostMove.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostDetail.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostThrow.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostTuple.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostPredef.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostCCheck.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostUtil.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostRegex.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostEndian.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAsio.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostAlign.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostSystem.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostIntrusive.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostHana.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostOutcome.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostBind.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostOptional.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostDateTime.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostSmartPtr.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostNumeric.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostLogic.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostStaticStr.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostIO.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostJson.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostContainer.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostVariant2.getPath(b), "include" }) });
lib.addIncludePath(.{ .cwd_relative = b.pathJoin(&.{ boostWinApi.getPath(b), "include" }) });

if (lib.rootModuleTarget().abi == .msvc)
lib.linkLibC()
else
lib.linkLibCpp();
return lib;
}

Expand Down
Loading

0 comments on commit 1e4f860

Please sign in to comment.