-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
132 lines (122 loc) · 4.9 KB
/
Copy pathbuild.zig
File metadata and controls
132 lines (122 loc) · 4.9 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
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
// An explicit GNU target makes Zig use its compatible libc startup files.
// Native GCC 16 crt objects currently contain .sframe relocations that the
// Zig 0.16 linker cannot consume.
const compile_target = if (target.query.isNative())
b.resolveTargetQuery(.{
.cpu_arch = target.result.cpu.arch,
.os_tag = target.result.os.tag,
.abi = target.result.abi,
.glibc_version = target.result.os.versionRange().gnuLibCVersion(),
})
else
target;
const optimize = b.standardOptimizeOption(.{});
const trie_logging_options = b.addOptions();
trie_logging_options.addOption([]const u8, "module_name", "permbox.trie");
const fuse_logging_options = b.addOptions();
fuse_logging_options.addOption([]const u8, "module_name", "permfs");
const trie_module = b.addModule("permtrie", .{
.root_source_file = b.path("src/trie/root.zig"),
.target = compile_target,
.optimize = optimize,
.imports = &.{
.{ .name = "logging_options", .module = trie_logging_options.createModule() },
},
});
const permfs_module = b.addModule("permfs", .{
.root_source_file = b.path("src/fuse/root.zig"),
.target = compile_target,
.optimize = optimize,
.imports = &.{
.{ .name = "permtrie", .module = trie_module },
.{ .name = "logging_options", .module = fuse_logging_options.createModule() },
},
});
permfs_module.link_libc = true;
permfs_module.addIncludePath(b.path("src"));
permfs_module.addIncludePath(.{ .cwd_relative = "/usr/include/fuse3" });
permfs_module.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
permfs_module.linkSystemLibrary("fuse3", .{});
const cli = b.addExecutable(.{
.name = "permfs",
.root_module = b.createModule(.{
.root_source_file = b.path("src/cli.zig"),
.target = compile_target,
.optimize = optimize,
.imports = &.{
.{ .name = "permfs", .module = permfs_module },
.{ .name = "permtrie", .module = trie_module },
},
}),
.use_llvm = true,
});
b.installArtifact(cli);
const test_step = b.step("test", "Run tests");
const test_runner: std.Build.Step.Compile.TestRunner = .{
.path = b.path("src/test_runner.zig"),
.mode = .simple,
};
const trie_tests = b.addTest(.{
.root_module = trie_module,
.test_runner = test_runner,
});
test_step.dependOn(&b.addRunArtifact(trie_tests).step);
const policy_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuse/policy.zig"),
.target = compile_target,
.optimize = optimize,
.imports = &.{.{ .name = "permtrie", .module = trie_module }},
}),
.test_runner = test_runner,
});
test_step.dependOn(&b.addRunArtifact(policy_tests).step);
const options_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuse/options.zig"),
.target = compile_target,
.optimize = optimize,
}),
.test_runner = test_runner,
});
test_step.dependOn(&b.addRunArtifact(options_tests).step);
const fs_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuse/fs.zig"),
.target = compile_target,
.optimize = optimize,
.imports = &.{
.{ .name = "permtrie", .module = trie_module },
.{ .name = "logging_options", .module = fuse_logging_options.createModule() },
},
}),
.test_runner = test_runner,
});
fs_tests.root_module.link_libc = true;
fs_tests.root_module.addIncludePath(b.path("src"));
fs_tests.root_module.addIncludePath(.{ .cwd_relative = "/usr/include/fuse3" });
fs_tests.root_module.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
fs_tests.root_module.linkSystemLibrary("fuse3", .{});
test_step.dependOn(&b.addRunArtifact(fs_tests).step);
const overlay_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/fuse/overlay.zig"),
.target = compile_target,
.optimize = optimize,
.imports = &.{
.{ .name = "logging_options", .module = fuse_logging_options.createModule() },
},
}),
.test_runner = test_runner,
});
overlay_tests.root_module.link_libc = true;
test_step.dependOn(&b.addRunArtifact(overlay_tests).step);
const api_tests = b.addTest(.{
.root_module = permfs_module,
.test_runner = test_runner,
});
test_step.dependOn(&b.addRunArtifact(api_tests).step);
}