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(.{});
|
|
|
|
const mode = b.standardReleaseOptions();
|
2022-11-20 13:33:05 +02:00
|
|
|
b.use_stage1 = true;
|
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;
|
|
|
|
|
2022-02-09 16:19:20 +02:00
|
|
|
const cmph = b.addStaticLibrary("cmph", null);
|
|
|
|
cmph.setTarget(target);
|
|
|
|
cmph.setBuildMode(mode);
|
|
|
|
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;
|
2022-11-20 13:33:05 +02:00
|
|
|
cmph.addIncludePath("deps/cmph/src");
|
|
|
|
cmph.addIncludePath("include/deps/cmph");
|
2022-02-09 16:19:20 +02:00
|
|
|
|
2022-07-09 17:33:13 +03:00
|
|
|
const bdz = b.addStaticLibrary("bdz", null);
|
|
|
|
bdz.setTarget(target);
|
|
|
|
bdz.setBuildMode(mode);
|
|
|
|
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;
|
2022-11-20 13:33:05 +02:00
|
|
|
bdz.addIncludePath("deps/cmph/src");
|
|
|
|
bdz.addIncludePath("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
|
|
|
{
|
2022-07-15 08:11:05 +03:00
|
|
|
const exe = b.addExecutable("turbonss-unix2db", "src/turbonss-unix2db.zig");
|
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
|
|
|
exe.setTarget(target);
|
|
|
|
exe.setBuildMode(mode);
|
|
|
|
addCmphDeps(exe, cmph);
|
|
|
|
exe.install();
|
|
|
|
}
|
2022-02-08 13:47:52 +02:00
|
|
|
|
2022-07-06 09:26:24 +03:00
|
|
|
{
|
2022-07-15 08:11:05 +03:00
|
|
|
const exe = b.addExecutable("turbonss-analyze", "src/turbonss-analyze.zig");
|
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-07-06 09:26:24 +03:00
|
|
|
exe.setTarget(target);
|
|
|
|
exe.setBuildMode(mode);
|
|
|
|
exe.install();
|
|
|
|
}
|
|
|
|
|
2022-07-28 07:00:18 +03:00
|
|
|
{
|
|
|
|
const exe = b.addExecutable("turbonss-makecorpus", "src/turbonss-makecorpus.zig");
|
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;
|
2022-07-28 07:00:18 +03:00
|
|
|
exe.setTarget(target);
|
|
|
|
exe.setBuildMode(mode);
|
|
|
|
exe.install();
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:09:01 +03:00
|
|
|
{
|
2022-07-15 08:11:05 +03:00
|
|
|
const exe = b.addExecutable("turbonss-getent", "src/turbonss-getent.zig");
|
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);
|
2022-11-20 13:33:05 +02:00
|
|
|
exe.addIncludePath("deps/cmph/src");
|
2022-07-14 11:09:01 +03:00
|
|
|
exe.setTarget(target);
|
|
|
|
exe.setBuildMode(mode);
|
|
|
|
exe.install();
|
|
|
|
}
|
|
|
|
|
2022-07-09 17:33:13 +03:00
|
|
|
{
|
|
|
|
const so = b.addSharedLibrary("nss_turbo", "src/libnss.zig", .{
|
|
|
|
.versioned = builtin.Version{
|
|
|
|
.major = 2,
|
|
|
|
.minor = 0,
|
|
|
|
.patch = 0,
|
|
|
|
},
|
|
|
|
});
|
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);
|
2022-11-20 13:33:05 +02:00
|
|
|
so.addIncludePath("deps/cmph/src");
|
2022-07-09 17:33:13 +03:00
|
|
|
so.setTarget(target);
|
|
|
|
so.setBuildMode(mode);
|
|
|
|
so.install();
|
|
|
|
}
|
|
|
|
|
2022-02-08 13:47:52 +02:00
|
|
|
{
|
2022-05-25 09:42:42 +03:00
|
|
|
const src_test = b.addTest("src/test_all.zig");
|
|
|
|
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);
|
2022-11-20 13:33:05 +02:00
|
|
|
exe.addIncludePath("deps/cmph/src");
|
2022-02-08 13:47:52 +02:00
|
|
|
}
|