2023-01-09 19:31:45 +08:00
|
|
|
// File: build.zig
|
|
|
|
// Created Time: 2023-01-07
|
|
|
|
// Author: sjinzh (sjinzh@gmail.com)
|
|
|
|
|
2023-01-08 20:38:48 +08:00
|
|
|
const std = @import("std");
|
|
|
|
|
2023-06-25 20:59:00 +08:00
|
|
|
// Zig Version: 0.11.0-dev.3379+629f0d23b
|
2023-01-10 19:29:57 +08:00
|
|
|
// Build Command: zig build
|
2023-06-25 20:59:00 +08:00
|
|
|
pub fn build(b: *std.Build) void {
|
2023-01-08 20:38:48 +08:00
|
|
|
const target = b.standardTargetOptions(.{});
|
2023-06-25 20:59:00 +08:00
|
|
|
const optimize = b.standardOptimizeOption(.{});
|
2023-01-08 20:38:48 +08:00
|
|
|
|
2023-06-25 20:59:00 +08:00
|
|
|
const group_name_path = .{
|
2023-01-10 17:19:21 +08:00
|
|
|
// Source File: "chapter_computational_complexity/time_complexity.zig"
|
2023-01-09 19:31:45 +08:00
|
|
|
// Run Command: zig build run_time_complexity
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "time_complexity",
|
|
|
|
.path = "chapter_computational_complexity/time_complexity.zig"
|
|
|
|
},
|
2023-01-09 19:31:45 +08:00
|
|
|
|
2023-01-10 17:19:21 +08:00
|
|
|
// Source File: "chapter_computational_complexity/worst_best_time_complexity.zig"
|
2023-01-09 19:31:45 +08:00
|
|
|
// Run Command: zig build run_worst_best_time_complexity
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "worst_best_time_complexity",
|
|
|
|
.path = "chapter_computational_complexity/worst_best_time_complexity.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-10 17:19:21 +08:00
|
|
|
// Source File: "chapter_computational_complexity/space_complexity.zig"
|
2023-01-09 19:31:45 +08:00
|
|
|
// Run Command: zig build run_space_complexity
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "space_complexity",
|
|
|
|
.path = "chapter_computational_complexity/space_complexity.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-11 17:39:28 +08:00
|
|
|
// Source File: "chapter_array_and_linkedlist/array.zig"
|
|
|
|
// Run Command: zig build run_array
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "array",
|
|
|
|
.path = "chapter_array_and_linkedlist/array.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-11 17:39:28 +08:00
|
|
|
// Source File: "chapter_array_and_linkedlist/linked_list.zig"
|
|
|
|
// Run Command: zig build run_linked_list
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "linked_list",
|
|
|
|
.path = "chapter_array_and_linkedlist/linked_list.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-11 17:39:28 +08:00
|
|
|
// Source File: "chapter_array_and_linkedlist/list.zig"
|
|
|
|
// Run Command: zig build run_list
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "list",
|
|
|
|
.path = "chapter_array_and_linkedlist/list.zig"
|
|
|
|
},
|
2023-01-11 17:39:28 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_array_and_linkedlist/my_list.zig"
|
|
|
|
// Run Command: zig build run_my_list
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "my_list",
|
|
|
|
.path = "chapter_array_and_linkedlist/my_list.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-12 21:51:11 +08:00
|
|
|
// Source File: "chapter_stack_and_queue/stack.zig"
|
|
|
|
// Run Command: zig build run_stack
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "stack",
|
|
|
|
.path = "chapter_stack_and_queue/stack.zig"
|
|
|
|
},
|
2023-01-12 21:51:11 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_stack_and_queue/linkedlist_stack.zig"
|
|
|
|
// Run Command: zig build run_linkedlist_stack
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "linkedlist_stack",
|
|
|
|
.path = "chapter_stack_and_queue/linkedlist_stack.zig"
|
|
|
|
},
|
2023-01-12 21:51:11 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_stack_and_queue/array_stack.zig"
|
|
|
|
// Run Command: zig build run_array_stack
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "array_stack",
|
|
|
|
.path = "chapter_stack_and_queue/array_stack.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-21 01:22:13 +08:00
|
|
|
// Source File: "chapter_stack_and_queue/queue.zig"
|
|
|
|
// Run Command: zig build run_queue
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "queue",
|
|
|
|
.path = "chapter_stack_and_queue/queue.zig"
|
|
|
|
},
|
2023-01-21 01:22:13 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_stack_and_queue/array_queue.zig"
|
|
|
|
// Run Command: zig build run_array_queue
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "array_queue",
|
|
|
|
.path = "chapter_stack_and_queue/array_queue.zig"
|
|
|
|
},
|
2023-01-21 01:22:13 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_stack_and_queue/linkedlist_queue.zig"
|
|
|
|
// Run Command: zig build run_linkedlist_queue
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "linkedlist_queue",
|
|
|
|
.path = "chapter_stack_and_queue/linkedlist_queue.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-21 01:22:13 +08:00
|
|
|
// Source File: "chapter_stack_and_queue/deque.zig"
|
|
|
|
// Run Command: zig build run_deque
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "deque",
|
|
|
|
.path = "chapter_stack_and_queue/deque.zig"
|
|
|
|
},
|
2023-01-21 01:22:13 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_stack_and_queue/linkedlist_deque.zig"
|
|
|
|
// Run Command: zig build run_linkedlist_deque
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "linkedlist_deque",
|
|
|
|
.path = "chapter_stack_and_queue/linkedlist_deque.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-13 20:17:44 +08:00
|
|
|
// Source File: "chapter_hashing/hash_map.zig"
|
|
|
|
// Run Command: zig build run_hash_map
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "hash_map",
|
|
|
|
.path = "chapter_hashing/hash_map.zig"
|
|
|
|
},
|
2023-01-13 20:17:44 +08:00
|
|
|
|
2023-01-18 08:58:41 +08:00
|
|
|
// Source File: "chapter_hashing/array_hash_map.zig"
|
|
|
|
// Run Command: zig build run_array_hash_map
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "array_hash_map",
|
|
|
|
.path = "chapter_hashing/array_hash_map.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-14 08:47:50 +08:00
|
|
|
// Source File: "chapter_tree/binary_tree.zig"
|
|
|
|
// Run Command: zig build run_binary_tree
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "binary_tree",
|
|
|
|
.path = "chapter_tree/binary_tree.zig"
|
|
|
|
},
|
2023-01-14 22:28:23 +08:00
|
|
|
|
2023-01-21 16:19:26 +08:00
|
|
|
// Source File: "chapter_tree/binary_tree_bfs.zig"
|
|
|
|
// Run Command: zig build run_binary_tree_bfs
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "binary_tree_bfs",
|
|
|
|
.path = "chapter_tree/binary_tree_bfs.zig"
|
|
|
|
},
|
2023-01-28 00:47:58 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_tree/binary_tree_dfs.zig"
|
|
|
|
// Run Command: zig build run_binary_tree_dfs
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "binary_tree_dfs",
|
|
|
|
.path = "chapter_tree/binary_tree_dfs.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-28 00:47:58 +08:00
|
|
|
// Source File: "chapter_tree/binary_search_tree.zig"
|
|
|
|
// Run Command: zig build run_binary_search_tree
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "binary_search_tree",
|
|
|
|
.path = "chapter_tree/binary_search_tree.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-28 00:47:58 +08:00
|
|
|
// Source File: "chapter_tree/avl_tree.zig"
|
|
|
|
// Run Command: zig build run_avl_tree
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "avl_tree",
|
|
|
|
.path = "chapter_tree/avl_tree.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-14 22:28:23 +08:00
|
|
|
// Source File: "chapter_heap/heap.zig"
|
|
|
|
// Run Command: zig build run_heap
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "heap",
|
|
|
|
.path = "chapter_heap/heap.zig"
|
|
|
|
},
|
2023-01-16 17:34:03 +08:00
|
|
|
|
|
|
|
// Source File: "chapter_heap/my_heap.zig"
|
|
|
|
// Run Command: zig build run_my_heap
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "my_heap",
|
|
|
|
.path = "chapter_heap/my_heap.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-13 23:23:26 +08:00
|
|
|
// Source File: "chapter_searching/linear_search.zig"
|
|
|
|
// Run Command: zig build run_linear_search
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "linear_search",
|
|
|
|
.path = "chapter_searching/linear_search.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-18 23:40:43 +08:00
|
|
|
// Source File: "chapter_searching/binary_search.zig"
|
|
|
|
// Run Command: zig build run_binary_search
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "binary_search",
|
|
|
|
.path = "chapter_searching/binary_search.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-18 23:40:43 +08:00
|
|
|
// Source File: "chapter_searching/hashing_search.zig"
|
|
|
|
// Run Command: zig build run_hashing_search
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "hashing_search",
|
|
|
|
.path = "chapter_searching/hashing_search.zig"
|
|
|
|
},
|
|
|
|
|
|
|
|
// Source File: "chapter_searching/two_sum.zig"
|
|
|
|
// Run Command: zig build run_two_sum
|
|
|
|
.{
|
|
|
|
.name = "two_sum",
|
|
|
|
.path = "chapter_searching/two_sum.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-12 21:51:11 +08:00
|
|
|
// Source File: "chapter_sorting/bubble_sort.zig"
|
|
|
|
// Run Command: zig build run_bubble_sort
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "bubble_sort",
|
|
|
|
.path = "chapter_sorting/bubble_sort.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-12 21:51:11 +08:00
|
|
|
// Source File: "chapter_sorting/insertion_sort.zig"
|
|
|
|
// Run Command: zig build run_insertion_sort
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "insertion_sort",
|
|
|
|
.path = "chapter_sorting/insertion_sort.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-19 23:27:14 +08:00
|
|
|
// Source File: "chapter_sorting/quick_sort.zig"
|
|
|
|
// Run Command: zig build run_quick_sort
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "quick_sort",
|
|
|
|
.path = "chapter_sorting/quick_sort.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-19 23:27:14 +08:00
|
|
|
// Source File: "chapter_sorting/merge_sort.zig"
|
|
|
|
// Run Command: zig build run_merge_sort
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "merge_sort",
|
|
|
|
.path = "chapter_sorting/merge_sort.zig"
|
|
|
|
},
|
|
|
|
|
2023-01-19 23:27:14 +08:00
|
|
|
// Source File: "chapter_sorting/radix_sort.zig"
|
|
|
|
// Run Command: zig build run_radix_sort
|
2023-06-25 20:59:00 +08:00
|
|
|
.{
|
|
|
|
.name = "radix_sort",
|
|
|
|
.path = "chapter_sorting/radix_sort.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);
|
|
|
|
}
|
2023-01-08 20:38:48 +08:00
|
|
|
}
|