@@ -50,17 +50,16 @@ pub fn build(b: *std.Build) !void {
50
50
51
51
pub fn install_xaudio2 (
52
52
step : * std.Build.Step ,
53
+ zwindows : * std.Build.Dependency ,
53
54
install_dir : std.Build.InstallDir ,
54
55
) void {
55
56
const b = step .owner ;
56
- const source_path_prefix = comptime std .fs .path .dirname (@src ().file ) orelse "." ;
57
57
step .dependOn (
58
58
& b .addInstallFileWithDir (
59
- .{
60
- .cwd_relative = b .pathJoin (
61
- &.{ source_path_prefix , "bin/x64/xaudio2_9redist.dll" },
62
- ),
63
- },
59
+ .{ .dependency = .{
60
+ .dependency = zwindows ,
61
+ .sub_path = "bin/x64/xaudio2_9redist.dll" ,
62
+ } },
64
63
install_dir ,
65
64
"xaudio2_9redist.dll" ,
66
65
).step ,
@@ -69,28 +68,26 @@ pub fn install_xaudio2(
69
68
70
69
pub fn install_d3d12 (
71
70
step : * std.Build.Step ,
71
+ zwindows : * std.Build.Dependency ,
72
72
install_dir : std.Build.InstallDir ,
73
73
) void {
74
74
const b = step .owner ;
75
- const source_path_prefix = comptime std .fs .path .dirname (@src ().file ) orelse "." ;
76
75
step .dependOn (
77
76
& b .addInstallFileWithDir (
78
- .{
79
- .cwd_relative = b .pathJoin (
80
- &.{ source_path_prefix , "bin/x64/D3D12Core.dll" },
81
- ),
82
- },
77
+ .{ .dependency = .{
78
+ .dependency = zwindows ,
79
+ .sub_path = "bin/x64/D3D12Core.dll" ,
80
+ } },
83
81
install_dir ,
84
82
"d3d12/D3D12Core.dll" ,
85
83
).step ,
86
84
);
87
85
step .dependOn (
88
86
& b .addInstallFileWithDir (
89
- .{
90
- .cwd_relative = b .pathJoin (
91
- &.{ source_path_prefix , "bin/x64/D3D12SDKLayers.dll" },
92
- ),
93
- },
87
+ .{ .dependency = .{
88
+ .dependency = zwindows ,
89
+ .sub_path = "bin/x64/D3D12SDKLayers.dll" ,
90
+ } },
94
91
install_dir ,
95
92
"d3d12/D3D12SDKLayers.dll" ,
96
93
).step ,
@@ -99,28 +96,26 @@ pub fn install_d3d12(
99
96
100
97
pub fn install_directml (
101
98
step : * std.Build.Step ,
99
+ zwindows : * std.Build.Dependency ,
102
100
install_dir : std.Build.InstallDir ,
103
101
) void {
104
102
const b = step .owner ;
105
- const source_path_prefix = comptime std .fs .path .dirname (@src ().file ) orelse "." ;
106
103
step .dependOn (
107
104
& b .addInstallFileWithDir (
108
- .{
109
- .cwd_relative = b .pathJoin (
110
- &.{ source_path_prefix , "bin/x64/DirectML.dll" },
111
- ),
112
- },
105
+ .{ .dependency = .{
106
+ .dependency = zwindows ,
107
+ .sub_path = "bin/x64/DirectML.dll" ,
108
+ } },
113
109
install_dir ,
114
110
"DirectML.dll" ,
115
111
).step ,
116
112
);
117
113
step .dependOn (
118
114
& b .addInstallFileWithDir (
119
- .{
120
- .cwd_relative = b .pathJoin (
121
- &.{ source_path_prefix , "bin/x64/DirectML.Debug.dll" },
122
- ),
123
- },
115
+ .{ .dependency = .{
116
+ .dependency = zwindows ,
117
+ .sub_path = "bin/x64/DirectML.Debug.dll" ,
118
+ } },
124
119
install_dir ,
125
120
"DirectML.Debug.dll" ,
126
121
).step ,
@@ -129,6 +124,7 @@ pub fn install_directml(
129
124
130
125
pub const CompileShaders = struct {
131
126
step : * std.Build.Step ,
127
+ zwindows : * std.Build.Dependency ,
132
128
shader_ver : []const u8 ,
133
129
134
130
pub fn addVsShader (
@@ -204,10 +200,9 @@ pub const CompileShaders = struct {
204
200
) void {
205
201
const b = self .step .owner ;
206
202
207
- const zwindows_path = comptime std .fs .path .dirname (@src ().file ) orelse "." ;
208
203
const dxc_path = switch (builtin .target .os .tag ) {
209
- .windows = > zwindows_path ++ "/ bin/x64/dxc.exe" ,
210
- .linux = > zwindows_path ++ "/ bin/x64/dxc" ,
204
+ .windows = > self . zwindows . path ( " bin/x64/dxc.exe"). getPath ( b ) ,
205
+ .linux = > self . zwindows . path ( " bin/x64/dxc"). getPath ( b ) ,
211
206
else = > @panic ("Unsupported target" ),
212
207
};
213
208
@@ -227,16 +222,22 @@ pub const CompileShaders = struct {
227
222
if (builtin .target .os .tag == .linux ) {
228
223
cmd_step .setEnvironmentVariable (
229
224
"LD_LIBRARY_PATH" ,
230
- zwindows_path ++ "/ bin/x64" ,
225
+ self . zwindows . path ( " bin/x64"). getPath ( b ) ,
231
226
);
232
227
}
233
228
self .step .dependOn (& cmd_step .step );
234
229
}
235
230
};
236
231
237
- pub fn addCompileShaders (b : * std.Build , comptime name : []const u8 , options : struct { shader_ver : []const u8 }) CompileShaders {
232
+ pub fn addCompileShaders (
233
+ b : * std.Build ,
234
+ comptime name : []const u8 ,
235
+ zwindows : * std.Build.Dependency ,
236
+ options : struct { shader_ver : []const u8 },
237
+ ) CompileShaders {
238
238
return .{
239
239
.step = b .step (name ++ "-dxc" , "Build shaders for '" ++ name ++ "'" ),
240
+ .zwindows = zwindows ,
240
241
.shader_ver = options .shader_ver ,
241
242
};
242
243
}
0 commit comments