-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
87 lines (74 loc) · 2.61 KB
/
build.zig
File metadata and controls
87 lines (74 loc) · 2.61 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Library module
const yaml_mod = b.addModule("yaml", .{
.root_source_file = b.path("src/yaml.zig"),
.target = target,
.optimize = optimize,
});
const lib = b.addLibrary(.{
.name = "yaml",
.root_module = yaml_mod,
});
const lib_install = b.addInstallArtifact(lib, .{});
b.getInstallStep().dependOn(&lib_install.step);
// Create test executable
const main_tests = b.addTest(.{
.name = "yaml-test",
.root_module = yaml_mod,
});
const run_main_tests = b.addRunArtifact(main_tests);
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_main_tests.step);
// Additional test files
const test_files = [_][]const u8{
"test/scanner_test.zig",
"test/value_test.zig",
"test/parser_test.zig",
"test/api_test.zig",
"test/spec_examples.zig",
"test/text_inputs.zig",
"test/stringify_test.zig",
"test/simple_indent_test.zig",
"test/debug_test.zig",
"test/kubeconfig_test.zig",
};
for (test_files) |test_file| {
const t = b.addTest(.{
.name = std.fs.path.basename(test_file),
.root_module = b.createModule(.{
.root_source_file = b.path(test_file),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "yaml", .module = yaml_mod },
},
}),
});
const run_t = b.addRunArtifact(t);
test_step.dependOn(&run_t.step);
}
// YAML Test Suite runner executable
const test_suite_exe = b.addExecutable(.{
.name = "yaml-test-suite",
.root_module = b.createModule(.{
.root_source_file = b.path("test/yaml_test_suite.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "yaml", .module = yaml_mod },
},
}),
});
const test_suite_install = b.addInstallArtifact(test_suite_exe, .{});
b.getInstallStep().dependOn(&test_suite_install.step);
// Step to run the test suite (requires yaml-test-suite directory)
const run_test_suite = b.addRunArtifact(test_suite_exe);
if (b.args) |args| {
run_test_suite.addArgs(args);
}
const test_suite_step = b.step("test-suite", "Run official YAML test suite");
test_suite_step.dependOn(&run_test_suite.step);
}