-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
106 lines (86 loc) · 3.3 KB
/
build.zig
File metadata and controls
106 lines (86 loc) · 3.3 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const enable_confgenfs = b.option(
bool,
"confgenfs",
"Build and install confgenfs",
) orelse true;
const zig_args = b.dependency("zig_args", .{
.target = target,
.optimize = optimize,
}).module("args");
const libcg = b.createModule(.{
.root_source_file = b.path("libcg/main.zig"),
.link_libc = true,
// required for luajit errors
.unwind_tables = .async,
.target = target,
.optimize = optimize,
});
libcg.linkSystemLibrary("luajit", .{});
const libcg_test = b.addTest(.{ .root_module = libcg, .name = "libcg test" });
const confgen = b.addModule("confgen", .{
.root_source_file = b.path("confgen/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "args", .module = zig_args },
.{ .name = "libcg", .module = libcg },
},
});
const confgen_exe = b.addExecutable(.{
.name = "confgen",
.root_module = confgen,
.use_llvm = true, // self-hosted crashes
});
b.installArtifact(confgen_exe);
b.installDirectory(.{
.source_dir = b.path("share"),
.install_dir = .{ .custom = "share" },
.install_subdir = ".",
});
const run_confgen_cmd = b.addRunArtifact(confgen_exe);
run_confgen_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_confgen_cmd.addArgs(args);
}
const run_confgen_step = b.step("run-confgen", "Run the confgen binary");
run_confgen_step.dependOn(&run_confgen_cmd.step);
const confgen_test = b.addTest(.{ .root_module = confgen, .name = "confgen test" });
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&b.addRunArtifact(libcg_test).step);
test_step.dependOn(&b.addRunArtifact(confgen_test).step);
if (enable_confgenfs) {
const confgenfs = b.addModule("confgenfs", .{
.root_source_file = b.path("confgenfs/main.zig"),
.link_libc = true,
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "args", .module = zig_args },
.{ .name = "libcg", .module = libcg },
},
});
confgenfs.linkSystemLibrary("fuse3", .{});
confgenfs.addCSourceFile(.{
.file = b.path("confgenfs/fuse_shim.c"),
});
const confgenfs_exe = b.addExecutable(.{
.name = "confgenfs",
.root_module = confgenfs,
.use_llvm = true, // self-hosted crashes
});
b.installArtifact(confgenfs_exe);
const run_confgenfs_cmd = b.addRunArtifact(confgenfs_exe);
run_confgenfs_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_confgenfs_cmd.addArgs(args);
}
const run_confgenfs_step = b.step("run-confgenfs", "Run the confgenfs binary");
run_confgenfs_step.dependOn(&run_confgenfs_cmd.step);
const confgenfs_test = b.addTest(.{ .root_module = confgenfs, .name = "confgenfs test" });
test_step.dependOn(&b.addRunArtifact(confgenfs_test).step);
}
}