-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.zig
87 lines (74 loc) · 2.8 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const step_128 = b.option(
bool,
"step-128",
"process 128 bytes of input per StructuralIndexer step. defaults to 64 if this flag is not present. ",
) orelse false;
const ondemand = b.option(
bool,
"ondemand",
"use the ondemand parser for validation",
) orelse false;
const ondemand_read_cap = b.option(
u16,
"ondemand-read-cap",
"the capacity of the ondemand read buffer. defaults to 4096 (4 Kb)",
) orelse 4096;
const log_level = b.option(
std.log.Level,
"log-level",
"The log level for the application. default .err",
) orelse .err;
const options = b.addOptions();
options.addOption(bool, "step_128", step_128);
options.addOption(bool, "ondemand", ondemand);
options.addOption(u16, "ondemand_read_cap", ondemand_read_cap);
options.addOption(std.log.Level, "log_level", log_level);
const options_mod = options.createModule();
const mod = b.addModule("simdjzon", .{
.root_source_file = b.path("src/simdjzon.zig"),
.imports = &.{
.{ .name = "build_options", .module = options_mod },
},
});
var main_tests = b.addTest(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
});
main_tests.root_module.addImport("simdjzon", mod);
// main_tests.setFilter("tape build 1");
const test_step = b.step("test", "Run tests");
const main_tests_run = b.addRunArtifact(main_tests);
main_tests_run.has_side_effects = true;
test_step.dependOn(&main_tests_run.step);
const exe = b.addExecutable(.{
.name = "simdjzon",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("simdjzon", mod);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args|
run_cmd.addArgs(args);
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const twitterbench = b.addExecutable(.{
.name = "twitterbench",
.root_source_file = b.path("bench/twitter/main.zig"),
.target = target,
.optimize = optimize,
});
twitterbench.root_module.addImport("simdjzon", mod);
b.installArtifact(twitterbench);
const run_twitter_bench = b.addRunArtifact(twitterbench);
if (b.args) |args| run_twitter_bench.addArgs(args);
const run_twitter_bench_step = b.step("twitter-bench", "Run the twitter-bench");
run_twitter_bench_step.dependOn(&run_twitter_bench.step);
}