-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
217 lines (168 loc) · 11.6 KB
/
build.zig
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
// File: build.zig
// Created Time: 2023-01-07
// Author: sjinzh (sjinzh@gmail.com)
const std = @import("std");
// Zig Version: 0.11.0-dev.3944+2e424e019
// Zig Build Command: zig build -Doptimize=ReleaseFast
// Zig Run Command: zig build run_* -Doptimize=ReleaseFast
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const group_name_path = .{
// Source File: "chapter_computational_complexity/time_complexity.zig"
// Run Command: zig build run_time_complexity -Doptimize=ReleaseFast
.{ .name = "time_complexity", .path = "chapter_computational_complexity/time_complexity.zig" },
// Source File: "chapter_computational_complexity/worst_best_time_complexity.zig"
// Run Command: zig build run_worst_best_time_complexity -Doptimize=ReleaseFast
.{ .name = "worst_best_time_complexity", .path = "chapter_computational_complexity/worst_best_time_complexity.zig" },
// Source File: "chapter_computational_complexity/space_complexity.zig"
// Run Command: zig build run_space_complexity -Doptimize=ReleaseFast
.{ .name = "space_complexity", .path = "chapter_computational_complexity/space_complexity.zig" },
// Source File: "chapter_array_and_linkedlist/array.zig"
// Run Command: zig build run_array -Doptimize=ReleaseFast
.{ .name = "array", .path = "chapter_array_and_linkedlist/array.zig" },
// Source File: "chapter_array_and_linkedlist/linked_list.zig"
// Run Command: zig build run_linked_list -Doptimize=ReleaseFast
.{ .name = "linked_list", .path = "chapter_array_and_linkedlist/linked_list.zig" },
// Source File: "chapter_array_and_linkedlist/list.zig"
// Run Command: zig build run_list -Doptimize=ReleaseFast
.{ .name = "list", .path = "chapter_array_and_linkedlist/list.zig" },
// Source File: "chapter_array_and_linkedlist/my_list.zig"
// Run Command: zig build run_my_list -Doptimize=ReleaseFast
.{ .name = "my_list", .path = "chapter_array_and_linkedlist/my_list.zig" },
// Source File: "chapter_stack_and_queue/stack.zig"
// Run Command: zig build run_stack -Doptimize=ReleaseFast
.{ .name = "stack", .path = "chapter_stack_and_queue/stack.zig" },
// Source File: "chapter_stack_and_queue/linkedlist_stack.zig"
// Run Command: zig build run_linkedlist_stack -Doptimize=ReleaseFast
.{ .name = "linkedlist_stack", .path = "chapter_stack_and_queue/linkedlist_stack.zig" },
// Source File: "chapter_stack_and_queue/array_stack.zig"
// Run Command: zig build run_array_stack -Doptimize=ReleaseFast
.{ .name = "array_stack", .path = "chapter_stack_and_queue/array_stack.zig" },
// Source File: "chapter_stack_and_queue/queue.zig"
// Run Command: zig build run_queue -Doptimize=ReleaseFast
.{ .name = "queue", .path = "chapter_stack_and_queue/queue.zig" },
// Source File: "chapter_stack_and_queue/array_queue.zig"
// Run Command: zig build run_array_queue -Doptimize=ReleaseFast
.{ .name = "array_queue", .path = "chapter_stack_and_queue/array_queue.zig" },
// Source File: "chapter_stack_and_queue/linkedlist_queue.zig"
// Run Command: zig build run_linkedlist_queue -Doptimize=ReleaseFast
.{ .name = "linkedlist_queue", .path = "chapter_stack_and_queue/linkedlist_queue.zig" },
// Source File: "chapter_stack_and_queue/deque.zig"
// Run Command: zig build run_deque -Doptimize=ReleaseFast
.{ .name = "deque", .path = "chapter_stack_and_queue/deque.zig" },
// Source File: "chapter_stack_and_queue/linkedlist_deque.zig"
// Run Command: zig build run_linkedlist_deque -Doptimize=ReleaseFast
.{ .name = "linkedlist_deque", .path = "chapter_stack_and_queue/linkedlist_deque.zig" },
// Source File: "chapter_hashing/hash_map.zig"
// Run Command: zig build run_hash_map -Doptimize=ReleaseFast
.{ .name = "hash_map", .path = "chapter_hashing/hash_map.zig" },
// Source File: "chapter_hashing/array_hash_map.zig"
// Run Command: zig build run_array_hash_map -Doptimize=ReleaseFast
.{ .name = "array_hash_map", .path = "chapter_hashing/array_hash_map.zig" },
// Source File: "chapter_tree/binary_tree.zig"
// Run Command: zig build run_binary_tree -Doptimize=ReleaseFast
.{ .name = "binary_tree", .path = "chapter_tree/binary_tree.zig" },
// Source File: "chapter_tree/binary_tree_bfs.zig"
// Run Command: zig build run_binary_tree_bfs -Doptimize=ReleaseFast
.{ .name = "binary_tree_bfs", .path = "chapter_tree/binary_tree_bfs.zig" },
// Source File: "chapter_tree/binary_tree_dfs.zig"
// Run Command: zig build run_binary_tree_dfs -Doptimize=ReleaseFast
.{ .name = "binary_tree_dfs", .path = "chapter_tree/binary_tree_dfs.zig" },
// Source File: "chapter_tree/binary_search_tree.zig"
// Run Command: zig build run_binary_search_tree -Doptimize=ReleaseFast
.{ .name = "binary_search_tree", .path = "chapter_tree/binary_search_tree.zig" },
// Source File: "chapter_tree/avl_tree.zig"
// Run Command: zig build run_avl_tree -Doptimize=ReleaseFast
.{ .name = "avl_tree", .path = "chapter_tree/avl_tree.zig" },
// Source File: "chapter_heap/heap.zig"
// Run Command: zig build run_heap -Doptimize=ReleaseFast
.{ .name = "heap", .path = "chapter_heap/heap.zig" },
// Source File: "chapter_heap/my_heap.zig"
// Run Command: zig build run_my_heap -Doptimize=ReleaseFast
.{ .name = "my_heap", .path = "chapter_heap/my_heap.zig" },
// Source File: "chapter_searching/linear_search.zig"
// Run Command: zig build run_linear_search -Doptimize=ReleaseFast
.{ .name = "linear_search", .path = "chapter_searching/linear_search.zig" },
// Source File: "chapter_searching/binary_search.zig"
// Run Command: zig build run_binary_search -Doptimize=ReleaseFast
.{ .name = "binary_search", .path = "chapter_searching/binary_search.zig" },
// Source File: "chapter_searching/hashing_search.zig"
// Run Command: zig build run_hashing_search -Doptimize=ReleaseFast
.{ .name = "hashing_search", .path = "chapter_searching/hashing_search.zig" },
// Source File: "chapter_searching/two_sum.zig"
// Run Command: zig build run_two_sum -Doptimize=ReleaseFast
.{ .name = "two_sum", .path = "chapter_searching/two_sum.zig" },
// Source File: "chapter_sorting/bubble_sort.zig"
// Run Command: zig build run_bubble_sort -Doptimize=ReleaseFast
.{ .name = "bubble_sort", .path = "chapter_sorting/bubble_sort.zig" },
// Source File: "chapter_sorting/insertion_sort.zig"
// Run Command: zig build run_insertion_sort -Doptimize=ReleaseFast
.{ .name = "insertion_sort", .path = "chapter_sorting/insertion_sort.zig" },
// Source File: "chapter_sorting/quick_sort.zig"
// Run Command: zig build run_quick_sort -Doptimize=ReleaseFast
.{ .name = "quick_sort", .path = "chapter_sorting/quick_sort.zig" },
// Source File: "chapter_sorting/merge_sort.zig"
// Run Command: zig build run_merge_sort -Doptimize=ReleaseFast
.{ .name = "merge_sort", .path = "chapter_sorting/merge_sort.zig" },
// Source File: "chapter_sorting/radix_sort.zig"
// Run Command: zig build run_radix_sort -Doptimize=ReleaseFast
.{ .name = "radix_sort", .path = "chapter_sorting/radix_sort.zig" },
// Source File: "chapter_dynamic_programming/climbing_stairs_backtrack.zig"
// Run Command: zig build run_climbing_stairs_backtrack -Doptimize=ReleaseFast
.{ .name = "climbing_stairs_backtrack", .path = "chapter_dynamic_programming/climbing_stairs_backtrack.zig" },
// Source File: "chapter_dynamic_programming/climbing_stairs_constraint_dp.zig"
// Run Command: zig build run_climbing_stairs_constraint_dp -Doptimize=ReleaseFast
.{ .name = "climbing_stairs_constraint_dp", .path = "chapter_dynamic_programming/climbing_stairs_constraint_dp.zig" },
// Source File: "chapter_dynamic_programming/climbing_stairs_dfs_mem.zig"
// Run Command: zig build run_climbing_stairs_dfs_mem -Doptimize=ReleaseFast
.{ .name = "climbing_stairs_dfs_mem", .path = "chapter_dynamic_programming/climbing_stairs_dfs_mem.zig" },
// Source File: "chapter_dynamic_programming/climbing_stairs_dfs.zig"
// Run Command: zig build run_climbing_stairs_dfs -Doptimize=ReleaseFast
.{ .name = "climbing_stairs_dfs", .path = "chapter_dynamic_programming/climbing_stairs_dfs.zig" },
// Source File: "chapter_dynamic_programming/climbing_stairs_dp.zig"
// Run Command: zig build run_climbing_stairs_dp -Doptimize=ReleaseFast
.{ .name = "climbing_stairs_dp", .path = "chapter_dynamic_programming/climbing_stairs_dp.zig" },
// Source File: "chapter_dynamic_programming/coin_change_ii.zig"
// Run Command: zig build run_coin_change_ii -Doptimize=ReleaseFast
.{ .name = "coin_change_ii", .path = "chapter_dynamic_programming/coin_change_ii.zig" },
// Source File: "chapter_dynamic_programming/coin_change.zig"
// Run Command: zig build run_coin_change -Doptimize=ReleaseFast
.{ .name = "coin_change", .path = "chapter_dynamic_programming/coin_change.zig" },
// Source File: "chapter_dynamic_programming/edit_distance.zig"
// Run Command: zig build run_edit_distance -Doptimize=ReleaseFast
.{ .name = "edit_distance", .path = "chapter_dynamic_programming/edit_distance.zig" },
// Source File: "chapter_dynamic_programming/knapsack.zig"
// Run Command: zig build run_knapsack -Doptimize=ReleaseFast
.{ .name = "knapsack", .path = "chapter_dynamic_programming/knapsack.zig" },
// Source File: "chapter_dynamic_programming/min_cost_climbing_stairs_dp.zig"
// Run Command: zig build run_min_cost_climbing_stairs_dp -Doptimize=ReleaseFast
.{ .name = "min_cost_climbing_stairs_dp", .path = "chapter_dynamic_programming/min_cost_climbing_stairs_dp.zig" },
// Source File: "chapter_dynamic_programming/min_path_sum.zig"
// Run Command: zig build run_min_path_sum -Doptimize=ReleaseFast
.{ .name = "min_path_sum", .path = "chapter_dynamic_programming/min_path_sum.zig" },
// Source File: "chapter_dynamic_programming/unbounded_knapsack.zig"
// Run Command: zig build run_unbounded_knapsack -Doptimize=ReleaseFast
.{ .name = "unbounded_knapsack", .path = "chapter_dynamic_programming/unbounded_knapsack.zig" },
// // Source File: "chapter_backtracking/n_queens.zig"
// // Run Command: zig build run_n_queens -Doptimize=ReleaseFast
// .{ .name = "n_queens", .path = "chapter_backtracking/n_queens.zig" },
};
inline for (group_name_path) |name_path| {
const exe = b.addExecutable(.{
.name = name_path.name,
.root_source_file = .{ .path = name_path.path },
.target = target,
.optimize = optimize,
});
exe.addModule("include", b.addModule("", .{
.source_file = .{ .path = "include/include.zig" },
}));
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
const run_step = b.step("run_" ++ name_path.name, "Run the app");
run_step.dependOn(&run_cmd.step);
}
}