-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
225 lines (196 loc) · 8.37 KB
/
Copy pathbuild.zig
File metadata and controls
225 lines (196 loc) · 8.37 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
const std = @import("std");
const IntLen = enum {
u16,
u32,
u64,
usize,
};
/// Configures build artifacts, helper steps, and test/check pipelines.
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,
});
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 stream_bench_exe = b.addExecutable(.{
.name = "zxml-stream-bench",
.root_module = b.createModule(.{
.root_source_file = b.path("bench/stream_bench.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 },
},
}),
});
const install_bench = b.addInstallArtifact(bench_exe, .{});
const install_stream_bench = b.addInstallArtifact(stream_bench_exe, .{});
b.getInstallStep().dependOn(&install_bench.step);
b.getInstallStep().dependOn(&install_stream_bench.step);
const bench_only_step = b.step("bench-only", "Build benchmark binaries only");
bench_only_step.dependOn(&install_bench.step);
bench_only_step.dependOn(&install_stream_bench.step);
b.installArtifact(tools_exe);
const tools_step = b.step("tools", "Run zxml-tools utility");
const bench_compare_step = b.step("bench-compare", "Benchmark against external parser implementations");
const bench_interleaved_step = b.step("bench-interleaved", "Compare two checkouts with interleaved benchmark runs");
const conformance_step = b.step("conformance", "Run XML conformance suites");
const docs_check_step = b.step("docs-check", "Validate markdown links and documented commands");
const examples_check_step = b.step("examples-check", "Compile and run all examples in test mode");
const tools_cmd = b.addRunArtifact(tools_exe);
const setup_parsers_cmd = b.addRunArtifact(tools_exe);
setup_parsers_cmd.addArg("setup-parsers");
const setup_fixtures_cmd = b.addRunArtifact(tools_exe);
setup_fixtures_cmd.addArg("setup-fixtures");
setup_fixtures_cmd.step.dependOn(&setup_parsers_cmd.step);
const compare_cmd = b.addRunArtifact(tools_exe);
compare_cmd.addArg("run-benchmarks");
compare_cmd.step.dependOn(&setup_fixtures_cmd.step);
const interleaved_cmd = b.addRunArtifact(tools_exe);
interleaved_cmd.addArg("compare-worktrees");
const conformance_cmd = b.addRunArtifact(tools_exe);
conformance_cmd.addArg("run-conformance");
conformance_cmd.addArg("--strict");
const docs_check_cmd = b.addRunArtifact(tools_exe);
docs_check_cmd.addArg("docs-check");
const examples_check_cmd = b.addRunArtifact(tools_exe);
examples_check_cmd.addArg("examples-check");
tools_step.dependOn(&tools_cmd.step);
bench_compare_step.dependOn(&compare_cmd.step);
bench_interleaved_step.dependOn(&interleaved_cmd.step);
conformance_step.dependOn(&conformance_cmd.step);
docs_check_step.dependOn(&docs_check_cmd.step);
examples_check_step.dependOn(&examples_check_cmd.step);
tools_cmd.step.dependOn(b.getInstallStep());
setup_parsers_cmd.step.dependOn(b.getInstallStep());
setup_fixtures_cmd.step.dependOn(b.getInstallStep());
compare_cmd.step.dependOn(b.getInstallStep());
interleaved_cmd.step.dependOn(b.getInstallStep());
conformance_cmd.step.dependOn(b.getInstallStep());
docs_check_cmd.step.dependOn(b.getInstallStep());
examples_check_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
tools_cmd.addArgs(args);
compare_cmd.addArgs(args);
interleaved_cmd.addArgs(args);
conformance_cmd.addArgs(args);
docs_check_cmd.addArgs(args);
examples_check_cmd.addArgs(args);
}
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);
const example_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("examples/basic_parse.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_example_tests = b.addRunArtifact(example_tests);
const bench_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("bench/runners/run_parse.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_bench_tests = b.addRunArtifact(bench_tests);
const tools_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("tools/scripts.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_tools_tests = b.addRunArtifact(tools_tests);
const tools_common_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("tools/common.zig"),
.target = target,
.optimize = optimize,
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_tools_common_tests = b.addRunArtifact(tools_common_tests);
const conformance_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("tools/conformance.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_conformance_tests = b.addRunArtifact(conformance_tests);
const public_api_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("tests/public_api.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zxml", .module = mod },
},
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_public_api_tests = b.addRunArtifact(public_api_tests);
const public_api_step = b.step("test-public-api", "Run exhaustive consumer-facing public API tests");
public_api_step.dependOn(&run_public_api_tests.step);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_example_tests.step);
test_step.dependOn(&run_bench_tests.step);
test_step.dependOn(&run_tools_tests.step);
test_step.dependOn(&run_tools_common_tests.step);
test_step.dependOn(&run_conformance_tests.step);
test_step.dependOn(&run_public_api_tests.step);
const ship_check_step = b.step("ship-check", "Run release-readiness checks (test + docs + examples)");
ship_check_step.dependOn(test_step);
ship_check_step.dependOn(docs_check_step);
ship_check_step.dependOn(examples_check_step);
}