-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.zig
More file actions
97 lines (86 loc) · 2.74 KB
/
build.zig
File metadata and controls
97 lines (86 loc) · 2.74 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Main library module
const zigzag_mod = b.addModule("zigzag", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// Examples
const examples = [_][]const u8{
"hello_world",
"counter",
"todo_list",
"text_editor",
"file_browser",
"dashboard",
"showcase",
"focus_form",
"modal",
"tooltip",
"tabs",
};
for (examples) |example_name| {
const example = b.addExecutable(.{
.name = example_name,
.root_module = b.createModule(.{
.root_source_file = b.path(b.fmt("examples/{s}.zig", .{example_name})),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zigzag", .module = zigzag_mod },
},
}),
});
b.installArtifact(example);
const run_cmd = b.addRunArtifact(example);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(
b.fmt("run-{s}", .{example_name}),
b.fmt("Run the {s} example", .{example_name}),
);
run_step.dependOn(&run_cmd.step);
}
// Tests
const test_files = [_][]const u8{
"tests/style_tests.zig",
"tests/input_tests.zig",
"tests/layout_tests.zig",
"tests/unicode_tests.zig",
"tests/program_tests.zig",
"tests/focus_tests.zig",
"tests/modal_tests.zig",
"tests/tooltip_tests.zig",
"tests/tab_group_tests.zig",
};
const test_step = b.step("test", "Run unit tests");
for (test_files) |test_file| {
const unit_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path(test_file),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zigzag", .module = zigzag_mod },
},
}),
});
const run_unit_tests = b.addRunArtifact(unit_tests);
test_step.dependOn(&run_unit_tests.step);
}
// Also run tests on the main library
const lib_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_lib_tests = b.addRunArtifact(lib_tests);
test_step.dependOn(&run_lib_tests.step);
}