1
Fork 0
turbonss/build.zig

90 lines
3.0 KiB
Zig
Raw Normal View History

2022-02-09 16:19:20 +02:00
const std = @import("std");
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
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
2022-02-09 16:19:20 +02:00
const cmph = b.addStaticLibrary("cmph", null);
cmph.setTarget(target);
cmph.setBuildMode(mode);
cmph.linkLibC();
cmph.force_pic = true;
cmph.addCSourceFiles(&.{
"deps/cmph/src/bdz.c",
//"deps/cmph/src/bdz_gen_lookup_table.c",
"deps/cmph/src/bdz_ph.c",
//"deps/cmph/src/bm_numbers.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_manage.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_benchmark.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/djb2_hash.c",
"deps/cmph/src/fch_buckets.c",
"deps/cmph/src/fch.c",
//"deps/cmph/src/fnv_hash.c",
"deps/cmph/src/graph.c",
"deps/cmph/src/hash.c",
//"deps/cmph/src/hashtree.c"
"deps/cmph/src/jenkins_hash.c",
"deps/cmph/src/linear_string_map.c",
//"deps/cmph/src/main.c",
"deps/cmph/src/miller_rabin.c",
//"deps/cmph/src/sdbm_hash.c",
"deps/cmph/src/select.c",
"deps/cmph/src/vqueue.c",
//"deps/cmph/src/vstack.c",
//"deps/cmph/src/wingetopt.c",
}, &.{
"-W",
"-Wno-unused-function",
"-fomit-frame-pointer",
//"-DDEBUG",
});
cmph.addIncludeDir("deps/cmph/src");
cmph.addIncludeDir("include/deps/cmph");
2022-02-08 13:47:52 +02:00
const exe = b.addExecutable("init-exe", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
2022-02-09 16:19:20 +02:00
addCmphDeps(exe, cmph);
2022-02-08 13:47:52 +02:00
exe.install();
{
2022-02-15 10:49:03 +02:00
const turbonss_test = b.addTest("src/test_main.zig");
2022-02-09 16:19:20 +02:00
addCmphDeps(turbonss_test, cmph);
2022-02-08 13:47:52 +02:00
const test_step = b.step("test", "Run the tests");
test_step.dependOn(&turbonss_test.step);
}
2022-02-09 16:19:20 +02:00
{
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}
}
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);
exe.addIncludeDir("deps/cmph/src");
2022-02-08 13:47:52 +02:00
}