-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.zig
More file actions
158 lines (144 loc) · 4.38 KB
/
build.zig
File metadata and controls
158 lines (144 loc) · 4.38 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
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",
"charts",
"showcase",
"focus_form",
"modal",
"tooltip",
"tabs",
"clipboard_osc52",
"theming",
"slider",
"menu_bar",
"checkbox_radio",
"dropdown",
"toast",
"context_menu",
"form",
"markdown",
"animation",
"mouse",
"accessibility",
"wasm_app",
"diff_view",
"code_view",
"sortable_table",
"text_overflow",
"async_tasks",
"sub_program",
"layers",
"virtual_list",
"calendar",
"heatmap",
"gauge",
"flex_layout",
};
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",
"tests/chart_tests.zig",
"tests/viewport_tests.zig",
"tests/theme_tests.zig",
"tests/slider_tests.zig",
"tests/menu_bar_tests.zig",
"tests/checkbox_radio_tests.zig",
"tests/dropdown_tests.zig",
"tests/toast_tests.zig",
"tests/context_menu_tests.zig",
"tests/form_tests.zig",
"tests/markdown_tests.zig",
"tests/animation_tests.zig",
"tests/accessibility_tests.zig",
"tests/mouse_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);
// WASM library build (for browser-based terminals)
const wasm_step = b.step("wasm", "Build ZigZag as a WASM library");
const wasm_target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
});
const wasm_lib = b.addLibrary(.{
.name = "zigzag",
.root_module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = wasm_target,
.optimize = .ReleaseSmall,
}),
.linkage = .static,
});
b.installArtifact(wasm_lib);
wasm_step.dependOn(&wasm_lib.step);
}