2022-02-09 16:19:20 +02:00
|
|
|
const std = @import("std");
|
2022-07-09 17:33:13 +03:00
|
|
|
const builtin = std.builtin;
|
2022-02-09 16:19:20 +02:00
|
|
|
const zbs = std.build;
|
2022-02-08 13:47:52 +02:00
|
|
|
|
2022-02-09 16:19:20 +02:00
|
|
|
pub fn build(b: *zbs.Builder) void {
|
2022-02-08 13:47:52 +02:00
|
|
|
const target = b.standardTargetOptions(.{});
|
2023-02-02 17:04:21 +02:00
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
2022-02-08 13:47:52 +02:00
|
|
|
|
2022-07-11 04:54:55 +03:00
|
|
|
const strip = b.option(bool, "strip", "Omit debug information") orelse false;
|
|
|
|
|
2023-02-02 17:04:21 +02:00
|
|
|
const cmph = b.addStaticLibrary(.{
|
|
|
|
.name = "cmph",
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-02-09 16:19:20 +02:00
|
|
|
cmph.linkLibC();
|
|
|
|
cmph.addCSourceFiles(&.{
|
|
|
|
"deps/cmph/src/bdz.c",
|
|
|
|
"deps/cmph/src/bdz_ph.c",
|
|
|
|
"deps/cmph/src/bmz8.c",
|
|
|
|
"deps/cmph/src/bmz.c",
|
|
|
|
"deps/cmph/src/brz.c",
|
|
|
|
"deps/cmph/src/buffer_entry.c",
|
|
|
|
"deps/cmph/src/buffer_manager.c",
|
|
|
|
"deps/cmph/src/chd.c",
|
|
|
|
"deps/cmph/src/chd_ph.c",
|
|
|
|
"deps/cmph/src/chm.c",
|
|
|
|
"deps/cmph/src/cmph.c",
|
|
|
|
"deps/cmph/src/cmph_structs.c",
|
|
|
|
"deps/cmph/src/compressed_rank.c",
|
|
|
|
"deps/cmph/src/compressed_seq.c",
|
|
|
|
"deps/cmph/src/fch_buckets.c",
|
|
|
|
"deps/cmph/src/fch.c",
|
|
|
|
"deps/cmph/src/graph.c",
|
|
|
|
"deps/cmph/src/hash.c",
|
|
|
|
"deps/cmph/src/jenkins_hash.c",
|
|
|
|
"deps/cmph/src/linear_string_map.c",
|
|
|
|
"deps/cmph/src/miller_rabin.c",
|
|
|
|
"deps/cmph/src/select.c",
|
|
|
|
"deps/cmph/src/vqueue.c",
|
|
|
|
}, &.{
|
|
|
|
"-W",
|
|
|
|
"-Wno-unused-function",
|
|
|
|
//"-DDEBUG",
|
|
|
|
});
|
2022-07-11 04:54:55 +03:00
|
|
|
cmph.strip = strip;
|
2022-11-30 11:56:02 +02:00
|
|
|
cmph.want_lto = true;
|
2022-07-20 14:30:48 +03:00
|
|
|
cmph.compress_debug_sections = .zlib;
|
2022-07-04 14:31:15 +03:00
|
|
|
cmph.omit_frame_pointer = true;
|
2023-08-21 13:50:52 +03:00
|
|
|
cmph.addIncludePath(.{ .path = "deps/cmph/src" });
|
2023-06-20 12:51:10 +03:00
|
|
|
cmph.addConfigHeader(b.addConfigHeader(.{}, .{
|
|
|
|
.HAVE_DLFCN_H = true,
|
|
|
|
.HAVE_GETOPT_H = true,
|
|
|
|
.HAVE_INTTYPES_H = true,
|
|
|
|
.HAVE_MATH_H = true,
|
|
|
|
.HAVE_MEMORY_H = true,
|
|
|
|
.HAVE_STDINT_H = true,
|
|
|
|
.HAVE_STDLIB_H = true,
|
|
|
|
.HAVE_STRINGS_H = true,
|
|
|
|
.HAVE_STRING_H = true,
|
|
|
|
.HAVE_SYS_STAT_H = true,
|
|
|
|
.HAVE_SYS_TYPES_H = true,
|
|
|
|
.HAVE_UNISTD_H = true,
|
|
|
|
.LT_OBJDIR = ".libs/",
|
|
|
|
.PACKAGE = "cmph",
|
|
|
|
.PACKAGE_BUGREPORT = "",
|
|
|
|
.PACKAGE_NAME = "cmph",
|
|
|
|
.PACKAGE_STRING = "cmph 2.0.2",
|
|
|
|
.PACKAGE_TARNAME = "cmph",
|
|
|
|
.PACKAGE_URL = "",
|
|
|
|
.PACKAGE_VERSION = "2.0.2",
|
|
|
|
.STDC_HEADERS = 1,
|
|
|
|
.VERSION = "2.0.2",
|
|
|
|
}));
|
2022-02-09 16:19:20 +02:00
|
|
|
|
2023-02-02 17:04:21 +02:00
|
|
|
const bdz = b.addStaticLibrary(.{
|
|
|
|
.name = "bdz",
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-07-09 17:33:13 +03:00
|
|
|
bdz.linkLibC();
|
|
|
|
bdz.addCSourceFiles(&.{
|
2022-07-09 18:15:04 +03:00
|
|
|
"deps/bdz_read.c",
|
2022-07-09 17:33:13 +03:00
|
|
|
"deps/cmph/src/hash.c",
|
|
|
|
"deps/cmph/src/jenkins_hash.c",
|
|
|
|
}, &.{
|
|
|
|
"-W",
|
|
|
|
"-Wno-unused-function",
|
2022-11-25 14:50:42 +02:00
|
|
|
"-fvisibility=hidden",
|
2022-11-30 11:56:02 +02:00
|
|
|
"-fpic",
|
2022-07-09 17:33:13 +03:00
|
|
|
//"-DDEBUG",
|
|
|
|
});
|
|
|
|
bdz.omit_frame_pointer = true;
|
2023-08-21 13:50:52 +03:00
|
|
|
bdz.addIncludePath(.{ .path = "deps/cmph/src" });
|
|
|
|
bdz.addIncludePath(.{ .path = "include/deps/cmph" });
|
2022-11-30 11:56:02 +02:00
|
|
|
bdz.want_lto = true;
|
2022-07-09 17:33:13 +03:00
|
|
|
|
2022-03-22 08:57:57 +02:00
|
|
|
{
|
2023-02-02 17:04:21 +02:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "turbonss-unix2db",
|
|
|
|
.root_source_file = .{ .path = "src/turbonss-unix2db.zig" },
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-07-20 14:30:48 +03:00
|
|
|
exe.compress_debug_sections = .zlib;
|
2022-07-11 04:54:55 +03:00
|
|
|
exe.strip = strip;
|
2022-11-30 11:56:02 +02:00
|
|
|
exe.want_lto = true;
|
2022-03-22 08:57:57 +02:00
|
|
|
addCmphDeps(exe, cmph);
|
2023-04-12 22:24:20 +03:00
|
|
|
b.installArtifact(exe);
|
2022-03-22 08:57:57 +02:00
|
|
|
}
|
2022-02-08 13:47:52 +02:00
|
|
|
|
2022-07-06 09:26:24 +03:00
|
|
|
{
|
2023-02-02 17:04:21 +02:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "turbonss-analyze",
|
|
|
|
.root_source_file = .{ .path = "src/turbonss-analyze.zig" },
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-07-20 14:30:48 +03:00
|
|
|
exe.compress_debug_sections = .zlib;
|
2022-07-11 04:54:55 +03:00
|
|
|
exe.strip = strip;
|
2022-11-30 11:56:02 +02:00
|
|
|
exe.want_lto = true;
|
2023-04-12 22:24:20 +03:00
|
|
|
b.installArtifact(exe);
|
2022-07-06 09:26:24 +03:00
|
|
|
}
|
|
|
|
|
2022-07-28 07:00:18 +03:00
|
|
|
{
|
2023-02-02 17:04:21 +02:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "turbonss-makecorpus",
|
|
|
|
.root_source_file = .{ .path = "src/turbonss-makecorpus.zig" },
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-08-23 15:50:00 +03:00
|
|
|
exe.compress_debug_sections = .zlib;
|
2022-07-28 07:00:18 +03:00
|
|
|
exe.strip = strip;
|
2022-11-30 11:56:02 +02:00
|
|
|
exe.want_lto = true;
|
2023-04-12 22:24:20 +03:00
|
|
|
b.installArtifact(exe);
|
2022-07-28 07:00:18 +03:00
|
|
|
}
|
|
|
|
|
2022-07-14 11:09:01 +03:00
|
|
|
{
|
2023-02-02 17:04:21 +02:00
|
|
|
const exe = b.addExecutable(.{
|
|
|
|
.name = "turbonss-getent",
|
|
|
|
.root_source_file = .{ .path = "src/turbonss-getent.zig" },
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-07-20 14:30:48 +03:00
|
|
|
exe.compress_debug_sections = .zlib;
|
2022-07-14 11:09:01 +03:00
|
|
|
exe.strip = strip;
|
2022-11-30 11:56:02 +02:00
|
|
|
exe.want_lto = true;
|
2022-07-14 11:09:01 +03:00
|
|
|
exe.linkLibC();
|
|
|
|
exe.linkLibrary(bdz);
|
2023-08-21 13:50:52 +03:00
|
|
|
exe.addIncludePath(.{ .path = "deps/cmph/src" });
|
2023-04-12 22:24:20 +03:00
|
|
|
b.installArtifact(exe);
|
2022-07-14 11:09:01 +03:00
|
|
|
}
|
|
|
|
|
2022-07-09 17:33:13 +03:00
|
|
|
{
|
2023-02-02 17:04:21 +02:00
|
|
|
const so = b.addSharedLibrary(.{
|
|
|
|
.name = "nss_turbo",
|
|
|
|
.root_source_file = .{ .path = "src/libnss.zig" },
|
2023-06-20 13:01:32 +03:00
|
|
|
.version = std.SemanticVersion{
|
2022-07-09 17:33:13 +03:00
|
|
|
.major = 2,
|
|
|
|
.minor = 0,
|
|
|
|
.patch = 0,
|
|
|
|
},
|
2023-02-02 17:04:21 +02:00
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
2022-07-09 17:33:13 +03:00
|
|
|
});
|
2022-07-20 14:30:48 +03:00
|
|
|
so.compress_debug_sections = .zlib;
|
2022-07-11 04:54:55 +03:00
|
|
|
so.strip = strip;
|
2022-11-30 11:56:02 +02:00
|
|
|
so.want_lto = true;
|
2022-07-09 17:33:13 +03:00
|
|
|
so.linkLibC();
|
|
|
|
so.linkLibrary(bdz);
|
2023-08-21 13:50:52 +03:00
|
|
|
so.addIncludePath(.{ .path = "deps/cmph/src" });
|
2023-04-12 22:24:20 +03:00
|
|
|
b.installArtifact(so);
|
2022-07-09 17:33:13 +03:00
|
|
|
}
|
|
|
|
|
2022-02-08 13:47:52 +02:00
|
|
|
{
|
2023-02-02 17:04:21 +02:00
|
|
|
const src_test = b.addTest(.{
|
|
|
|
.root_source_file = .{ .path = "src/test_all.zig" },
|
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
2022-05-25 09:42:42 +03:00
|
|
|
addCmphDeps(src_test, cmph);
|
2022-02-08 13:47:52 +02:00
|
|
|
const test_step = b.step("test", "Run the tests");
|
2022-05-25 09:42:42 +03:00
|
|
|
test_step.dependOn(&src_test.step);
|
2022-02-08 13:47:52 +02:00
|
|
|
}
|
2022-02-09 16:19:20 +02:00
|
|
|
}
|
2022-02-08 13:47:52 +02:00
|
|
|
|
2022-02-09 16:19:20 +02:00
|
|
|
fn addCmphDeps(exe: *zbs.LibExeObjStep, cmph: *zbs.LibExeObjStep) void {
|
|
|
|
exe.linkLibC();
|
|
|
|
exe.linkLibrary(cmph);
|
2023-08-21 13:50:52 +03:00
|
|
|
exe.addIncludePath(.{ .path = "deps/cmph/src" });
|
2022-02-08 13:47:52 +02:00
|
|
|
}
|