-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.zig
More file actions
106 lines (92 loc) · 3.47 KB
/
build.zig
File metadata and controls
106 lines (92 loc) · 3.47 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
// Copyright (C) 2021-2024 Chadwain Holness
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
const Build = std.Build;
const Module = Build.Module;
const Config = struct {
optimize: std.builtin.OptimizeMode,
target: Build.ResolvedTarget,
};
pub fn build(b: *Build) void {
const config = Config{
.optimize = b.standardOptimizeOption(.{}),
.target = b.standardTargetOptions(.{}),
};
const deps = .{
.named_character_references = b.dependency("named_character_references", .{
.target = config.target,
.optimize = config.optimize,
}),
};
const rem = b.addModule("rem", .{
.root_source_file = b.path("rem.zig"),
.target = config.target,
.optimize = config.optimize,
.imports = &.{
.{ .name = "named_character_references", .module = deps.named_character_references.module("named_character_references") },
},
});
addUnitTests(b, rem);
addHtml5LibTokenizerTests(b, config, rem);
addHtml5LibTreeConstructionTests(b, config, rem);
addExample(b, config, rem);
}
fn addUnitTests(b: *Build, rem: *Module) void {
const rem_unit_tests = b.addTest(.{
.name = "rem-unit-tests",
.root_module = rem,
});
b.installArtifact(rem_unit_tests);
const step = b.step("test", "Run unit tests");
step.dependOn(&b.addRunArtifact(rem_unit_tests).step);
}
fn addHtml5LibTokenizerTests(b: *Build, config: Config, rem: *Module) void {
const html5lib_tokenizer_tests = b.addTest(.{
.name = "html5lib-tokenizer-tests",
.root_module = b.createModule(.{
.root_source_file = b.path("test/html5lib-test-tokenizer.zig"),
.target = config.target,
.optimize = config.optimize,
.imports = &.{
.{ .name = "rem", .module = rem },
},
}),
});
b.installArtifact(html5lib_tokenizer_tests);
const step = b.step("test-tokenizer", "Run tokenizer tests from html5lib-tests");
step.dependOn(&b.addRunArtifact(html5lib_tokenizer_tests).step);
}
fn addHtml5LibTreeConstructionTests(b: *Build, config: Config, rem: *Module) void {
const html5lib_tree_construction_tests = b.addTest(.{
.name = "html5lib-tree-construction-tests",
.root_module = b.createModule(.{
.root_source_file = b.path("test/html5lib-test-tree-construction.zig"),
.target = config.target,
.optimize = config.optimize,
.imports = &.{
.{ .name = "rem", .module = rem },
},
}),
});
b.installArtifact(html5lib_tree_construction_tests);
const step = b.step("test-tree-construction", "Run tree construction tests from html5lib-tests");
step.dependOn(&b.addRunArtifact(html5lib_tree_construction_tests).step);
}
fn addExample(b: *Build, config: Config, rem: *Module) void {
const example = b.addExecutable(.{
.name = "example",
.root_module = b.createModule(.{
.root_source_file = b.path("./example.zig"),
.target = config.target,
.optimize = config.optimize,
.imports = &.{
.{ .name = "rem", .module = rem },
},
}),
});
b.installArtifact(example);
const step = b.step("example", "Run an example program");
step.dependOn(&b.addRunArtifact(example).step);
}