-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
46 lines (35 loc) · 1.38 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const std = @import("std");
pub fn build(b: *std.Build) void {
// OPTIONS
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const fast_fallback = b.option(bool, "gxhash_fast_fallback", "Use Wyhash when hardware AES is not available") orelse false;
const hybrid = b.option(bool, "gxhash_hybrid", "Use V-AES to compress large inputs on x86 when available") orelse true;
// MODULE
const options = b.addOptions();
options.addOption(bool, "fast_fallback", fast_fallback);
options.addOption(bool, "hybrid", hybrid);
const options_module = options.createModule();
const gxhash = b.addModule("gxhash", .{
.root_source_file = b.path("src/root.zig"),
.imports = &.{.{ .name = "options", .module = options_module }},
});
// LIBRARY
const lib = b.addStaticLibrary(.{
.name = "zig-gxhash",
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(lib);
// TESTS
const tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
});
tests.root_module.addImport("gxhash", gxhash);
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests.step);
}