forked from kivikakk/koino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
49 lines (42 loc) · 1.85 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
const std = @import("std");
const linkPcre = @import("vendor/libpcre/build.zig").linkPcre;
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
var deps = std.StringHashMap(*std.build.Module).init(b.allocator);
try deps.put("libpcre", b.addModule("libpcre", .{ .source_file = .{ .path = "vendor/libpcre/src/main.zig" } }));
try deps.put("htmlentities", b.addModule("htmlentities", .{ .source_file = .{ .path = "vendor/htmlentities/src/main.zig" } }));
try deps.put("clap", b.addModule("clap", .{ .source_file = .{ .path = "vendor/zig-clap/clap.zig" } }));
try deps.put("zunicode", b.addModule("zunicode", .{ .source_file = .{ .path = "vendor/zunicode/src/zunicode.zig" } }));
const exe = b.addExecutable(.{
.name = "koino",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
try addCommonRequirements(b, exe, &deps);
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
if (b.args) |args| {
run_cmd.addArgs(args);
}
const test_exe = b.addTest(.{
.name = "test",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
try addCommonRequirements(b, test_exe, &deps);
const test_step = b.step("test", "Run all the tests");
test_step.dependOn(&test_exe.step);
}
fn addCommonRequirements(b: *std.Build, cs: *std.build.CompileStep, deps: *const std.StringHashMap(*std.build.Module)) !void {
var it = deps.iterator();
while (it.next()) |entry| {
cs.addModule(entry.key_ptr.*, entry.value_ptr.*);
}
try linkPcre(b, cs);
}