-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
43 lines (37 loc) · 1.35 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
const std = @import("std");
const zb = std.build;
pub fn build(b: *zb.Builder) !void {
const mode = b.standardReleaseOptions();
const lib = b.addSharedLibrary(
"pam_sauron",
"src/pam_sauron.zig",
.unversioned,
);
lib.addIncludeDir("deps/RealSenseID/wrappers/c/include");
lib.setBuildMode(mode);
lib.linkLibC();
lib.linkSystemLibrary("pam");
lib.linkSystemLibrary("rsid_c");
const lib_install = try b.allocator.create(PamSauronInstallStep);
lib_install.* = .{
.builder = b,
.step = zb.Step.init(.custom, "install pam_sauron.so", b.allocator, PamSauronInstallStep.make),
.pam_sauron = lib,
};
lib_install.step.dependOn(&lib.step);
b.getInstallStep().dependOn(&lib_install.step);
}
// Largely borrowed from:
// https://github.com/ifreund/rundird/blob/trunk/build.zig#L51-L63
// See: https://github.com/ziglang/zig/issues/2231
const PamSauronInstallStep = struct {
builder: *zb.Builder,
step: zb.Step,
pam_sauron: *zb.LibExeObjStep,
fn make(step: *zb.Step) !void {
const self = @fieldParentPtr(PamSauronInstallStep, "step", step);
const b = self.builder;
const full_dest_path = b.getInstallPath(.{ .custom = "lib/security" }, "pam_sauron.so");
try b.updateFile(self.pam_sauron.getOutputSource().getPath(b), full_dest_path);
}
};