-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
112 lines (96 loc) · 3.57 KB
/
build.zig
File metadata and controls
112 lines (96 loc) · 3.57 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
108
109
110
111
112
const std = @import("std");
const IntLen = enum {
u16,
u32,
u64,
usize,
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const intlen = b.option(IntLen, "intlen", "Integer width used for DOM spans and node indexes") orelse .u32;
const config_options = b.addOptions();
config_options.addOption(IntLen, "intlen", intlen);
const mod = b.addModule("zxml", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// Mirror htmlparser-style config injection so index-width selection stays a
// build-time constant all the way into the parser types.
mod.addOptions("config", config_options);
const bench_exe = b.addExecutable(.{
.name = "zxml-bench",
.root_module = b.createModule(.{
.root_source_file = b.path("bench/bench.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
});
const ours_runner_exe = b.addExecutable(.{
.name = "ours_runner",
.root_module = b.createModule(.{
.root_source_file = b.path("bench/runners/ours_runner.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
});
const tools_exe = b.addExecutable(.{
.name = "zxml-tools",
.root_module = b.createModule(.{
.root_source_file = b.path("tools/scripts.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
});
b.installArtifact(bench_exe);
b.installArtifact(ours_runner_exe);
b.installArtifact(tools_exe);
const bench_step = b.step("bench", "Run local zxml benchmark");
const tools_step = b.step("tools", "Run zxml-tools utility");
const bench_compare_step = b.step("bench-compare", "Run parser comparison benchmarks");
const conformance_step = b.step("conformance", "Run XML conformance suites");
const bench_cmd = b.addRunArtifact(bench_exe);
const tools_cmd = b.addRunArtifact(tools_exe);
const compare_cmd = b.addRunArtifact(tools_exe);
compare_cmd.addArg("run-benchmarks");
const conformance_cmd = b.addRunArtifact(tools_exe);
conformance_cmd.addArg("run-conformance");
bench_step.dependOn(&bench_cmd.step);
tools_step.dependOn(&tools_cmd.step);
bench_compare_step.dependOn(&compare_cmd.step);
conformance_step.dependOn(&conformance_cmd.step);
bench_cmd.step.dependOn(b.getInstallStep());
tools_cmd.step.dependOn(b.getInstallStep());
compare_cmd.step.dependOn(b.getInstallStep());
conformance_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
bench_cmd.addArgs(args);
tools_cmd.addArgs(args);
compare_cmd.addArgs(args);
conformance_cmd.addArgs(args);
} else {
bench_cmd.addArg("bench/fixtures/note.xml");
bench_cmd.addArg("1");
tools_cmd.addArg("--help");
}
const mod_tests = b.addTest(.{
.root_module = mod,
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_mod_tests = b.addRunArtifact(mod_tests);
if (b.args) |args| {
run_mod_tests.addArgs(args);
}
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
}