-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.zig
More file actions
107 lines (93 loc) · 3.65 KB
/
Copy pathbuild.zig
File metadata and controls
107 lines (93 loc) · 3.65 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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);
options.addOption(bool, "is_wine", b.enable_wine);
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 },
},
.target = target,
});
var main_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
}),
.filters = if (b.option([]const u8, "test-filter", "test filter")) |f|
try b.allocator.dupe([]const u8, &.{f})
else
&.{},
});
main_tests.root_module.addImport("simdjzon", mod);
main_tests.root_module.addImport("build_options", options_mod);
main_tests.use_llvm = true; // TODO remove when #26 is resolved
b.installArtifact(main_tests);
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_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
exe.root_module.addImport("simdjzon", mod);
exe.use_llvm = true; // TODO remove when #26 is resolved
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
run_cmd.addPassthruArgs();
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const twitterbench = b.addExecutable(.{
.name = "twitterbench",
.root_module = b.createModule(.{
.root_source_file = b.path("bench/twitter/main.zig"),
.target = target,
.optimize = optimize,
}),
});
twitterbench.root_module.addImport("simdjzon", mod);
twitterbench.use_llvm = true; // TODO remove when #26 is resolved
b.installArtifact(twitterbench);
const run_twitter_bench = b.addRunArtifact(twitterbench);
run_twitter_bench.addPassthruArgs();
const run_twitter_bench_step = b.step("twitter-bench", "Run the twitter-bench");
run_twitter_bench_step.dependOn(&run_twitter_bench.step);
const exe_check = b.addExecutable(.{ .name = "check", .root_module = mod });
const check = b.step("check", "Check if everything compiles");
check.dependOn(&exe_check.step);
check.dependOn(test_step);
}