-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
58 lines (47 loc) · 1.84 KB
/
build.zig
File metadata and controls
58 lines (47 loc) · 1.84 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const allocator = b.allocator;
const arch = @tagName(target.query.cpu_arch orelse unreachable);
const os = @tagName(target.query.os_tag orelse unreachable);
const out_subdir = std.fmt.allocPrint(allocator, "{s}-{s}", .{ arch, os }) catch unreachable;
// Create the shared lib module
const lib = b.createModule(.{
.root_source_file = b.path("src/lib/lib.zig"),
});
// Define tool names and variants
const tools = [_][]const u8{
"clean_bill",
"extract_amendments",
"extract_headings",
"extract_money",
"filter_keywords",
"split_sections",
};
const variants = [_][]const u8{
"file",
"stream",
};
// Loop over tools and variants to build each executable
for (variants) |variant| {
for (tools) |tool| {
const exe_name = std.fmt.allocPrint(allocator, "{s}_{s}", .{ tool, variant }) catch unreachable;
const src_path = std.fmt.allocPrint(allocator, "src/{s}/{s}.zig", .{ variant, tool }) catch unreachable;
const exe = b.addExecutable(.{
.name = exe_name,
.root_source_file = b.path(src_path),
.target = target,
.optimize = optimize,
});
// Add the lib module to each executable
exe.root_module.addImport("lib", lib);
// Install the executable
const install_step = b.addInstallArtifact(exe, .{
.dest_dir = .{ .override = .{ .custom = out_subdir } },
});
// Ensure install step depends on this tool
b.getInstallStep().dependOn(&install_step.step);
}
}
}