-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
122 lines (117 loc) · 3.72 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
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const zwindows = b.dependency("zwindows", .{
.zxaudio2_debug_layer = b.option(
bool,
"zxaudio2_debug_layer",
"Enable XAudio2 debug layer",
) orelse false,
.zd3d12_debug_layer = b.option(
bool,
"zd3d12_debug_layer",
"Enable DirectX 12 debug layer",
) orelse false,
.zd3d12_gbv = b.option(
bool,
"zd3d12_gbv",
"Enable DirectX 12 GPU-Based Validation (GBV)",
) orelse false,
});
_ = b.addModule("root", .{
.root_source_file = b.path("src/openvr.zig"),
.imports = &.{
.{ .name = "zwindows", .module = zwindows.module("zwindows") },
},
});
}
pub fn addLibraryPathsTo(zopenvr: *std.Build.Dependency, compile_step: *std.Build.Step.Compile) void {
const target = compile_step.rootModuleTarget();
switch (target.os.tag) {
.windows => {
if (target.cpu.arch.isX86()) {
compile_step.addLibraryPath(.{ .dependency = .{
.dependency = zopenvr,
.sub_path = "libs/openvr/lib/win64",
} });
}
},
.linux => {
if (target.cpu.arch.isX86()) {
compile_step.addLibraryPath(.{ .dependency = .{
.dependency = zopenvr,
.sub_path = "libs/openvr/lib/linux64",
} });
}
},
else => {},
}
}
pub fn addRPathsTo(zopenvr: *std.Build.Dependency, compile_step: *std.Build.Step.Compile) void {
const target = compile_step.rootModuleTarget();
switch (target.os.tag) {
.windows => {
if (target.cpu.arch.isX86()) {
compile_step.addRPath(.{ .dependency = .{
.dependency = zopenvr,
.sub_path = "libs/openvr/bin/win64",
} });
}
},
.linux => {
if (target.cpu.arch.isX86()) {
compile_step.addRPath(.{ .dependency = .{
.dependency = zopenvr,
.sub_path = "libs/openvr/bin/linux64",
} });
}
},
else => {},
}
}
pub fn linkOpenVR(compile_step: *std.Build.Step.Compile) void {
switch (compile_step.rootModuleTarget().os.tag) {
.windows, .linux => {
compile_step.linkSystemLibrary("openvr_api");
},
else => {},
}
}
pub fn installOpenVR(
zopenvr: *std.Build.Dependency,
step: *std.Build.Step,
target: std.Target,
install_dir: std.Build.InstallDir,
) void {
const b = step.owner;
switch (target.os.tag) {
.windows => {
if (target.cpu.arch.isX86()) {
step.dependOn(
&b.addInstallFileWithDir(
.{ .dependency = .{
.dependency = zopenvr,
.sub_path = "libs/openvr/bin/win64/openvr_api.dll",
} },
install_dir,
"openvr_api.dll",
).step,
);
}
},
.linux => {
if (target.cpu.arch.isX86()) {
step.dependOn(
&b.addInstallFileWithDir(
.{ .dependency = .{
.dependency = zopenvr,
.sub_path = "libs/openvr/bin/linux64/libopenvr_api.so",
} },
install_dir,
"libopenvr_api.so.0",
).step,
);
}
},
else => {},
}
}